protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            string     text  = this.Page.Request.QueryString["action"].ToNullString();
            MemberInfo user  = HiContext.Current.User;
            string     text2 = Globals.UrlDecode(HttpContext.Current.Request.QueryString["ReturnUrl"]);

            if (string.IsNullOrEmpty(text2))
            {
                text2 = HttpContext.Current.Request.Url.ToString();
            }
            DateTime now;

            if (user != null && user.UserId > 0)
            {
                HttpCookie httpCookie = HiContext.Current.Context.Request.Cookies["Shop-Member"];
                if (httpCookie != null)
                {
                    HttpCookie httpCookie2 = httpCookie;
                    now = DateTime.Now;
                    httpCookie2.Expires = now.AddDays(30.0);
                    HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
                if (!user.CellPhoneVerification)
                {
                    string text3 = HttpContext.Current.Request.Url.ToString().ToLower();
                    if (text3.IndexOf("/bindphone") == -1)
                    {
                        if (MemberProcessor.IsTrustLoginUser(user) && HiContext.Current.SiteSettings.QuickLoginIsForceBindingMobbile)
                        {
                            HttpContext.Current.Response.Redirect("BindPhone");
                        }
                        else if (HiContext.Current.SiteSettings.UserLoginIsForceBindingMobbile)
                        {
                            HttpContext.Current.Response.Redirect("BindPhone");
                        }
                    }
                }
            }
            if (user.UserId == 0 || (user.UserId != 0 && !user.IsLogined))
            {
                string query = HttpContext.Current.Request.Url.Query;
                query = ((string.IsNullOrEmpty(query) || !query.StartsWith("?")) ? "" : ("&" + query.Substring(1)));
                if (base.ClientType == ClientType.VShop)
                {
                    OAuthUserInfo oAuthUserInfo = base.GetOAuthUserInfo(true);
                    if (!this.HasLogin(oAuthUserInfo.OpenId, oAuthUserInfo.unionId, oAuthUserInfo.IsAttention))
                    {
                        if (!string.IsNullOrEmpty(oAuthUserInfo.OpenId))
                        {
                            HttpCookie httpCookie3 = new HttpCookie("openId");
                            httpCookie3.HttpOnly = true;
                            httpCookie3.Value    = oAuthUserInfo.OpenId;
                            httpCookie3.Expires  = DateTime.MaxValue;
                            HttpContext.Current.Response.Cookies.Add(httpCookie3);
                        }
                        string text4 = Globals.UrlEncode(oAuthUserInfo.HeadImageUrl.ToNullString());
                        bool   isAttention;
                        if (!string.IsNullOrEmpty(oAuthUserInfo.NickName))
                        {
                            if (string.IsNullOrEmpty(text))
                            {
                                HttpResponse response = this.Page.Response;
                                string[]     obj      = new string[12]
                                {
                                    "/Vshop/Login?openId=",
                                    oAuthUserInfo.OpenId,
                                    "&headimage=",
                                    text4,
                                    "&nickname=",
                                    oAuthUserInfo.NickName,
                                    "&IsSubscribe=",
                                    null,
                                    null,
                                    null,
                                    null,
                                    null
                                };
                                isAttention = oAuthUserInfo.IsAttention;
                                obj[7]      = isAttention.ToString();
                                obj[8]      = "&unionId=";
                                obj[9]      = oAuthUserInfo.unionId;
                                obj[10]     = query;
                                obj[11]     = ((query.IndexOf("returnUrl") > -1) ? "" : ("&returnUrl=" + Globals.UrlEncode(text2)));
                                response.Redirect(string.Concat(obj));
                            }
                            else
                            {
                                HttpResponse response2 = this.Page.Response;
                                string[]     obj2      = new string[14]
                                {
                                    "/Vshop/Login.aspx?action=",
                                    text,
                                    "&openId=",
                                    oAuthUserInfo.OpenId,
                                    "&headimage=",
                                    text4,
                                    "&nickname=",
                                    oAuthUserInfo.NickName,
                                    "&IsSubscribe=",
                                    null,
                                    null,
                                    null,
                                    null,
                                    null
                                };
                                isAttention = oAuthUserInfo.IsAttention;
                                obj2[9]     = isAttention.ToString();
                                obj2[10]    = "&unionId=";
                                obj2[11]    = oAuthUserInfo.unionId;
                                obj2[12]    = query;
                                obj2[13]    = ((query.IndexOf("returnUrl") > -1) ? "" : ("&returnUrl=" + Globals.UrlEncode(text2)));
                                response2.Redirect(string.Concat(obj2));
                            }
                        }
                        else if (string.IsNullOrEmpty(text))
                        {
                            HttpResponse response3 = this.Page.Response;
                            string[]     obj3      = new string[10]
                            {
                                "/Vshop/Login?openId=",
                                oAuthUserInfo.OpenId,
                                "&IsSubscribe=",
                                null,
                                null,
                                null,
                                null,
                                null,
                                null,
                                null
                            };
                            isAttention = oAuthUserInfo.IsAttention;
                            obj3[3]     = isAttention.ToString();
                            obj3[4]     = "&headimage=";
                            obj3[5]     = text4;
                            obj3[6]     = "&unionId=";
                            obj3[7]     = oAuthUserInfo.unionId;
                            obj3[8]     = query;
                            obj3[9]     = ((query.IndexOf("returnUrl") > -1) ? "" : ("&returnUrl=" + Globals.UrlEncode(text2)));
                            response3.Redirect(string.Concat(obj3));
                        }
                        else
                        {
                            HttpResponse response4 = this.Page.Response;
                            string[]     obj4      = new string[12]
                            {
                                "/Vshop/Login?action=",
                                text,
                                "&openId=",
                                oAuthUserInfo.OpenId,
                                "&headimage=",
                                text4,
                                "&IsSubscribe=",
                                null,
                                null,
                                null,
                                null,
                                null
                            };
                            isAttention = oAuthUserInfo.IsAttention;
                            obj4[7]     = isAttention.ToString();
                            obj4[8]     = "&unionId=";
                            obj4[9]     = oAuthUserInfo.unionId;
                            obj4[10]    = query;
                            obj4[11]    = ((query.IndexOf("returnUrl") > -1) ? "" : ("&returnUrl=" + Globals.UrlEncode(text2)));
                            response4.Redirect(string.Concat(obj4));
                        }
                    }
                }
                else if (string.IsNullOrEmpty(text))
                {
                    this.Page.Response.Redirect("Login?returnUrl=" + HttpUtility.UrlEncode(text2), true);
                }
                else
                {
                    this.Page.Response.Redirect("Login?action=" + text + "&returnUrl=" + HttpUtility.UrlEncode(text2), true);
                }
            }
            else
            {
                HttpCookie httpCookie4 = HiContext.Current.Context.Request.Cookies[WAPMemberTemplatedWebControl.autoSetTags + "_" + user.UserId];
                if (httpCookie4 == null)
                {
                    IList <MemberTagInfo> list = MemberTagHelper.AutoTagsByMember(user.UserId, user.OrderNumber, user.Expenditure);
                    if (list.Count > 0)
                    {
                        string text5 = user.TagIds;
                        foreach (MemberTagInfo item in list)
                        {
                            if (string.IsNullOrEmpty(text5))
                            {
                                text5 = text5 + "," + item.TagId + ",";
                            }
                            if (!("," + text5 + ",").Contains("," + item.TagId + ","))
                            {
                                text5 = ((text5.LastIndexOf(",") != text5.Length - 1) ? (text5 + "," + item.TagId + ",") : (text5 + item.TagId + ","));
                            }
                        }
                        if (MemberTagHelper.UpdateSingleMemberTags(user.UserId, text5) > 0)
                        {
                            httpCookie4          = new HttpCookie(WAPMemberTemplatedWebControl.autoSetTags + "_" + user.UserId);
                            httpCookie4.HttpOnly = true;
                            HttpCookie httpCookie5 = httpCookie4;
                            now = DateTime.Now;
                            httpCookie5.Expires = now.AddDays(1.0);
                            httpCookie4.Value   = Globals.UrlEncode(user.UserId.ToString());
                            HttpContext.Current.Response.Cookies.Add(httpCookie4);
                        }
                    }
                }
                HttpCookie httpCookie6 = HiContext.Current.Context.Request.Cookies["openId"];
                if (httpCookie6 != null && !string.IsNullOrEmpty(httpCookie6.Value))
                {
                    lock (this.lockCopyRedEnvelope)
                    {
                        this.CopyRedEnvelope(httpCookie6.Value, user);
                    }
                }
            }
        }
        public OAuthUserInfo GetOAuthUserInfo(bool needNickName = true)
        {
            OAuthUserInfo oAuthUserInfo = new OAuthUserInfo();
            string        text          = this.Page.Request.QueryString["action"].ToNullString();

            if (!string.IsNullOrEmpty(this.site.WeixinAppId) && !string.IsNullOrEmpty(this.site.WeixinAppSecret))
            {
                string text2 = this.Page.Request.QueryString["code"];
                if (!string.IsNullOrEmpty(text2))
                {
                    string responseResult = this.GetResponseResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + this.site.WeixinAppId + "&secret=" + this.site.WeixinAppSecret + "&code=" + text2 + "&grant_type=authorization_code");
                    if (responseResult.Contains("access_token"))
                    {
                        JObject jObject         = JsonConvert.DeserializeObject(responseResult) as JObject;
                        string  arg             = jObject["openid"].ToString();
                        string  text3           = jObject["access_token"].ToNullString();
                        string  responseResult2 = this.GetResponseResult($"https://api.weixin.qq.com/cgi-bin/user/info?access_token={text3}&openid={arg}&lang=zh_CN");
                        if (responseResult2.Contains("errcode"))
                        {
                            Globals.AppendLog("获取用户信息时报错,结果:" + responseResult2, text3, responseResult, "GetOAuthUserInfoErr");
                            if (responseResult2.Contains("access_token is invalid or not latest"))
                            {
                                text3           = AccessTokenContainer.TryGetToken(this.site.WeixinAppId, this.site.WeixinAppSecret, true);
                                responseResult2 = this.GetResponseResult($"https://api.weixin.qq.com/cgi-bin/user/info?access_token={text3}&openid={arg}&lang=zh_CN");
                            }
                        }
                        if (responseResult2.IndexOf("subscribe") != -1)
                        {
                            JObject jObject2 = JsonConvert.DeserializeObject(responseResult2) as JObject;
                            oAuthUserInfo.OpenId = jObject2["openid"].ToString();
                            if (jObject2["nickname"] != null)
                            {
                                oAuthUserInfo.NickName = jObject2["nickname"].ToString();
                            }
                            else
                            {
                                oAuthUserInfo.NickName = "";
                            }
                            if (jObject2["headimgurl"] != null)
                            {
                                oAuthUserInfo.HeadImageUrl = jObject2["headimgurl"].ToString();
                            }
                            else
                            {
                                oAuthUserInfo.HeadImageUrl = "";
                            }
                            if (jObject2["unionid"] != null)
                            {
                                oAuthUserInfo.unionId = jObject2["unionid"].ToString();
                            }
                            oAuthUserInfo.IsAttention = Convert.ToBoolean(jObject2["subscribe"]);
                            if (needNickName && string.IsNullOrEmpty(oAuthUserInfo.NickName))
                            {
                                MemberInfo memberByOpenId = MemberProcessor.GetMemberByOpenId("hishop.plugins.openid.weixin", oAuthUserInfo.OpenId);
                                string     text4          = "";
                                string     text5          = "";
                                if (memberByOpenId == null)
                                {
                                    text3 = jObject["access_token"].ToNullString();
                                    string responseResult3 = this.GetResponseResult("https://api.weixin.qq.com/sns/userinfo?access_token=" + text3 + "&openid=" + oAuthUserInfo.OpenId + "&lang=zh_CN");
                                    if (!string.IsNullOrEmpty(responseResult3) && responseResult3.Contains("nickname"))
                                    {
                                        JObject jObject3 = JsonConvert.DeserializeObject(responseResult3) as JObject;
                                        string  text6    = Convert.ToString(jObject2["nickname"]);
                                        oAuthUserInfo.NickName     = jObject3["nickname"].ToNullString();
                                        oAuthUserInfo.HeadImageUrl = jObject3["headimgurl"].ToNullString();
                                    }
                                    else if (this.Page.Request.QueryString["state"].ToNullString() != "REGET")
                                    {
                                        NameValueCollection queryString = HttpContext.Current.Request.QueryString;
                                        string text7 = "";
                                        foreach (string item in queryString)
                                        {
                                            if (!(item.ToLower() == "state") && !(item.ToLower() == "code"))
                                            {
                                                if (item.ToLower() == "returnurl")
                                                {
                                                    text7 = queryString[item];
                                                }
                                                else
                                                {
                                                    text4 = text4 + item + "=" + queryString[item] + "&";
                                                }
                                            }
                                        }
                                        text4 = text4.TrimEnd('&');
                                        if (!string.IsNullOrEmpty(text7))
                                        {
                                            text4 += (string.IsNullOrEmpty(text4) ? "?" : ("&returnUrl=" + text7));
                                        }
                                        text5 = Globals.HostPath(HttpContext.Current.Request.Url) + "/" + HttpContext.Current.Request.Url.AbsolutePath + (string.IsNullOrEmpty(text4) ? "" : ("?" + text4));
                                        Globals.AppendLog("非静默授权", HttpContext.Current.Request.Url.ToString(), text5, "oAuthUserInfoReGet");
                                        string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + this.site.WeixinAppId + "&redirect_uri=" + Globals.UrlEncode(text5) + "&response_type=code&scope=snsapi_userinfo&state=REGET#wechat_redirect";
                                        this.Page.Response.Redirect(url);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        oAuthUserInfo.ErrMsg = "获取access_token失败,返回结果:" + responseResult + ",参数:appid=" + this.site.WeixinAppId + "---secret=" + this.site.WeixinAppSecret + "---code=" + text2;
                        IDictionary <string, string> dictionary = new Dictionary <string, string>();
                        dictionary.Add("Result", responseResult);
                        dictionary.Add("WeixinAppId", this.site.WeixinAppId);
                        dictionary.Add("WeixinAppSecret", this.site.WeixinAppSecret);
                        Globals.AppendLog(dictionary, "", "", "", "OAuthUserInfoError");
                    }
                }
                else if (!string.IsNullOrEmpty(this.Page.Request.QueryString["state"]))
                {
                    if (!string.IsNullOrEmpty(text))
                    {
                        this.Page.Response.Redirect("/Vshop/Login?action=" + text + "&returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()));
                    }
                    else
                    {
                        this.Page.Response.Redirect("/Vshop/Login?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()));
                    }
                }
                else
                {
                    string url2 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + this.site.WeixinAppId + "&redirect_uri=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()) + "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
                    this.Page.Response.Redirect(url2);
                }
            }
            else
            {
                MemberInfo user  = HiContext.Current.User;
                string     text9 = this.Page.Request.Url.ToNullString().ToLower();
                if ((user.UserId == 0 || (user.UserId != 0 && !user.IsLogined)) && !text9.Contains(this.site.WeixinLoginUrl.ToNullString()) && !text9.Contains("login"))
                {
                    oAuthUserInfo.ErrMsg = "未选择是否是验证的服务号,或者appid,secret参数错误";
                    if (!string.IsNullOrEmpty(this.site.WeixinLoginUrl))
                    {
                        this.Page.Response.Redirect(this.site.WeixinLoginUrl);
                    }
                    else if (!string.IsNullOrEmpty(text))
                    {
                        this.Page.Response.Redirect("/Vshop/Login?action=" + text + "&returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()));
                    }
                    else
                    {
                        this.Page.Response.Redirect("/Vshop/Login?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()));
                    }
                }
            }
            return(oAuthUserInfo);
        }