index.vue 6.8 KB

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