PasswordResetNewPassword.vue 12 KB

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