login.vue 9.2 KB

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