tanghaolin
2022-07-28 62aa8e0f0b366bc131309b72e1350d800d30be72
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
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