Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

register-step2.vue 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <!-- 注册第2步 -->
  2. <template>
  3. <view class="register-main">
  4. <view class="title">请输入验证码</view>
  5. <view class="hint">验证码已发送至:{{ phone }}</view>
  6. <view class="input-code">
  7. <verification-code-input v-model="code"></verification-code-input>
  8. </view>
  9. <view class="hint2">
  10. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  11. <view class="grey" @click="sendRegisterCode">{{
  12. codeDuration === 0 ? "重新发送验证码" : "秒后可重新发送验证码"
  13. }}</view>
  14. </view>
  15. </view>
  16. <!-- <view class="btn">
  17. <submit-button title="下一步" @submit="nextStep"></submit-button>
  18. </view> -->
  19. <view class="register-main">
  20. <view class="title">请设置登录密码</view>
  21. <view class="hint">设置登录密码用于登录</view>
  22. <view class="hint1">密码</view>
  23. <view class="form-input">
  24. <input class="input" v-model="state.password" placeholder="请输入密码" placeholder-class="form-placeholder"
  25. :password="state.isPwdType ? true : false" type="text" />
  26. <image :src="`${$imgUrl}login/${
  27. state.isPwdType ? 'icon_eye_close' : 'icon_eye_open'
  28. }.png`" class="eye" @click="state.isPwdType = !state.isPwdType" mode="aspectFill"></image>
  29. </view>
  30. <view class="hint4">{{ state.pwdHint }}</view>
  31. </view>
  32. <view class="btn">
  33. <submit-button title="确认注册" @submit="doRegister"></submit-button>
  34. </view>
  35. </template>
  36. <script setup lang="ts">
  37. import { msg, navTo, confirm } from "@/utils/utils";
  38. import { onLoad } from "@dcloudio/uni-app";
  39. import { ref } from "vue";
  40. import { request,requestNew } from "@/utils/network/request";
  41. import { sendMessage,regist } from "@/utils/network/api.js";
  42. import { reactive } from "vue";
  43. //上个界面传递的电话号码
  44. const phone = ref("");
  45. const code = ref(null);
  46. //倒计时时常
  47. const codeDuration = ref(0);
  48. let interval = null;
  49. const state = reactive({
  50. isPwdType: true,
  51. isAffirmPwdType: true,
  52. password: "", //密码
  53. phone: "", //手机号
  54. code: "", //验证码
  55. pwdHint: "密码不少于10位,必须同时包含数字、大小写字母和特殊符号,不能使用3个连续字符",
  56. });
  57. onLoad((options) => {
  58. phone.value = options.phone;
  59. codeInterval();
  60. });
  61. /* 验证码倒计时 */
  62. const codeInterval = () => {
  63. codeDuration.value = 60;
  64. interval = setInterval(() => {
  65. codeDuration.value--;
  66. if (codeDuration.value === 0) {
  67. if (interval) {
  68. clearInterval(interval);
  69. interval = null;
  70. }
  71. }
  72. }, 1000);
  73. };
  74. /* 发送验证码 */
  75. const sendRegisterCode = () => {
  76. if (codeDuration.value !== 0) {
  77. return;
  78. }
  79. const options = {
  80. type: 2,
  81. data: {
  82. mobile: phone.value ,
  83. businessType:1
  84. },
  85. method: "POST",
  86. showLoading: true,
  87. };
  88. requestNew(sendMessage, options).then((res) => {
  89. msg("验证码发送成功!");
  90. codeInterval();
  91. });
  92. };
  93. /* 注册 */
  94. const doRegister = () => {
  95. if (!code.value) {
  96. msg("请先输入验证码!");
  97. return;
  98. }
  99. if (!state.password) {
  100. msg("请输入密码");
  101. return;
  102. }
  103. const options = {
  104. type: 2,
  105. data: {
  106. loginPass: state.password,
  107. mobile: phone.value,
  108. code: code.value,
  109. nickName: phone.value,
  110. },
  111. method: "POST",
  112. showLoading: true,
  113. };
  114. requestNew(regist, options).then((res) => {
  115. confirm(
  116. "注册成功,请登录!",
  117. () => {
  118. uni.$emit("login", { phone: phone.value });
  119. uni.navigateBack({ delta: 2 });
  120. },
  121. "提示",
  122. false
  123. );
  124. });
  125. };
  126. </script>
  127. <style lang="scss" scoped>
  128. .register-main {
  129. border-top: 1rpx solid #dcdcdc;
  130. padding: 78rpx 30rpx 50rpx;
  131. .title {
  132. font-size: 32rpx;
  133. color: #333333;
  134. font-weight: 600;
  135. }
  136. .hint {
  137. font-size: 24rpx;
  138. color: #999999;
  139. margin-top: 20rpx;
  140. }
  141. }
  142. .input-code {
  143. // margin: 100rpx -10rpx 0px;
  144. background: transparent !important;
  145. }
  146. ::v-deep .flex-box .hide-input {
  147. background: transparent !important;
  148. }
  149. ::v-deep .code-box {
  150. background: transparent !important;
  151. }
  152. .hint2 {
  153. margin-top: 40rpx;
  154. display: flex;
  155. .green {
  156. font-size: 28rpx;
  157. color: #00b38b;
  158. }
  159. .grey {
  160. font-size: 24rpx;
  161. color: #999999;
  162. margin-left: 16rpx;
  163. }
  164. }
  165. .btn {
  166. width: 90%;
  167. margin: 0 auto;
  168. margin-top: 100rpx;
  169. }
  170. .form-input {
  171. display: flex;
  172. flex-direction: row;
  173. align-items: center;
  174. height: 90rpx;
  175. margin-top: 30rpx;
  176. border-bottom: 1rpx solid #dcdcdc;
  177. color: #333333;
  178. .input {
  179. flex: 1;
  180. padding-right: 48rpx;
  181. font-size: 26rpx;
  182. background: transparent;
  183. }
  184. .eye {
  185. width: 48rpx;
  186. height: 48rpx;
  187. }
  188. }
  189. .register-main {
  190. border-top: 1rpx solid #dcdcdc;
  191. padding: 78rpx 30rpx 50rpx;
  192. .title {
  193. font-size: 32rpx;
  194. color: #333333;
  195. font-weight: 600;
  196. }
  197. .hint {
  198. font-size: 24rpx;
  199. color: #999999;
  200. margin-top: 20rpx;
  201. }
  202. .hint1 {
  203. color: #333333;
  204. font-size: 28rpx;
  205. margin-top: 100rpx;
  206. font-weight: 600;
  207. }
  208. .hint4 {
  209. margin-top: 30rpx;
  210. font-size: 26rpx;
  211. color: #00b38b;
  212. }
  213. }
  214. </style>