EncryptedSettingSecondStep.vue 12 KB

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