register.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="register-container">
  3. <JHeader title="" width="50" height="50" style="padding: 24rpx 0 0;"></JHeader>
  4. <view class="titleBox">
  5. <p class="bigTitle">填写注册信息</p>
  6. <p class="tips">请仔细填写以下信息,以免后期登陆异常</p>
  7. </view>
  8. <view class="formBox">
  9. <tui-form ref="form" :show-message="false">
  10. <view class="formItem">
  11. <tui-input
  12. v-model="registerQuery.phone" placeholder-class="inputs" label="" border-color="#EA5B1D"
  13. placeholder="请输入电话号码" :border-top="false" color="#222229" clearable
  14. size="34"
  15. ></tui-input>
  16. </view>
  17. <view class="formItem">
  18. <tui-input
  19. v-model="registerQuery.verificationCode" padding="26rpx 20rpx 26rpx 0"
  20. placeholder-style="color: #f3c1c4;font-size: 32rpx;" background-color="transparent" :border-top="false"
  21. border-color="#EA5B1D" label-color="#ffffff" placeholder="请输入验证码" color="#222229"
  22. style="border-bottom: 2rpx solid #ffffff;"
  23. >
  24. <template #right>
  25. <tui-countdown-verify
  26. ref="refRegisterVerify" width="188rpx" height="48rpx" border-width="0"
  27. text="获取验证码"
  28. :size="30" color="#EF530E" @send="handleSendVerify"
  29. ></tui-countdown-verify>
  30. </template>
  31. </tui-input>
  32. </view>
  33. <view class="formItem">
  34. <tui-input
  35. v-model="registerQuery.password" placeholder-class="inputs" type="password" label=""
  36. border-color="#EA5B1D" placeholder="请输入密码" :border-top="false" color="#222229"
  37. clearable
  38. size="34"
  39. ></tui-input>
  40. </view>
  41. <view class="formItem">
  42. <tui-input
  43. v-model="registerQuery.passwordAgain" placeholder-class="inputs" type="password" label=""
  44. border-color="#EA5B1D" placeholder="请再次确认密码" :border-top="false" color="#222229"
  45. clearable
  46. size="34"
  47. ></tui-input>
  48. </view>
  49. </tui-form>
  50. <view class="tips">密码长度8-16位,必须同时含有字母和数字</view>
  51. </view>
  52. <button
  53. class="loginBtn"
  54. :class="{ disbleds: !!(registerQuery.password && registerQuery.passwordAgain && registerQuery.phone && registerQuery.verificationCode) }"
  55. @click="addAcount"
  56. >
  57. 确定
  58. </button>
  59. <view class="agreement">
  60. 登录即代表你已阅读并同意<text style="color: #222229;">《用户服务协议》</text>
  61. </view>
  62. <tui-toast ref="toast"></tui-toast>
  63. <tui-modal :show="hasRegister" custom fade-i :button="[]" @cancel="hasRegister = false">
  64. <view style="padding: 28rpx 0;text-align: center;">
  65. <image style="width: 240rpx;height: 144rpx;" src="../../static/images/icon/acount.png"></image>
  66. <view
  67. style="margin-top: 46rpx;font-size: 36rpx;font-weight: normal;line-height: 52rpx;text-align: center;color: #222229;"
  68. >
  69. 注册完成
  70. </view>
  71. <view
  72. style="margin-top: 18rpx;font-size: 28fpx;font-weight: 350;line-height: 40fpx;text-align: center;color: #888889;"
  73. >
  74. 您已完成注册,请前往首页
  75. </view>
  76. <button
  77. style="width: 484rpx;height: 80rpx;border-radius: 8rpx;background: #EF530E;color: #fff;line-height: 80rpx;margin-top: 80rpx;"
  78. @click="$switchTab('/pages/index/index')"
  79. >
  80. 立即跳转
  81. </button>
  82. </view>
  83. </tui-modal>
  84. </view>
  85. </template>
  86. <script>
  87. import { updatePhoneLoginRegisterApi, getVerifyCodeApi } from '../../api/anotherTFInterface'
  88. export default {
  89. name: 'Register',
  90. data() {
  91. return {
  92. registerQuery: {
  93. password: '',
  94. passwordAgain: '',
  95. phone: '',
  96. verificationCode: ''
  97. },
  98. hasRegister: false
  99. }
  100. },
  101. methods: {
  102. // 获取验证码
  103. handleSendVerify() {
  104. if (!this.registerQuery.phone) {
  105. this.$refs.refRegisterVerify.reset()
  106. return this.$showToast('请填写手机号')
  107. }
  108. if (!/^1[3-9]\d{9}$/.test(this.registerQuery.phone)) {
  109. this.$refs.refRegisterVerify.reset()
  110. return this.$showToast('请输入正确的手机号')
  111. }
  112. getVerifyCodeApi({ phone: this.registerQuery.phone })
  113. .then((res) => {
  114. this.$refs.refRegisterVerify.success()
  115. this.$showToast('发送成功,请注意查看手机短信')
  116. })
  117. .catch(() => {
  118. this.$refs.refRegisterVerify.reset()
  119. })
  120. },
  121. addAcount() {
  122. this.$refs.form.validate(this.registerQuery, [
  123. {
  124. name: 'phone',
  125. rule: ['required', 'isMobile'],
  126. msg: ['请输入手机号', '请输入正确的手机号']
  127. },
  128. {
  129. name: 'verificationCode',
  130. rule: [ 'required' ],
  131. msg: [ '请输入验证码' ]
  132. },
  133. {
  134. name: 'password',
  135. rule: ['required', 'isEnAndNo'],
  136. msg: ['请输入密码', '密码为8~20位英文和数字组合']
  137. },
  138. {
  139. name: 'passwordAgain',
  140. rule: ['required', 'isSame:password'],
  141. msg: ['请再次确认密码', '两次密码不一致']
  142. }
  143. ])
  144. .then(() => {
  145. updatePhoneLoginRegisterApi({
  146. type: 1,
  147. phone: this.registerQuery.phone,
  148. verificationCode: this.registerQuery.verificationCode,
  149. password: this.registerQuery.password
  150. }).then((res) => {
  151. this.$store.dispatch('auth/LoginAfterAction', { type: 'phone', data: res.data })
  152. this.hasRegister = true
  153. })
  154. })
  155. .catch((e) => {
  156. this.$showToast(JSON.stringify(e.errorMsg))
  157. })
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="less" scoped>
  163. .register-container {
  164. position: relative;
  165. min-height: 100vh;
  166. box-sizing: border-box;
  167. .disbleds {
  168. background-color: #EF530E !important;
  169. }
  170. .titleBox {
  171. width: 100vw;
  172. box-sizing: border-box;
  173. padding: 64rpx;
  174. .bigTitle {
  175. font-family: Source Han Sans;
  176. font-size: 64rpx;
  177. font-weight: normal;
  178. line-height: 90rpx;
  179. color: #303030;
  180. }
  181. .tips {
  182. font-family: Source Han Sans;
  183. font-size: 28rpx;
  184. font-weight: normal;
  185. line-height: 40rpx;
  186. color: #303030;
  187. }
  188. }
  189. .formBox {
  190. width: 100vw;
  191. box-sizing: border-box;
  192. padding: 0rpx 40rpx;
  193. .formItem {
  194. height: 120rpx;
  195. }
  196. .tips {
  197. margin-left: 26rpx;
  198. font-family: Source Han Sans;
  199. font-size: 24rpx;
  200. font-weight: normal;
  201. line-height: 32rpx;
  202. color: #646466;
  203. }
  204. }
  205. .loginBtn {
  206. margin-top: 64rpx;
  207. width: 622rpx;
  208. height: 96rpx;
  209. border-radius: 16rpx;
  210. background: #C6C7CB;
  211. color: #FFFFFF;
  212. font-size: 32rpx;
  213. }
  214. .agreement {
  215. position: absolute;
  216. bottom: 48rpx;
  217. left: 50%;
  218. transform: translateX(-50%);
  219. white-space: nowrap;
  220. font-size: 28rx;
  221. font-weight: 350;
  222. line-height: 36rpx;
  223. text-align: center;
  224. letter-spacing: 0rpx;
  225. color: #888889;
  226. }
  227. }
  228. </style>