You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

forget-pwd-step2.vue 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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="register-main">
  17. <view class="title">请输入验证码</view>
  18. <view class="hint">验证码已发送至:{{ phone }}</view>
  19. <view class="input-code">
  20. <verification-code-input v-model="code" ></verification-code-input>
  21. </view>
  22. <view class="hint2">
  23. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  24. <view class="grey" @click="sendRegisterCode">{{
  25. codeDuration === 0 ? "重新发送验证码" : "秒后可重新发送验证码"
  26. }}</view>
  27. </view>
  28. </view> -->
  29. <u-form ref="myForm">
  30. <view class="from">
  31. <u-form-item prop="phone">
  32. <view class="from_item" style="background-color: #f7f7f7">
  33. <text><text style="color: red"></text>手机号:</text>
  34. <u-input v-model="phone" :disabled="true" class="input" />
  35. </view>
  36. </u-form-item>
  37. <u-form-item prop="code">
  38. <view class="from_item">
  39. <text><text style="color: red"></text>验证码:</text>
  40. <u-input v-model="code" placeholder="请输入验证码" class="input" />
  41. <view class="hint2">
  42. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  43. <view class="grey" @click="sendRegisterCode">{{
  44. codeDuration === 0 ? "发送验证码" : "秒后可重发"
  45. }}</view>
  46. </view>
  47. </view>
  48. </u-form-item>
  49. </view>
  50. </u-form>
  51. <view class="btn">
  52. <submit-button title="下一步" @submit="nextStep"></submit-button>
  53. </view>
  54. </template>
  55. <script setup lang="ts">
  56. import { msg, navTo } from "@/utils/utils";
  57. import { onLoad } from "@dcloudio/uni-app";
  58. import { ref } from "vue";
  59. import { request } from "@/utils/network/request";
  60. import { sendCode } from "@/utils/network/api.js";
  61. //上个界面传递的电话号码
  62. const phone = ref("");
  63. const code = ref(null);
  64. //倒计时时常
  65. const codeDuration = ref(0);
  66. let interval = null;
  67. onLoad((options) => {
  68. phone.value = options.phone;
  69. codeInterval();
  70. });
  71. /* 验证码倒计时 */
  72. const codeInterval = () => {
  73. codeDuration.value = 60;
  74. interval = setInterval(() => {
  75. codeDuration.value--;
  76. if (codeDuration.value === 0) {
  77. if (interval) {
  78. clearInterval(interval);
  79. interval = null;
  80. }
  81. }
  82. }, 1000);
  83. };
  84. /* 发送验证码 */
  85. const sendRegisterCode = () => {
  86. if (codeDuration.value !== 0) {
  87. return;
  88. }
  89. const options = {
  90. type: 2,
  91. data: { mobile: phone.value },
  92. method: "POST",
  93. showLoading: true,
  94. };
  95. request(sendCode, options).then((res) => {
  96. msg("验证码发送成功!");
  97. codeInterval();
  98. });
  99. };
  100. /* 下一步 */
  101. const nextStep = () => {
  102. if (!code.value) {
  103. msg("请先输入验证码!");
  104. return;
  105. }
  106. navTo(`/login/forget-pwd-step3?phone=${phone.value}&code=${code.value}`);
  107. };
  108. </script>
  109. <style lang="scss" scoped>
  110. .register-main {
  111. border-top: 1rpx solid #dcdcdc;
  112. padding: 78rpx 30rpx 50rpx;
  113. .title {
  114. font-size: 32rpx;
  115. color: #333333;
  116. font-weight: 600;
  117. }
  118. .hint {
  119. font-size: 24rpx;
  120. color: #999999;
  121. margin-top: 20rpx;
  122. }
  123. }
  124. .input-code {
  125. margin: 100rpx -10rpx 0px;
  126. }
  127. .hint2 {
  128. margin-top: 40rpx;
  129. display: flex;
  130. .green {
  131. font-size: 28rpx;
  132. color: #00b38b;
  133. }
  134. .grey {
  135. font-size: 24rpx;
  136. color: #999999;
  137. margin-left: 16rpx;
  138. }
  139. }
  140. .btn {
  141. margin: 200rpx 40rpx 0px;
  142. }
  143. </style>