index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="mine-box">
  3. <div class="mine-body">
  4. <div class="form-list-box">
  5. <div class="info-box">
  6. <div class="label">当前密码</div>
  7. <div class="input-box">
  8. <input :type="show1 ? 'text' : 'password'" placeholder="请输入" v-model="lastPassword" />
  9. </div>
  10. <div class="icon-box" @click="getShow('1')">
  11. <van-icon name="eye-o" v-if="show1" />
  12. <van-icon name="closed-eye" v-else class="iconfont" />
  13. </div>
  14. </div>
  15. <div class="info-box">
  16. <div class="label">修改密码</div>
  17. <div class="input-box">
  18. <input :type="show2 ? 'text' : 'password'" placeholder="请输入" v-model="password" />
  19. </div>
  20. <div class="icon-box" @click="getShow('2')">
  21. <van-icon name="eye-o" v-if="show2" />
  22. <van-icon name="closed-eye" v-else class="iconfont" />
  23. </div>
  24. </div>
  25. <div class="info-box">
  26. <div class="label">确认修改密码</div>
  27. <div class="input-box">
  28. <input :type="show3 ? 'text' : 'password'" placeholder="请输入" v-model="checkPassword" />
  29. </div>
  30. <div class="icon-box" @click="getShow('3')">
  31. <van-icon name="eye-o" v-if="show3" />
  32. <van-icon name="closed-eye" v-else class="iconfont" />
  33. </div>
  34. </div>
  35. <div class="foot-box">
  36. <div class="but" @click="editPassword">保存</div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. import { hexMD5 } from './md5.js'
  44. import { editPassword, getUserLocalStorageInfo } from "@/js_sdk/http";
  45. // import auth from "@/service/auth";
  46. export default {
  47. name: "PasswordEdit",
  48. data() {
  49. return {
  50. show1: false,
  51. show2: false,
  52. show3: false,
  53. lastPassword: "",
  54. password: "",
  55. checkPassword: "",
  56. };
  57. },
  58. created() { },
  59. mounted() { },
  60. methods: {
  61. getShow(type) {
  62. this["show" + type] = !this["show" + type];
  63. },
  64. editPassword() {
  65. if (this.password === "") {
  66. this.$showToast("请填写密码");
  67. return false;
  68. }
  69. if (this.lastPassword === "") {
  70. this.$showToast("请填写原密码");
  71. return false;
  72. }
  73. if (this.password !== this.checkPassword) {
  74. this.$showToast("确认密码与密码不一致");
  75. return false;
  76. }
  77. if (this.password.length <= 6) {
  78. this.$showToast("新密码必须超过六位数!");
  79. return false;
  80. }
  81. var pwdRegex = new RegExp("(?=.*[0-9])(?=.*[a-zA-Z]).{8,30}");
  82. if (!pwdRegex.test(this.password)) {
  83. this.$showToast(
  84. "您的密码复杂度太低(密码中必须包含字母、数字),请及时修改密码!"
  85. );
  86. return false;
  87. }
  88. editPassword({
  89. userId: getUserLocalStorageInfo().user.id,
  90. newPassword: hexMD5(this.password),
  91. oldPassword: hexMD5(this.lastPassword),
  92. }).then((res) => {
  93. if (res.errno === 0 && res.data) {
  94. uni.clearStorageSync();
  95. uni.reLaunch({
  96. url: "/pages/login/login",
  97. });
  98. this.$showToast("修改成功,请重新登陆");
  99. } else {
  100. this.$showToast(res.errmsg);
  101. }
  102. });
  103. },
  104. },
  105. };
  106. </script>
  107. <style lang="scss" scoped>
  108. .mine-box {
  109. width: 100%;
  110. height: 100%;
  111. // background-image: url("../../assets/image/mine/mine-bg.jpg");
  112. // background-image: url("../../../static/passwordbac.png");
  113. background-image: url("https://pgy.idea-sf.com/mnpApi/FileController/download/128270394311049216");
  114. background-size: 100% 100%;
  115. background-repeat: no-repeat;
  116. box-sizing: border-box;
  117. overflow: hidden;
  118. .mine-body {
  119. padding: 30rpx;
  120. box-sizing: border-box;
  121. height: calc(100vh - 100rpx);
  122. box-sizing: border-box;
  123. overflow-y: auto;
  124. .form-list-box {
  125. width: 100%;
  126. background: rgba(#fff, 0.8);
  127. border-radius: 20rpx;
  128. box-sizing: border-box;
  129. margin-top: 160rpx;
  130. padding: 15rpx 30rpx;
  131. box-sizing: border-box;
  132. .info-box {
  133. height: 100rpx;
  134. @include flex;
  135. border-bottom: 1rpx solid #c6c5c9;
  136. .label {
  137. width: 200rpx;
  138. line-height: 100rpx;
  139. height: 100rpx;
  140. font-size: 30rpx;
  141. color: #262626;
  142. }
  143. .input-box {
  144. width: 260rpx;
  145. input {
  146. width: 100%;
  147. height: 100rpx;
  148. font-size: 30rpx;
  149. color: #999999;
  150. background: rgba(#fff, 0);
  151. }
  152. }
  153. .icon-box {
  154. width: 100rpx;
  155. text-align: center;
  156. i {
  157. font-size: 35rpx;
  158. color: #333;
  159. }
  160. }
  161. &:last-child {
  162. border-bottom: none;
  163. }
  164. }
  165. .foot-box {
  166. margin-top: 200rpx;
  167. width: 100%;
  168. .but {
  169. text-align: center;
  170. background: rgba(102, 0, 255, 1);
  171. color: #fff;
  172. font-size: 30rpx;
  173. line-height: 100rpx;
  174. border-radius: 10rpx;
  175. }
  176. }
  177. }
  178. }
  179. }
  180. </style>