PasswordResetNewPassword.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <template>
  2. <div class="validation">
  3. <div class="container">
  4. <div class="content">
  5. <div class="content-top">
  6. <h3>密码重置</h3>
  7. <div class="step">
  8. <img src="/images/all/step02.png" alt=""/>
  9. <div class="step-item"><span class="active">账号验证</span><span class="active">密码设置</span><span>设置完成</span></div>
  10. </div>
  11. </div>
  12. <div>
  13. <el-form :model="newPassword" :rules="rulesQuestion" ref="newPassword" label-width="100px" class="demo-ruleForm">
  14. <el-form-item prop="password">
  15. <el-input type="password" v-model="newPassword.password" auto-complete="off" placeholder="新密码"></el-input>
  16. <div class="pwd sm" v-show="showMsgTip1">密码强度 <em></em><em></em><em></em><span>弱</span></div>
  17. <div class="pwd md" v-show="showMsgTip2">密码强度 <em></em><em></em><em></em><span>中</span></div>
  18. <div class="pwd lar" v-show="showMsgTip3">密码强度 <em></em><em></em><em></em><span>强</span></div>
  19. <div class="pwd low" v-show="showMsgTip4">密码强度 <em></em><em></em><em></em></div>
  20. </el-form-item>
  21. <el-form-item prop="confirm">
  22. <el-input type="password"
  23. v-model="newPassword.confirm"
  24. v-bind:class="{active: showPasswordError}"
  25. auto-complete="off"
  26. placeholder="确认密码"></el-input>
  27. <span class="tip passwordError" v-show="showPasswordError">两次输入密码不一致</span>
  28. </el-form-item>
  29. <el-form-item>
  30. <a class="btn finish"
  31. :disabled="!passwordChecked || !confirmChecked"
  32. @click="passwordSubmit">提交</a>
  33. </el-form-item>
  34. </el-form>
  35. </div>
  36. </div>
  37. <loading v-show="isShowLoading"/>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import Loading from '~components/common/loading/Loading.vue'
  43. export default {
  44. name: 'validation',
  45. components: {
  46. Loading
  47. },
  48. data () {
  49. // 验证密保
  50. var validatePassword = (rule, value, callback) => {
  51. if (this.newPassword.password !== '') {
  52. if (value.length <= 20 && value.length >= 8) {
  53. var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  54. var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  55. if (reg1.test(value)) {
  56. // callback(new Error('密码强度强'))
  57. this.showMsgTip3 = true
  58. this.showMsgTip2 = false
  59. this.showMsgTip1 = false
  60. this.showMsgTip4 = false
  61. this.passwordChecked = true
  62. } else if (reg2.test(value)) {
  63. // callback(new Error('密码强度中'))
  64. this.showMsgTip2 = true
  65. this.showMsgTip3 = false
  66. this.showMsgTip1 = false
  67. this.showMsgTip4 = false
  68. this.passwordChecked = true
  69. } else {
  70. this.showMsgTip1 = true
  71. this.showMsgTip3 = false
  72. this.showMsgTip2 = false
  73. this.showMsgTip4 = false
  74. this.passwordChecked = false
  75. }
  76. } else {
  77. this.showMsgTip3 = false
  78. this.showMsgTip2 = false
  79. this.showMsgTip1 = false
  80. this.showMsgTip4 = true
  81. this.passwordChecked = false
  82. }
  83. }
  84. callback()
  85. }
  86. var validatePasswordTip = (rule, value, callback) => {
  87. if (value === '') {
  88. callback(new Error('请输入密码'))
  89. this.passwordChecked = false
  90. } else {
  91. if (this.newPassword.password !== '') {
  92. if (value.length <= 20 && value.length >= 8) {
  93. var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  94. var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  95. if (reg1.test(value)) {
  96. this.passwordChecked = true
  97. } else if (reg2.test(value)) {
  98. this.passwordChecked = true
  99. } else {
  100. callback(new Error('密码须为8-20字符的英文、数字混合'))
  101. this.passwordChecked = false
  102. }
  103. } else {
  104. callback(new Error('密码须为8-20字符的英文、数字混合'))
  105. this.passwordChecked = false
  106. }
  107. if (this.newPassword.confirm !== '') {
  108. if (value !== this.newPassword.confirm) {
  109. this.showPasswordError = true
  110. // callback(new Error('两次输入密码不一致!'))
  111. this.confirmChecked = false
  112. } else {
  113. this.confirmChecked = true
  114. this.showPasswordError = false
  115. callback()
  116. }
  117. }
  118. }
  119. callback()
  120. }
  121. }
  122. var validateConfirm = (rule, value, callback) => {
  123. if (value === '') {
  124. callback(new Error('请再次输入密码'))
  125. this.showPasswordError = false
  126. this.confirmChecked = false
  127. } else if (value !== this.newPassword.password) {
  128. // callback(new Error('两次输入密码不一致!'))
  129. this.showPasswordError = true
  130. this.confirmChecked = false
  131. } else {
  132. this.showPasswordError = false
  133. this.confirmChecked = true
  134. callback()
  135. }
  136. }
  137. return {
  138. showPasswordError: false,
  139. isShowLoading: false,
  140. showMsgTip1: false,
  141. showMsgTip2: false,
  142. showMsgTip3: false,
  143. showMsgTip4: false,
  144. passwordChecked: false,
  145. confirmChecked: false,
  146. getQuestions: '',
  147. question1: '',
  148. question2: '',
  149. sort1: '',
  150. sort2: '',
  151. answer1SecondChecked: false,
  152. answer2SecondChecked: false,
  153. newPassword: {
  154. password: '',
  155. confirm: ''
  156. },
  157. rulesQuestion: {
  158. password: [
  159. { validator: validatePasswordTip, trigger: 'blur' },
  160. { validator: validatePassword, trigger: 'change' }
  161. ],
  162. confirm: [
  163. { validator: validateConfirm, trigger: 'blur' }
  164. ]
  165. }
  166. }
  167. },
  168. computed: {
  169. firstStepToken () {
  170. return this.$store.state.login.token.data
  171. }
  172. },
  173. mounted () {
  174. // 获取邮箱token
  175. this.$nextTick(() => {
  176. this.getEmailLinkToken()
  177. })
  178. },
  179. methods: {
  180. passwordSubmit () {
  181. if (this.passwordChecked && this.confirmChecked) {
  182. this.isShowLoading = true
  183. let param = new FormData()
  184. param.append('password', this.newPassword.password)
  185. param.append('token', this.firstStepToken)
  186. let config = {
  187. headers: {'Content-Type': 'multipart/form-data'}
  188. }
  189. this.$http.post(`/sso/resetPwd`, param, config)
  190. .then(response => {
  191. if (response.data.success) {
  192. this.isShowLoading = false
  193. this.$router.push({ path: '/reset/passwordResetSetSuccess' })
  194. } else {
  195. return Promise.reject(response.data)
  196. }
  197. }).catch(err => {
  198. this.isShowLoading = false
  199. this.$message.error(err.errMsg)
  200. })
  201. }
  202. },
  203. // 获得邮箱token
  204. getEmailLinkToken () {
  205. var url = window.location.search
  206. var request = {}
  207. if (url.indexOf('?' !== -1)) {
  208. var str = url.substr(1)
  209. var strs = str.split('&')
  210. for (var i = 0; i < strs.length; i++) {
  211. request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
  212. }
  213. }
  214. this.Token = request['token'] || ''
  215. if (this.Token) {
  216. this.$store.commit('login/GET_TOKEN', this.Token)
  217. }
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. .validation {
  224. margin: 0 auto;
  225. width: 100%;
  226. background: #eee;
  227. .container{
  228. padding-top: 50px;
  229. margin: 0 auto;
  230. width: 980px;
  231. text-align: center;
  232. .content{
  233. padding: 0 50px;
  234. margin: 50px auto 0;
  235. width: 100%;
  236. /*height: 540px;*/
  237. text-align: center;
  238. background: #fff;
  239. .content-top{
  240. height: 80px;
  241. line-height: 80px;
  242. h3{
  243. margin-bottom: 0;
  244. font-size: 24px;
  245. color: #000;
  246. border-bottom: 1px solid #dcdcdc;
  247. }
  248. .step{
  249. position: relative;
  250. margin-top: 10px;
  251. img{
  252. width: 315px;
  253. height: 46px;
  254. }
  255. .step-item{
  256. position: absolute;
  257. top: 45px;
  258. left: 265px;
  259. span{
  260. margin-right: 85px;
  261. font-size: 14px;
  262. color: #b4b4b4;
  263. }
  264. span.active {
  265. color: #0076ad;
  266. }
  267. }
  268. }
  269. }
  270. form {
  271. margin-top: 150px;
  272. padding-bottom: 44px;
  273. input{
  274. padding: 0 0 0 18px;
  275. width: 360px;
  276. height: 44px;
  277. line-height: 44px;
  278. font-size: 14px;
  279. color: #000;
  280. border-radius: 0;
  281. }
  282. input.answer {
  283. background: url("/images/all/more.png") no-repeat 325px center;
  284. cursor: pointer;
  285. }
  286. .pwd {
  287. margin: 6px 0 -15px 0;
  288. text-align: left;
  289. font-size: 13px;
  290. em{
  291. display: inline-block;
  292. margin: 0 8px 2px 0;
  293. width: 24px;
  294. height: 6px;
  295. &:first-child{
  296. margin-left: 10px;
  297. }
  298. }
  299. span{
  300. margin-left: 10px;
  301. font-size: 13px;
  302. }
  303. }
  304. .pwd.sm{
  305. color: #8c8c8c;
  306. em {
  307. background: #bfbfbf;
  308. &:first-child{
  309. background: #ff4e00;
  310. }
  311. }
  312. span{
  313. color: #ff4e00;
  314. }
  315. }
  316. .pwd.md{
  317. color: #8c8c8c;
  318. em {
  319. background: #22ac38;
  320. &:nth-child(3){
  321. background: #bfbfbf;
  322. }
  323. }
  324. span{
  325. color: #22ac38;
  326. }
  327. }
  328. .pwd.lar{
  329. color: #8c8c8c;
  330. em {
  331. background: #00a0e9;
  332. }
  333. span{
  334. color: #00a0e9;
  335. }
  336. }
  337. .pwd.low{
  338. color: #8c8c8c;
  339. em{
  340. background: #bfbfbf;
  341. }
  342. }
  343. span.tip{
  344. position: absolute;
  345. top: 0;
  346. right: -238px;
  347. font-size: 13px;
  348. color: #8c8c8c;
  349. a{
  350. font-size: 13px;
  351. color: #0076ad;
  352. }
  353. }
  354. span.tip.passwordError{
  355. position: absolute;
  356. top: 3px;
  357. left: 380px;
  358. width: 200px;
  359. text-align: left;
  360. color: #ff4949;
  361. font-size: 12px;
  362. }
  363. i{
  364. position: absolute;
  365. top: 13px;
  366. left: 20px;
  367. font-size: 20px;
  368. color: #a0a0a0;
  369. }
  370. .btn {
  371. margin: 34px 0 16px 0;
  372. width: 360px;
  373. height: 44px;
  374. line-height: 44px;
  375. font-size: 16px;
  376. color: #fff;
  377. background: #0076AD;
  378. border-radius: 3px;
  379. }
  380. }
  381. .content-bottom{
  382. margin: 155px auto 0;
  383. padding-bottom: 50px;
  384. width: 360px;
  385. div.warp{
  386. padding-bottom: 65px;
  387. }
  388. p{
  389. font-size: 24px;
  390. color: #323232;
  391. img{
  392. margin-right: 20px;
  393. width: 30px;
  394. height: 28px;
  395. }
  396. }
  397. p.pass{
  398. font-size: 24px;
  399. color: #e77405;
  400. img{
  401. height: 30px;
  402. }
  403. }
  404. p.passed {
  405. color: #2ab300;
  406. img{
  407. height: 30px;
  408. }
  409. }
  410. span{
  411. display: inline-block;
  412. font-size: 14px;
  413. color: #8b8b8b;
  414. }
  415. span.close-tip{
  416. margin: 15px 0 140px 0;
  417. }
  418. .close-btn{
  419. margin: 0 auto;
  420. width: 200px;
  421. height: 36px;
  422. line-height: 36px;
  423. font-size: 14px;
  424. text-align: center;
  425. color: #323232;
  426. border: 1px solid #d2d2d2;
  427. border-radius: 3px;
  428. cursor: pointer ;
  429. }
  430. span.use{
  431. display: inline-block;
  432. margin-bottom: 30px;
  433. width: 360px;
  434. font-size: 14px;
  435. color: #000;
  436. text-align: left;
  437. em{
  438. font-size: 14px;
  439. font-style: normal;
  440. color: #000;
  441. }
  442. }
  443. .form-group {
  444. margin: 0 auto 16px;
  445. position: relative;
  446. width: 360px;
  447. height: 44px;
  448. line-height: 44px;
  449. input{
  450. padding: 0 0 0 18px;
  451. width: 360px;
  452. height: 44px;
  453. line-height: 44px;
  454. font-size: 14px;
  455. color: #000;
  456. border-radius: 0;
  457. }
  458. input.msg{
  459. float: left;
  460. width: 210px;
  461. padding: 0 0 0 18px;
  462. height: 44px;
  463. line-height: 44px;
  464. font-size: 14px;
  465. color: #000;
  466. border-radius: 0;
  467. }
  468. span.msg{
  469. float: right;
  470. margin: 0;
  471. width: 130px;
  472. height: 44px;
  473. line-height: 44px;
  474. text-align: center ;
  475. font-size: 14px;
  476. color: #5a5a5a;
  477. background: #f4f4f4;
  478. border: 1px solid #dcdcdc;
  479. cursor: pointer;
  480. }
  481. span.msg.send{
  482. background: #d2d2d2;
  483. color: #fff;
  484. }
  485. }
  486. .btn {
  487. margin: 34px 0 10px 0;
  488. width: 360px;
  489. height: 44px;
  490. line-height: 44px;
  491. font-size: 16px;
  492. color: #fff;
  493. background: #0076AD;
  494. border-radius: 3px;
  495. }
  496. }
  497. .choose{
  498. margin: 155px auto 0;
  499. padding-bottom: 44px;
  500. div{
  501. padding: 0 15px;
  502. margin: 0 auto 16px;
  503. width: 360px;
  504. height: 60px;
  505. line-height: 60px;
  506. text-align: left;
  507. overflow: hidden;
  508. border: 1px solid #d2d2d2;
  509. cursor: pointer;
  510. &:hover,&.active{
  511. border-color: #0076ad;
  512. span{
  513. color: #0076ad;
  514. }
  515. i.second {
  516. color: #0076ad;
  517. }
  518. }
  519. img.first{
  520. float: left;
  521. margin: 24px 20px 0 0;
  522. font-size: 20px;
  523. color: #323232;
  524. }
  525. img.first.mob{
  526. margin: 22px 20px 0 5px;
  527. font-size: 28px;
  528. }
  529. i.second {
  530. float: right;
  531. margin: 20px 0 0 5px;
  532. font-size: 20px;
  533. color: #323232;
  534. }
  535. span{
  536. float: left;
  537. font-size: 14px;
  538. color: #323232;
  539. }
  540. }
  541. }
  542. a.return{
  543. position: absolute;
  544. left: 0;
  545. top: -15px;
  546. img{
  547. width: 34px !important;
  548. height: 34px !important;
  549. }
  550. }
  551. }
  552. }
  553. }
  554. </style>