index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. handleBack() {
  74. uni.navigateBack()
  75. },
  76. // 获取验证码
  77. handleSendVerify() {
  78. if (!this.registerQuery.phone) {
  79. this.$refs.refRegisterVerify.reset()
  80. return this.$showToast('请填写手机号')
  81. }
  82. if (!/^1[3-9]\d{9}$/.test(this.registerQuery.phone)) {
  83. this.$refs.refRegisterVerify.reset()
  84. return this.$showToast('请输入正确的手机号')
  85. }
  86. getVerifyCodeApi({ phone: this.registerQuery.phone })
  87. .then((res) => {
  88. this.$refs.refRegisterVerify.success()
  89. this.$showToast('发送成功,请注意查看手机短信')
  90. })
  91. .catch(() => {
  92. this.$refs.refRegisterVerify.reset()
  93. })
  94. },
  95. addAcount() {
  96. this.$refs.form.validate(this.registerQuery, [
  97. {
  98. name: 'phone',
  99. rule: ['required', 'isMobile'],
  100. msg: ['请输入手机号', '请输入正确的手机号']
  101. },
  102. {
  103. name: 'verificationCode',
  104. rule: [ 'required' ],
  105. msg: [ '请输入验证码' ]
  106. }
  107. // {
  108. // name: 'password',
  109. // rule: ['required', 'isEnAndNo'],
  110. // msg: ['请输入密码', '密码为8~20位英文和数字组合']
  111. // },
  112. // {
  113. // name: 'passwordAgain',
  114. // rule: ['required', 'isSame:password'],
  115. // msg: ['请再次确认密码', '两次密码不一致']
  116. // }
  117. ])
  118. .then(() => {
  119. updatePhoneLoginRegisterApi({
  120. type: 1,
  121. phone: this.registerQuery.phone,
  122. verificationCode: this.registerQuery.verificationCode,
  123. password: this.registerQuery.password
  124. }).then((res) => {
  125. this.$store.dispatch('auth/LoginAfterAction', { type: 'phone', data: res.data })
  126. this.hasRegister = true
  127. })
  128. })
  129. .catch((e) => {
  130. this.$showToast(JSON.stringify(e.errorMsg))
  131. })
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .register {
  138. position: relative;
  139. padding: 190rpx 65rpx 0;
  140. box-sizing: border-box;
  141. .back {
  142. position: absolute;
  143. top: 80rpx;
  144. left: 35rpx;
  145. }
  146. .title {
  147. padding-left: 25rpx;
  148. h2 {
  149. font-size: 64rpx;
  150. font-weight: normal;
  151. }
  152. p {
  153. margin-top: 10rpx;
  154. }
  155. }
  156. .ipt {
  157. margin-top: 80rpx;
  158. .code-box {
  159. margin-top: 40rpx;
  160. position: relative;
  161. .code {
  162. position: absolute;
  163. right: 0;
  164. top: 50%;
  165. transform: translateY(-50%);
  166. }
  167. }
  168. .text {
  169. margin-top: 30rpx;
  170. display: flex;
  171. font-size: 24rpx;
  172. margin-left: 30rpx;
  173. p {
  174. color: #646466;
  175. }
  176. span {
  177. color: #397BFF;
  178. }
  179. }
  180. }
  181. .btn-list {
  182. margin-top: 80rpx;
  183. }
  184. footer {
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. width: 100%;
  189. position: fixed;
  190. left: 0;
  191. bottom: 100rpx;
  192. font-size: 24rpx;
  193. p {
  194. color: #888889;
  195. }
  196. span {
  197. font-weight: 500;
  198. }
  199. }
  200. .tui-modal-custom {
  201. padding: 40rpx 0;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. flex-direction: column;
  206. gap: 30rpx;
  207. position: relative;
  208. .img-box {
  209. width: 200rpx;
  210. height: 120rpx;
  211. img {
  212. width: 100%;
  213. height: 100%;
  214. }
  215. }
  216. .tui-modal-custom-text {
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. flex-direction: column;
  221. gap: 30rpx;
  222. margin-bottom: 50rpx;
  223. }
  224. }
  225. }
  226. </style>