<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>
|