changePassword.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view>
  3. <cu-custom id="custom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png"
  5. :isBack="true">
  6. <block slot="content">
  7. 修改密码
  8. </block>
  9. </cu-custom>
  10. <view class="box">
  11. <view class="label">原密码</view>
  12. <u-input placeholder="原密码" type="password" border="surround" v-model="password" />
  13. <view class="label">新密码</view>
  14. <u-input placeholder="新密码" type="password" border="surround" v-model="newPassword" />
  15. <view class="label">确认密码</view>
  16. <u-input placeholder="确认密码" type="password" border="surround" v-model="verifyNewPassword" />
  17. </view>
  18. <view class="but-box">
  19. <u-button hairline text="修 改" :disabled="!password || !newPassword || !verifyNewPassword" :loading="loading"
  20. loadingText="修改中 ..." color="rgb(10, 57, 113)" @click="onClick" />
  21. </view>
  22. </view>
  23. </template>
  24. <!-- -->
  25. <script>
  26. import { hexMD5 } from "../../login/modules/md5";
  27. export default {
  28. name: "changePassword",
  29. data() {
  30. return {
  31. loading: false,
  32. password: "", //原密码
  33. newPassword: "", //新密码
  34. verifyNewPassword: "" //确认密码
  35. }
  36. },
  37. methods: {
  38. /* 修改密码 */
  39. onClick() {
  40. this.loading = true;
  41. let that = this;
  42. if (this.newPassword != this.verifyNewPassword) return uni.showToast({
  43. title: '两遍密码不一致!',
  44. duration: 2000,
  45. icon: "none"
  46. });
  47. uni.showModal({
  48. title: '提示',
  49. content: '是否确定修改登录密码',
  50. success: (success) => {
  51. that.$Http.basic({
  52. id: 20230608105202,
  53. "content": {
  54. "password": hexMD5(that.password),
  55. "newpassword": hexMD5(that.newPassword)
  56. }
  57. }).then(res => {
  58. console.log("修改登录密码", res)
  59. that.loading = false;
  60. uni.showToast({
  61. title: res.data == '失败' ? res.msg : '修改成功,请重新登陆',
  62. icon: "none",
  63. mask: res.data == '成功'
  64. });
  65. if (res.data == '成功') setTimeout(() => {
  66. uni.redirectTo({
  67. url: '/pages/login/login'
  68. });
  69. }, 1000)
  70. })
  71. },
  72. })
  73. },
  74. },
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .box {
  79. width: 355px;
  80. margin: 0 auto;
  81. .label {
  82. color: #fff;
  83. font-size: 12px;
  84. margin: 10px 4px;
  85. }
  86. /deep/ .u-input {
  87. background: #fff;
  88. }
  89. /deep/ .uni-input-placeholder {
  90. font-size: 10px;
  91. }
  92. }
  93. .but-box {
  94. width: 355px;
  95. margin: 60px auto 0;
  96. opacity: .8;
  97. /deep/.u-button__text {
  98. font-size: 14px !important;
  99. }
  100. }
  101. </style>