[测评系统]--前端(用户答题页面)
阳洁
2024-02-01 c69c4f72ce65388f0d8387c5ab67841377f53b7a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template>
  <div>
  </div>
</template>
 
<script>
import demographyApi from '@/api/demography'
import { mapMutations, mapState } from 'vuex'
import examPaperApi from '@/api/examPaper'
export default {
  // components: { QuestionEdit },
  data () {
    return {
      demographyMenber: { data: [] },
      paraMemberToken: this.$route.params.memberToken,
      productId: 0,
      paramsInfo: {},
      parasInfos: [],
      parasInfoIds: {},
      formDo: {},
      reportTemplateType: null,
      statusInfo: { '2': this.$t('statusInfo2'), '3': this.$t('statusInfo3'), '4': this.$t('statusInfo4') }
    }
  },
  created () {
    let _this = this
    _this.getLangType()
    // 记录登陆日志
    examPaperApi.recordLogininfor(_this.paraMemberToken).then(re => {
    }).catch(e => {
    })
    // 已经答完了不能答题
    examPaperApi.selectTokenId(_this.paraMemberToken).then(re => {
      if (re.response.finish === 1) {
        _this.$router.push({ path: '/exam/finish', query: { name: '', content: _this.$t('finishMsg'), tokenId: _this.paraMemberToken } })
      } else if (re.response.status !== '1') {
        _this.$router.push({ path: '/exam/exception', query: { name: '', content: _this.statusInfo[re.response.status] } })
      } else {
        // _this.doUrl = re.response.doUrl
        _this.reportTemplateType = re.response.productType
        _this.setMemberTocken(_this.paraMemberToken)
        _this.setDoUrl(re.response.doUrl)
        _this.setReportTemplateId(re.response.reportTemplateId)
        _this.queryCreate()
      }
    }).catch(e => {
    })
  },
  methods: {
    queryCreate: function () {
      // 先查询人口学是否已经填完
      let _this = this
      demographyApi.queryDemographyParamInfo(_this.paraMemberToken).then(
        reParam => {
          if (reParam.code !== 1) {
            // 职业兴趣报告特殊化处理 只有中文
            if(_this.doUrl === 'career_interests') {
              _this.$i18n.locale = 'zh'
              _this.setLangType('Chinese')
              _this.$router.push({ path: '/demography/fill/index', query: { demographyMenber: _this.memberToken, isStart: false } })
              return
            }
 
            // APIFan做特殊处理 只有中文
            if (_this.reportTemplateType === 'APIFan') {
              _this.$i18n.locale = 'zh'
              _this.setLangType('Chinese')
              _this.$router.push({ path: '/demography/fill/index', query: { demographyMenber: _this.memberToken, isStart: false } })
              return
            }
 
            // 先选择密码
            _this.$router.push({ path: '/demography/fill/langOption', query: { langSelectValue: _this.langType } })
            _this.setMemberTocken(_this.paraMemberToken)
            return
          }
          if (reParam.response[0].langType === 'Chinese') {
            this.$i18n.locale = 'zh'
            _this.setLangType('Chinese')
          } else {
            _this.setLangType('English')
            this.$i18n.locale = 'en'
          }
          _this.setMemberId(reParam.response[0].memberId)
          // 判断如果是在第一题,那么就展示指导语
          examPaperApi.selectTokenId(_this.memberToken).then(re => {
            let answered = re.response.examItemOrderAndContentList
            if (answered === null) {
              examPaperApi.select(_this.memberToken, _this.langType).then(re => {
                _this.formDo = re.response
                _this.setDoUrl(re.response.questionTemplateId)
                _this.$router.push({ path: '/guide/index', query: { formDo: _this.formDo } })
              }).catch(e => {
                _this.$message.error(_this.$t('noquestionMsg'))
              })
            } else {
              _this.$router.push({ path: '/exam/' + _this.doUrl })
            }
          }).catch(e => {
          })
        }
      ).catch(e => {
      })
    },
    ...mapMutations('user', ['setMemberTocken']),
    ...mapMutations('user', ['setMemberId']),
    ...mapMutations('exam', ['setDoUrl']),
    ...mapMutations('exam', ['setReportTemplateId']),
    ...mapMutations('user', ['setLangType']),
    ...mapMutations('user', ['getLangType'])
  },
  computed: {
    ...mapState('user', { memberToken: state => state.memberToken }),
    ...mapState('user', { memberId: state => state.memberId }),
    ...mapState('exam', { doUrl: state => state.doUrl }),
    ...mapState('exam', { reportTemplateId: state => state.reportTemplateId }),
    ...mapState('user', { langType: state => state.langType })
  }
}
</script>
 
<style lang="scss" scoped>
  .demography {
    width: 90%;
    margin: 0 auto;
    margin-top: 5%;
  }
 
  .align-center {
    text-align: center
  }
</style>