Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

change-phone-code-ali.vue 2.7KB

před 1 rokem
před 7 měsíci
před 1 rokem
před 7 měsíci
před 1 rokem
před 7 měsíci
před 1 rokem
před 7 měsíci
před 1 rokem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <!-- 注册第2步 -->
  2. <template>
  3. <view class="register-main">
  4. <view class="title">验证码</view>
  5. <view class="input-code">
  6. <input class="input" v-model="code" placeholder="请输入验证码" placeholder-class="form-placeholder"
  7. maxlength="6" type="number" />
  8. </view>
  9. </view>
  10. <view class="btn">
  11. <submit-button title="更换手机号" @submit="nextStep"></submit-button>
  12. </view>
  13. </template>
  14. <script setup lang="ts">
  15. import {
  16. msg,
  17. navTo
  18. } from "@/utils/utils";
  19. import {
  20. onLoad
  21. } from "@dcloudio/uni-app";
  22. import {
  23. ref
  24. } from "vue";
  25. import {
  26. request,requestNew
  27. } from "@/utils/network/request";
  28. import {
  29. sendMessage,
  30. changePhone
  31. } from "@/utils/network/api.js";
  32. import {
  33. useUserStore
  34. } from '@/stores/user';
  35. const userStore = useUserStore();
  36. const {
  37. loginOutNoConfirm
  38. } = userStore;
  39. //上个界面传递的电话号码
  40. const phone = ref("");
  41. const code = ref(null);
  42. //倒计时时常
  43. const codeDuration = ref(0);
  44. let interval = null;
  45. onLoad((options) => {
  46. phone.value = options.phone;
  47. codeInterval();
  48. });
  49. /* 验证码倒计时 */
  50. const codeInterval = () => {
  51. codeDuration.value = 60;
  52. interval = setInterval(() => {
  53. codeDuration.value--;
  54. if (codeDuration.value === 0) {
  55. if (interval) {
  56. clearInterval(interval);
  57. interval = null;
  58. }
  59. }
  60. }, 1000);
  61. };
  62. /* 发送验证码 */
  63. const sendRegisterCode = () => {
  64. if (codeDuration.value !== 0) {
  65. return;
  66. }
  67. const options = {
  68. type: 2,
  69. data: {
  70. mobile: phone.value
  71. },
  72. method: "POST",
  73. showLoading: true,
  74. };
  75. requestNew(sendMessage, options).then((res) => {
  76. msg("验证码发送成功!");
  77. codeInterval();
  78. });
  79. };
  80. /* 下一步 */
  81. const nextStep = () => {
  82. if (!code.value) {
  83. msg("请先输入验证码!");
  84. return;
  85. }
  86. const options = {
  87. type: 2,
  88. data: {
  89. mobile: phone.value,
  90. verificationCode: code.value
  91. },
  92. method: "POST",
  93. showLoading: true,
  94. };
  95. requestNew(changePhone, options).then((res) => {
  96. msg("更改手机号成功");
  97. codeInterval();
  98. var pages = getCurrentPages().length;
  99. uni.navigateBack({
  100. delta: pages,
  101. });
  102. loginOutNoConfirm()
  103. });
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. .register-main {
  108. border-top: 1rpx solid #dcdcdc;
  109. padding: 78rpx 30rpx 50rpx;
  110. .title {
  111. font-size: 32rpx;
  112. color: #333333;
  113. font-weight: 600;
  114. }
  115. .hint {
  116. font-size: 24rpx;
  117. color: #999999;
  118. margin-top: 20rpx;
  119. }
  120. }
  121. .input-code {
  122. margin: 100rpx -10rpx 0px;
  123. }
  124. .hint2 {
  125. margin-top: 40rpx;
  126. display: flex;
  127. .green {
  128. font-size: 28rpx;
  129. color: #00b38b;
  130. }
  131. .grey {
  132. font-size: 24rpx;
  133. color: #999999;
  134. margin-left: 16rpx;
  135. }
  136. }
  137. .btn {
  138. margin: 200rpx 40rpx 0px;
  139. }
  140. </style>