forgot.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="page-box">
  3. <uni-forms :modelValue="postForm" ref="postForm" :rules="rules" :label-width="80">
  4. <sms-box v-model="postForm" ref="smsBox" :type="2"></sms-box>
  5. <uni-forms-item name="newPassword" label="新的密码" required>
  6. <uni-easyinput type="text" v-model="postForm.newPassword" placeholder="输入新密码" />
  7. </uni-forms-item>
  8. </uni-forms>
  9. <view>
  10. <button type="primary" @tap="handleReset">重设密码</button>
  11. </view>
  12. <view class="login-opt">
  13. <a @tap="$navs.toReg">立即注册</a>
  14. <a @tap="$navs.toLogin">已有账号?</a>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import { resetPass } from '@/api/user.js'
  20. import SmsBox from './components/SmsBox.vue'
  21. export default {
  22. components: {
  23. SmsBox
  24. },
  25. data() {
  26. return {
  27. rules: {
  28. newPassword: {
  29. rules: [{
  30. required: true,
  31. errorMessage: '新密码不能为空!'
  32. }]
  33. }
  34. },
  35. postForm: {
  36. captchaKey: '',
  37. captchaValue: '',
  38. smsCode: '',
  39. mobile: '',
  40. newPassword: ''
  41. }
  42. }
  43. },
  44. created(){
  45. },
  46. methods: {
  47. async handleReset() {
  48. let that = this
  49. // 消息框
  50. const smsCheck = await this.$refs.smsBox.validate().then(res=>{return res});
  51. if(!smsCheck){
  52. return;
  53. }
  54. // 对整个表单进行校验,返回一个 Promise
  55. this.$refs.postForm.validate().then((res)=>{
  56. uni.showLoading({
  57. title: '加载中...'
  58. });
  59. // 快速注册后开始考试
  60. resetPass(this.postForm).then(data => {
  61. // 关闭加载
  62. uni.hideLoading()
  63. uni.showToast({
  64. title: '密码重置成功,请重新登录!',
  65. icon:'none',
  66. duration: 2000
  67. })
  68. setTimeout(()=>{
  69. //打印请求返回的数据
  70. uni.switchTab({
  71. url: '/pages/index/index'
  72. });
  73. },1500)
  74. });
  75. }).catch((err)=>{
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style>
  82. </style>