changePassword.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view>
  3. <u-navbar title="修改密码" title-color="#101010"></u-navbar>
  4. <view class="main">
  5. <view class="original-password">
  6. <text>原密码 </text><u-input v-model="form.oldPassword" style="padding: 0 0 0 20px" class="password-input" type="password" placeholder="填写原密码" :password-icon="true" />
  7. </view>
  8. <view class="new-password">
  9. <text>新密码</text><u-input v-model="form.password" style="padding: 0 0 0 20px" class="password-input" type="password" placeholder="创建6-16位组合新密码" :password-icon="true" />
  10. </view>
  11. </view>
  12. <!-- 确认修改 -->
  13. <button class="confirm" @click="changePassword">确认修改</button>
  14. </view>
  15. </template>
  16. <script>
  17. import * as API from '@/apis/pagejs/user.js'
  18. export default {
  19. data() {
  20. return {
  21. form: {
  22. oldPassword: '',
  23. password: '',
  24. },
  25. }
  26. },
  27. methods: {
  28. changePassword(){
  29. if (!this.form.oldPassword) {
  30. uni.showToast({
  31. title: "请输入原密码",
  32. icon: "none"
  33. })
  34. return
  35. }
  36. if (!this.form.password) {
  37. uni.showToast({
  38. title: "请输入新密码",
  39. icon: "none"
  40. })
  41. return
  42. }
  43. uni.showLoading({
  44. title: "加载中",
  45. mask: true,
  46. })
  47. API.changePassword(this.form).then((response) => {
  48. uni.hideLoading();
  49. this.form.password=""
  50. this.form.oldPassword=""
  51. uni.showModal({
  52. title:"提示",
  53. content:"密码修改成功!",
  54. showCancel:false,
  55. success() {
  56. uni.reLaunch({
  57. url:"/pages/mine/mine"
  58. })
  59. }
  60. })
  61. }).catch(error => {
  62. uni.showToast({
  63. title: error,
  64. icon: "none"
  65. })
  66. })
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .main{
  73. background-color: #fff;
  74. margin-top: 24rpx;
  75. .original-password,.new-password{
  76. line-height: 96rpx;
  77. padding:0 32rpx;
  78. display: flex;
  79. align-items: center;
  80. border-bottom: 1px solid rgba(221,221,221,1);
  81. ::v-deep.u-input__input{
  82. height: 96rpx;
  83. }
  84. }
  85. text{
  86. display: inline-block;
  87. width: 128rpx;
  88. color: rgba(51,51,51,1);
  89. font-size: 32rpx;
  90. }
  91. }
  92. // 确认修改
  93. .confirm{
  94. border-radius: 8px;
  95. background-color: rgba(22,119,255,1);
  96. color: rgba(255,255,255,1);
  97. font-size: 32rpx;
  98. line-height: 88rpx;
  99. margin: 24rpx 32rpx;
  100. }
  101. </style>