register.vue 8.2 KB

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