EncryptedSettingSecondStep.vue 12 KB

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