login.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <!--
  2. * @Author: wangwei
  3. * @Date: 2020-12-29 16:05:36
  4. * @LastEditTime: 2021-01-15 19:08:07
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 登录密码
  7. * @FilePath: /java-pc/src/views/member/center/accountSafe.vue
  8. -->
  9. <template>
  10. <div class="sld_login_password_mange" v-if="getLatestMemberInfo">
  11. <MemberTitle :memberTitle="L['登录密码']"></MemberTitle>
  12. <div class="container">
  13. <div class="title">
  14. {{ memberInfo.data.hasLoginPassword ? L["修改"] : L["设置"] }}
  15. {{ L["登录密码"] }}
  16. </div>
  17. <div class="mange_con">
  18. <div class="without_phone_tip" v-if="!memberInfo.data.memberEmail">
  19. {{ L["请先绑定邮箱,再进行登陆密码操作!"] }}
  20. </div>
  21. <!-- 修改登录密码 start -->
  22. <template v-if="memberInfo.data.hasLoginPassword">
  23. <span class="current"
  24. >{{ L["当前邮箱账号"] }}
  25. {{
  26. memberInfo.data.memberEmail ? memberInfo.data.memberEmail : "--"
  27. }}</span
  28. >
  29. <div class="sms_code_con">
  30. <el-input
  31. v-model="sms_code"
  32. :placeholder="L['请输入邮件验证码']"
  33. ></el-input>
  34. <div class="get_sms pointer" @click="getSmsCode">
  35. {{ countDownM ? countDownM + L["s后获取"] : L["获取验证码"] }}
  36. </div>
  37. </div>
  38. <el-input
  39. type="password"
  40. class="password input"
  41. v-model="old_password"
  42. :placeholder="L['请输入原密码']"
  43. ></el-input>
  44. <el-input
  45. type="password"
  46. class="password input"
  47. v-model="password"
  48. :placeholder="L['请输入新密码']"
  49. ></el-input>
  50. <el-input
  51. type="password"
  52. class="password input"
  53. v-model="confirm_password"
  54. :placeholder="L['请再次输入新密码']"
  55. ></el-input>
  56. <div class="error_tip">
  57. <span
  58. v-if="errorMsg"
  59. style="color: #e1251b; font-size: 14px"
  60. class="iconfont icon-jubao"
  61. ></span>
  62. {{ errorMsg }}
  63. </div>
  64. <div class="next flex_row_center_center pointer" @click="next">
  65. {{ L["修改密码"] }}
  66. </div>
  67. </template>
  68. <!-- 修改登录密码 end -->
  69. </div>
  70. <!-- <div class="manage_tips">-->
  71. <!-- <p class="tips_title">{{ L["温馨提示"] }}:</p>-->
  72. <!-- <p>• {{ L["为了保障您的账号安全,变更重要信息需进行身份验证。"] }}</p>-->
  73. <!-- <p>• {{ L["变更过程中有任何疑问请联系在线客服解决。"] }}</p>-->
  74. <!-- <p>-->
  75. <!-- •-->
  76. <!-- {{ L["如手机号/邮箱已不再使用无法获取验证码,请联系在线客服解决。"] }}-->
  77. <!-- </p>-->
  78. <!-- <p>• {{ L["复杂的密码可使账号更安全且建议定期更换密码。"] }}</p>-->
  79. <!-- </div>-->
  80. </div>
  81. </div>
  82. </template>
  83. <script setup>
  84. import { ElInput, ElMessage } from "element-plus";
  85. import { getCurrentInstance, reactive, ref, watch } from "vue";
  86. // import { lang_zn } from "@/assets/language/zh";
  87. import { getCurLanguage } from "@/composables/common.js";
  88. import { useFiltersStore } from "@/store/filter.js";
  89. const filtersStore = useFiltersStore();
  90. // const L = lang_zn;
  91. const L = getCurLanguage();
  92. definePageMeta({
  93. layout: "member",
  94. middleware: ["auth"],
  95. });
  96. const sms_code = ref("");
  97. const errorMsg = ref("");
  98. const password = ref(""); //输入新密码
  99. const confirm_password = ref(""); //再次输入新密码
  100. const old_password = ref(""); //输入旧密码
  101. // const confirm_password = ref("");
  102. const timeOutId = ref(""); //定时器的返回值
  103. const countDownM = ref(0); //短信验证码倒计时
  104. const memberInfo = reactive({ data: {} });
  105. const isSmsClick = ref(false);
  106. const getLatestMemberInfo = ref(false);
  107. const getMemberInfo = () => {
  108. get("v3/member/front/member/getInfo").then((res) => {
  109. if (res.state == 200) {
  110. memberInfo.data = res.data;
  111. filtersStore.setMemberInfo(res.data);
  112. getLatestMemberInfo.value = true;
  113. }
  114. });
  115. };
  116. getMemberInfo();
  117. const getSmsCode = () => {
  118. if (isSmsClick.value) {
  119. return;
  120. } else if (countDownM.value) {
  121. return;
  122. }
  123. isSmsClick.value = true;
  124. var param = {};
  125. param.verifyType = 1;
  126. param.verifyAddr = memberInfo.data.memberEmail;
  127. get("v3/msg/front/commons/sendVerifyCode", param).then((res) => {
  128. if (res.state == 200) {
  129. countDownM.value = 60;
  130. countDown();
  131. isSmsClick.value = false;
  132. } else {
  133. ElMessage.error(res.msg);
  134. isSmsClick.value = false;
  135. }
  136. });
  137. };
  138. const next = () => {
  139. isSmsClick.value = false;
  140. let url = "";
  141. let param = {};
  142. if (memberInfo.data.hasLoginPassword) {
  143. if (!sms_code.value) {
  144. errorMsg.value = L["请输入验证码"];
  145. return false;
  146. }
  147. //修改登录密码
  148. if (!old_password.value) {
  149. errorMsg.value = L["请输入原密码"];
  150. return false;
  151. }
  152. if (!password.value) {
  153. errorMsg.value = L["请输入新密码"];
  154. return false;
  155. }
  156. if (!confirm_password.value) {
  157. errorMsg.value = L["请再次输入新密码"];
  158. return false;
  159. }
  160. if (password.value != confirm_password.value) {
  161. errorMsg.value = L["请输入一致的新密码"];
  162. return false;
  163. }
  164. //验证新密码是否符合规则
  165. let checkPwdVal = checkPwd(password.value);
  166. if (checkPwdVal !== true) {
  167. errorMsg.value = checkPwdVal;
  168. return false;
  169. }
  170. url = "v3/member/front/memberPassword/editLoginPwd";
  171. param.oldLoginPwd = old_password.value;
  172. param.loginPwd = password.value;
  173. param.memberEmail = memberInfo.data.memberEmail;
  174. param.verifyCode = sms_code.value;
  175. }
  176. post(url, param).then((res) => {
  177. if (res.state == 200) {
  178. ElMessage.success(res.msg);
  179. if (!memberInfo.data.hasLoginPassword) {
  180. memberInfo.data.hasLoginPassword = 1;
  181. filtersStore.setMemberInfo(memberInfo.data);
  182. }
  183. errorMsg.value = "";
  184. password.value = "";
  185. confirm_password.value = "";
  186. old_password.value = "";
  187. } else {
  188. errorMsg.value = res.msg;
  189. }
  190. });
  191. };
  192. //倒计时
  193. const countDown = () => {
  194. countDownM.value--;
  195. if (countDownM.value == 0) {
  196. isSmsClick.value = false;
  197. clearTimeout(timeOutId.value);
  198. } else {
  199. timeOutId.value = setTimeout(countDown, 1000);
  200. }
  201. };
  202. watch([old_password, password, confirm_password], () => {
  203. old_password.value = old_password.value.substring(0, 20);
  204. password.value = password.value.substring(0, 20);
  205. confirm_password.value = confirm_password.value.substring(0, 20);
  206. });
  207. </script>
  208. <style lang="scss" scoped>
  209. @import "@/assets/style/theme.scss";
  210. .sld_login_password_mange {
  211. width: 957px;
  212. float: left;
  213. margin-left: 10px;
  214. .container {
  215. background-color: white;
  216. width: 100%;
  217. box-sizing: border-box;
  218. border: 1px solid #eaeaea;
  219. padding: 25px 40px;
  220. .manage_tips {
  221. width: 938px;
  222. background: #fffdee;
  223. border: 1px solid #edd28b;
  224. padding: 15px 36px;
  225. margin-top: 117px;
  226. p {
  227. color: #555555;
  228. margin-top: 10px;
  229. }
  230. .tips_title {
  231. font-weight: bold;
  232. margin-bottom: 11px;
  233. margin-top: 0;
  234. }
  235. }
  236. .title {
  237. font-size: 18px;
  238. border-bottom: 1px dashed #eaeaea;
  239. padding-bottom: 25px;
  240. font-weight: 600;
  241. margin-bottom: 20px;
  242. }
  243. .mange_con {
  244. width: 360px;
  245. margin: 62px auto 0;
  246. .current {
  247. line-height: 56px;
  248. font-size: 14px;
  249. color: #000000;
  250. }
  251. .error_tip {
  252. height: 15px;
  253. margin-top: 10px;
  254. color: #f30213;
  255. i {
  256. margin-right: 10px;
  257. }
  258. }
  259. .without_phone_tip {
  260. line-height: 56px;
  261. font-size: 16px;
  262. color: $colorMain2;
  263. }
  264. .sms_code_con {
  265. position: relative;
  266. width: 100%;
  267. :deep(.el-input) {
  268. width: 250px;
  269. z-index: 1;
  270. }
  271. :deep(.el-input__inner) {
  272. width: 250px;
  273. }
  274. .get_sms {
  275. display: flex;
  276. justify-content: center; /* 水平居中 */
  277. align-items: center; /* 垂直居中 */
  278. text-align: center; /* 多行文本居中 */
  279. position: absolute;
  280. right: -25px;
  281. top: 0;
  282. width: 120px;
  283. height: 40px;
  284. background: #00985e;
  285. color: white;
  286. font-size: 14px;
  287. border-radius: 0 3px 3px 0;
  288. }
  289. }
  290. .margin {
  291. margin-top: 20px;
  292. }
  293. .next {
  294. width: 170px;
  295. height: 40px;
  296. background: #00985e;
  297. color: #fff;
  298. font-size: 18px;
  299. font-weight: bold;
  300. text-align: center;
  301. color: white;
  302. margin-top: 20px;
  303. line-height: 40px;
  304. border-radius: 3px;
  305. margin: 42px auto 0;
  306. }
  307. }
  308. }
  309. }
  310. </style>
  311. <style lang="scss">
  312. .sld_login_password_mange {
  313. .el-input {
  314. width: 280px;
  315. height: 40px;
  316. border-radius: 3px 0 0 3px;
  317. position: inherit;
  318. }
  319. .el-input__inner {
  320. width: 280px;
  321. height: 40px;
  322. border-radius: 3px 0 0 3px;
  323. }
  324. .input {
  325. width: 100%;
  326. height: 40px;
  327. margin-top: 20px;
  328. border-radius: 3px;
  329. .el-input__wrapper {
  330. width: 100%;
  331. }
  332. .el-input__inner {
  333. height: 40px;
  334. border-radius: 3px;
  335. width: 100%;
  336. }
  337. }
  338. }
  339. .el-input__inner:focus {
  340. border-color: $colorMain;
  341. outline: 0;
  342. }
  343. /**
  344. * 解决el-input设置类型为number时,中文输入法光标上移问题
  345. **/
  346. .el-input__inner {
  347. line-height: 1px !important;
  348. }
  349. </style>