password.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view>
  3. <u-navbar :border-bottom="false" :is-back="true" title="修改密码">
  4. </u-navbar>
  5. <view class="u-m-20">
  6. <u-toast ref="uToast"/>
  7. <view>
  8. <u-cell-group>
  9. <u-field
  10. v-model="oldpassword"
  11. focus
  12. icon="lock"
  13. iconColor="#d5d5d5"
  14. label="旧密码"
  15. label-width="180"
  16. password
  17. placeholder="请填写旧密码"
  18. >
  19. </u-field>
  20. <u-field
  21. v-model="newpassword"
  22. icon="lock"
  23. iconColor="#d5d5d5"
  24. label="新密码"
  25. label-width="180"
  26. password
  27. placeholder="请填写新密码"
  28. >
  29. </u-field>
  30. <u-field
  31. v-model="password"
  32. icon="lock-fill"
  33. iconColor="#d5d5d5"
  34. label="确认密码"
  35. label-width="180"
  36. password
  37. placeholder="请再次填写密码"
  38. >
  39. </u-field>
  40. </u-cell-group>
  41. </view>
  42. </view>
  43. <view class="bottomView">
  44. <u-button :custom-style="customStyle" class="u-m-40" hover-class="none" @tap="changePasswold">提交</u-button>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. oldpassword: '',
  53. newpassword: '',
  54. password: '',
  55. customStyle: {
  56. marginTop: '20px', // 注意驼峰命名,并且值必须用引号包括,因为这是对象
  57. color: '#FFF',
  58. backgroundColor: '#ff536f'
  59. }
  60. }
  61. },
  62. methods: {
  63. changePasswold() {
  64. if (!this.oldpassword) {
  65. return this.$mytip.toast('请输入旧密码')
  66. }
  67. if (!this.newpassword) {
  68. return this.$mytip.toast('请输入新密码')
  69. }
  70. if (!this.password) {
  71. return this.$mytip.toast('请确认密码')
  72. }
  73. if (this.newpassword != this.password) {
  74. return this.$mytip.toast('密码不一致,请确认')
  75. }
  76. let url = "api/profile/updatePwd";
  77. let userId = uni.getStorageSync('lifeData').vuex_user.user.userId;
  78. this.$u.put(url, {
  79. userId: userId,
  80. oldPassword: this.oldpassword,
  81. newPassword: this.newpassword
  82. }).then(data => {
  83. //提示后跳转页面
  84. this.$mytip.toast('密码修改成功')
  85. setTimeout(() => {
  86. uni.switchTab({
  87. url: '/pages/center/center'
  88. })
  89. }, 1000);
  90. });
  91. },
  92. }
  93. };
  94. </script>
  95. <style lang="scss" scoped>
  96. page {
  97. overflow: hidden;
  98. }
  99. .logo {
  100. display: flex;
  101. justify-content: center;
  102. align-items: center;
  103. width: 100%;
  104. height: 550 rpx;
  105. img {
  106. text-align: center;
  107. }
  108. }
  109. .version {
  110. position: fixed;
  111. bottom: 0;
  112. width: 100%;
  113. text-align: center;
  114. padding: 15 rpx;
  115. }
  116. </style>