liyaozhi
2025-10-28 1320688354fd168c51cf2e05f29a2253f4ed9c00
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
import config from '../config.js'
/*导航菜单白名单*/
const tabBarLinks = [
    '/pages/index/index',
    '/pages/product/category',
    '/pages/shop/middle',
    '/pages/cart/cart',
    '/pages/tabBar/user/index'
];
 
/*分享页面,扫码白名单*/
const shareLinks = [
    '/pages/plus/assemble/fight-group-detail/fight-group-detail',
    '/pages/plus/bargain/haggle/haggle',
    '/pages/user/invite/invite',
    '/pages/product/detail/detail'
]
 
/*
 * 跳转页面
 */
export const gotopage = (url, type) => {
    if (!url || url.length == 0) {
        return false;
    }
 
    if (url.substr(0, 1) !== '/') {
        url = '/' + url;
    }
    let p = url;
    if (url.indexOf('?') != -1) {
        p = url.substr(0, url.indexOf('?'));
        // #ifdef  H5
        if (url.search("app_id") == -1) {
            url = url + '&app_id=' + config.app_id;
        }
        // #endif
    } else {
        // #ifdef  H5
        if (url.search("app_id") == -1) {
            url = url + '?app_id=' + config.app_id;
        }
        // #endif
    }
 
    let diyTabBarLinks = uni.getStorageSync('TabBar').list;
    let res = diyTabBarLinks.some(item => {
        if (item.link_url == p) {
            return true
        }
    })
    if (res) {
        uni.reLaunch({
            url: url
        });
        return
    }
    // tabBar页面
    if (tabBarLinks.indexOf(p) > -1) {
        uni.reLaunch({
            url: url
        })
    } else {
        if (process.env.NODE_ENV === 'production') {
            //判断是否分享页面
            if (shareLinks.indexOf(p) > -1) {
                //公众号
                // #ifdef  H5
                window.location.href = config.app_url + config.h5_addr + url;
                return;
                // #endif
            }
        }
        if (type == 'redirect') {
            uni.redirectTo({
                url: url
            });
            return
        }
        if (type == 'reLaunch') {
            uni.reLaunch({
                url: url
            });
            return
        }
        // 普通页面
        uni.navigateTo({
            url: url
        });
    }
}