PasswordResetValidQuestion.vue 10 KB

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