ann0707
2018-08-16 c9bc8ec61cff4076132f6396d99d383a2cdf5a03
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
<template>
    <div class="blank-page">
 
    </div>
</template>
 
<script>
    /**
     * Created by c.y on 2018/4/3.
     * 空白页
     */
    import systemApi from '../../api/api';
    import store from '../../store/index';
    import statusCodeManage from '../../api/statusCodeManage';
 
    export default {
        name: 'f-blank-page',
        data(){
            return {
 
            }
        },
        methods:{
            init:function () {
                let _this = this;
 
                let _newClientInfo =null;
                _newClientInfo = window.localStorage.getItem('newClientInfo');
                _newClientInfo = JSON.parse(_newClientInfo);
                // 这里区分是 H5 还是 原生环境
                if(_newClientInfo.cn == ''){  // 这里是原生环境
                    let _intId = setInterval(function () {
                        _newClientInfo = window.localStorage.getItem('newClientInfo');
                        _newClientInfo = JSON.parse(_newClientInfo);
                        // console.log(_newClientInfo)
                        if(_newClientInfo.appVersion && _newClientInfo.appVersion.length){
                            _this.getRouterConfig();
                            clearInterval(_intId);
                        }
                    },40)
                }else{  // H5 环境
                    _this.$router.push({ path: '/f-main',query:{cn:_newClientInfo.cn} });
                }
 
            },
            getRouterConfig:function () {
                let _this = this;
                systemApi.getRouterControlConfig().then(
                    res => {
                        if(res){
                            store.commit('UPDATE_LOADING', {isLoading: false});
                            let router = true;
                            let routerConfig = res.isPublish;
                            //根据配置文件去控制使用 审核业务路由 还是 正常路由
                            let _clientInfo = window.localStorage.getItem ('newClientInfo');
                            _clientInfo = JSON.parse (_clientInfo);
                            let _chanNo = routerConfig[_clientInfo.chanNo];
                            for (let _obj in _chanNo) {
                                if (_chanNo[_obj][_clientInfo.childChan] != undefined) {
                                    const _len = _chanNo[_obj][_clientInfo.childChan].length;
                                    const _appVerisonArr = _chanNo[_obj][_clientInfo.childChan];
                                    for (let i = 0; i < _len; i++) {
                                        if (_appVerisonArr[i] == _clientInfo.appVersion) {
                                            // 进入审核业务路由
                                            router = false;
                                            // window.localStorage.setItem('initRouter','auditRouter');
                                            // _this.$router.addRoutes(auditRouter);
                                            // _this.$router.push({ path: '/f-main' });
                                            _this.$router.push({ path: '/iosnewsHome' });
                                            return false;
                                        }
                                    }
                                }
                            }
                            if(router){
                                // 跳转到 旧C 端
                                // _this.$router.addRoutes(auditRouter);
                                // 进入到这个判断一定是原生环境
                                _this.$router.push({ path: '/f-main'});
                            }
                        }
                    },
                    error => {
                        statusCodeManage.showTipOfStatusCode(error,_this);
                    }
                );
            }
        },
        activated(){
            store.commit('UPDATE_LOADING', {isLoading: true});
            this.init()
        }
    };
</script>
 
 
<style lang="less">
</style>