PasswordStepSecurity.vue 10 KB

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