index.vue 5.9 KB

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