register.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view class="content">
  3. <view class="top_bg">
  4. <image class="top_close" @click="$navBack()" src="/static/image/login/close_icon.png" mode="scaleToFill" />
  5. <view class="top_text">
  6. <view>注册众酬帮</view>
  7. <image
  8. class="top_icon"
  9. src="/static//image/login/dot_icon.png"
  10. mode="scaleToFill"
  11. />
  12. </view>
  13. </view>
  14. <view class="w pdx-40 main">
  15. <u--input class="h-112" v-model="loginParam.inviteCode" placeholder="请输入邀请码" border="bottom"
  16. clearable></u--input>
  17. <u--input class="h-112" v-model="loginParam.phone" placeholder="请输入手机号码" border="bottom"
  18. clearable></u--input>
  19. <u--input class="h-112 mgt-16" v-model="loginParam.code" placeholder="请输入验证码" border="bottom" clearable>
  20. <template slot="suffix">
  21. <u-code :seconds="seconds" @end="end" @start="start" change-text="xs" ref="uCode"
  22. :keep-running="true" @change="codeChange"></u-code>
  23. <u-button :disabled="!isShowCode" @tap="sliderVerify" class="code_btn">{{ tips }}</u-button>
  24. </template>
  25. </u--input>
  26. <u--input class="h-112 mgt-16" v-model="loginParam.password" :password="!isViewPassword" placeholder="请输入密码"
  27. border="bottom" clearable>
  28. <template slot="suffix">
  29. <u-icon @click="isViewPassword = !isViewPassword" :name="isViewPassword ? 'eye-fill' : 'eye-off'"
  30. color="#303030" size="24"></u-icon>
  31. </template>
  32. </u--input>
  33. <u--input class="h-112 mgt-16" v-model="loginParam.confirmPwd" :password="!isViewConfirmPwd"
  34. placeholder="请确认密码" border="bottom" clearable>
  35. <template slot="suffix">
  36. <u-icon @click="isViewConfirmPwd = !isViewConfirmPwd"
  37. :name="isViewConfirmPwd ? 'eye-fill' : 'eye-off'" color="#303030" size="24"></u-icon>
  38. </template>
  39. </u--input>
  40. <u-button :disabled="!isSubmit" class="login" @tap="submit">提交</u-button>
  41. <view class="mgt-48 text-24 text-7E7E7E text-500">
  42. 登录即代表同意
  43. <text class="text-303030">《用户协议》</text>和
  44. <text class="text-303030">《隐私政策》</text>
  45. </view>
  46. </view>
  47. <zmm-slider-verify ref="sliderVerify" @success="successHandle" @error="errorHandle"
  48. @close="closeHandle"></zmm-slider-verify>
  49. </view>
  50. </template>
  51. <script>
  52. import { isValidPhone, isValidPassword } from '@/utils/index'
  53. export default {
  54. data() {
  55. return {
  56. isViewPassword: false,
  57. isViewConfirmPwd: false,
  58. isCode: false,//验证码按钮状态
  59. tips: '',// 验证码提示文字
  60. seconds: 60,//验证码秒数
  61. loginParam: {
  62. inviteCode: undefined,
  63. phone: undefined,
  64. code: undefined,
  65. password: undefined,
  66. confirmPwd: undefined,
  67. },
  68. }
  69. },
  70. computed: {
  71. isShowCode() {
  72. return this.loginParam.phone && !this.isCode
  73. },
  74. isSubmit() {
  75. return this.loginParam.phone && this.loginParam.code &&
  76. this.loginParam.password && this.loginParam.confirmPwd
  77. }
  78. },
  79. watch: {
  80. },
  81. onLoad() {
  82. },
  83. methods: {
  84. //显示验证组件
  85. sliderVerify() {
  86. if(isValidPhone(this.loginParam.phone)) {
  87. this.$refs['sliderVerify'].show()
  88. } else {
  89. uni.$u.toast('请输入正确手机号');
  90. }
  91. },
  92. //验证通过回调
  93. successHandle(e) {
  94. console.log(e)
  95. this.getCode()
  96. },
  97. //验证失败回调
  98. errorHandle(e) {
  99. console.log(e)
  100. },
  101. //组件关闭回调
  102. closeHandle(e) {
  103. console.log(e)
  104. },
  105. codeChange(text) {
  106. this.tips = text;
  107. },
  108. getCode() {
  109. if (this.$refs.uCode.canGetCode) {
  110. // 模拟向后端请求验证码
  111. uni.showLoading({
  112. title: '正在获取验证码'
  113. })
  114. setTimeout(() => {
  115. uni.hideLoading();
  116. // 这里此提示会被this.start()方法中的提示覆盖
  117. uni.$u.toast('验证码已发送');
  118. // 通知验证码组件内部开始倒计时
  119. this.$refs.uCode.start();
  120. }, 2000);
  121. } else {
  122. uni.$u.toast('倒计时结束后再发送');
  123. }
  124. },
  125. end() {
  126. // uni.$u.toast('倒计时结束');
  127. this.isCode = false
  128. },
  129. start() {
  130. // uni.$u.toast('倒计时开始');
  131. this.isCode = true
  132. },
  133. submit() {
  134. if(isValidPhone(this.loginParam.phone)) return uni.$u.toast('请输入正确手机号');
  135. if(isValidPassword(this.loginParam.password)) {
  136. if(this.loginParam.password !== this.loginParam.confirmPwd) return uni.$u.toast('两次输入的密码不一致');
  137. console.log('提交参数 :===>>', this.loginParam);
  138. //todo 请求后端接口
  139. // 通过后跳转到个人中心
  140. this.$navTo('/pages/my/index','redirect')
  141. }
  142. }
  143. }
  144. }
  145. </script>
  146. <style scoped lang="scss">
  147. .content {
  148. width: 100vw;
  149. height: 100vh;
  150. display: flex;
  151. flex-direction: column;
  152. align-items: center;
  153. position: relative;
  154. }
  155. .top_bg {
  156. position: relative;
  157. width: 100vw;
  158. height: 568rpx;
  159. flex-shrink: 0;
  160. background: linear-gradient(to bottom, #ffd8bf, #ffffff);
  161. .top_close {
  162. position: absolute;
  163. top: 128rpx;
  164. left: 40rpx;
  165. width: 48rpx;
  166. height: 48rpx;
  167. }
  168. .top_text {
  169. position: absolute;
  170. top: 224rpx;
  171. left: 64rpx;
  172. display: flex;
  173. color: #070602;
  174. font-family: "MiSans VF";
  175. font-size: 52rpx;
  176. font-style: normal;
  177. font-weight: 600;
  178. line-height: normal;
  179. letter-spacing: 0.66rpx;
  180. text-transform: uppercase;
  181. }
  182. .top_icon {
  183. margin-top: -10rpx;
  184. margin-left: 8rpx;
  185. width: 24rpx;
  186. height: 24rpx;
  187. }
  188. }
  189. .main {
  190. margin-top: -72rpx;
  191. .login {
  192. margin-top: 112rpx;
  193. height: 96rpx;
  194. width: 100%;
  195. flex-shrink: 0;
  196. border-radius: 64rpx;
  197. background: #FE6505;
  198. color: #ffffff;
  199. text-align: center;
  200. font-family: "MiSans VF";
  201. font-size: 36rpx;
  202. font-style: normal;
  203. font-weight: 500;
  204. }
  205. .code_btn {
  206. padding: 0rpx 24rpx;
  207. height: 60rpx;
  208. border-radius: 32rpx;
  209. font-size: 24rpx;
  210. color: #fff;
  211. font-weight: 400;
  212. background: linear-gradient(0deg, #FE6505 0%, #FE6505 100%), #141111;
  213. }
  214. .code_btn_off {
  215. background: #fe65054d;
  216. }
  217. }
  218. </style>