schangxiang@126.com
2025-04-01 de7dbe7cf85aa01abb64040aae1c04dfba74c135
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
<script>
    import Vue from 'vue'
    export default {
        onLaunch: function() {
            if (!uni.getStorageSync('switchs')) {
                uni.setStorageSync('switchs', JSON.stringify(true))
            }
            //获取头部高度
            uni.getSystemInfo({
                success: function(e) {
                    // console.log('手机牌子'+e.brand) //手机牌子
                    // console.log('手机型号'+e.model) //手机型号
                    Vue.prototype.PhoneModel = e.model
                    // #ifndef MP
                    Vue.prototype.StatusBar = e.statusBarHeight;
                    Vue.prototype.CustomBar = e.statusBarHeight + 45;
                    console.log(e.platform)
                    // if (e.platform == 'android') {
                    //     Vue.prototype.CustomBar = e.statusBarHeight + 50;
                    // } else {
                    //     Vue.prototype.CustomBar = e.statusBarHeight + 45;
                    // };
                    // #endif
 
                    // #ifdef MP-WEIXIN || MP-QQ
                    Vue.prototype.StatusBar = e.statusBarHeight;
                    let capsule = wx.getMenuButtonBoundingClientRect();
                    if (capsule) {
                        Vue.prototype.Custom = capsule;
                        // Vue.prototype.capsuleSafe = uni.upx2px(750) - capsule.left + uni.upx2px(750) - capsule.right;
                        Vue.prototype.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
                    } else {
                        Vue.prototype.CustomBar = e.statusBarHeight + 50;
                    }
                    // #endif        
 
 
                    // #ifdef MP-ALIPAY
                    Vue.prototype.StatusBar = e.statusBarHeight;
                    Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
                    // #endif
 
                }
            })
 
 
 
        },
        onShow: function() {
            console.log('App Show')
        },
        onError:function(error,msg){
            console.log(error.toString())
            if(error.toString().indexOf('SyntaxError') != -1 ){ //子页面token失效报错
                if(!uni.getStorageSync('userInfo')){
                    uni.showToast({
                            title: 'token失效,请重新登陆',
                            icon: 'none',
                            duration: 2000
                    });
                    // 跳转到登录
                    uni.redirectTo({
                        url: '/pages/login/login'
                    })
                }
                
            }
        },
        methods: {
            
        }
    }
</script>
 
<style lang="scss">
    /* 要写在第一行,同时给style标签加入lang="scss"属性 */
    @import "uview-ui/index.scss";
    /*每个页面公共css */
    @import "styles/iconfont/iconfont.css";
    @import "styles/main.css";
    @import "styles/index.css";
 
    page {
        width: 100%;
        min-height: 100vh;
        background-color: #F2F2F2;
        box-sizing: border-box;
    }
</style>