[测评系统]--前端(用户答题页面)
linzhijie
2023-04-28 57f1b45ee6d64bc6bf6fc65b30a06434e032a4aa
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
<template>
  <el-dropdown trigger="click" class="international" @command="handleSetLanguage">
    <div style="color:white">
      <svg-icon class-name="international-icon" icon-class="language" style="color:white"/>
       LANGUAGE
    </div>
    <el-dropdown-menu slot="dropdown">
      <template v-for="item in langType">
        <el-dropdown-item :command="item.dictValue">
          {{item.dictLabel}}
        </el-dropdown-item>
      </template>
    </el-dropdown-menu>
  </el-dropdown>
</template>
 
<script>
import demographyApi from '@/api/demography'
import { mapState, mapMutations } from 'vuex'
 
export default {
  data () {
    return {
      langType: []
    }
  },
  created () {
    let _this = this
    demographyApi.queryLangList(_this.memberToken).then(function (result) {
      if (result && result.code === 1) {
        _this.langType = result.response
      }
    }
    ).catch(e => {
      _this.$message.error(_this.$t('noquestionMsg'))
    })
  },
  computed: {
    ...mapState('user', { memberToken: state => state.memberToken }),
    ...mapState('user', { langType: state => state.langType })
  },
  methods: {
    handleSetLanguage (lang) {
      let _this = this
      _this.setLangType(lang)
      if (lang === 'Chinese') {
        _this.$i18n.locale = 'zh'
      } else {
        _this.$i18n.locale = 'en'
      }
    },
    ...mapMutations('user', ['setLangType'])
  }
}
</script>