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.

verify-phone-code.vue 3.2KB

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