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