forgetpwd.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="pwd-retrieve-container pwd">
  3. <uni-forms ref="form" :value="user" >
  4. <uni-forms-item name="phonenumber" label="手机号码">
  5. <uni-easyinput :inputBorder="false" type="number" v-model="phonenumber" placeholder="请输入您的手机号码" />
  6. </uni-forms-item>
  7. <uni-forms-item name="code" label="验证码">
  8. <uni-easyinput :inputBorder="false" v-model="code" placeholder="请输入验证码" />
  9. <view class="line flex0"></view>
  10. <view v-if="timefalg" class="code act">{{time}}秒</view>
  11. <view v-else @click="getCode" class="code">发送验证码</view>
  12. </uni-forms-item>
  13. <view class="rbtn" @click="submit">下一步</view>
  14. </uni-forms>
  15. </view>
  16. </template>
  17. <script>
  18. import { getappForgetPW } from "@/api/system/user"
  19. export default {
  20. data() {
  21. return {
  22. timefalg:false,
  23. time:'',
  24. phonenumber:'',
  25. code:'',
  26. newcode:'',//验证码
  27. user:{},
  28. }
  29. },
  30. onReady() {
  31. },
  32. methods: {
  33. getCode(){
  34. var that=this;
  35. if (!this.phonenumber ) {
  36. that.$toast("请输入手机号")
  37. return
  38. }
  39. let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  40. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  41. that.$toast("请输入正确的手机号")
  42. return
  43. }
  44. getappForgetPW(this.phonenumber).then(res=>{
  45. if (res.code == 200) {
  46. // 发送验证码
  47. that.$toast("发送成功")
  48. that.newcode=res.msg
  49. that.time=60;
  50. that.timefalg=true;
  51. that.setTimein()
  52. } else {
  53. that.$toast(res.msg)
  54. }
  55. // 判断是不是对等的
  56. // that.getCodesend(that.phonenumber)
  57. })
  58. },
  59. // 验证码倒计时
  60. setTimein(){
  61. var that=this;
  62. clearInterval(that.timer)
  63. that.timer=setInterval(()=>{
  64. if(that.time<=1){
  65. that.timefalg=false;
  66. that.time=60;
  67. clearInterval(that.timer)
  68. }
  69. that.time=that.time-1;
  70. },1000)
  71. },
  72. submit() {
  73. var that = this;
  74. if (!this.phonenumber ) {
  75. that.$toast("请输入手机号")
  76. return
  77. }
  78. if (!this.code ) {
  79. that.$toast("请输入验证码")
  80. return
  81. }
  82. if(this.code!=this.newcode){
  83. that.$toast("验证码错误,请重新输入")
  84. return
  85. }
  86. let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  87. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  88. that.$toast("请输入正确的手机号")
  89. return
  90. }
  91. this.$tab.navigateTo(`/pages/mine/pwd/resetpwd?phone=`+this.phonenumber+'&code='+this.code)
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. page {
  98. background-color: #f5f5f5;
  99. }
  100. .line{width: 2rpx;height: 24rpx;background: #CDCDCD;margin: 0 24rpx;}
  101. .code{font-size: 30rpx;color: $com-cd3;
  102. &.act{color: #666666;}
  103. }
  104. .pwd-retrieve-container {
  105. padding: 10rpx 36rpx;
  106. }
  107. .pwd .rbtn{width: 100%;height: 98rpx;background: $com-cd3;border-radius: 49rpx;text-align: center;line-height: 98rpx;font-size: 32rpx;font-weight: bold;color: #FFFEFE;margin-top: 68rpx;}
  108. .pwd /deep/ .uni-forms-item{height: 126rpx;background: #FFFFFF;border-radius: 18rpx;margin-top: 30rpx;padding: 0 40rpx;box-sizing: border-box;display: flex;align-items: center;margin-bottom: 0;}
  109. .pwd /deep/ .uni-forms-item__label{font-size: 32rpx;font-weight: 500;
  110. color: #161616;flex: 0 0 auto;width: auto !important;}
  111. .pwd /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 32rpx;color: #161616;}
  112. .pwd /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  113. .pwd /deep/ .uni-easyinput__placeholder-class{font-size: 30rpx;}
  114. .pwd /deep/ .uni-easyinput__content-input{font-size: 30rpx;}
  115. .pwd /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  116. </style>