register.vue 6.3 KB

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