resetpass.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="pages">
  3. <u-navbar
  4. title="修改密码"
  5. :placeholder="true"
  6. :autoBack="true"
  7. :safeAreaInsetTop="true"
  8. >
  9. </u-navbar>
  10. <view class="page-wrap">
  11. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" >
  12. <u-form-item label="" prop="oldPassword" borderBottom ref="oldPassword" >
  13. <u--input
  14. v-model="form.oldPassword"
  15. border="none"
  16. placeholder="请输入旧密码"
  17. :customStyle="inputCustomStyle"
  18. ></u--input>
  19. </u-form-item>
  20. <u-form-item label="" prop="password" borderBottom ref="password" >
  21. <u--input
  22. v-model="form.password"
  23. border="none"
  24. :password="true"
  25. placeholder="请输入新密码"
  26. :customStyle="inputCustomStyle"
  27. ></u--input>
  28. </u-form-item>
  29. <u-form-item label="" prop="comfpassword" borderBottom ref="comfpassword" >
  30. <u--input
  31. v-model="form.comfpassword"
  32. border="none"
  33. :password="true"
  34. placeholder="确认密码"
  35. :customStyle="inputCustomStyle"
  36. ></u--input>
  37. </u-form-item>
  38. </u--form>
  39. <u-button
  40. @click="submit"
  41. text="确定"
  42. type="primary"
  43. shape="circle"
  44. :customStyle="{'margin-top':'60rpx',height:'98rpx','box-sizing':'border-box'}"
  45. color="linear-gradient(90deg, #00D17D 0%, #00A447 100%)">
  46. </u-button>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. form:{
  55. oldPassword:'',
  56. password:'',
  57. comfpassword:'',
  58. },
  59. rules: {
  60. oldPassword: {
  61. type: 'string',
  62. required: true,
  63. message: '请输入旧密码',
  64. trigger: ['blur', 'change']
  65. },
  66. password: [
  67. {
  68. type: 'string',
  69. required: true,
  70. message: '请输入新密码',
  71. trigger: ['blur', 'change']
  72. },
  73. {
  74. min: 6,
  75. max: 10,
  76. message: '长度在6-10个字符之间',
  77. trigger: 'blur',
  78. },
  79. ],
  80. comfpassword: [
  81. {
  82. type: 'string',
  83. required: true,
  84. message: '请确认密码',
  85. trigger: ['blur', 'change']
  86. },
  87. {
  88. validator: (rule, value, callback) => {
  89. if (value === '') {
  90. callback(new Error('请再次输入密码'));
  91. } else if (value !== this.form.password) {
  92. callback(new Error('两次输入密码不一致!'));
  93. } else {
  94. callback();
  95. }
  96. },
  97. trigger: 'blur',
  98. }
  99. ],
  100. },
  101. inputCustomStyle:{
  102. height:'98rpx',
  103. 'border-color':'#eee',
  104. 'padding-left':'30rpx',
  105. 'box-sizing':'border-box',
  106. }
  107. }
  108. },
  109. onShow() {
  110. },
  111. onReady() {
  112. this.$refs.uForm.setRules(this.rules)
  113. },
  114. onLoad() {
  115. },
  116. methods: {
  117. chekPass(){
  118. console.log('chekPass---',this.form);
  119. return new Promise((resolve, reject)=>{
  120. if(!password){
  121. reject('needAuth');
  122. }
  123. })
  124. },
  125. async submit(){
  126. // console.log('form',this.form);
  127. this.$refs.uForm.validate().then(res => {
  128. // let chekPassResult = await this.chekPass();
  129. // return
  130. // uni.$u.toast('校验通过')
  131. const param = {
  132. oldPassword:this.form.oldPassword,
  133. password:this.form.password
  134. }
  135. this.$u.api.updatePassword(param).then(res=>{
  136. // console.log('res',res.data);
  137. this.$u.vuex('vuex_user_info', res.data);
  138. uni.showToast({
  139. title:res.msg,
  140. icon:'success'
  141. })
  142. setTimeout(()=>{
  143. uni.$u.route('/pages/login/login');
  144. },2000)
  145. // uni.reLaunch({url: this.backUrl});
  146. }).catch(err=>{
  147. console.log('login',err);
  148. })
  149. }).catch(errors => {
  150. uni.$u.toast('请正确填写表单')
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. </style>