PasswordResetNewPassword.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  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. console.log(callback)
  124. if (value === '') {
  125. callback(new Error('请再次输入密码'))
  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. this.isShowLoading = true
  182. if (this.passwordChecked && this.confirmChecked) {
  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.$message.error(err.errMsg)
  199. })
  200. }
  201. },
  202. // 获得邮箱token
  203. getEmailLinkToken () {
  204. var url = window.location.search
  205. var request = {}
  206. if (url.indexOf('?' !== -1)) {
  207. var str = url.substr(1)
  208. var strs = str.split('&')
  209. for (var i = 0; i < strs.length; i++) {
  210. request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
  211. }
  212. }
  213. this.Token = request['token'] || ''
  214. if (this.Token) {
  215. this.$store.commit('login/GET_TOKEN', this.Token)
  216. }
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss" scoped>
  222. .validation {
  223. margin: 0 auto;
  224. width: 100%;
  225. background: #eee;
  226. .container{
  227. padding-top: 50px;
  228. margin: 0 auto;
  229. width: 980px;
  230. text-align: center;
  231. .content{
  232. padding: 0 50px;
  233. margin: 50px auto 0;
  234. width: 100%;
  235. /*height: 540px;*/
  236. text-align: center;
  237. background: #fff;
  238. .content-top{
  239. height: 80px;
  240. line-height: 80px;
  241. h3{
  242. margin-bottom: 0;
  243. font-size: 24px;
  244. color: #000;
  245. border-bottom: 1px solid #dcdcdc;
  246. }
  247. .step{
  248. position: relative;
  249. margin-top: 10px;
  250. img{
  251. width: 315px;
  252. height: 46px;
  253. }
  254. .step-item{
  255. position: absolute;
  256. top: 45px;
  257. left: 265px;
  258. span{
  259. margin-right: 85px;
  260. font-size: 14px;
  261. color: #b4b4b4;
  262. }
  263. span.active {
  264. color: #0076ad;
  265. }
  266. }
  267. }
  268. }
  269. form {
  270. margin-top: 150px;
  271. padding-bottom: 44px;
  272. input{
  273. padding: 0 0 0 18px;
  274. width: 360px;
  275. height: 44px;
  276. line-height: 44px;
  277. font-size: 14px;
  278. color: #000;
  279. border-radius: 0;
  280. }
  281. input.answer {
  282. background: url("/images/all/more.png") no-repeat 325px center;
  283. cursor: pointer;
  284. }
  285. .pwd {
  286. margin: 6px 0 -15px 0;
  287. text-align: left;
  288. font-size: 13px;
  289. em{
  290. display: inline-block;
  291. margin: 0 8px 2px 0;
  292. width: 24px;
  293. height: 6px;
  294. &:first-child{
  295. margin-left: 10px;
  296. }
  297. }
  298. span{
  299. margin-left: 10px;
  300. font-size: 13px;
  301. }
  302. }
  303. .pwd.sm{
  304. color: #8c8c8c;
  305. em {
  306. background: #bfbfbf;
  307. &:first-child{
  308. background: #ff4e00;
  309. }
  310. }
  311. span{
  312. color: #ff4e00;
  313. }
  314. }
  315. .pwd.md{
  316. color: #8c8c8c;
  317. em {
  318. background: #22ac38;
  319. &:nth-child(3){
  320. background: #bfbfbf;
  321. }
  322. }
  323. span{
  324. color: #22ac38;
  325. }
  326. }
  327. .pwd.lar{
  328. color: #8c8c8c;
  329. em {
  330. background: #00a0e9;
  331. }
  332. span{
  333. color: #00a0e9;
  334. }
  335. }
  336. .pwd.low{
  337. color: #8c8c8c;
  338. em{
  339. background: #bfbfbf;
  340. }
  341. }
  342. span.tip{
  343. position: absolute;
  344. top: 0;
  345. right: -238px;
  346. font-size: 13px;
  347. color: #8c8c8c;
  348. a{
  349. font-size: 13px;
  350. color: #0076ad;
  351. }
  352. }
  353. span.tip.passwordError{
  354. position: absolute;
  355. top: 3px;
  356. left: 378px;
  357. width: 200px;
  358. text-align: left;
  359. color: #ff4949;
  360. font-size: 12px;
  361. }
  362. i{
  363. position: absolute;
  364. top: 13px;
  365. left: 20px;
  366. font-size: 20px;
  367. color: #a0a0a0;
  368. }
  369. .btn {
  370. margin: 34px 0 16px 0;
  371. width: 360px;
  372. height: 44px;
  373. line-height: 44px;
  374. font-size: 16px;
  375. color: #fff;
  376. background: #0076AD;
  377. border-radius: 3px;
  378. }
  379. }
  380. .content-bottom{
  381. margin: 155px auto 0;
  382. padding-bottom: 50px;
  383. width: 360px;
  384. div.warp{
  385. padding-bottom: 65px;
  386. }
  387. p{
  388. font-size: 24px;
  389. color: #323232;
  390. img{
  391. margin-right: 20px;
  392. width: 30px;
  393. height: 28px;
  394. }
  395. }
  396. p.pass{
  397. font-size: 24px;
  398. color: #e77405;
  399. img{
  400. height: 30px;
  401. }
  402. }
  403. p.passed {
  404. color: #2ab300;
  405. img{
  406. height: 30px;
  407. }
  408. }
  409. span{
  410. display: inline-block;
  411. font-size: 14px;
  412. color: #8b8b8b;
  413. }
  414. span.close-tip{
  415. margin: 15px 0 140px 0;
  416. }
  417. .close-btn{
  418. margin: 0 auto;
  419. width: 200px;
  420. height: 36px;
  421. line-height: 36px;
  422. font-size: 14px;
  423. text-align: center;
  424. color: #323232;
  425. border: 1px solid #d2d2d2;
  426. border-radius: 3px;
  427. cursor: pointer ;
  428. }
  429. span.use{
  430. display: inline-block;
  431. margin-bottom: 30px;
  432. width: 360px;
  433. font-size: 14px;
  434. color: #000;
  435. text-align: left;
  436. em{
  437. font-size: 14px;
  438. font-style: normal;
  439. color: #000;
  440. }
  441. }
  442. .form-group {
  443. margin: 0 auto 16px;
  444. position: relative;
  445. width: 360px;
  446. height: 44px;
  447. line-height: 44px;
  448. input{
  449. padding: 0 0 0 18px;
  450. width: 360px;
  451. height: 44px;
  452. line-height: 44px;
  453. font-size: 14px;
  454. color: #000;
  455. border-radius: 0;
  456. }
  457. input.msg{
  458. float: left;
  459. width: 210px;
  460. padding: 0 0 0 18px;
  461. height: 44px;
  462. line-height: 44px;
  463. font-size: 14px;
  464. color: #000;
  465. border-radius: 0;
  466. }
  467. span.msg{
  468. float: right;
  469. margin: 0;
  470. width: 130px;
  471. height: 44px;
  472. line-height: 44px;
  473. text-align: center ;
  474. font-size: 14px;
  475. color: #5a5a5a;
  476. background: #f4f4f4;
  477. border: 1px solid #dcdcdc;
  478. cursor: pointer;
  479. }
  480. span.msg.send{
  481. background: #d2d2d2;
  482. color: #fff;
  483. }
  484. }
  485. .btn {
  486. margin: 34px 0 10px 0;
  487. width: 360px;
  488. height: 44px;
  489. line-height: 44px;
  490. font-size: 16px;
  491. color: #fff;
  492. background: #0076AD;
  493. border-radius: 3px;
  494. }
  495. }
  496. .choose{
  497. margin: 155px auto 0;
  498. padding-bottom: 44px;
  499. div{
  500. padding: 0 15px;
  501. margin: 0 auto 16px;
  502. width: 360px;
  503. height: 60px;
  504. line-height: 60px;
  505. text-align: left;
  506. overflow: hidden;
  507. border: 1px solid #d2d2d2;
  508. cursor: pointer;
  509. &:hover,&.active{
  510. border-color: #0076ad;
  511. span{
  512. color: #0076ad;
  513. }
  514. i.second {
  515. color: #0076ad;
  516. }
  517. }
  518. img.first{
  519. float: left;
  520. margin: 24px 20px 0 0;
  521. font-size: 20px;
  522. color: #323232;
  523. }
  524. img.first.mob{
  525. margin: 22px 20px 0 5px;
  526. font-size: 28px;
  527. }
  528. i.second {
  529. float: right;
  530. margin: 20px 0 0 5px;
  531. font-size: 20px;
  532. color: #323232;
  533. }
  534. span{
  535. float: left;
  536. font-size: 14px;
  537. color: #323232;
  538. }
  539. }
  540. }
  541. a.return{
  542. position: absolute;
  543. left: 0;
  544. top: -15px;
  545. img{
  546. width: 34px !important;
  547. height: 34px !important;
  548. }
  549. }
  550. }
  551. }
  552. }
  553. </style>