private void VerifyOneOffPass(string openid, string weixinpass) { if (openid != "" && weixinpass != "") { B2bCrmData dateuser = new B2bCrmData(); string data = CrmMemberJsonData.WeixinLogin(openid, weixinpass, comid, out userinfo); if (data == "OK") //正确的一次性密码 { HttpCookie cookie = new HttpCookie("AccountId"); //实例化HttpCookie类并添加值 cookie.Value = userinfo.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); var returnmd5 = EncryptionHelper.ToMD5(userinfo.Idcard.ToString() + userinfo.Id.ToString(), "UTF-8"); cookie = new HttpCookie("AccountKey"); //实例化HttpCookie类并添加值 cookie.Value = returnmd5; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("openid"); //实例化HttpCookie类并添加值 cookie.Value = openid; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); if (userinfo != null) { Readuser(userinfo.Idcard, comid);//读取用户信息 } } } new B2bCrmData().WeixinConPass(openid, comid);//清空微信密码 }
public void DealUserinfo1(string openid, string weixinpass, int comid, int questtype) { if (Request.Cookies["AccountId"] != null) { string accountmd5 = ""; int AccountId = int.Parse(Request.Cookies["AccountId"].Value); if (Request.Cookies["AccountKey"] != null) { accountmd5 = Request.Cookies["AccountKey"].Value; } var data = CrmMemberJsonData.WeixinCookieLogin(AccountId.ToString(), accountmd5, comid, out userinfo); if (data != "OK") { //当cookie错误无法登陆则清除所有COOKIE; HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } if (questtype == 1) { VerifyOneOffPass(openid, weixinpass);//重新验证一下是否是正确的一次性密码 } else if (questtype == 2) { GetOpenId(weixinpass, comid);//微信授权验证 } } else { //从cookie中得到微信号 if (Request.Cookies["openid"] != null) { openid = Request.Cookies["openid"].Value; } B2bCrmData dateuser = new B2bCrmData(); dateuser.WeixinConPass(openid, comid);//清空微信密码 } } else { if (questtype == 1) { VerifyOneOffPass(openid, weixinpass);//重新验证一下是否是正确的一次性密码 } else if (questtype == 2) { GetOpenId(weixinpass, comid);//微信授权验证 } } }
protected void Page_Load(object sender, EventArgs e) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u); materialid = Request["materialid"].ConvertTo <int>(0); if (materialid != 0) { //if (bo == false) //{ // if (materialid == 101) // { // Response.Redirect("http://vctrip.etown.cn/"); // } // Response.Redirect("http://shop" + materialid + ".etown.cn"); //} B2b_company_info info = new B2bCompanyInfoData().GetCompanyInfo(materialid); if (info != null) { phone = info.Tel; address = info.Scenic_address; } B2b_company com = B2bCompanyData.GetCompany(materialid); if (com != null) { name = com.Com_name; } if (Request.Cookies["AccountId"] != null)//判断是否有登陆COOKI { string accountmd5 = ""; int AccountId = int.Parse(Request.Cookies["AccountId"].Value); if (Request.Cookies["AccountKey"] != null) { accountmd5 = Request.Cookies["AccountKey"].Value; } B2b_crm userinfo; var data = CrmMemberJsonData.WeixinCookieLogin(AccountId.ToString(), accountmd5, materialid, out userinfo); if (data == "OK") { if (userinfo != null) { string openid_temp = userinfo.Weixin; GetMenshiDetail(openid_temp, materialid); } } } } }
/// <summary> /// 获取会员信息分两种方式:a.根据客户端保存的cookie值获取 b.根据传递过来的参数获取 /// </summary> /// <param name="weixincode"></param> /// <param name="openid"></param> /// <param name="weixinpass"></param> private void GetCrmInfo(string weixincode, string openid, string weixinpass) { if (Request.Cookies["AccountId"] != null) { string accountmd5 = ""; int AccountId = int.Parse(Request.Cookies["AccountId"].Value); if (Request.Cookies["AccountKey"] != null) { accountmd5 = Request.Cookies["AccountKey"].Value; } var data1 = CrmMemberJsonData.WeixinCookieLogin(AccountId.ToString(), accountmd5, comid, out userinfo); if (data1 == "OK") { //从cookie中得到微信号 if (Request.Cookies["openid"] != null) { openid = Request.Cookies["openid"].Value; } if (userinfo != null) { Readuser(userinfo.Idcard, comid);//读取用户信息 } } else { //当cookie错误无法登陆则清除所有COOKIE; HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } //根据传递过来的参数获取会员信息 GetCrmByParam(weixincode, openid, weixinpass); } } else { //根据传递过来的参数获取会员信息 GetCrmByParam(weixincode, openid, weixinpass); } }
/// <summary> /// 验证微信一次性密码 /// </summary> /// <param name="openid"></param> /// <param name="weixinpass"></param> private bool VerifyOneOffPass(string openid, string weixinpass) { if (openid != null && openid != "" && weixinpass != "" && weixinpass != null) { B2b_crm b2bcrm = new B2b_crm(); B2bCrmData dateuser = new B2bCrmData(); string data = CrmMemberJsonData.WeixinLogin(openid, weixinpass, comid, out b2bcrm); //清空微信一次性密码 new B2bCrmData().WeixinConPass(openid, comid); if (data == "OK") { HttpCookie cookie = new HttpCookie("AccountId"); //实例化HttpCookie类并添加值 cookie.Value = b2bcrm.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); var returnmd5 = EncryptionHelper.ToMD5(b2bcrm.Idcard.ToString() + b2bcrm.Id.ToString(), "UTF-8"); cookie = new HttpCookie("AccountKey"); //实例化HttpCookie类并添加值 cookie.Value = returnmd5; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("openid"); //实例化HttpCookie类并添加值 cookie.Value = openid; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); return(true); } else { return(false); } } else { return(false); } }
private void VerifyOneOffPass(string openid, string weixinpass, int comid) { if (openid != "" && weixinpass != "") { string data = CrmMemberJsonData.WeixinLogin(openid, weixinpass, comid, out crminfo); if (data == "OK")//正确的一次性密码 { Session["AccountId"] = crminfo.Id; Session["AccountKey"] = crminfo.Name; Session["openid"] = crminfo.Idcard; HttpCookie cookie = new HttpCookie("AccountId"); //实例化HttpCookie类并添加值 cookie.Value = crminfo.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); var returnmd5 = EncryptionHelper.ToMD5(crminfo.Idcard.ToString() + crminfo.Id.ToString(), "UTF-8"); cookie = new HttpCookie("AccountKey"); //实例化HttpCookie类并添加值 cookie.Value = returnmd5; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("openid"); //实例化HttpCookie类并添加值 cookie.Value = openid; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); } else //错误的一次性密码 { GetUserByclient(comid);//通过客户端保存数据获得用户信息 } } else { GetUserByclient(comid);//通过客户端保存数据获得用户信息 } new B2bCrmData().WeixinConPass(openid, comid);//清空微信密码 }
private void GetMemberCard(string openid, string weixincode, string weixinpass, int comid) { //如果SESSION有值,进行赋值 if (openid == "" && Session["Openid"] != null) { openid = Session["Openid"].ToString(); } //判断商家是否微信认证 if (weixincode != "")//进行过微信认证,微信认证登陆 { //如果微信ID,递实现自动登陆 GetOpenId(weixincode, comid); } else if (openid != "" && weixinpass != "") { //最后判断传递过来的微信一次性密码 VerifyOneOffPass(openid, weixinpass); } //判断登陆状态 if (Session["AccountId"] != null) { //先判断Session AccountId = int.Parse(Session["AccountId"].ToString()); B2bCrmData dateuser = new B2bCrmData(); B2b_crm userinfo = dateuser.Readuser(AccountId, comid); if (userinfo != null) { Readuser(userinfo.Idcard, comid); } } else {//再判断COOKIES if (Request.Cookies["AccountId"] != null) { string accountmd5 = ""; AccountId = int.Parse(Request.Cookies["AccountId"].Value); if (Request.Cookies["AccountKey"] != null) { accountmd5 = Request.Cookies["AccountKey"].Value; } B2b_crm userinfo; var data = CrmMemberJsonData.WeixinCookieLogin(AccountId.ToString(), accountmd5, comid, out userinfo); if (data == "OK") { Session["AccountId"] = userinfo.Id; Session["AccountName"] = userinfo.Name; Session["AccountCard"] = userinfo.Idcard; Session["Com_id"] = comid; HttpCookie cookie = new HttpCookie("AccountId"); //实例化HttpCookie类并添加值 cookie.Value = userinfo.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); var returnmd5 = EncryptionHelper.ToMD5(userinfo.Idcard.ToString() + userinfo.Id.ToString(), "UTF-8"); cookie = new HttpCookie("AccountKey"); //实例化HttpCookie类并添加值 cookie.Value = returnmd5; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("openid"); //实例化HttpCookie类并添加值 cookie.Value = userinfo.Weixin; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); if (userinfo != null) { Readuser(userinfo.Idcard, comid);//读取用户信息 } Response.Redirect(Request.Url.ToString()); //登陆成功,刷新页面 } else { //当cookie错误无法登陆则清除所有COOKIE HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } if (Request.Cookies["AccountId"] != null) { HttpCookie mycookie; mycookie = Request.Cookies["AccountId"]; TimeSpan ts = new TimeSpan(0, 0, 0, 0); //时间跨度 mycookie.Expires = DateTime.Now.Add(ts); //立即过期 Response.Cookies.Remove("AccountId"); //清除 Response.Cookies.Add(mycookie); //写入立即过期的*/ Response.Cookies["AccountId"].Expires = DateTime.Now.AddDays(-1); } if (Request.Cookies["AccountName"] != null) { HttpCookie mycookie = Request.Cookies["AccountName"]; TimeSpan ts = new TimeSpan(0, 0, 0, 0); //时间跨度 mycookie.Expires = DateTime.Now.Add(ts); //立即过期 Response.Cookies.Remove("AccountName"); //清除 Response.Cookies.Add(mycookie); //写入立即过期的*/ Response.Cookies["AccountName"].Expires = DateTime.Now.AddDays(-1); } if (Request.Cookies["AccountKey"] != null) { HttpCookie mycookie = Request.Cookies["AccountKey"]; TimeSpan ts = new TimeSpan(0, 0, 0, 0); //时间跨度 mycookie.Expires = DateTime.Now.Add(ts); //立即过期 Response.Cookies.Remove("AccountKey"); //清除 Response.Cookies.Add(mycookie); //写入立即过期的*/ Response.Cookies["AccountKey"].Expires = DateTime.Now.AddDays(-1); } if (weixincode != "") {//如果微信认证代码,微信认证登陆 GetOpenId(weixincode, comid); } else if (openid != "" && weixinpass != "") { VerifyOneOffPass(openid, weixinpass); } } } } }
public string comlogo = ""; //公司logo地址 protected void Page_Load(object sender, EventArgs e) { comid = Request["comid"].ConvertTo <int>(0); openid = Request["openid"].ConvertTo <string>(""); weixinpass = Request["weixinpass"].ConvertTo <string>(""); RequestUrl = Request.ServerVariables["SERVER_NAME"].ToLower(); if (Domain_def.Domain_yanzheng(RequestUrl))//如果符合shop101.etown.cn的格式,则从多微信商户基本信息表中获取comid { //先通过正则表达式获取COMid comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl).ToString()); if (comid == 0) { comid = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestUrl).Comid; } } else { B2b_company_info companyinfo = B2bCompanyData.GetComId(RequestUrl); if (companyinfo != null) { comid = companyinfo.Com_id; } } if (comid != 0) { //根据公司id得到公司logo地址和公司名称 comname = B2bCompanyData.GetCompany(comid).Com_name; B2b_company_saleset pro = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (pro != null) { comlogo = FileSerivce.GetImgUrl(pro.Logo.ConvertTo <int>(0)); } } if (openid != null && openid != "") { //只要传递过来微信ID 直接SESSION Session["Openid"] = openid; } //判断登陆状态 if (Session["AccountId"] != null) {//先判断Session AccountId = Session["AccountId"].ToString(); AccountName = Session["AccountName"].ToString(); AccountCard = Session["AccountCard"].ToString(); Today = DateTime.Now.ToString("yyyy-MM-dd"); B2bCrmData dateuser = new B2bCrmData(); dateuser.WeixinConPass(openid, comid);//只要包含SESSION登陆成功,清空微信密码 } else {//再判断COOKIES if (Request.Cookies["AccountId"] != null && Request.Cookies["AccountKey"] != null) { AccountId = Request.Cookies["AccountId"].Value; string accountmd5 = Request.Cookies["AccountKey"].Value; B2b_crm userinfo; var data = CrmMemberJsonData.WeixinCookieLogin(AccountId, accountmd5, comid, out userinfo); if (data == "OK") { Session["AccountId"] = userinfo.Id; Session["AccountName"] = userinfo.Name; Session["AccountCard"] = userinfo.Idcard; HttpCookie cookie = new HttpCookie("AccountId", userinfo.Id.ToString()); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("AccountName", userinfo.Name.ToString()); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); var returnmd5 = EncryptionHelper.ToMD5(userinfo.Idcard.ToString() + userinfo.Id.ToString(), "UTF-8"); cookie = new HttpCookie("AccountKey", returnmd5); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); Response.Redirect(Request.Url.ToString()); //登陆成功,刷新页面 } else { //如果微信ID,递实现自动登陆 if (openid != null && openid != "" && weixinpass != "" && weixinpass != null) { //只要传递过来微信ID 直接SESSION Session["Openid"] = openid; B2bCrmData dateuser = new B2bCrmData(); data = CrmMemberJsonData.WeixinLogin(openid, weixinpass, comid, out userinfo); if (data == "OK") { dateuser.WeixinConPass(openid, comid);//登陆成功,清空微信密码 Session["AccountId"] = userinfo.Id; Session["AccountName"] = userinfo.Name; Session["AccountCard"] = userinfo.Idcard; HttpCookie cookie = new HttpCookie("AccountId", userinfo.Id.ToString()); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("AccountName", userinfo.Name.ToString()); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); var returnmd5 = EncryptionHelper.ToMD5(userinfo.Idcard.ToString() + userinfo.Id.ToString(), "UTF-8"); cookie = new HttpCookie("AccountKey", returnmd5); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); Response.Redirect(Request.Url.ToString()); } } } } else { //最后判断传递过来的微信一次性密码 //如果微信ID,递实现自动登陆 if (openid != null && openid != "" && weixinpass != "" && weixinpass != null) { //只要传递过来微信ID 直接SESSION Session["Openid"] = openid; B2bCrmData dateuser = new B2bCrmData(); B2b_crm userinfo = new B2b_crm(); var data = CrmMemberJsonData.WeixinLogin(openid, weixinpass, comid, out userinfo); if (data == "OK") { dateuser.WeixinConPass(openid, comid);//登陆成功,清空微信密码 Session["AccountId"] = userinfo.Id; Session["AccountName"] = userinfo.Name; Session["AccountCard"] = userinfo.Idcard; HttpCookie cookie = new HttpCookie("AccountId", userinfo.Id.ToString()); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("AccountName", userinfo.Name.ToString()); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); var returnmd5 = EncryptionHelper.ToMD5(userinfo.Idcard.ToString() + userinfo.Id.ToString(), "UTF-8"); cookie = new HttpCookie("AccountKey", returnmd5); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); Response.Redirect(Request.Url.ToString()); } } } } }
private void GetUserByclient(int comid) { #region 客户端没有保存数据cookie,session ,不处理 if (Request.Cookies["AccountId"] == null && Session["AccountId"] == null) { } #endregion 客户端保存了数据cookie,session ,处理 #region else { if (Session["AccountId"] != null) { int crmid = Session["AccountId"].ToString().ConvertTo <int>(0); if (crmid > 0) { crminfo = new B2bCrmData().GetB2bCrmById(crmid); } } else { if (Request.Cookies["AccountId"] != null) { string accountmd5 = ""; int AccountId = int.Parse(Request.Cookies["AccountId"].Value); if (Request.Cookies["AccountKey"] != null) { accountmd5 = Request.Cookies["AccountKey"].Value; } var data1 = CrmMemberJsonData.WeixinCookieLogin(AccountId.ToString(), accountmd5, comid, out crminfo); if (data1 != "OK") { //当cookie错误无法登陆则清除所有COOKIE; HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } } else { //从cookie中得到accountid,accountkey,openid string openid = Request.Cookies["openid"].Value; string accountid = Request.Cookies["AccountId"].Value; string accountkey = Request.Cookies["AccountKey"].Value; int crmid = accountid.ConvertTo <int>(0); if (crmid > 0) { crminfo = new B2bCrmData().GetB2bCrmById(crmid); } } } } } #endregion }
public void DealUserinfo1(string openid, string weixinpass, int comid, int questtype) { if (Request.Cookies["AccountId"] != null) { string accountmd5 = ""; int AccountId = int.Parse(Request.Cookies["AccountId"].Value); if (Request.Cookies["AccountKey"] != null) { accountmd5 = Request.Cookies["AccountKey"].Value; } var data = CrmMemberJsonData.WeixinCookieLogin(AccountId.ToString(), accountmd5, comid, out userinfo); if (data != "OK") { //当cookie错误无法登陆则清除所有COOKIE; HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } if (questtype == 1) { VerifyOneOffPass(openid, weixinpass);//重新验证一下是否是正确的一次性密码 } else if (questtype == 2) { openid = GetOpenId(weixinpass, comid);//微信授权验证 } } else { //从cookie中得到微信号 if (Request.Cookies["openid"] != null) { openid = Request.Cookies["openid"].Value; } B2bCrmData dateuser = new B2bCrmData(); dateuser.WeixinConPass(openid, comid);//清空微信密码 if (userinfo != null) { Readuser(userinfo.Idcard, comid);//读取用户信息 } } } else { if (questtype == 1) { VerifyOneOffPass(openid, weixinpass);//重新验证一下是否是正确的一次性密码 } else if (questtype == 2) { { openid = GetOpenId(weixinpass, comid);//微信授权验证 } } } //根据微信号得到会员所在的门市信息 Member_Channel_company menshi = new MemberChannelcompanyData().GetMenShiByJumpId(openid, comid); if (menshi != null) { if (menshi.Whetherdepartment == 0) { //如果不是内部部门,显示门店列表 channelcompanyid = menshi.Id; } } }
/// <summary> /// 获取会员信息分两种方式:a.根据客户端保存的cookie值获取 b.根据传递过来的参数获取 /// </summary> /// <param name="weixincode"></param> /// <param name="openid"></param> /// <param name="weixinpass"></param> private void GetCrmInfo(string weixincode, string openid, string weixinpass) { //如果SESSION有值,进行赋值 if (openid == "" && Session["Openid"] != null) { openid = Session["Openid"].ToString(); } //判断商家是否微信认证 if (weixincode != "")//进行过微信认证,微信认证登陆 { //如果微信ID,递实现自动登陆 GetOpenId(weixincode, comid); } else if (openid != "" && weixinpass != "") { //最后判断传递过来的微信一次性密码 VerifyOneOffPass(openid, weixinpass); } //判断登陆状态 if (Session["AccountId"] != null) { //先判断Session int AccountId = int.Parse(Request.Cookies["AccountId"].Value); B2bCrmData dateuser = new B2bCrmData(); B2b_crm userinfo = dateuser.Readuser(AccountId, comid); if (userinfo != null) { Readuser(userinfo.Idcard, comid); } } else {//再判断COOKIES if (Request.Cookies["AccountId"] != null) { string accountmd5 = ""; int AccountId = int.Parse(Request.Cookies["AccountId"].Value); if (Request.Cookies["AccountKey"] != null) { accountmd5 = Request.Cookies["AccountKey"].Value; } var data1 = CrmMemberJsonData.WeixinCookieLogin(AccountId.ToString(), accountmd5, comid, out userinfo); if (data1 == "OK") { //从cookie中得到微信号 if (Request.Cookies["openid"] != null) { openid = Request.Cookies["openid"].Value; } if (userinfo != null) { Readuser(userinfo.Idcard, comid);//读取用户信息 } } else { //当cookie错误无法登陆则清除所有COOKIE; HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } //根据传递过来的参数获取会员信息 GetCrmByParam(weixincode, openid, weixinpass); } } else { //根据传递过来的参数获取会员信息 GetCrmByParam(weixincode, openid, weixinpass); } } }
protected void Page_Load(object sender, EventArgs e) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u); RequestUrl = Request.ServerVariables["SERVER_NAME"].ToLower(); //根据域名读取商户ID,如果没有绑定域名直接跳转后台 if (Domain_def.Domain_yanzheng(RequestUrl))//如果符合shop101.etown.cn的格式,则从多微信商户基本信息表中获取comid { //先通过正则表达式获取COMid comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl).ToString()); if (comid == 0) { comid = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestUrl).Comid; } } else { B2b_company_info companyinfo = B2bCompanyData.GetComId(RequestUrl); if (companyinfo != null) { comid = companyinfo.Com_id; } } //if (bo == false) //{ // if (comid == 101) // { // Response.Redirect("http://vctrip.etown.cn/"); // } // Response.Redirect("http://shop" + comid + ".etown.cn"); //} if (openid != null && openid != "") { //只要传递过来微信ID 直接SESSION Session["Openid"] = openid; } //判断登陆状态 if (Session["AccountId"] != null) {//先判断Session AccountId = Int32.Parse(Session["AccountId"].ToString()); AccountName = Session["AccountName"].ToString(); AccountCard = Session["AccountCard"].ToString(); Today = DateTime.Now.ToString("yyyy-MM-dd"); //comid = int.Parse(Session["Com_id"].ToString()); //AccountId = Int32.Parse(Session["AccountId"].ToString()); B2bCrmData dateuser1 = new B2bCrmData(); B2b_crm modeluser = dateuser1.Readuser(AccountId, comid); if (modeluser != null) { openid = modeluser.Weixin; Accountphone = modeluser.Phone; AccountName = modeluser.Name; AccountCard = modeluser.Idcard.ToString(); AccountBirthday = modeluser.Birthday; Accountsex = modeluser.Sex; year = AccountBirthday.Year.ToString(); month = AccountBirthday.Month.ToString(); day = AccountBirthday.Day.ToString(); comid = int.Parse(modeluser.Com_id.ToString()); } B2bCrmData dateuser = new B2bCrmData(); dateuser.WeixinConPass(openid, comid);//只要包含SESSION登陆成功,清空微信密码 } else {//再判断COOKIES //comid = Request["comid"].ConvertTo<int>(0); if (Request.Cookies["AccountId"] != null && Request.Cookies["AccountKey"] != null) { AccountId = Int32.Parse(Request.Cookies["AccountId"].Value); string accountmd5 = Request.Cookies["AccountKey"].Value; B2b_crm userinfo; var data = CrmMemberJsonData.WeixinCookieLogin(AccountId.ToString(), accountmd5, comid, out userinfo); if (data == "OK") { Session["AccountId"] = userinfo.Id; Session["AccountName"] = userinfo.Name; Session["AccountCard"] = userinfo.Idcard; Session["Com_id"] = comid; //Accountsex = userinfo.Sex; openid = userinfo.Weixin; HttpCookie cookie = new HttpCookie("AccountId", userinfo.Id.ToString()); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("AccountName", userinfo.Name.ToString()); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); var returnmd5 = EncryptionHelper.ToMD5(userinfo.Idcard.ToString() + userinfo.Id.ToString(), "UTF-8"); cookie = new HttpCookie("AccountKey", returnmd5); //实例化HttpCookie类并添加值 cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); } } } }