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-ali.vue 6.0KB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <!-- 注册第2步 -->
  2. <template>
  3. <u-form ref="myForm">
  4. <view class="from">
  5. <u-form-item prop="phone">
  6. <view class="from_item" style="background-color: #f7f7f7">
  7. <text><text style="color: red"></text>手机号:</text>
  8. <u-input v-model="phone" :disabled="true" class="input" />
  9. </view>
  10. </u-form-item>
  11. <u-form-item prop="code">
  12. <view class="from_item">
  13. <text><text style="color: red"></text>验证码:</text>
  14. <u-input v-model="code" placeholder="请输入验证码" class="input" />
  15. <view class="hint2">
  16. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  17. <view class="grey" @click="sendRegisterCode">{{
  18. codeDuration === 0 ? "发送验证码" : "秒后可重发"
  19. }}</view>
  20. </view>
  21. </view>
  22. </u-form-item>
  23. </view>
  24. </u-form>
  25. <!-- <view class="btn">
  26. <submit-button title="下一步" @submit="nextStep"></submit-button>
  27. </view> -->
  28. <view class="register-main">
  29. <!-- <view class="title">重置密码</view>
  30. <view class="hint">重置之前的密码,设置新密码</view> -->
  31. <view class="hint1">请输入密码</view>
  32. <view class="form-input">
  33. <input class="input" v-model="state.password" placeholder="请输入密码" placeholder-class="form-placeholder"
  34. :password="state.isPwdType ? true : false" type="text" />
  35. <image :src="`${$imgUrl}login/${
  36. state.isPwdType ? 'icon_eye_close' : 'icon_eye_open'
  37. }.png`" class="eye" @click="state.isPwdType = !state.isPwdType" mode="aspectFill"></image>
  38. </view>
  39. <view class="hint2">请再次输入密码</view>
  40. <view class="form-input">
  41. <input class="input" v-model="state.affirmPassword" placeholder="请再次输入密码"
  42. placeholder-class="form-placeholder" :password="state.isAffirmPwdType ? true : false" type="text" />
  43. <image :src="`${$imgUrl}login/${
  44. state.isAffirmPwdType ? 'icon_eye_close' : 'icon_eye_open'
  45. }.png`" class="eye" @click="state.isAffirmPwdType = !state.isAffirmPwdType" mode="aspectFill"></image>
  46. </view>
  47. <view class="hint4">{{ state.pwdHint }}</view>
  48. </view>
  49. <view class="btn">
  50. <submit-button title="确认更改" @submit="doResetPwd"></submit-button>
  51. </view>
  52. </template>
  53. <script setup lang="ts">
  54. import { msg, navTo, confirm, checkStr } from "@/utils/utils";
  55. import { onLoad } from "@dcloudio/uni-app";
  56. import { reactive } from "vue";
  57. import { ref } from "vue";
  58. import { request } from "@/utils/network/request";
  59. import { sendCode, resetPwd } from "@/utils/network/api.js";
  60. //上个界面传递的电话号码
  61. const phone = ref("");
  62. const code = ref(null);
  63. //倒计时时常
  64. const codeDuration = ref(0);
  65. let interval = null;
  66. const state = reactive({
  67. isPwdType: true,
  68. isAffirmPwdType: true,
  69. password: "", //密码
  70. affirmPassword: "",//再次输入密码
  71. phone: "", //手机号
  72. code: "", //验证码
  73. pwdHint: "密码不少于10位,必须同时包含数字、大小写字母和特殊符号,不能使用3个连续字符",
  74. });
  75. onLoad((options) => {
  76. phone.value = options.phone;
  77. codeInterval();
  78. });
  79. /* 验证码倒计时 */
  80. const codeInterval = () => {
  81. codeDuration.value = 60;
  82. interval = setInterval(() => {
  83. codeDuration.value--;
  84. if (codeDuration.value === 0) {
  85. if (interval) {
  86. clearInterval(interval);
  87. interval = null;
  88. }
  89. }
  90. }, 1000);
  91. };
  92. /* 发送验证码 */
  93. const sendRegisterCode = () => {
  94. if (codeDuration.value !== 0) {
  95. return;
  96. }
  97. const options = {
  98. type: 2,
  99. data: { mobile: phone.value },
  100. method: "POST",
  101. showLoading: true,
  102. };
  103. request(sendCode, options).then((res) => {
  104. msg("验证码发送成功!");
  105. codeInterval();
  106. });
  107. };
  108. /* 下一步 */
  109. const nextStep = () => {
  110. if (!code.value) {
  111. msg("请先输入验证码!");
  112. return;
  113. }
  114. navTo(`/login/forget-pwd-step3?phone=${phone.value}&code=${code.value}`);
  115. };
  116. /* 忘记密码 */
  117. const doResetPwd = () => {
  118. if (!code.value) {
  119. msg("请先输入验证码!");
  120. return;
  121. }
  122. if (!state.password) {
  123. msg("请输入密码");
  124. return;
  125. }
  126. if (!state.affirmPassword) {
  127. msg("请再次输入密码");
  128. return;
  129. }
  130. if (state.password !== state.affirmPassword) {
  131. msg("两次密码输入不一致,请重新输入!");
  132. return;
  133. }
  134. const options = {
  135. type: 2,
  136. data: {
  137. newPassword: state.password,
  138. affirmNewPassword: state.affirmPassword,
  139. mobile: phone.value,
  140. code: code.value,
  141. },
  142. method: "POST",
  143. showLoading: true,
  144. };
  145. request(resetPwd, options).then((res) => {
  146. confirm(
  147. "密码重置成功,请登录!",
  148. () => {
  149. uni.$emit("login", { phone: phone.value });
  150. uni.navigateBack({ delta: 2 });
  151. },
  152. "提示",
  153. false
  154. );
  155. });
  156. };
  157. </script>
  158. <style lang="scss" scoped>
  159. .register-main {
  160. border-top: 1rpx solid #dcdcdc;
  161. padding: 78rpx 30rpx 50rpx;
  162. .title {
  163. font-size: 32rpx;
  164. color: #333333;
  165. font-weight: 600;
  166. }
  167. .hint {
  168. font-size: 24rpx;
  169. color: #999999;
  170. margin-top: 20rpx;
  171. }
  172. }
  173. .input-code {
  174. margin: 100rpx -10rpx 0px;
  175. }
  176. .hint2 {
  177. margin-top: 40rpx;
  178. display: flex;
  179. .green {
  180. font-size: 28rpx;
  181. color: #00b38b;
  182. }
  183. .grey {
  184. font-size: 24rpx;
  185. color: #999999;
  186. margin-left: 16rpx;
  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. .hint2 {
  209. color: #333333;
  210. font-size: 28rpx;
  211. margin-top: 50rpx;
  212. font-weight: 600;
  213. }
  214. .hint4 {
  215. margin-top: 30rpx;
  216. font-size: 26rpx;
  217. color: #00b38b;
  218. }
  219. }
  220. .form-input {
  221. display: flex;
  222. flex-direction: row;
  223. align-items: center;
  224. height: 90rpx;
  225. margin-top: 30rpx;
  226. border-bottom: 1rpx solid #dcdcdc;
  227. color: #333333;
  228. .input {
  229. flex: 1;
  230. padding-right: 48rpx;
  231. font-size: 26rpx;
  232. background: transparent;
  233. }
  234. .eye {
  235. width: 48rpx;
  236. height: 48rpx;
  237. }
  238. }
  239. .form-placeholder {
  240. color: #999999;
  241. }
  242. .btn {
  243. margin: 80rpx 40px;
  244. }
  245. </style>