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.

forgotPassword.vue 3.8 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="page">
  3. <view class="content" v-if="type == 'sendCode'">
  4. <l-input v-model="phone" placeholder="请输入手机号" left>
  5. <l-icon slot="title" type="phone" />
  6. </l-input>
  7. <view class="btn" @click="sendCode">发送验证码</view>
  8. </view>
  9. <view class="content" v-if="type == 'checkCode'">
  10. <l-input v-model="phone" placeholder="请输入手机号" left disabled>
  11. <l-icon slot="title" type="phone" />
  12. </l-input>
  13. <l-input v-model="verifycode" placeholder="请输入验证码" left password>
  14. <l-icon slot="title" type="lock" />
  15. </l-input>
  16. <view style="margin-top: 4px;color: color: #606266;">
  17. 未收到验证码?<text :style="{color:time==0?'#409EFF':'#999'}" @click="()=>{if(time==0)type='sendCode'}">重新发送</text>
  18. {{time?'( '+time+ 's'+' )' :''}}
  19. </view>
  20. <view class="btn" @click="checkverifycode">下一步</view>
  21. </view>
  22. <view class="content" v-if="type == 'setPassword'">
  23. <l-input v-model="phone" placeholder="请输入手机号" left disabled>
  24. <l-icon slot="title" type="phone" />
  25. </l-input>
  26. <l-input v-model="form.newpassword" placeholder="请输入新密码" left password>
  27. <l-icon slot="title" type="lock" />
  28. </l-input>
  29. <l-input v-model="form.newpassword1" placeholder="请再次输入新密码" left password>
  30. <l-icon slot="title" type="lock" />
  31. </l-input>
  32. <view class="btn" @click="setPassword">确认修改</view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. // import moment from 'moment';
  38. export default{
  39. data() {
  40. return {
  41. type:'sendCode',
  42. phone:'',
  43. verifycode:'',
  44. time: 0,
  45. timeT: '',
  46. form:{
  47. newpassword:'',
  48. newpassword1:'',
  49. },
  50. }
  51. },
  52. destroyed() {
  53. this.timeT && clearInterval(this.timeT)
  54. },
  55. methods:{
  56. // 发送验证码
  57. sendCode(){
  58. if(!this.phone){
  59. this.TOAST('请输入手机号!')
  60. return
  61. }else if(!/^1[0-9]{10}$/.test(this.phone)){
  62. this.TOAST('手机号格式不正确!')
  63. return
  64. }
  65. this.LOADING()
  66. this.HTTP_POST('learun/adms/usernologin/sendcode',{username:this.phone}).then(res=>{
  67. this.HIDE_LOADING()
  68. if(!res){
  69. return
  70. }
  71. this.type = 'checkCode'
  72. this.time = 60
  73. this.timeT = setInterval(() => {
  74. this.time--
  75. if (this.time == 0) {
  76. clearInterval(this.timeT)
  77. this.timeT = ''
  78. return
  79. }
  80. }, 1000);
  81. })
  82. },
  83. // 验证码校验
  84. async checkverifycode() {
  85. if (!this.verifycode) {
  86. this.TOAST('请输入验证码');
  87. return
  88. }
  89. this.LOADING('正在校验...')
  90. let codeResult = await this.HTTP_POST('learun/adms/user/logincodeverify', {
  91. mobile: this.phone,
  92. verifycode: this.verifycode
  93. })
  94. this.HIDE_LOADING()
  95. if(!codeResult)return
  96. this.type = 'setPassword'
  97. },
  98. // 设置密码
  99. async setPassword(){
  100. if(!this.form.newpassword){
  101. this.TOAST('请输入新密码');
  102. return
  103. }
  104. if(!/^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\.])[0-9a-zA-Z!@#$%^&*,\.]{8,20}$/.test(this.form.newpassword)){
  105. this.TOAST('您的密码不满足强度要求,请重新输入');
  106. return
  107. }
  108. if(!this.form.newpassword1){
  109. this.TOAST('请再次输入新密码');
  110. return
  111. }
  112. if(this.form.newpassword != this.form.newpassword1){
  113. this.TOAST('两次密码输入不一致');
  114. return
  115. }
  116. this.LOADING()
  117. let res = await this.HTTP_POST('learun/adms/usernologin/forgetpass', {
  118. newpassword:this.MD5(this.form.newpassword),
  119. // this.MD5()
  120. phone:this.phone
  121. })
  122. this.HIDE_LOADING()
  123. if(!res)return
  124. this.TOAST('修改成功')
  125. setTimeout(()=>{
  126. this.NAV_TO('/pages/login')
  127. },500)
  128. }
  129. },
  130. }
  131. </script>
  132. <style scoped>
  133. .page {
  134. height: 100vh;
  135. width: 100%;
  136. display: flex;
  137. justify-content: center;
  138. align-items: center;
  139. }
  140. .content{
  141. width: 80%;
  142. padding-bottom: 60px;
  143. }
  144. </style>