index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="info">
  3. <view class='zhanline'></view>
  4. <uni-forms class="pl12" ref="form" :value="user">
  5. <uni-forms-item name="oldPassword" style='margin-bottom: 0;'>
  6. <view class="flexc infolist">
  7. <view class="f16 fw c34 flex0">旧密码</view>
  8. <input placeholder="请输入旧密码" v-if="oldcheckeye" type="text" v-model="user.oldPassword" class="f16 c34 flex1 txr"/>
  9. <input placeholder="请输入旧密码" v-else type="password" v-model="user.oldPassword" class="f16 c34 flex1 txr"/>
  10. <view class="input_ye ml8" v-if="user.oldPassword" @click="oldcheckeye=!oldcheckeye">
  11. <image :src="yeimgs" v-if="oldcheckeye"></image>
  12. <image :src="yeimg" v-else></image>
  13. </view>
  14. </view>
  15. </uni-forms-item>
  16. <uni-forms-item name="newPassword" style='margin-bottom: 0;'>
  17. <view class="flexc infolist">
  18. <view class="f16 fw c34 flex0">新密码</view>
  19. <input placeholder="请输入新密码" v-if="newcheckeye" type="text" v-model="user.newPassword" class="f16 c34 flex1 txr"/>
  20. <input placeholder="请输入新密码" v-else type="password" v-model="user.newPassword" class="f16 c34 flex1 txr"/>
  21. <view class="input_ye ml8" v-if="user.newPassword" @click="newcheckeye=!newcheckeye">
  22. <image :src="yeimgs" v-if="newcheckeye"></image>
  23. <image :src="yeimg" v-else></image>
  24. </view>
  25. </view>
  26. </uni-forms-item>
  27. <uni-forms-item name="confirmPassword" style='margin-bottom: 0;'>
  28. <view class="flexc infolist">
  29. <view class="f16 fw c34 flex0">再次确认新密码</view>
  30. <input placeholder="请再次输入新密码" v-if="concheckeye" type="text" v-model="user.confirmPassword" class="f16 c34 flex1 txr"/>
  31. <input placeholder="请再次输入新密码" v-else type="password" v-model="user.confirmPassword" class="f16 c34 flex1 txr"/>
  32. <view class="input_ye ml8" v-if="user.confirmPassword" @click="concheckeye=!concheckeye">
  33. <image :src="yeimgs" v-if="concheckeye"></image>
  34. <image :src="yeimg" v-else></image>
  35. </view>
  36. </view>
  37. </uni-forms-item>
  38. <view class="infobtn flexcc cf f16 mt60 f500" @click="submit">确认修改</view>
  39. </uni-forms>
  40. </view>
  41. </template>
  42. <script>
  43. import { updateUserPwd } from "@/api/system/user"
  44. export default {
  45. data() {
  46. return {
  47. yeimg:require("@/static/images/mine/nyea.png"),
  48. yeimgs:require("@/static/images/mine/yea.png"),
  49. newcheckeye:false,
  50. concheckeye:false,
  51. oldcheckeye:false,
  52. user: {
  53. oldPassword: undefined,
  54. newPassword: undefined,
  55. confirmPassword: undefined
  56. },
  57. rules: {
  58. oldPassword: {
  59. rules: [{
  60. required: true,
  61. errorMessage: '旧密码不能为空'
  62. }]
  63. },
  64. newPassword: {
  65. rules: [{
  66. required: true,
  67. errorMessage: '新密码不能为空',
  68. },
  69. {
  70. minLength: 6,
  71. maxLength: 20,
  72. errorMessage: '长度在 6 到 20 个字符'
  73. }
  74. ]
  75. },
  76. confirmPassword: {
  77. rules: [{
  78. required: true,
  79. errorMessage: '确认密码不能为空'
  80. }, {
  81. validateFunction: (rule, value, data) => data.newPassword === value,
  82. errorMessage: '两次输入的密码不一致'
  83. }
  84. ]
  85. }
  86. }
  87. }
  88. },
  89. onReady() {
  90. this.$refs.form.setRules(this.rules)
  91. },
  92. methods: {
  93. submit() {
  94. var that=this;
  95. this.$refs.form.validate().then(res => {
  96. // this.user.oldPassword,
  97. updateUserPwd(this.user.oldPassword,this.user.newPassword).then(response => {
  98. this.$toast("修改成功")
  99. setTimeout(function(){
  100. that.$tab.reLaunch('/pages/mine/index')
  101. },1500)
  102. })
  103. })
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss">
  109. page {
  110. background-color: #ffffff;
  111. }
  112. .infolist{border-bottom: 2rpx solid #E5E5E5;padding: 40rpx 0;padding-right: 24rpx;}
  113. .infobtn{width: 700rpx;height: 88rpx;background: #FA5F03;border-radius:10rpx;line-height: 88rpx;}
  114. .input_ye image{width: 34rpx;height: 18rpx;}
  115. </style>