ValidationEmailStepSecurity.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="f-main">
  3. <div class="content-top">
  4. <p>验证邮箱</p>
  5. <a href="javascript:void(0)" class="back" @click="jump('select')"><i class="el-icon-back"></i></a>
  6. </div>
  7. <div class="f-form">
  8. <div class="page-part">
  9. <p class="security">密保问题一:<span v-text="questions[0].question"></span></p>
  10. </div>
  11. <div class="page-part">
  12. <mt-field placeholder="请填写答案一"
  13. :state="state.answer1"
  14. @blur.native.capture="validAnswer1"
  15. v-model="valid.answer1"></mt-field>
  16. </div>
  17. <div class="page-part">
  18. <p class="security">密保问题二:<span v-text="questions[1].question"></span></p>
  19. </div>
  20. <div class="page-part">
  21. <mt-field placeholder="请填写答案二"
  22. :state="state.answer2"
  23. @blur.native.capture="validAnswer2"
  24. v-model="valid.answer2"></mt-field>
  25. </div>
  26. <div class="page-part">
  27. <mt-button size="large" type="primary" @click="sureAccount('new')">下一步</mt-button>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'step-security',
  35. data () {
  36. return {
  37. state: {
  38. answer1: 'error',
  39. answer2: 'error'
  40. },
  41. valid: {
  42. answer1: '',
  43. answer2: ''
  44. },
  45. questions: [
  46. {question: ''},
  47. {question: ''}
  48. ],
  49. token: ''
  50. }
  51. },
  52. mounted () {
  53. this.$nextTick(() => {
  54. this.loadIssue()
  55. })
  56. },
  57. methods: {
  58. jump (type) {
  59. this.$emit('stepEvent', type)
  60. },
  61. // 警告弹窗
  62. downToast (type) {
  63. this.$toast({
  64. message: type,
  65. iconClass: 'el-icon-warning'
  66. })
  67. },
  68. // 验证密保答案一
  69. validAnswer1 () {
  70. if (!this.valid.answer1) {
  71. this.downToast('请填写问题一的正确答案')
  72. this.state.answer1 = 'error'
  73. } else {
  74. this.state.answer1 = 'success'
  75. }
  76. },
  77. // 验证密保答案二
  78. validAnswer2 () {
  79. if (!this.valid.answer2) {
  80. this.downToast('请填写问题二的正确答案')
  81. this.state.answer2 = 'error'
  82. } else {
  83. this.state.answer2 = 'success'
  84. }
  85. },
  86. // 获取密保问题
  87. loadIssue () {
  88. this.$http.get('/update/user/check/question')
  89. .then(response => {
  90. if (response.data.success) {
  91. this.questions = response.data.content.questions
  92. } else {
  93. this.downToast(response.data.errMsg)
  94. }
  95. })
  96. },
  97. sureAccount (type) {
  98. if (this.state.answer1 !== 'success' || this.state.answer2 !== 'success') {
  99. this.downToast('请确认填写部分是否有误')
  100. } else {
  101. this.$indicator.open('验证过程中...')
  102. let param = new FormData()
  103. let answer = []
  104. answer.push({'answer': this.valid.answer1, sort: this.questions[0].sort}, {
  105. 'answer': this.valid.answer2, sort: this.questions[1].sort
  106. })
  107. let answers = JSON.stringify(answer)
  108. param.append('answers', answers)
  109. let config = {
  110. headers: {'Content-Type': 'multipart/form-data'}
  111. }
  112. this.$http.post(`/update/user/check/question`, param, config)
  113. .then(response => {
  114. this.$indicator.close()
  115. if (response.data.success) {
  116. this.$emit('stepEvent', type)
  117. this.$emit('tokenEvent', response.data.content.token)
  118. } else {
  119. this.downToast(response.data.errMsg)
  120. }
  121. }).catch((err) => {
  122. this.$indicator.close()
  123. this.downToast(err.errMsg)
  124. })
  125. }
  126. }
  127. }
  128. }
  129. </script>
  130. <style scoped type="text/scss" lang="scss">
  131. </style>