PasswordResetValidQuestion.vue 11 KB

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