切换URL

版权声明:v1.0.0 https://blog.csdn.net/weixin_40374953/article/details/84308753
toggleSigninStatus: function(e) {
    var el = $(e.target),
        searchResult = '',
        searchInfo = location.search.replace(/type=biz/gi, '');
    if (el.hasClass('person')) { // 个人版
        if (searchInfo.indexOf('?') != -1) {
            //最后一个是&
            if (searchInfo.split('').reverse().join('').indexOf('&') == 0) {
                searchResult += searchInfo + 'type=biz';
            } else {
                searchResult += searchInfo + '&type=biz';
            }
        } else {
            searchResult = '?type=biz';
        }
    } else { // 企业版
        searchResult = searchInfo;

    }
    location.href = location.protocol + '//' + location.host + location.pathname + searchResult;
},

猜你喜欢

转载自blog.csdn.net/weixin_40374953/article/details/84308753