editPassword.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view>
  3. <view class="content">
  4. <view class="flex item">
  5. <view>旧密码</view>
  6. <view><input class="uni-input" :password="show" maxlength="16" v-model="pwd.oldPassword" placeholder="请输入旧密码" /></view>
  7. <view class="label show"><view class="icon" :class="{ active: !show }" @click="show = !show">&#xe7a6;</view></view>
  8. </view>
  9. <view class="flex item">
  10. <view>新密码</view>
  11. <view><input class="uni-input" :password="newPwd" maxlength="16" v-model="pwd.newPassword" placeholder="请输入新密码" /></view>
  12. <view class="label show"><view class="icon" :class="{ active: !newPwd }" @click="newPwd = !newPwd">&#xe7a6;</view></view>
  13. </view>
  14. <view class="flex item">
  15. <view>确认密码</view>
  16. <view><input class="uni-input" :password="reNewPwd" maxlength="16" v-model="pwd.rePassword" placeholder="请再次输入新密码" /></view>
  17. <view class="label show"><view class="icon" :class="{ active: !reNewPwd }" @click="reNewPwd = !newPwd">&#xe7a6;</view></view>
  18. </view>
  19. <view class="item">
  20. <text style="color: gray;">密码必须是8-16位英文字母、数字、字符组合(不能是纯数字)</text>
  21. </view>
  22. <view class="item">
  23. <button class="btn" @click="edit()">确认修改</button>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. user: this.getUser(),
  33. pwd: {},
  34. show: true,
  35. newPwd: true,
  36. reNewPwd: true,
  37. }
  38. },
  39. methods: {
  40. edit(){
  41. console.log(this.pwd)
  42. let rule = [
  43. { name: 'newPassword', checkType: 'notnull', errorMsg: '请输入新密码' },
  44. { name: 'rePassword', checkType: 'same', checkRule: this.pwd.newPassword, errorMsg: '两次输入不一致' },
  45. ];
  46. if (!this.verify.check(this.pwd, rule)) {
  47. uni.showModal({ content: this.verify.error, showCancel: false });
  48. return false;
  49. }
  50. this.http.request({
  51. url: '/sp-admin/app/AppUser/modifyPassword',
  52. data: this.pwd,
  53. success: res => {
  54. uni.showModal({ content: '修改成功,请重新登录', showCancel: false });
  55. this.exitLogin()
  56. }
  57. });
  58. },
  59. exitLogin() {
  60. let param = {
  61. appUserId: this.getUser().id
  62. }
  63. this.http.request({
  64. url: '/sp-admin/app/AppUser/logout',
  65. data: param,
  66. success: res => {
  67. uni.removeStorageSync('token');
  68. uni.removeStorageSync('info');
  69. uni.removeStorageSync('menu');
  70. uni.redirectTo({ url: '/pages/login/login' });
  71. }
  72. });
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. page {
  79. background-color: $pg;
  80. }
  81. .content {
  82. padding: 20px 10px;
  83. }
  84. .item{
  85. height: 60px;
  86. display: flex;
  87. align-items: center;
  88. border-top: 1px solid #DCDCDC;
  89. }
  90. .btn{
  91. margin-top: 40px;
  92. width: 200px;
  93. }
  94. .show{
  95. position: relative;
  96. left: 100px;
  97. }
  98. </style>