Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

verify-phone-code.vue 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. </template>
  20. <script setup lang="ts">
  21. import {
  22. msg,
  23. navTo
  24. } from "@/utils/utils";
  25. import {
  26. onLoad
  27. } from "@dcloudio/uni-app";
  28. import {
  29. ref,
  30. reactive
  31. } from "vue";
  32. import {
  33. request
  34. } from "@/utils/network/request";
  35. import {
  36. sendCode,
  37. changePhone
  38. } from "@/utils/network/api.js";
  39. import {
  40. useUserStore
  41. } from '@/stores/user';
  42. const state = reactive({
  43. promoteId: '',
  44. userType: '',
  45. type: '',
  46. isValueCard: '',
  47. phone: "", //电话
  48. checked: false, //是否勾选阅读协议
  49. });
  50. const userStore = useUserStore();
  51. const {
  52. loginOutNoConfirm
  53. } = userStore;
  54. //上个界面传递的电话号码
  55. const phone = ref("");
  56. const code = ref(null);
  57. //倒计时时常
  58. const codeDuration = ref(0);
  59. let interval = null;
  60. onLoad((option) => {
  61. state.type = option.type; //客车
  62. state.userType = option.userType;
  63. state.promoteId = option.promoteId;
  64. state.isValueCard=option.isValueCard
  65. phone.value = option.phone;
  66. codeInterval();
  67. });
  68. /* 验证码倒计时 */
  69. const codeInterval = () => {
  70. codeDuration.value = 60;
  71. interval = setInterval(() => {
  72. codeDuration.value--;
  73. if (codeDuration.value === 0) {
  74. if (interval) {
  75. clearInterval(interval);
  76. interval = null;
  77. }
  78. }
  79. }, 1000);
  80. };
  81. /* 发送验证码 */
  82. const sendRegisterCode = () => {
  83. if (codeDuration.value !== 0) {
  84. return;
  85. }
  86. const options = {
  87. type: 2,
  88. data: {
  89. mobile: phone.value
  90. },
  91. method: "POST",
  92. showLoading: true,
  93. };
  94. request(sendCode, options).then((res) => {
  95. msg("验证码发送成功!");
  96. codeInterval();
  97. });
  98. };
  99. /* 下一步 */
  100. const nextStep = () => {
  101. if (!code.value) {
  102. msg("请先输入验证码!");
  103. return;
  104. }
  105. const options = {
  106. type: 2,
  107. data: {
  108. mobile: phone.value,
  109. code: code.value
  110. },
  111. method: "POST",
  112. showLoading: true,
  113. };
  114. request('966', options).then((res) => {
  115. uni.redirectTo({
  116. url: `/subpackage/orders/essential-information?promoteId=${state.promoteId}&userType=${state.userType}&type=${state.type}&isValueCard=${state.isValueCard}`,
  117. });
  118. });
  119. };
  120. </script>
  121. <style lang="scss" scoped>
  122. .register-main {
  123. border-top: 1rpx solid #dcdcdc;
  124. padding: 78rpx 30rpx 50rpx;
  125. .title {
  126. font-size: 32rpx;
  127. color: #333333;
  128. font-weight: 600;
  129. }
  130. .hint {
  131. font-size: 24rpx;
  132. color: #999999;
  133. margin-top: 20rpx;
  134. }
  135. }
  136. .input-code {
  137. margin: 100rpx -10rpx 0px;
  138. }
  139. .hint2 {
  140. margin-top: 40rpx;
  141. display: flex;
  142. .green {
  143. font-size: 28rpx;
  144. color: #00b38b;
  145. }
  146. .grey {
  147. font-size: 24rpx;
  148. color: #999999;
  149. margin-left: 16rpx;
  150. }
  151. }
  152. .btn {
  153. margin: 200rpx 40rpx 0px;
  154. }
  155. </style>