editPwd.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="editPwd">
  3. <view class="input-li">
  4. <text class="custom-icon custom-icon-mima"></text>
  5. <input placeholder="请输入旧密码" placeholder-class="input-pl" type="password" v-model="oldPwd" />
  6. </view>
  7. <view class="input-li">
  8. <text class="custom-icon custom-icon-mima"></text>
  9. <input placeholder="请输入新密码" placeholder-class="input-pl" type="password" v-model="newPwd" />
  10. </view>
  11. <view class="input-li">
  12. <text class="custom-icon custom-icon-dunpai"></text>
  13. <input placeholder="请再次输入新密码" placeholder-class="input-pl" type="password" v-model="againPwd" />
  14. </view>
  15. <view class="conform-btn" @click="editPwd">确认修改</view>
  16. </view>
  17. </template>
  18. <script>
  19. import { mapActions } from 'vuex';
  20. export default {
  21. data() {
  22. return {
  23. oldPwd: '',
  24. newPwd: '',
  25. againPwd: ''
  26. };
  27. },
  28. methods: {
  29. ...mapActions({
  30. logout: 'logout'
  31. }),
  32. editPwd() {
  33. if (this.newPwd !== this.againPwd) {
  34. this.$u.toast('两次输入密码不一致');
  35. return false;
  36. }
  37. this.$u.api
  38. .updateUserCenterData({
  39. newPassword: this.newPwd,
  40. oldPassword: this.oldPwd,
  41. rePassword: this.againPwd
  42. })
  43. .then(res => {
  44. this.$u.toast('修改成功,请重新登录');
  45. setTimeout(() => {
  46. this.logout();
  47. }, 500);
  48. });
  49. }
  50. }
  51. };
  52. </script>
  53. <style lang="scss" scope>
  54. .editPwd {
  55. padding-top: 50rpx;
  56. }
  57. .input-li {
  58. width: 702rpx;
  59. margin: 30rpx auto 0;
  60. border: 1px solid #eeeeee;
  61. line-height: 80rpx;
  62. border-radius: 8rpx;
  63. padding: 0 30rpx;
  64. .input-pl {
  65. font-size: 24rpx;
  66. font-weight: 300;
  67. }
  68. .custom-icon {
  69. color: #444444;
  70. font-size: 32rpx;
  71. }
  72. input {
  73. padding-left: 30rpx;
  74. display: inline-block;
  75. vertical-align: middle;
  76. }
  77. }
  78. .conform-btn {
  79. width: 680rpx;
  80. color: #ffffff;
  81. line-height: 80rpx;
  82. background-color: $uni-color-primary;
  83. text-align: center;
  84. border-radius: 10rpx;
  85. margin: 60rpx auto 0;
  86. }
  87. </style>