微信扫码登录与微信授权登录

//生成二维码
function wxLoadPage() {
    WXloginDiv();

    var url = window.location.pathname + window.location.search;

    //编码替换加号

    if (url.indexOf("+") > 0)
    {
        url = url.replace("+", "%2B");
    }
    var objd = new WxLogin({
        id: "wxlogin",
        appid: "wxf3de3ade76b72a44",
        scope: "snsapi_login",
        redirect_uri: "http%3a%2f%2fwww.ansying.com" + url,
        state: "STATE",
        style: "black",
        href: "https://www.ansying.com/css/weixin/weixin.css"
    });

}

//扫码登入后跳转
function WX_Login() {
    is_weixn();
    SetHref();
    if (is_weixn() == true) {
        $("#wx").css("display", "block");
    }
    else {
        $("#wxpc").css("display", "block");
    }
    var code = GetRequest()['code'];
    var href = window.location.href;
    if (code != "undefined" && code != null) {
        $.ajax({
            type: "Post",
            url: "/AnsYingWeiXin/WeChatDev/wxt",
            data: { "code": code, "href": href },
            success: function (result) {
                if (result == "1") {
                    var h = window.location.href;
                    var href = h.split("?")[0] + "?" + h.split("?")[1].split("&code")[0];
                    if (h.split("?")[0] != "http://www.ansying.com/AnsYingWeb/Login/Index") {
                        //code在前未去除情况,如:http://www.ansying.com/Serach/LawSearch?code=051zxkli2pSqVE0mcgki2Y3lli2zxklo&state=STATE
                        if (href.indexOf('code') > 0)
                        {
                            href = href.split('?')[0];
                        }
                        //诚信详情页情况
                        if (href.split('=')[0] == "http://www.ansying.com/AnsYingCredit/AYZXin/ZXEDetails?CompanyID")
                        {
                            href = href + "&Distinguish=0";
                        }
                        //中介服务机构情况
                        if (href.split('=')[0] == "http://www.ansying.com/AnsYingCredit/IntermediaryService/ISEDetails?IntermediaryID")
                        {
                            href = href + "&Distinguish=0";
                        }
                        window.location.href = href;
                    }
                    else {
                        window.location.href = "http://www.ansying.com/AnsYingWeb/Home/Main";
                    }
                }
                else if (result == "NoRegister") {
                    //window.open("/AnsYingWeb/Login/Register?Register=0");
                    window.location.href = "/AnsYingWeb/Login/Register?Register=0";
                }
            },
            error: function () {
            }
        });
    }
}

页面加载方法加入WX_Login()方法

后台

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值