register.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="content">
  3. <view class="logo">
  4. <image
  5. style="height:104rpx;width:104rpx"
  6. src="/static/czzn-img/login/logo.jpg"
  7. mode="aspectFit"
  8. />
  9. <view class="app-name">{{$t('login.e')}}</view>
  10. </view>
  11. <view class="login-title">
  12. <span>{{$t('login.register')}}</span>
  13. </view>
  14. <!-- 公司编号 -->
  15. <view class="inp_box">
  16. <input type="text" v-model="registerForm.code" :placeholder="this.$t('login.codePlaceholder')" @blur="getUrl" />
  17. </view>
  18. <!-- 名称 -->
  19. <view class="inp_box">
  20. <input type="text" v-model="registerForm.displayName" :placeholder="this.$t('login.displayNamePlaceholder')" />
  21. </view>
  22. <!-- 手机号 -->
  23. <view class="inp_box">
  24. <input type="text" maxlength="11" @input="phoneInput" v-model="registerForm.phone" :placeholder="this.$t('login.phonePlaceholder')" />
  25. </view>
  26. <!-- 密码 -->
  27. <view class="inp_box">
  28. <input type="text" v-model="registerForm.password" :placeholder="this.$t('login.passwordPlaceholder')" />
  29. </view>
  30. <!-- 验证码
  31. <view class="inp_box">
  32. <input v-model="registerForm.verificationCode"
  33. :placeholder="this.$t('login.verifyCodePlaceholder')" />
  34. <button :class="time!=0?'load-reget':''" @click="getCode" :disabled='time!=0'
  35. class="get-code-btn">{{isGetCode?$t("login.reGetCode"):$t("login.getCode")}}{{time?`(${time}s)`:''}}</button>
  36. </view> -->
  37. <view class="btn-wrap">
  38. <button @click="phoneLogin" :class="urlFlag ? 'bind-btn' : 'btn-disabled'" :disabled="!urlFlag">{{$t('login.register')}}</button>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. getRegTelCode,
  45. register,
  46. getUrlByCode,
  47. bindNameCode
  48. } from '../../api/login'
  49. export default {
  50. data() {
  51. return {
  52. serverStatus:'',
  53. agree: [],
  54. time: 0,
  55. timer: '',
  56. isGetCode: false,
  57. option: [{
  58. text: '',
  59. value: 1,
  60. }],
  61. registerForm: {
  62. code:"",
  63. phone: "",
  64. password:"",
  65. displayName: "",
  66. verificationCode: "",
  67. type: "",
  68. },
  69. urlFlag:false,
  70. roleList: [{
  71. value: 0,
  72. text: this.$t("login.dealer")
  73. },
  74. {
  75. value: 1,
  76. text: this.$t("login.driver")
  77. }
  78. ]
  79. }
  80. },
  81. onLoad(options) {
  82. this.registerForm.type = options.type
  83. this.serverStatus=uni.getStorageSync('serverStatus');
  84. },
  85. methods: {
  86. //手机号输入
  87. phoneInput(){
  88. if(this.registerForm.phone.length >11){
  89. uni.showToast({
  90. title: this.$t('base.smsCode.phoneTooLong'),
  91. icon: 'none'
  92. })
  93. }
  94. },
  95. //获取请求地址
  96. getUrl(){
  97. if (this.registerForm.code == '') {
  98. uni.showToast({
  99. title: this.$t('login.codePlaceholder'),
  100. icon: "none",
  101. duration: 2500,
  102. })
  103. }else{
  104. getUrlByCode(this.registerForm.code).then(r=>{
  105. if (r.statusCode === 200 && r.data.code === 0) {
  106. let data = r.data.data
  107. uni.setStorageSync('serverAddress', data.requestUrl);
  108. uni.setStorageSync('serverPrefix', data.methodPrefix);
  109. this.urlFlag = true
  110. }else{
  111. uni.showToast({
  112. title: r.data.msg,
  113. icon: "none",
  114. duration: 2500,
  115. })
  116. }
  117. })
  118. }
  119. },
  120. backLogin() {
  121. uni.navigateBack({
  122. delta: 1
  123. })
  124. },
  125. //获取验证码
  126. getCode() {
  127. let phone = /^\d{9}$/
  128. if (!this.registerForm.type) {
  129. uni.showToast({
  130. title: this.$t('login.displayNamePlaceholder'),
  131. icon: "none",
  132. duration: 2500,
  133. })
  134. return;
  135. }
  136. if (!this.registerForm.displayName) {
  137. uni.showToast({
  138. title: this.$t('login.displayNamePlaceholder'),
  139. icon: "none",
  140. duration: 2500,
  141. })
  142. return;
  143. }
  144. if (!this.registerForm.password) {
  145. uni.showToast({
  146. title: this.$t('login.passwordPlaceholder'),
  147. icon: "none",
  148. duration: 2500,
  149. })
  150. return;
  151. }
  152. if (!this.registerForm.phone) {
  153. uni.showToast({
  154. title: this.$t('login.phonePlaceholder'),
  155. icon: "none",
  156. duration: 2500,
  157. })
  158. return;
  159. }
  160. // if (!phone.test(this.registerForm.phone)) {
  161. // uni.showToast({
  162. // title: this.$t('base.smsCode.phoneErrTip'),
  163. // icon: "none",
  164. // duration: 2500,
  165. // })
  166. // return;
  167. // }
  168. getRegTelCode(this.registerForm.phone).then(res => {
  169. if (res.statusCode === 200) {
  170. if(res.data && res.data.code==1){
  171. uni.showToast({
  172. title: res.data.msg,
  173. icon: "none",
  174. duration: 2500,
  175. })
  176. return;
  177. }
  178. this.isGetCode = true
  179. this.time = 60
  180. this.timer = setInterval(() => {
  181. this.time--
  182. if (this.time == 0) {
  183. clearInterval(this.timer)
  184. }
  185. }, 1000)
  186. }
  187. })
  188. },
  189. //注册并登录
  190. phoneLogin() {
  191. let phone = /^\d{9}$/
  192. if (this.registerForm.code == '' || !this.urlFlag) {
  193. uni.showToast({
  194. title: this.$t('login.codePlaceholder'),
  195. icon: "none",
  196. duration: 2500,
  197. })
  198. return;
  199. }
  200. if (this.registerForm.displayName == '') {
  201. uni.showToast({
  202. title: this.$t('login.displayNamePlaceholder'),
  203. icon: "none",
  204. duration: 2500,
  205. })
  206. return;
  207. }
  208. if (this.registerForm.password == '') {
  209. uni.showToast({
  210. title: this.$t('login.passwordPlaceholder'),
  211. icon: "none",
  212. duration: 2500,
  213. })
  214. return;
  215. }
  216. if (this.registerForm.phone == '') {
  217. uni.showToast({
  218. title: this.$t('login.phonePlaceholder'),
  219. icon: "none",
  220. duration: 2500,
  221. })
  222. return;
  223. }
  224. // if (!phone.test(this.registerForm.phone)) {
  225. // uni.showToast({
  226. // title: this.$t('base.smsCode.phoneErrTip'),
  227. // icon: "none",
  228. // duration: 2500,
  229. // })
  230. // return;
  231. // }
  232. // if (this.registerForm.verificationCode == '') {
  233. // uni.showToast({
  234. // title: this.$t('login.verifyCodePlaceholder'),
  235. // icon: "none",
  236. // duration: 2500,
  237. // })
  238. // return;
  239. // }
  240. let datasss = JSON.parse(JSON.stringify(this.registerForm))
  241. datasss.tenantId = this.registerForm.code
  242. register(datasss).then(res => {
  243. if (res.statusCode == 200 && res.data.code==0) {
  244. let data = {
  245. username: this.registerForm.phone,
  246. companyCode: this.registerForm.code
  247. }
  248. bindNameCode(data).then(res=>{
  249. if (res.statusCode === 200 && res.data.data.code === 0) {
  250. uni.showToast({
  251. title: '注册成功',
  252. icon: "none",
  253. duration: 2000,
  254. })
  255. setTimeout(() => {
  256. uni.redirectTo({
  257. url: `/pages/login/login?username=${this.registerForm.phone}`
  258. })
  259. }, 2000)
  260. }else{
  261. this.canLogin = false
  262. uni.showToast({
  263. title: res.data.data.msg,
  264. icon: "none",
  265. duration: 2500,
  266. })
  267. }
  268. })
  269. }
  270. })
  271. },
  272. }
  273. }
  274. </script>
  275. <style>
  276. /* #ifndef APP-NVUE */
  277. view {
  278. display: flex;
  279. box-sizing: border-box;
  280. flex-direction: column;
  281. }
  282. page {
  283. box-sizing: border-box;
  284. padding: 0rpx 48rpx 80rpx;
  285. height: 100%;
  286. }
  287. /* #endif*/
  288. </style>
  289. <style lang="scss" scoped>
  290. @import '../../common/css/login.scss';
  291. .bgc{
  292. position: absolute;
  293. height: 77%;
  294. width: 160%;
  295. bottom: 0;
  296. left: -30%;
  297. z-index: -50;
  298. background-color: #4680F9;
  299. border-top-left-radius: 200px;
  300. border-top-right-radius: 200px;
  301. }
  302. </style>