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.
 
 
 
 
 
 

151 lines
3.9 KiB

  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. codeType:'forgetpwd',
  51. }
  52. },
  53. destroyed() {
  54. this.timeT && clearInterval(this.timeT)
  55. },
  56. methods:{
  57. // 发送验证码
  58. sendCode(){
  59. if(!this.phone){
  60. this.TOAST('请输入手机号!')
  61. return
  62. }else if(!/^1[0-9]{10}$/.test(this.phone)){
  63. this.TOAST('手机号格式不正确!')
  64. return
  65. }
  66. this.LOADING()
  67. this.HTTP_POST('learun/adms/usernologin/sendcode',{username:this.phone,codeType:this.codeType}).then(res=>{
  68. this.HIDE_LOADING()
  69. if(!res){
  70. return
  71. }
  72. this.type = 'checkCode'
  73. this.time = 60
  74. this.timeT = setInterval(() => {
  75. this.time--
  76. if (this.time == 0) {
  77. clearInterval(this.timeT)
  78. this.timeT = ''
  79. return
  80. }
  81. }, 1000);
  82. })
  83. },
  84. // 验证码校验
  85. async checkverifycode() {
  86. if (!this.verifycode) {
  87. this.TOAST('请输入验证码');
  88. return
  89. }
  90. this.LOADING('正在校验...')
  91. let codeResult = await this.HTTP_POST('learun/adms/usernologin/logincodeverify', {
  92. mobile: this.phone,
  93. verifycode: this.verifycode,
  94. codeType: this.codeType
  95. })
  96. this.HIDE_LOADING()
  97. if(!codeResult)return
  98. this.type = 'setPassword'
  99. },
  100. // 设置密码
  101. async setPassword(){
  102. if(!this.form.newpassword){
  103. this.TOAST('请输入新密码');
  104. return
  105. }
  106. if(!/^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\.])[0-9a-zA-Z!@#$%^&*,\.]{8,20}$/.test(this.form.newpassword)){
  107. this.TOAST('您的密码不满足强度要求,请重新输入');
  108. return
  109. }
  110. if(!this.form.newpassword1){
  111. this.TOAST('请再次输入新密码');
  112. return
  113. }
  114. if(this.form.newpassword != this.form.newpassword1){
  115. this.TOAST('两次密码输入不一致');
  116. return
  117. }
  118. this.LOADING()
  119. let res = await this.HTTP_POST('learun/adms/usernologin/forgetpass', {
  120. newpassword:this.MD5(this.form.newpassword),
  121. // this.MD5()
  122. phone:this.phone
  123. })
  124. this.HIDE_LOADING()
  125. if(!res)return
  126. this.TOAST('修改成功')
  127. setTimeout(()=>{
  128. this.NAV_TO('/pages/login')
  129. },500)
  130. }
  131. },
  132. }
  133. </script>
  134. <style scoped>
  135. .page {
  136. height: 100vh;
  137. width: 100%;
  138. display: flex;
  139. justify-content: center;
  140. align-items: center;
  141. }
  142. .content{
  143. width: 80%;
  144. padding-bottom: 60px;
  145. }
  146. </style>