password.vue 2.6 KB

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