PasswordStepNew.vue 13 KB

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