changePassword.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="password">
  3. <u--form labelPosition="left" :model="changeForm" :rules="rules" ref="changeForm">
  4. <u-form-item label="" prop="newPass" borderBottom labelWidth="0" :style="{'marginBottom': '30rpx'}">
  5. <u--input v-model="changeForm.newPass" border="none" prefixIcon="lock"
  6. prefixIconStyle="font-size: 40rpx;color: #638EE3" placeholder="输入新密码"
  7. placeholderStyle="font-size: 24rpx" password></u--input>
  8. </u-form-item>
  9. <u-form-item label="" prop="confirmPass" borderBottom labelWidth="0">
  10. <u--input v-model="changeForm.confirmPass" border="none" prefixIcon="lock"
  11. prefixIconStyle="font-size: 40rpx;color: #638EE3" placeholder="确认新密码"
  12. placeholderStyle="font-size: 24rpx" password></u--input>
  13. </u-form-item>
  14. <u-form-item label="" labelWidth="0">
  15. <view class="confirm-button">
  16. <u-button type="primary" text="确认" color="#638EE3" :customStyle="{borderRadius: '20rpx'}"
  17. @click="submitChangeForm" :loading="loading"></u-button>
  18. </view>
  19. </u-form-item>
  20. </u--form>
  21. <u-toast ref="uToast"></u-toast>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. changeForm: {
  29. newPass: '',
  30. confirmPass: ''
  31. },
  32. rules: {
  33. newPass: {
  34. type: 'string',
  35. required: true,
  36. message: '输入新密码',
  37. trigger: ['blur', 'change']
  38. },
  39. confirmPass: {
  40. type: 'string',
  41. required: true,
  42. message: '输入确认密码',
  43. trigger: ['blur', 'change']
  44. }
  45. },
  46. loading: false
  47. }
  48. },
  49. methods: {
  50. submitChangeForm() {
  51. this.$refs.changeForm.validate().then(res => {
  52. console.log(this.changeForm)
  53. if (this.changeForm.newPass === this.changeForm.confirmPass) {
  54. this.loading = true
  55. this.$refs.uToast.show({
  56. type: 'success',
  57. title: '提示',
  58. message: "修改成功",
  59. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  60. })
  61. setTimeout(() => {
  62. uni.$u.route({
  63. url: 'pages/mine/mine',
  64. type: 'switchTab'
  65. })
  66. }, 2000)
  67. } else {
  68. this.$refs.uToast.show({
  69. type: 'warning',
  70. title: '提示',
  71. message: "两次密码不一致",
  72. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/warning.png'
  73. })
  74. }
  75. }).catch(error => {
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .password {
  83. padding: 100rpx 68rpx;
  84. .confirm-button {
  85. width: 100%;
  86. margin-top: 200rpx;
  87. }
  88. }
  89. </style>