findpaypass.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="page-wrap">
  3. <u-navbar
  4. title="忘记密码"
  5. :placeholder="true"
  6. :autoBack="true"
  7. :safeAreaInsetTop="true"
  8. >
  9. </u-navbar>
  10. <view class="title">手机验证身份</view>
  11. <view class="phone">
  12. <text v-if="leftTime>0">验证码已发送</text>
  13. <text v-else>手机号:</text>
  14. {{vuex_member_info.mobile|hidePhoneNumber}}</view>
  15. <u-code-input
  16. v-model="value"
  17. mode="line"
  18. :maxlength="4"
  19. @finish="finish">
  20. </u-code-input>
  21. <u-button class="button" type="primary" :disabled="leftTime>0" @click="sendSMS" :text="btnStatus"></u-button>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. value:'',
  29. leftTime: 0, // 剩余时间
  30. btnStatus: '发送验证码', // 按钮状态
  31. params:{
  32. }
  33. }
  34. },
  35. onShow() {
  36. },
  37. onLoad() {
  38. },
  39. methods: {
  40. sendSMS() {
  41. // console.log('发送短信验证码到:', 手机号码);
  42. this.$u.api.getCode({mobile:this.vuex_member_info.mobile}).then(res=>{
  43. this.leftTime = 60;
  44. this.btnStatus = `${this.leftTime}秒后重试`;
  45. const timer = setInterval(() => {
  46. this.leftTime--;
  47. this.btnStatus = `${this.leftTime}秒后重试`;
  48. if (this.leftTime <= 0) {
  49. clearInterval(timer);
  50. this.btnStatus = '重新发送验证码';
  51. }
  52. }, 1000);
  53. console.log('res',res.data);
  54. }).catch(err=>{
  55. console.log('getCode',err);
  56. });
  57. },
  58. finish(){
  59. console.log('value',this.value);
  60. this.$u.api.verifyCode({mobile:this.vuex_member_info.mobile,code:this.value}).then(res=>{
  61. uni.$u.route('/center/setPaypass', {
  62. fromPage: 'forget',
  63. code:this.value
  64. });
  65. console.log('res',res.data);
  66. }).catch(err=>{
  67. console.log('getCode',err);
  68. });
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .page-wrap{
  75. text-align: center;
  76. .title{
  77. font-size: 32rpx;
  78. font-weight: 600;
  79. color: #333333;
  80. line-height: 45rpx;
  81. margin: 40rpx auto 30rpx;
  82. }
  83. .phone{
  84. font-size: 26rpx;
  85. font-weight: 400;
  86. color: #999999;
  87. line-height: 37rpx;
  88. margin-bottom: 130rpx;
  89. }
  90. }
  91. /deep/ .u-code-input__item{
  92. flex-grow: 1;
  93. }
  94. /deep/ .u-button{
  95. margin-top: 80rpx;
  96. width: 80%!important;
  97. }
  98. </style>