EncryptedSettingSecondStep.vue 12 KB

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