ValidationEmailStepSecurity.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. token: ''
  47. }
  48. },
  49. mounted () {
  50. this.$nextTick(() => {
  51. this.loadIssue()
  52. })
  53. },
  54. methods: {
  55. jump (type) {
  56. this.$emit('stepEvent', type)
  57. },
  58. // 警告弹窗
  59. downToast (type) {
  60. this.$toast({
  61. message: type,
  62. iconClass: 'el-icon-warning'
  63. })
  64. },
  65. // 验证密保答案一
  66. validAnswer1 () {
  67. if (!this.valid.answer1) {
  68. this.downToast('请填写问题一的正确答案')
  69. this.state.answer1 = 'error'
  70. } else {
  71. this.state.answer1 = 'success'
  72. }
  73. },
  74. // 验证密保答案二
  75. validAnswer2 () {
  76. if (!this.valid.answer2) {
  77. this.downToast('请填写问题二的正确答案')
  78. this.state.answer2 = 'error'
  79. } else {
  80. this.state.answer2 = 'success'
  81. }
  82. },
  83. // 获取密保问题
  84. loadIssue () {
  85. this.$http.get('/update/user/check/question')
  86. .then(response => {
  87. if (response.data.success) {
  88. this.questions = response.data.content.questions
  89. } else {
  90. this.downToast(response.data.errMsg)
  91. }
  92. })
  93. },
  94. sureAccount (type) {
  95. if (this.state.answer1 !== 'success' || this.state.answer2 !== 'success') {
  96. this.downToast('请确认填写部分是否有误')
  97. } else {
  98. this.$indicator.open('验证过程中...')
  99. let param = new FormData()
  100. let answer = []
  101. answer.push({'answer': this.valid.answer1, sort: this.questions[0].sort}, {
  102. 'answer': this.valid.answer2, sort: this.questions[1].sort
  103. })
  104. let answers = JSON.stringify(answer)
  105. param.append('answers', answers)
  106. let config = {
  107. headers: {'Content-Type': 'multipart/form-data'}
  108. }
  109. this.$http.post(`/update/user/check/question`, param, config)
  110. .then(response => {
  111. this.$indicator.close()
  112. if (response.data.success) {
  113. this.$emit('stepEvent', type)
  114. this.$emit('tokenEvent', response.data.content.token)
  115. } else {
  116. this.downToast(response.data.errMsg)
  117. }
  118. }).catch((err) => {
  119. this.$indicator.close()
  120. this.downToast(err.errMsg)
  121. })
  122. }
  123. }
  124. }
  125. }
  126. </script>
  127. <style scoped type="text/scss" lang="scss">
  128. </style>