pass.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="main">
  3. <view class="form">
  4. <view class="form_group">
  5. <view class="lable">旧密码</view>
  6. <view class="icon" :class="{ active: !show }" @click="show = !show">&#xe6ef;</view>
  7. <input :password="show" v-model="item.oldPassword" placeholder="请输入旧密码" />
  8. </view>
  9. <view class="form_group">
  10. <view class="lable">新密码</view>
  11. <view class="icon" :class="{ active: !show }" @click="show = !show">&#xe6ef;</view>
  12. <input :password="show" v-model="item.newPassword" placeholder="请输入新密码" />
  13. </view>
  14. <view class="form_group">
  15. <view class="lable">重复密码</view>
  16. <view class="icon" :class="{ active: !show }" @click="show = !show">&#xe6ef;</view>
  17. <input :password="show" v-model="item.again" placeholder="请再次输入新密码" />
  18. </view>
  19. </view>
  20. <button class="btn" @click="save()">确认</button>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. item: {},
  28. show: true
  29. };
  30. },
  31. methods: {
  32. save() {
  33. let rule = [
  34. { name: 'oldPassword', checkType: 'notnull', errorMsg: '请输入旧密码' },
  35. { name: 'newPassword', checkType: 'notnull', errorMsg: '请输入新密码' },
  36. { name: 'again', checkType: 'same', checkRule: this.item.newPassword, errorMsg: '两次输入不一致' }
  37. ];
  38. if (!this.verify.check(this.item, rule)) {
  39. uni.showModal({ content: this.verify.error, showCancel: false });
  40. return false;
  41. }
  42. this.http.request({
  43. url: '/system/user/profile/updatePwd',
  44. data: this.item,
  45. method: 'PUT',
  46. contentType: 'application/x-www-form-urlencoded',
  47. success: (res) => {
  48. this.http.request({
  49. url: '/logout',
  50. success: (res) => {
  51. uni.showModal({
  52. title: '提示',
  53. content: '修改成功,请重新登录',
  54. showCancel: false,
  55. success: (res) => {
  56. if (res.confirm) {
  57. uni.removeStorageSync('user');
  58. uni.redirectTo({ url: '/pages/user/loginDoctor' });
  59. }
  60. }
  61. });
  62. }
  63. });
  64. }
  65. });
  66. }
  67. }
  68. };
  69. </script>
  70. <style lang="scss">
  71. .form_group {
  72. input {
  73. width: 60%;
  74. }
  75. .icon {
  76. float: right;
  77. margin-top: 12px;
  78. font-size: 20px;
  79. padding-left: 10px;
  80. color: $font-c;
  81. &.active {
  82. color: $main-color;
  83. }
  84. }
  85. }
  86. </style>