index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="reset-pwd-root">
  3. <erp-nav-bar title="修改密码" />
  4. <view class="pwd-form">
  5. <view class="form-item">
  6. <text class="form-label">旧密码</text>
  7. <input class="form-input" type="password" v-model="oldPassword" placeholder="请输入旧密码" password />
  8. </view>
  9. <view class="form-item">
  10. <text class="form-label">新密码</text>
  11. <input class="form-input" type="password" v-model="newPassword" placeholder="请输入新密码" password />
  12. </view>
  13. <view class="form-item">
  14. <text class="form-label">确认密码</text>
  15. <input class="form-input" type="password" v-model="confirmPassword" placeholder="请再次输入新密码" password />
  16. </view>
  17. </view>
  18. <view class="submit-area">
  19. <view class="submit-btn" :class="{ disabled: submitting }" @click="doSubmit">
  20. <text>{{ submitting ? '提交中...' : '确认修改' }}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import ErpNavBar from '@/components/erp-nav-bar.vue';
  27. import { resetPassword } from '@/api/system/employee.js';
  28. export default {
  29. components: { ErpNavBar },
  30. data() {
  31. return {
  32. oldPassword: '',
  33. newPassword: '',
  34. confirmPassword: '',
  35. submitting: false
  36. }
  37. },
  38. methods: {
  39. async doSubmit() {
  40. if (!this.oldPassword) {
  41. uni.showToast({ title: '请输入旧密码', icon: 'none' });
  42. return;
  43. }
  44. if (!this.newPassword) {
  45. uni.showToast({ title: '请输入新密码', icon: 'none' });
  46. return;
  47. }
  48. if (this.newPassword.length < 6) {
  49. uni.showToast({ title: '新密码长度不能少于6位', icon: 'none' });
  50. return;
  51. }
  52. if (this.newPassword !== this.confirmPassword) {
  53. uni.showToast({ title: '两次输入的新密码不一致', icon: 'none' });
  54. return;
  55. }
  56. this.submitting = true;
  57. try {
  58. await resetPassword({
  59. oldPassword: this.oldPassword,
  60. newPassword: this.newPassword
  61. });
  62. uni.showToast({ title: '密码修改成功', icon: 'success' });
  63. setTimeout(() => {
  64. uni.navigateBack();
  65. }, 1200);
  66. } catch (e) {
  67. uni.showToast({ title: e || '修改失败', icon: 'none' });
  68. } finally {
  69. this.submitting = false;
  70. }
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped>
  76. .reset-pwd-root {
  77. width: 100vw;
  78. height: 100vh;
  79. background: #F4F6F9;
  80. display: flex;
  81. flex-direction: column;
  82. }
  83. .pwd-form {
  84. background: #fff;
  85. margin: 20rpx 24rpx 0;
  86. border-radius: 20rpx;
  87. padding: 0 36rpx;
  88. box-shadow: 0 2rpx 16rpx rgba(0, 0, 0, 0.02);
  89. }
  90. .form-item {
  91. display: flex;
  92. align-items: center;
  93. min-height: 104rpx;
  94. border-bottom: 1rpx solid #F0F0F3;
  95. }
  96. .form-item:last-child {
  97. border-bottom: none;
  98. }
  99. .form-label {
  100. font-size: 30rpx;
  101. color: #1A1A2E;
  102. font-weight: 500;
  103. width: 160rpx;
  104. flex-shrink: 0;
  105. }
  106. .form-input {
  107. flex: 1;
  108. font-size: 28rpx;
  109. color: #1A1A2E;
  110. }
  111. .submit-area {
  112. padding: 60rpx 60rpx 0;
  113. }
  114. .submit-btn {
  115. height: 88rpx;
  116. border-radius: 20rpx;
  117. background: linear-gradient(135deg, #C1001C 0%, #E8553D 100%);
  118. display: flex;
  119. align-items: center;
  120. justify-content: center;
  121. color: #fff;
  122. font-size: 32rpx;
  123. font-weight: 600;
  124. }
  125. .submit-btn.disabled {
  126. opacity: 0.6;
  127. }
  128. </style>