editPassword.vue 2.7 KB

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