modifyPassword.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <div class="page_noPassword">
  3. <div class="nopasswordTitle">
  4. <i class="iconfont icon-zuojiantou jiantou" @click="$router.go(-1)"></i>
  5. <span class="titleName">修改密码</span>
  6. </div>
  7. <div class="forgetmyInput">
  8. <el-form ref="forgetForm" :model="forgetForm" :rules="rules">
  9. <el-form-item required prop="phone">
  10. <div class="phoneLine">
  11. <i class="el-icon-mobile mobile"></i>
  12. <el-input
  13. class="phoneInput"
  14. placeholder="请填写手机号码"
  15. v-model="forgetForm.phone"
  16. v-on:input="watchNum"
  17. maxlength="11"
  18. readonly
  19. @input="change(forgetForm.phone)"
  20. ></el-input>
  21. </div>
  22. </el-form-item>
  23. <el-form-item required prop="code">
  24. <div class="code">
  25. <i class="iconfont icon-dunpai dunpai"></i>
  26. <el-input
  27. v-model="forgetForm.code"
  28. placeholder="请填写验证码"
  29. v-on:input="watchNum"
  30. ></el-input>
  31. <div class="getCode" @click="getVerifyCode()">
  32. {{ code_btn_title }}
  33. </div>
  34. </div>
  35. </el-form-item>
  36. <el-form-item>
  37. <div class="phoneLine">
  38. <i class="el-icon-lock lock"></i>
  39. <el-input
  40. class="phoneInput"
  41. v-model="psd"
  42. placeholder="请填写新密码"
  43. show-password
  44. v-on:input="watchNum"
  45. clearable
  46. ></el-input>
  47. </div>
  48. </el-form-item>
  49. </el-form>
  50. </div>
  51. <div class="login" @click="modifyAndLogin()" v-show="loginshow">保存</div>
  52. <div class="logintwo" v-show="loginshowtwo">保存</div>
  53. <div class="problem">
  54. 遇到问题?点击
  55. <span @click="contact = true">联系客服</span>
  56. </div>
  57. <!-- 弹窗 联系客服 -->
  58. <el-dialog
  59. title="客服电话"
  60. :visible.sync="contact"
  61. width="19.1875rem"
  62. top="12.5rem"
  63. center
  64. class="myDialog"
  65. >
  66. <span class="telephone">0755-86526342</span>
  67. <span slot="footer" class="dialog-footer">
  68. <span @click="contact = false">取消</span>
  69. <span>|</span>
  70. <span type="primary" @click="callPhone()">拨打</span>
  71. </span>
  72. </el-dialog>
  73. </div>
  74. </template>
  75. <script>
  76. // import { getCode, NextStep } from "@/api/login/login";
  77. import "@/styles/newStyle.scss";
  78. import { getCodeInit, getVerifyCode, forgetPassWord } from "@/api/login";
  79. import { checkMobile } from "@/utils/tools";
  80. import { hex_md5 } from "@/utils/md5";
  81. import { setRem } from "@/libs/functionRem";
  82. export default {
  83. data() {
  84. var checkMobileRule = (rule, value, callback) => {
  85. if (!checkMobile(value)) {
  86. callback(new Error("请填写正确的手机号"));
  87. } else {
  88. callback();
  89. }
  90. };
  91. return {
  92. phone: "",
  93. code: "",
  94. psd: "",
  95. contact: false,
  96. count_downing: false,
  97. count_down: 0,
  98. aespass: "",
  99. forgetForm: {
  100. phone: "",
  101. code: ""
  102. },
  103. rules: {
  104. phone: [
  105. { required: true, message: "手机号码不能为空" },
  106. { validator: checkMobileRule }
  107. ],
  108. code: [{ required: true, message: "验证码不能为空" }]
  109. },
  110. loginshow: false,
  111. loginshowtwo: true,
  112. codeshow: false,
  113. codeshowtwo: true
  114. };
  115. },
  116. created() {
  117. setRem()
  118. this.GetCodeInit();
  119. this.forgetForm.phone = this.$store.getters.user.admin.mobile;
  120. },
  121. methods: {
  122. modifyAndLogin() {
  123. if (this.forgetForm.phone.trim().length == 0) {
  124. this.$toast({
  125. message: "手机号码不能为空!"
  126. });
  127. return;
  128. }
  129. if (!checkMobile(this.forgetForm.phone)) {
  130. this.$toast({
  131. message: "请填写正确的手机号码!"
  132. });
  133. return;
  134. }
  135. if (this.forgetForm.code.trim().length == 0) {
  136. this.$toast({
  137. message: "验证码不能为空!"
  138. });
  139. return;
  140. }
  141. let params = {
  142. mobile: this.forgetForm.phone,
  143. code: this.forgetForm.code,
  144. password: hex_md5(this.psd)
  145. };
  146. forgetPassWord(params).then(response => {
  147. if (response.data.state === 1) {
  148. this.$router.go(-1);
  149. } else {
  150. this.$toast({
  151. message: response.data.msg
  152. });
  153. }
  154. });
  155. },
  156. GetCodeInit() {
  157. getCodeInit().then(response => {
  158. if (response.data.state === 1) {
  159. this.aespass = response.data.data.aespass;
  160. }
  161. });
  162. },
  163. getVerifyCode() {
  164. if (this.forgetForm.phone.length == 0) {
  165. this.$toast({
  166. message: "手机号码不能为空!"
  167. });
  168. return;
  169. }
  170. if (!checkMobile(this.forgetForm.phone)) {
  171. this.$toast({
  172. message: "请填写正确的手机号码!"
  173. });
  174. return;
  175. }
  176. if (!this.count_downing) {
  177. let parms = {
  178. phone: this.forgetForm.phone,
  179. aespass: this.aespass
  180. };
  181. getVerifyCode(parms).then(response => {
  182. if (response.data.state === 1) {
  183. this.count_downing = true;
  184. this.count_down = 61;
  185. this.countDown();
  186. }
  187. });
  188. }
  189. },
  190. callPhone() {
  191. window.location.href = "tel://075586526342";
  192. },
  193. countDown: function() {
  194. this.count_down = this.count_down - 1;
  195. if (this.count_down === 0) {
  196. this.count_downing = false;
  197. return;
  198. }
  199. var t = this;
  200. setTimeout(() => {
  201. this.countDown();
  202. }, 1000);
  203. },
  204. watchNum() {
  205. if (this.forgetForm.phone.length === 11) {
  206. this.codeshow = true;
  207. this.codeshowtwo = false;
  208. } else {
  209. this.codeshow = false;
  210. this.codeshowtwo = true;
  211. }
  212. if (
  213. this.forgetForm.phone === "" ||
  214. this.forgetForm.code === "" ||
  215. this.psd === ""
  216. ) {
  217. this.loginshow = false;
  218. this.loginshowtwo = true;
  219. } else {
  220. this.loginshow = true;
  221. this.loginshowtwo = false;
  222. }
  223. },
  224. change(value) {
  225. this.forgetForm.phone = value.replace(/[^0-9]+/g, "");
  226. }
  227. },
  228. computed: {
  229. code_btn_title: function() {
  230. if (this.count_down == 0) {
  231. return "获取验证码";
  232. } else {
  233. return "重新发送(" + this.count_down + ")";
  234. }
  235. }
  236. }
  237. };
  238. </script>
  239. <style lang="scss" scoped>
  240. .page_noPassword {
  241. overflow: hidden;
  242. height: 100%;
  243. .nopasswordTitle {
  244. height: 3.125rem;
  245. line-height: 3.125rem;
  246. display: flex;
  247. align-items: center;
  248. }
  249. .jiantou {
  250. margin-left: 1.25rem;
  251. font-size: 1.5rem;
  252. font-weight: 600;
  253. margin-right: 7rem;
  254. }
  255. .titleName {
  256. font-size: 1.125rem;
  257. font-weight: 600;
  258. }
  259. .forgetmyInput {
  260. margin-top: 4rem;
  261. .phoneLine {
  262. width: 84%;
  263. margin: 0 auto;
  264. display: flex;
  265. border-bottom: 1px solid #e6e6e6;
  266. .mobile {
  267. float: left;
  268. color: #acacac;
  269. font-size: 1.5rem;
  270. // margin-left: 0.375rem;
  271. line-height: 3.375rem;
  272. width: 1.5rem;
  273. }
  274. .phoneInput {
  275. width: 95%;
  276. }
  277. }
  278. .lock {
  279. float: left;
  280. color: #acacac;
  281. font-size: 1.5rem;
  282. // margin-left: 0.375rem;
  283. line-height: 3.375rem;
  284. width: 1.5rem;
  285. }
  286. .code {
  287. line-height: 3.375rem;
  288. width: 84%;
  289. height: 3.375rem;
  290. margin: 0 auto;
  291. border-bottom: 1px solid #e6e6e6;
  292. display: flex;
  293. align-items: center;
  294. .dunpai {
  295. float: left;
  296. color: #acacac;
  297. font-size: 1.5rem;
  298. // margin-left: 0.375rem;
  299. }
  300. .el-input {
  301. float: left;
  302. width: 10.6rem;
  303. border: none;
  304. padding: 0;
  305. }
  306. .el-input__inner {
  307. padding: 0;
  308. padding-left: 0.75rem;
  309. }
  310. .getCode {
  311. // float: left;
  312. width: 5.75rem;
  313. height: 2rem;
  314. line-height: 2rem;
  315. text-align: center;
  316. color: #fff;
  317. background: #338afb;
  318. border-radius: 1.4375rem;
  319. font-size: 0.8125rem;
  320. }
  321. .getCodetwo {
  322. width: 5.75rem;
  323. height: 2rem;
  324. // line-height: 2rem;
  325. text-align: center;
  326. color: #fff;
  327. background: #e5e5e5;
  328. border-radius: 1.4375rem;
  329. font-size: 0.8125rem;
  330. }
  331. .el-button--primary {
  332. border-color: transparent;
  333. }
  334. }
  335. }
  336. .login {
  337. width: 19.25rem;
  338. height: 2.875rem;
  339. background: linear-gradient(
  340. -90deg,
  341. rgba(129, 159, 246, 1),
  342. rgba(81, 119, 238, 1),
  343. rgba(75, 102, 234, 1)
  344. );
  345. border-radius: 1.4375rem;
  346. margin: 0 auto;
  347. line-height: 2.875rem;
  348. text-align: center;
  349. color: #fff;
  350. margin-top: 2.875rem;
  351. font-size: 1rem;
  352. }
  353. .problem {
  354. width: 84%;
  355. font-size: 0.8125rem;
  356. margin: 15rem auto 0;
  357. text-align: center;
  358. span {
  359. color: #338afb;
  360. }
  361. }
  362. }
  363. .el-form-item__error {
  364. margin-left: 2.5rem;
  365. }
  366. .logintwo {
  367. width: 19.25rem;
  368. height: 2.875rem;
  369. background: #e5e5e5;
  370. border-radius: 1.4375rem;
  371. margin: 0 auto;
  372. line-height: 2.875rem;
  373. text-align: center;
  374. color: #fff;
  375. margin-top: 2.875rem;
  376. font-size: 1rem;
  377. }
  378. .el-button--medium {
  379. padding: 0;
  380. }
  381. </style>
  382. <style lang="scss">
  383. .forgetmyInput {
  384. .el-form-item {
  385. margin-bottom: 0;
  386. }
  387. .el-input {
  388. display: flex;
  389. align-items: center;
  390. margin: 0 auto;
  391. color: rgba(155, 155, 155, 1);
  392. padding-left: 0.75rem;
  393. box-sizing: border-box;
  394. height: 3.375rem;
  395. line-height: 3.375rem;
  396. }
  397. .el-input__inner {
  398. border: none;
  399. font-size: 1rem;
  400. padding-left: 0;
  401. }
  402. .el-input__prefix {
  403. font-size: 1.5rem;
  404. color: #acacac;
  405. }
  406. .phoneLine {
  407. .el-input__clear {
  408. // margin-right: 0.625rem;
  409. }
  410. .el-input__icon {
  411. line-height: 3.375rem;
  412. font-size: 1.5rem;
  413. }
  414. }
  415. }
  416. .myDialog {
  417. line-height: 50%;
  418. height: 100%;
  419. .el-dialog {
  420. border-radius: 10px;
  421. }
  422. .el-dialog__title {
  423. color: #000000;
  424. }
  425. .telephone {
  426. width: 12.5rem;
  427. height: 1.125rem;
  428. font-size: 1.5rem;
  429. font-weight: 500;
  430. color: #338afb;
  431. margin-left: 2.5rem;
  432. }
  433. .dialog-footer {
  434. font-size:1rem;
  435. > span:nth-of-type(1) {
  436. color: #9b9b9b;
  437. }
  438. > span:nth-of-type(2) {
  439. padding: 0 3.125rem;
  440. color: #e6e6e6;
  441. }
  442. > span:nth-of-type(3) {
  443. color: #000000;
  444. }
  445. }
  446. }
  447. </style>