stepSecurity .vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="f-main">
  3. <div class="content-top">
  4. <p>密码重置</p>
  5. </div>
  6. <div class="f-form">
  7. <div class="page-part">
  8. <p class="security">密保问题一:<span v-text="questions[0].question"></span></p>
  9. </div>
  10. <div class="page-part">
  11. <mt-field placeholder="请填写答案一"
  12. :state="state.answer1"
  13. @blur.native.capture="validAnswer1"
  14. v-model="valid.answer1"></mt-field>
  15. </div>
  16. <div class="page-part">
  17. <p class="security">密保问题二:<span v-text="questions[1].question"></span></p>
  18. </div>
  19. <div class="page-part">
  20. <mt-field placeholder="请填写答案二"
  21. :state="state.answer2"
  22. @blur.native.capture="validAnswer2"
  23. v-model="valid.answer2"></mt-field>
  24. </div>
  25. <div class="page-part">
  26. <mt-button size="large" type="primary" @click="sureAccount('new')">下一步</mt-button>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. export default {
  33. name: 'step-security',
  34. props: ['tokenId'],
  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. // 警告弹窗
  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('/sso/resetPwd/check/question', {params: {token: this.$route.query.token ? this.$route.query.token : this.tokenId}})
  86. .then(response => {
  87. if (response.data.success) {
  88. this.questions = response.data.content.questions
  89. this.token = response.data.content.token
  90. if (this.questions.length === 0) {
  91. this.$emit('stepEvent', 'new')
  92. }
  93. } else {
  94. this.downToast(response.data.errMsg)
  95. }
  96. })
  97. },
  98. sureAccount (type) {
  99. if (this.state.answer1 !== 'success' || this.state.answer2 !== 'success') {
  100. this.downToast('请确认填写部分是否有误')
  101. } else {
  102. this.$indicator.open('验证过程中...')
  103. let param = new FormData()
  104. let answer = []
  105. answer.push({'answer': this.valid.answer1, id: this.questions[0].id}, {
  106. 'answer': this.valid.answer2,
  107. id: this.questions[1].id
  108. })
  109. let answers = JSON.stringify(answer)
  110. param.append('answers', answers)
  111. param.append('token', this.token)
  112. param.append('pageToken', this.tokenId)
  113. let config = {
  114. headers: {'Content-Type': 'multipart/form-data'}
  115. }
  116. this.$http.post(`/sso/resetPwd/check/question`, param, config)
  117. .then(response => {
  118. this.$indicator.close()
  119. if (response.data.success) {
  120. this.$emit('stepEvent', type)
  121. this.$emit('tokenEvent', response.data.content.token)
  122. } else {
  123. this.downToast(response.data.errMsg)
  124. }
  125. }).catch((err) => {
  126. this.$indicator.close()
  127. this.downToast(err.errMsg)
  128. })
  129. }
  130. }
  131. }
  132. }
  133. </script>
  134. <style scoped type="text/scss" lang="scss">
  135. </style>