LangeSelect.vue
3.3 KB
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
<template>
<el-dropdown trigger="click" class="international" @command="handleSetLanguage">
<div>
<span class="el-dropdown-link">
{{language}}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="zh_CN">简体</el-dropdown-item>
<el-dropdown-item command="zh_TW">繁體</el-dropdown-item>
<el-dropdown-item command="en_US">English</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
export default {
inject: ["reload"],
data() {
return {
language: ""
};
},
mounted() {
let _lang = "";
if (this.$Project === "store") {
_lang = localStorage.getItem("lang");
this.getLanguage(_lang);
this.$i18n.locale = _lang;
// this.langAddClass()
} else {
_lang = localStorage.getItem("lang");
this.getLanguage(_lang);
this.$i18n.locale = _lang;
}
},
methods: {
handleSetLanguage(lang) {
this.$i18n.locale = lang;
localStorage.setItem("lang", lang);
this.reload();
this.getLanguage(lang);
// this.langAddClass()
},
getLanguage(val) {
document.title = this.$t('login.platformName')
if (val === "zh_CN" || val === "mall_CN") {
this.language = "简体";
// val == "mall_CN"
// ? (document.querySelector("title").innerText = "智慧商业客流分析平台")
// : (document.querySelector("title").innerText =
// "智慧连锁客流分析平台");
}
if (val === "en_US") {
this.language = "English";
// document.querySelector("title").innerText =
// "Wisdom Chain Traffic Analysis Platform";
}
if (val === "zh_TW") {
this.language = "繁體";
// document.querySelector("title").innerText = "智慧連鎖客流分析平台";
}
},
langAddClass() {
var elementDict = {
"el-dialog": "enDialog",
"el-form-item__label": "enLabel",
"el-form-item__content": "enContent",
"chart-title-icon": "en-icon"
};
if (this.language == "English") {
setTimeout(() => {
$(".el-dialog").addClass("en-dialog");
$(".el-form-item__label").addClass("en-label");
$(".el-form-item__content").addClass("en-content");
$(".chart-title-icon").addClass("en-icon");
$(".home .menu-item-box").addClass("home-title");
}, 0);
} else if (this.language == "简体") {
setTimeout(() => {
$(".el-dialog").removeClass("en-dialog");
$(".el-form-item__label").removeClass("en-label");
$(".el-form-item__content ").removeClass("en-content ");
$(".home .menu-item-box").removeClass("home-title");
}, 0);
}
}
}
};
</script>
<style>
.international .el-dropdown-link {
cursor: pointer;
color: #fff;
font-size: 14px;
margin-left: 40px;
}
.el-icon-arrow-down {
font-size: 14px;
}
.en-class {
padding-left: 0.6rem !important;
}
.en-icon {
left: 250px;
}
</style>
<style scoped>
.international-icon {
font-size: 20px;
cursor: pointer;
vertical-align: -5px !important;
}
@media only screen and (max-width: 1280px) {
.international .el-dropdown-link {
font-size: 13px;
margin-left: 10px;
}
}
</style>