forgetpwd.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. import {sendSmsCode} from "@/api/login.js"
  20. export default {
  21. data() {
  22. return {
  23. timefalg:false,
  24. time:'',
  25. phonenumber:'',
  26. code:'',
  27. newcode:'',//验证码
  28. user:{},
  29. }
  30. },
  31. onReady() {
  32. },
  33. methods: {
  34. getCode(){
  35. var that=this;
  36. if (!this.phonenumber ) {
  37. that.$toast("请输入手机号")
  38. return
  39. }
  40. 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}$/
  41. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  42. that.$toast("请输入正确的手机号")
  43. return
  44. }
  45. var params={
  46. phonenumber:this.phonenumber,
  47. type:3,//1:登录 2:注册 3:修改密码
  48. }
  49. sendSmsCode(params).then(res=>{
  50. if (res.code == 200) {
  51. // 发送验证码
  52. that.$toast("发送成功")
  53. that.newcode=res.msg
  54. that.time=60;
  55. that.timefalg=true;
  56. that.setTimein()
  57. } else {
  58. that.$toast(res.msg)
  59. }
  60. // 判断是不是对等的
  61. // that.getCodesend(that.phonenumber)
  62. })
  63. },
  64. // 验证码倒计时
  65. setTimein(){
  66. var that=this;
  67. clearInterval(that.timer)
  68. that.timer=setInterval(()=>{
  69. if(that.time<=1){
  70. that.timefalg=false;
  71. that.time=60;
  72. clearInterval(that.timer)
  73. }
  74. that.time=that.time-1;
  75. },1000)
  76. },
  77. submit() {
  78. var that = this;
  79. if (!this.phonenumber ) {
  80. that.$toast("请输入手机号")
  81. return
  82. }
  83. if (!this.code ) {
  84. that.$toast("请输入验证码")
  85. return
  86. }
  87. // if(this.code!=this.newcode){
  88. // that.$toast("验证码错误,请重新输入")
  89. // return
  90. // }
  91. 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}$/
  92. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  93. that.$toast("请输入正确的手机号")
  94. return
  95. }
  96. this.$tab.navigateTo(`/mine/pages/pwd/resetpwd?phone=`+this.phonenumber+'&code='+this.code)
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. page {
  103. background-color: #f5f5f5;
  104. }
  105. .line{width: 2rpx;height: 24rpx;background: #CDCDCD;margin: 0 24rpx;}
  106. .code{font-size: 30rpx;color: $com-cd3;
  107. &.act{color: #666666;}
  108. }
  109. .pwd-retrieve-container {
  110. padding: 10rpx 36rpx;
  111. }
  112. .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;}
  113. .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;}
  114. .pwd /deep/ .uni-forms-item__label{font-size: 32rpx;font-weight: 500;
  115. color: #161616;flex: 0 0 auto;width: auto !important;}
  116. .pwd /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 32rpx;color: #161616;}
  117. .pwd /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  118. .pwd /deep/ .uni-easyinput__placeholder-class{font-size: 30rpx;}
  119. .pwd /deep/ .uni-easyinput__content-input{font-size: 30rpx;}
  120. .pwd /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  121. </style>