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
/**
 * 作者:c.y
 * 文件说明:  微信分享的额外添加参数的判断
 * created by c.k on 2018/2/27
 *
 */
 
export default {
    // 判断地址栏出现微信自己加的参数问题
    getUrlQuestionMark () {
        let url = window.location.href;
        let matchResult = url.match(/\?/g);
        // 如果地址栏中,出现了两个问号的话,那么是微信在分享添加了参数
        // 如果地址栏中,出现了form=,那么就是微信分享添加的参数
        // 需要注意,不要在我们的路由地址上添加,from=这个参数,这个是为了区分微信
        return (matchResult ? matchResult.length >= 2 : false) || (/from=/.test(url));
    },
    // 把地址栏的中微信追加的参数去掉,返回我们自己项目的地址
    getRightProjectUrl () {
        let location = window.location;
        return location.origin + location.pathname + location.hash;
    }
};