alterPassword.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="container">
  3. <view class="mim-view">
  4. <!-- <view>
  5. <view class="mim-font-16 bold mim-flex-wrap-left" style="margin-bottom: 24rpx;">
  6. <text class="mim-font-16 bold">原密码</text>
  7. <text class="mim-font-16 bold mimRed">*</text>
  8. </view>
  9. <u-input type="password" v-model="form.password" placeholder='请输入原密码'
  10. placeholder-style="color: #BDBDBD;" height="96" cursor-spacing="12" :clearable='false'
  11. :custom-style="customStyle" />
  12. </view> -->
  13. <view class="marginTop">
  14. <view class="mim-font-16 bold mim-flex-wrap-left" style="margin-bottom: 24rpx;">
  15. <text class="mim-font-16 bold">新密码</text>
  16. <text class="mim-font-16 bold mimRed">*</text>
  17. </view>
  18. <u-input type="password" v-model="form.password" placeholder='请输入新密码'
  19. placeholder-style="color: #BDBDBD;" height="96" cursor-spacing="12" :clearable='false'
  20. :custom-style="customStyle" />
  21. </view>
  22. <view class="marginTop">
  23. <view class="mim-font-16 bold mim-flex-wrap-left" style="margin-bottom: 24rpx;">
  24. <text class="mim-font-16 bold">再次输入新密码</text>
  25. <text class="mim-font-16 bold mimRed">*</text>
  26. </view>
  27. <u-input type="password" v-model="form.password_confirmation" placeholder='请再次输入新密码'
  28. placeholder-style="color: #BDBDBD;" height="96" cursor-spacing="12" :clearable='false'
  29. :custom-style="customStyle" />
  30. </view>
  31. </view>
  32. <view class="mim-foot">
  33. <view class="mim-foot-button mim-button mim-flex-wrap" :class="{ disabled: isButtonDisabled }"
  34. @click="amend">
  35. 修改密码
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. customStyle: {
  45. fontSize: '32rpx',
  46. paddingLeft: '24rpx',
  47. background: '#f7f7f7',
  48. borderRadius: '8rpx'
  49. },
  50. form: {
  51. password: '',
  52. password_confirmation: '',
  53. },
  54. isButtonDisabled: false, // 按钮是否禁用
  55. };
  56. },
  57. methods: {
  58. amend() {
  59. if (this.isButtonDisabled) {
  60. return false; // 如果按钮已禁用,直接返回
  61. }
  62. if (!this.form.password || !this.form.password_confirmation) {
  63. this.$u.toast('请将密码信息输入完整!')
  64. return false
  65. }
  66. if (this.form.password != this.form.password_confirmation) {
  67. this.$u.toast('二次输入的密码信息不一致!')
  68. return false
  69. }
  70. this.isButtonDisabled = true; // 禁用按钮
  71. this.amendPasswordFn()
  72. },
  73. async amendPasswordFn() {
  74. setTimeout(() => {
  75. this.isButtonDisabled = false; // 启用按钮
  76. }, 1000)
  77. const res = await this.$u.api.amendPassword(this.form)
  78. console.log(res)
  79. this.$u.toast(res.message)
  80. setTimeout(() => {
  81. uni.removeStorageSync('token')
  82. uni.removeStorageSync('password')
  83. this.$u.route({
  84. type: 'reLaunch',
  85. url: '/pages/login/login'
  86. })
  87. }, 1000)
  88. },
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. page {
  94. background-color: #f7f7f7;
  95. .container {
  96. .mim-view {
  97. .marginTop {
  98. margin-top: 24rpx;
  99. }
  100. }
  101. .mim-foot {
  102. width: 100%;
  103. height: 136rpx;
  104. position: fixed;
  105. bottom: 0;
  106. left: 0;
  107. background-color: #ffffff;
  108. padding: 20rpx 24rpx;
  109. box-sizing: border-box;
  110. z-index: 9;
  111. &-button {
  112. border-radius: 48rpx;
  113. opacity: 1;
  114. background: #DE2E27;
  115. font-size: 32rpx;
  116. font-weight: normal;
  117. line-height: 32rpx;
  118. letter-spacing: 0px;
  119. color: #FFFFFF;
  120. height: 96rpx;
  121. cursor: pointer;
  122. }
  123. }
  124. }
  125. }
  126. </style>