import languageHelper from "@/utils/languageHelper";
|
import corpHelper from "@/utils/spumpCorp.js";
|
|
var targetpageMixin = {
|
data() {
|
return{
|
m_currentLanguage: 0,
|
m_corpInfo : { ID: 0, CorpFlag: "XXX", ShortName: "XX" }
|
}
|
},
|
beforeMount() {
|
//初始化语言
|
this.initialLanguage();
|
},
|
methods: {
|
//初始化语言
|
initialLanguage() {
|
var currentLanguage = this.getLanguageTypeFromRout();
|
this.m_currentLanguage = currentLanguage;
|
if (currentLanguage == 0) {
|
this.$i18n.locale = "cn";
|
}
|
else if (currentLanguage == 2) {
|
this.$i18n.locale = "en";
|
}
|
else if (currentLanguage == 6) {
|
this.$i18n.locale = "es";
|
}
|
else if (currentLanguage == 8) {
|
this.$i18n.locale = "ko";
|
}
|
else {
|
this.$i18n.locale = "cn";
|
}
|
},
|
//初始化公司信息
|
initialCorpInfo() {
|
var corpname = this.$route.params.corpname;
|
if (corpname == "" || corpname == undefined) {
|
this.m_isShowLoadingFrm = false;
|
this.$router.push({
|
path: "/404",
|
replace: true,
|
});
|
return false;
|
}
|
|
var corp = corpHelper.getCorpByRounte(corpname);
|
if (corp == null) {
|
this.m_isShowLoadingFrm = false;
|
this.$router.push({
|
path: "/404",
|
replace: true,
|
});
|
return false;
|
}
|
this.m_corpInfo = corp;
|
|
return true;
|
},
|
//从路由中获取语言类型
|
getLanguageTypeFromRout() {
|
return languageHelper.getTypeFromRout(window.location.href);
|
},
|
gotoPage(url, query, replace) {
|
if (replace == null)
|
replace = true;
|
var url_lang = this.buildCurrentLanguageUrl(url);
|
this.$router.push({
|
path: url_lang,
|
query: query,
|
replace: replace
|
});
|
},
|
buildCurrentLanguageUrl(url) {
|
if (url.startsWith("/")) {
|
return `/${this.getCurrentLanguageUrl()}/Target/` + this.m_corpInfo.CorpFlag + url;
|
}
|
else {
|
return `/${this.getCurrentLanguageUrl()}/Target/` + this.m_corpInfo.CorpFlag + "/" + url;
|
}
|
},
|
gotoIndexPage() {
|
this.$router.push({
|
path: `/${this.getCurrentLanguageUrl()}/Target/`+this.m_corpInfo.CorpFlag +`Index`,
|
});
|
},
|
//获取语言名称(大写)
|
getLanguageParaName() {
|
return languageHelper.getParaNameByType(this.m_currentLanguage);
|
},
|
//获取语言类型
|
getCurrentLanguageType() {
|
return this.m_currentLanguage;
|
},
|
//获取语言路由字符
|
getCurrentLanguageUrl() {
|
return languageHelper.getRouterUrlByType(this.m_currentLanguage);
|
}
|
}
|
}
|
|
export default targetpageMixin
|