PasswordResetValidQuestion.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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. this.isShowLoading = true
  153. if (this.answer1SecondChecked && this.answer2SecondChecked) {
  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. if (response.data.success) {
  167. this.isShowLoading = false
  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.$message.error(err.errMsg)
  175. })
  176. }
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .validation {
  183. margin: 0 auto;
  184. width: 100%;
  185. background: #eee;
  186. .container{
  187. padding-top: 50px;
  188. margin: 0 auto;
  189. width: 980px;
  190. text-align: center;
  191. .content{
  192. padding: 0 50px;
  193. margin: 50px auto 0;
  194. width: 100%;
  195. /*height: 540px;*/
  196. text-align: center;
  197. background: #fff;
  198. .content-top{
  199. height: 80px;
  200. line-height: 80px;
  201. h3{
  202. margin-bottom: 0;
  203. font-size: 24px;
  204. color: #000;
  205. border-bottom: 1px solid #dcdcdc;
  206. }
  207. .step{
  208. position: relative;
  209. margin-top: 10px;
  210. img{
  211. width: 315px;
  212. height: 46px;
  213. }
  214. .step-item{
  215. position: absolute;
  216. top: 45px;
  217. left: 265px;
  218. span{
  219. margin-right: 85px;
  220. font-size: 14px;
  221. color: #b4b4b4;
  222. }
  223. span.active {
  224. color: #0076ad;
  225. }
  226. }
  227. }
  228. }
  229. form {
  230. margin-top: 150px;
  231. padding-bottom: 44px;
  232. input{
  233. padding: 0 0 0 18px;
  234. width: 360px;
  235. height: 44px;
  236. line-height: 44px;
  237. font-size: 14px;
  238. color: #000;
  239. border-radius: 0;
  240. }
  241. input.answer {
  242. background: url("/images/all/more.png") no-repeat 325px center;
  243. cursor: pointer;
  244. }
  245. ul{
  246. display: none;
  247. position: absolute;
  248. top: 44px;
  249. left: 0;
  250. width: 360px;
  251. background: #fff;
  252. box-shadow: 0 0 5px rgba(0,0,0,.5);
  253. -moz-box-shadow: 0 0 5px rgba(0,0,0,.5);
  254. -o-box-shadow: 0 0 5px rgba(0,0,0,.5);
  255. -webkit-box-shadow: 0 0 5px rgba(0,0,0,.5);
  256. z-index: 10;
  257. li{
  258. padding-left: 18px;
  259. width: 100%;
  260. height: 30px;
  261. line-height: 30px;
  262. text-align: left;
  263. font-size: 14px;
  264. color: #000;
  265. cursor: pointer;
  266. &:hover{
  267. background: #0076ad;
  268. color: #fff;
  269. }
  270. }
  271. }
  272. span.tip{
  273. position: absolute;
  274. top: 0;
  275. right: -238px;
  276. font-size: 13px;
  277. color: #8c8c8c;
  278. a{
  279. font-size: 13px;
  280. color: #0076ad;
  281. }
  282. }
  283. span.tip.codeError-tip{
  284. position: absolute;
  285. top: 3px;
  286. left: 378px;
  287. width: 200px;
  288. text-align: left;
  289. color: #ff4949;
  290. font-size: 12px;
  291. }
  292. i{
  293. position: absolute;
  294. top: 13px;
  295. left: 20px;
  296. font-size: 20px;
  297. color: #a0a0a0;
  298. }
  299. .btn {
  300. margin: 34px 0 16px 0;
  301. width: 360px;
  302. height: 44px;
  303. line-height: 44px;
  304. font-size: 16px;
  305. color: #fff;
  306. background: #0076AD;
  307. border-radius: 3px;
  308. }
  309. }
  310. .content-bottom{
  311. margin: 155px auto 0;
  312. padding-bottom: 50px;
  313. width: 360px;
  314. div.warp{
  315. padding-bottom: 65px;
  316. }
  317. p{
  318. font-size: 24px;
  319. color: #323232;
  320. img{
  321. margin-right: 20px;
  322. width: 30px;
  323. height: 28px;
  324. }
  325. }
  326. p.pass{
  327. font-size: 24px;
  328. color: #e77405;
  329. img{
  330. height: 30px;
  331. }
  332. }
  333. p.passed {
  334. color: #2ab300;
  335. img{
  336. height: 30px;
  337. }
  338. }
  339. span{
  340. display: inline-block;
  341. font-size: 14px;
  342. color: #8b8b8b;
  343. }
  344. span.close-tip{
  345. margin: 15px 0 140px 0;
  346. }
  347. .close-btn{
  348. margin: 0 auto;
  349. width: 200px;
  350. height: 36px;
  351. line-height: 36px;
  352. font-size: 14px;
  353. text-align: center;
  354. color: #323232;
  355. border: 1px solid #d2d2d2;
  356. border-radius: 3px;
  357. cursor: pointer ;
  358. }
  359. span.use{
  360. display: inline-block;
  361. margin-bottom: 30px;
  362. width: 360px;
  363. font-size: 14px;
  364. color: #000;
  365. text-align: left;
  366. em{
  367. font-size: 14px;
  368. font-style: normal;
  369. color: #000;
  370. }
  371. }
  372. .form-group {
  373. margin: 0 auto 16px;
  374. position: relative;
  375. width: 360px;
  376. height: 44px;
  377. line-height: 44px;
  378. input{
  379. padding: 0 0 0 18px;
  380. width: 360px;
  381. height: 44px;
  382. line-height: 44px;
  383. font-size: 14px;
  384. color: #000;
  385. border-radius: 0;
  386. }
  387. input.msg{
  388. float: left;
  389. width: 210px;
  390. padding: 0 0 0 18px;
  391. height: 44px;
  392. line-height: 44px;
  393. font-size: 14px;
  394. color: #000;
  395. border-radius: 0;
  396. }
  397. span.msg{
  398. float: right;
  399. margin: 0;
  400. width: 130px;
  401. height: 44px;
  402. line-height: 44px;
  403. text-align: center ;
  404. font-size: 14px;
  405. color: #5a5a5a;
  406. background: #f4f4f4;
  407. border: 1px solid #dcdcdc;
  408. cursor: pointer;
  409. }
  410. span.msg.send{
  411. background: #d2d2d2;
  412. color: #fff;
  413. }
  414. }
  415. .btn {
  416. margin: 34px 0 10px 0;
  417. width: 360px;
  418. height: 44px;
  419. line-height: 44px;
  420. font-size: 16px;
  421. color: #fff;
  422. background: #0076AD;
  423. border-radius: 3px;
  424. }
  425. }
  426. .choose{
  427. margin: 155px auto 0;
  428. padding-bottom: 44px;
  429. div{
  430. padding: 0 15px;
  431. margin: 0 auto 16px;
  432. width: 360px;
  433. height: 60px;
  434. line-height: 60px;
  435. text-align: left;
  436. overflow: hidden;
  437. border: 1px solid #d2d2d2;
  438. cursor: pointer;
  439. &:hover,&.active{
  440. border-color: #0076ad;
  441. span{
  442. color: #0076ad;
  443. }
  444. i.second {
  445. color: #0076ad;
  446. }
  447. }
  448. img.first{
  449. float: left;
  450. margin: 24px 20px 0 0;
  451. font-size: 20px;
  452. color: #323232;
  453. }
  454. img.first.mob{
  455. margin: 22px 20px 0 5px;
  456. font-size: 28px;
  457. }
  458. i.second {
  459. float: right;
  460. margin: 20px 0 0 5px;
  461. font-size: 20px;
  462. color: #323232;
  463. }
  464. span{
  465. float: left;
  466. font-size: 14px;
  467. color: #323232;
  468. }
  469. }
  470. }
  471. a.return{
  472. position: absolute;
  473. left: 0;
  474. top: -15px;
  475. img{
  476. width: 34px !important;
  477. height: 34px !important;
  478. }
  479. }
  480. }
  481. }
  482. }
  483. </style>