stepSecurity .vue 4.1 KB

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