/// <summary> /// 绑定已经存在账户,需要短信验证 /// </summary> private void bind2() { string openid = WeiSha.Common.Request.QueryString["openid"].String; string token = WeiSha.Common.Request.QueryString["token"].String; string mobi = WeiSha.Common.Request.Form["mobi"].String; //手机号 string vname = WeiSha.Common.Request.Form["vname"].String; string imgCode = WeiSha.Common.Request.Cookies[vname].ParaValue; //取图片验证码 string userCode = WeiSha.Common.Request.Form["vcode"].MD5; //取输入的验证码 string sms = WeiSha.Common.Request.Form["sms"].MD5; //输入的短信验证码 //短信验证码Cookie名称 string smsName = WeiSha.Common.Request.Form["smsname"].String; string btnName = WeiSha.Common.Request.Form["smsbtn"].String; //验证图片验证码 if (imgCode != userCode) { Response.Write("{\"success\":\"-1\",\"state\":\"1\",\"btn\":\"" + btnName + "\"}"); //图片验证码不正确 return; } //验证短信验证码 bool isSmsCode = true; //是否短信验证; string smsCode = WeiSha.Common.Request.Cookies[smsName].ParaValue; if (isSmsCode && sms != smsCode) { Response.Write("{\"success\":\"-1\",\"state\":\"3\",\"btn\":\"" + btnName + "\"}"); //短信验证失败 return; } string unionid = string.Empty; Song.Entities.Accounts acctm = getUserInfo(token, openid, out unionid); Song.Entities.Accounts acc = null; //验证手机号是否存在 if (!string.IsNullOrWhiteSpace(mobi)) { acc = Business.Do <IAccounts>().IsAccountsExist(-1, mobi, 1); if (acc == null) { Response.Write("{\"success\":\"-1\",\"state\":\"2\",\"btn\":\"" + btnName + "\"}"); //手机号不存在 return; } //是否已经绑过微信的openid if (!string.IsNullOrWhiteSpace(acc.Ac_WeixinOpenID)) { Response.Write("{\"success\":\"-1\",\"state\":\"4\"}"); //已经绑定过openid return; } } //绑定 if (acc != null) { if (string.IsNullOrWhiteSpace(acc.Ac_WeixinOpenID)) { acc.Ac_WeixinOpenID = unionid; Business.Do <IAccounts>().AccountsSave(acc); LoginState.Accounts.Write(acc); //登录成功 Business.Do <IAccounts>().PointAdd4Login(acc, "电脑网页", "微信登录", ""); //增加登录积分 string domain = getOrganDomain(getOrgan(-1)); Response.Write("{\"success\":\"1\",\"name\":\"" + acc.Ac_Name + "\",\"domain\":\"" + domain + "\",\"acid\":\"" + acc.Ac_ID + "\",\"state\":\"1\",\"btn\":\"" + btnName + "\"}"); } else { Response.Write("{\"success\":\"-1\",\"state\":\"4\"}"); //已经绑定过微信号 } } }
/// <summary> /// 手机号注册,需短信验证 /// </summary> private void register2() { string vname = WeiSha.Common.Request.Form["vname"].String; string imgCode = WeiSha.Common.Request.Cookies[vname].ParaValue; //取图片验证码 string userCode = WeiSha.Common.Request.Form["vcode"].MD5; //取输入的验证码 string openid = WeiSha.Common.Request.QueryString["openid"].String; string token = WeiSha.Common.Request.QueryString["token"].String; string mobi = WeiSha.Common.Request.Form["mobi"].String; //手机号 string sms = WeiSha.Common.Request.Form["sms"].MD5; //输入的短信验证码 int sex = WeiSha.Common.Request.Form["sex"].Int16 ?? 0; string name = WeiSha.Common.Request.Form["name"].String; string photo = WeiSha.Common.Request.Form["photo"].String; //短信验证码Cookie名称 string smsName = WeiSha.Common.Request.Form["smsname"].String; string btnName = WeiSha.Common.Request.Form["smsbtn"].String; //验证图片验证码 if (imgCode != userCode) { Response.Write("{\"success\":\"-1\",\"state\":\"1\",\"btn\":\"" + btnName + "\"}"); //图片验证码不正确 return; } //验证手机号是否存在 Song.Entities.Accounts acc = Business.Do <IAccounts>().IsAccountsExist(-1, mobi, 1); if (acc != null) { Response.Write("{\"success\":\"-1\",\"state\":\"2\",\"btn\":\"" + btnName + "\"}"); //手机号已经存在 return; } //验证短信验证码 bool isSmsCode = true; //是否短信验证; string smsCode = WeiSha.Common.Request.Cookies[smsName].ParaValue; if (isSmsCode && sms != smsCode) { Response.Write("{\"success\":\"-1\",\"state\":\"3\",\"btn\":\"" + btnName + "\"}"); //短信验证失败 return; } else { //创建新账户 string unionid = string.Empty; Song.Entities.Accounts tmp = getUserInfo(token, openid, out unionid); Song.Entities.Organization org = getOrgan(-1); tmp.Ac_AccName = string.IsNullOrWhiteSpace(mobi) ? openid : mobi; tmp.Ac_MobiTel1 = tmp.Ac_MobiTel2 = mobi; //手机号 tmp.Org_ID = org.Org_ID; //头像图片 string photoPath = Upload.Get["Accounts"].Physics + unionid + ".jpg"; WeiSha.Common.Request.LoadFile(photo, photoPath); tmp.Ac_Photo = unionid + ".jpg"; //获取推荐人 int recid = WeiSha.Common.Request.Cookies["sharekeyid"].Int32 ?? 0; Song.Entities.Accounts accRec = null; if (accRec == null && recid > 0) { accRec = Business.Do <IAccounts>().AccountsSingle(recid); } if (accRec != null && accRec.Ac_ID != tmp.Ac_ID) { tmp.Ac_PID = accRec.Ac_ID; //设置推荐人,即:当前注册账号为推荐人的下线 Business.Do <IAccounts>().PointAdd4Register(accRec); //增加推荐人积分 } //如果需要审核通过 tmp.Ac_IsPass = tmp.Ac_IsUse = true; int id = Business.Do <IAccounts>().AccountsAdd(tmp); LoginState.Accounts.Write(tmp); string domain = getOrganDomain(org); Response.Write("{\"success\":\"1\",\"name\":\"" + tmp.Ac_Name + "\",\"domain\":\"" + domain + "\",\"acid\":\"" + tmp.Ac_ID + "\",\"state\":\"1\",\"btn\":\"" + btnName + "\"}"); } }
/// <summary> /// 绑定,但不验证手机号 /// </summary> private void bind1() { string openid = WeiSha.Common.Request.QueryString["openid"].String; string token = WeiSha.Common.Request.QueryString["token"].String; string mobi = WeiSha.Common.Request.Form["mobi"].String; //手机号 string pw = WeiSha.Common.Request.Form["pw"].MD5; //登录密码 string vname = WeiSha.Common.Request.Form["vname"].String; string imgCode = WeiSha.Common.Request.Cookies[vname].ParaValue; //取图片验证码 string userCode = WeiSha.Common.Request.Form["vcode"].MD5; //取输入的验证码 int sex = WeiSha.Common.Request.Form["sex"].Int16 ?? 0; string name = WeiSha.Common.Request.Form["name"].String; string photo = WeiSha.Common.Request.Form["photo"].String; //验证图片验证码 if (imgCode != userCode) { Response.Write("{\"success\":\"-1\",\"state\":\"1\"}"); //图片验证码不正确 return; } string unionid = string.Empty; Song.Entities.Accounts acctm = getUserInfo(token, openid, out unionid); Song.Entities.Accounts acc = null; //验证手机号是否存在 if (!string.IsNullOrWhiteSpace(mobi)) { acc = Business.Do <IAccounts>().IsAccountsExist(-1, mobi, 1); if (acc == null) { Response.Write("{\"success\":\"-1\",\"state\":\"2\"}"); //手机号不存在 return; } //验证密码 if (!string.Equals(acc.Ac_Pw, pw, StringComparison.CurrentCultureIgnoreCase)) { Response.Write("{\"success\":\"-1\",\"state\":\"3\"}"); //登录密码不正确 return; } //是否已经绑过微信的openid if (!string.IsNullOrWhiteSpace(acc.Ac_WeixinOpenID)) { Response.Write("{\"success\":\"-1\",\"state\":\"4\"}"); //已经绑定过openid return; } } //绑定 if (acc != null) { if (string.IsNullOrWhiteSpace(acc.Ac_WeixinOpenID)) { acc.Ac_WeixinOpenID = unionid; Business.Do <IAccounts>().AccountsSave(acc); LoginState.Accounts.Write(acc); //登录成功 Business.Do <IAccounts>().PointAdd4Login(acc, "电脑网页", "微信登录", ""); //增加登录积分 string domain = getOrganDomain(this.getOrgan(-1)); Response.Write("{\"success\":\"1\",\"name\":\"" + acc.Ac_Name + "\",\"domain\":\"" + domain + "\",\"acid\":\"" + acc.Ac_ID + "\",\"state\":\"1\"}"); } else { Response.Write("{\"success\":\"-1\",\"state\":\"4\"}"); //已经绑定过微信号 } } }
/// <summary> /// 手机注册的验证 /// </summary> private void mobiregister_verify() { string vname = WeiSha.Common.Request.Form["vname"].String; string imgCode = WeiSha.Common.Request.Cookies[vname].ParaValue; //取图片验证码 string userCode = WeiSha.Common.Request.Form["tbCode"].MD5; //取输入的验证码 string phone = WeiSha.Common.Request.Form["Ac_MobiTel1"].String; //输入的手机号 string sms = WeiSha.Common.Request.Form["tbSms"].MD5; //输入的短信验证码 string rec = WeiSha.Common.Request.Form["rec"].String; //推荐人的电话 int recid = WeiSha.Common.Request.Form["recid"].Int32 ?? 0; //推荐人的账户id //验证图片验证码 if (imgCode != userCode) { Response.Write("{\"success\":\"-1\",\"state\":\"1\"}"); //图片验证码不正确 return; } //验证手机号是否存在 Song.Entities.Accounts acc = Business.Do <IAccounts>().IsAccountsExist(-1, phone, 1); if (acc != null) { Response.Write("{\"success\":\"-1\",\"state\":\"2\"}"); //手机号已经存在 return; } //验证短信验证码 bool isSmsCode = true; //是否短信验证; WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config); isSmsCode = config["IsRegSms"].Value.Boolean ?? true; string smsCode = WeiSha.Common.Request.Cookies["reg_mobi_" + vname].ParaValue; if (isSmsCode && sms != smsCode) { Response.Write("{\"success\":\"-1\",\"state\":\"3\"}"); //短信验证失败 return; } else { //创建新账户 Song.Entities.Accounts tmp = new Entities.Accounts(); tmp = fillData(tmp); tmp.Ac_AccName = tmp.Ac_MobiTel1; //获取推荐人 Song.Entities.Accounts accRec = null; if (!string.IsNullOrWhiteSpace(rec)) { accRec = Business.Do <IAccounts>().AccountsSingle(rec, true, true); } if (accRec == null && recid > 0) { accRec = Business.Do <IAccounts>().AccountsSingle(recid); } if (accRec != null && accRec.Ac_ID != tmp.Ac_ID) { tmp.Ac_PID = accRec.Ac_ID; //设置推荐人,即:当前注册账号为推荐人的下线 Business.Do <IAccounts>().PointAdd4Register(accRec); //增加推荐人积分 } //如果需要审核通过 tmp.Ac_IsPass = !(bool)(config["IsVerifyStudent"].Value.Boolean ?? true); tmp.Ac_IsUse = tmp.Ac_IsPass; int id = Business.Do <IAccounts>().AccountsAdd(tmp); //以下为判断是否审核通过 if (tmp.Ac_IsPass) { LoginState.Accounts.Write(tmp); Response.Write("{\"success\":\"1\",\"name\":\"" + tmp.Ac_Name + "\",\"acid\":\"" + tmp.Ac_ID + "\",\"state\":\"1\"}"); } else { //注册成功,但待审核 Response.Write("{\"success\":\"1\",\"name\":\"" + tmp.Ac_Name + "\",\"acid\":\"" + tmp.Ac_ID + "\",\"state\":\"0\"}"); } } }
/// <summary> /// get请求时 /// </summary> protected void _StateForGET() { string token = WeiSha.Common.Request.QueryString["token"].String; string openid = WeiSha.Common.Request.QueryString["openid"].String; this.Document.Variables.SetValue("openid", openid); this.Document.Variables.SetValue("token", token); //设置主域,用于js跨根域 int multi = Business.Do <ISystemPara>()["MultiOrgan"].Int32 ?? 0; if (multi == 0 && !WeiSha.Common.Server.IsLocalIP) { this.Document.Variables.SetValue("domain", WeiSha.Common.Server.MainName); } //当前机构 Song.Entities.Organization org = getOrgan(-1); this.Document.Variables.SetValue("org", org); if (multi == 0 && !WeiSha.Common.Server.IsLocalIP) { this.Document.Variables.SetValue("domain", WeiSha.Common.Server.MainName); } this.Document.SetValue("domain2", getOrganDomain(org)); //获取帐户,如果已经注册,则直接实现登录 string unionid = string.Empty; Song.Entities.Accounts acctm = getUserInfo(token, openid, out unionid); Song.Entities.Accounts acc = null; if (acctm != null && !string.IsNullOrWhiteSpace(unionid)) { acc = Business.Do <IAccounts>().Account4Weixin(unionid); } if (acc != null) { this.Document.Variables.SetValue("acc", acc); //直接实现登录 if (acc.Ac_IsPass && acc.Ac_IsUse) { LoginState.Accounts.Write(acc); Business.Do <IAccounts>().PointAdd4Login(acc, "电脑网页", "微信登录", ""); //增加登录积分 Business.Do <IStudent>().LogForLoginAdd(acc); this.Document.Variables.SetValue("success", "1"); //登录成功 } else { this.Document.Variables.SetValue("success", "-1"); //账户禁用中 } } else { //账户不存在,以下用于注册 //相关参数 WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config); //登录方式 bool IsLoginForPw = config["IsLoginForPw"].Value.Boolean ?? true; //启用账号密码登录 bool IsLoginForSms = config["IsLoginForSms"].Value.Boolean ?? true; //启用手机短信验证登录 this.Document.SetValue("forpw", IsLoginForPw); this.Document.SetValue("forsms", IsLoginForSms); this.Document.SetValue("IsWeixinDirect", Business.Do <ISystemPara>()["WeixinDirectIs"].Boolean ?? true); //是否允许微信直接注册登录 //获取qq登录账户的信息 if (acctm != null) { this.Document.Variables.SetValue("name", acctm.Ac_Name); //QQ昵称 this.Document.Variables.SetValue("photo", acctm.Ac_Photo); //40*40头像 this.Document.Variables.SetValue("gender", acctm.Ac_Sex); //性别 } this.Document.Variables.SetValue("acctm", acctm); } }
protected override void InitPageTemplate(HttpContext context) { #region 此段代码用于取token与openid string code = WeiSha.Common.Request.QueryString["code"].String; //验证用的code,只用一次即失效 if (Request.ServerVariables["REQUEST_METHOD"] == "GET" && !string.IsNullOrWhiteSpace(code)) { string orgid = WeiSha.Common.Request.QueryString["state"].String; //机构id string token = getToken(); //Access_Token,用于进一步获取信息时的认证码 string uri = context.Request.FilePath + "?token={0}&openid={1}&orgid={2}"; uri = string.Format(uri, token, getOpenid(token), orgid); if (WeiSha.Common.Browser.IsMobile) { uri = "/Mobile" + uri; } Response.Redirect(uri); return; } #endregion #region 具体操作代码 string access_token = WeiSha.Common.Request.QueryString["token"].String; string openid = WeiSha.Common.Request.QueryString["openid"].String; if (Request.ServerVariables["REQUEST_METHOD"] == "GET" && !string.IsNullOrWhiteSpace(access_token)) { this.Document.Variables.SetValue("token", access_token); this.Document.Variables.SetValue("openid", openid); //设置主域,用于js跨根域 int multi = Business.Do <ISystemPara>()["MultiOrgan"].Int32 ?? 0; if (multi == 0 && !WeiSha.Common.Server.IsLocalIP) { this.Document.Variables.SetValue("domain", WeiSha.Common.Server.MainName); } //QQ回调域 string returl = Business.Do <ISystemPara>()["QQReturl"].Value ?? WeiSha.Common.Server.MainName; this.Document.SetValue("QQReturl", returl); //当前机构 Song.Entities.Organization org = getOrgan(); this.Document.SetValue("domain2", getOrganDomain(org)); //获取帐户,如果已经注册,则直接实现登录 Song.Entities.Accounts acc = _ExistAcc(openid); if (acc == null) { //账户不存在,以下用于注册 WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config); this.Document.SetValue("forpw", config["IsLoginForPw"].Value.Boolean ?? true); //启用账号密码登录 this.Document.SetValue("forsms", config["IsLoginForSms"].Value.Boolean ?? true); //启用手机短信验证登录 this.Document.SetValue("IsQQDirect", Business.Do <ISystemPara>()["QQDirectIs"].Boolean ?? true); //是否允许qq直接注册登录 //获取qq登录账户的信息 acc = getUserInfo(access_token, openid); this.Document.Variables.SetValue("name", acc.Ac_Name); //QQ昵称 this.Document.Variables.SetValue("photo2", acc.Ac_Photo); //100*100头像 this.Document.Variables.SetValue("gender", acc.Ac_Sex); //性别 } } #endregion #region ajax请求 //此页面的ajax提交,全部采用了POST方式 if (Request.ServerVariables["REQUEST_METHOD"] == "POST") { string action = WeiSha.Common.Request.Form["action"].String; switch (action) { case "Direct": _DirectLogin(); //直接登录 break; case "getRegSms": sendSmsVcode(); //验证手机注册时,获取短信时的验证码 break; case "register1": register1(); //直接注册,无需验证手机号 break; case "register2": register2(); //用手机注册,需短信验证手机号 break; case "bind1": bind1(); //绑定已经存在账户,不验证手机 break; case "bind2": bind2(); //绑定已经存在账户,验证手机号 break; default: //acclogin_verify(); //验证账号登录时的密码 break; } Response.End(); } #endregion }
/// <summary> /// 手机号注册,需短信验证 /// </summary> private void register2() { string vname = WeiSha.Common.Request.Form["vname"].String; string imgCode = WeiSha.Common.Request.Cookies[vname].ParaValue; //取图片验证码 string userCode = WeiSha.Common.Request.Form["vcode"].MD5; //取输入的验证码 string access_token = WeiSha.Common.Request.QueryString["token"].String; string openid = WeiSha.Common.Request.Form["openid"].String; string mobi = WeiSha.Common.Request.Form["mobi"].String; //手机号 string sms = WeiSha.Common.Request.Form["sms"].MD5; //输入的短信验证码 //短信验证码Cookie名称 string smsName = WeiSha.Common.Request.Form["smsname"].String; string btnName = WeiSha.Common.Request.Form["smsbtn"].String; //验证图片验证码 if (imgCode != userCode) { Response.Write("{\"success\":\"-1\",\"state\":\"1\",\"btn\":\"" + btnName + "\"}"); //图片验证码不正确 return; } //验证手机号是否存在 Song.Entities.Accounts acc = Business.Do <IAccounts>().IsAccountsExist(-1, mobi, 1); if (acc != null) { Response.Write("{\"success\":\"-1\",\"state\":\"2\",\"btn\":\"" + btnName + "\"}"); //手机号已经存在 return; } //验证短信验证码 bool isSmsCode = true; //是否短信验证; string smsCode = WeiSha.Common.Request.Cookies[smsName].ParaValue; if (isSmsCode && sms != smsCode) { Response.Write("{\"success\":\"-1\",\"state\":\"3\",\"btn\":\"" + btnName + "\"}"); //短信验证失败 return; } else { //获取qq登录账户的信息 acc = getUserInfo(access_token, openid); acc.Ac_AccName = acc.Ac_MobiTel1 = acc.Ac_MobiTel2 = mobi; //手机号 //头像图片 string photoPath = Upload.Get["Accounts"].Physics + openid + ".jpg"; WeiSha.Common.Request.LoadFile(acc.Ac_Photo, photoPath); acc.Ac_Photo = openid + ".jpg"; //获取推荐人 int recid = WeiSha.Common.Request.Cookies["sharekeyid"].Int32 ?? 0; Song.Entities.Accounts accRec = null; if (accRec == null && recid > 0) { accRec = Business.Do <IAccounts>().AccountsSingle(recid); } if (accRec != null && accRec.Ac_ID != acc.Ac_ID) { acc.Ac_PID = accRec.Ac_ID; //设置推荐人,即:当前注册账号为推荐人的下线 Business.Do <IAccounts>().PointAdd4Register(accRec); //增加推荐人积分 } //如果需要审核通过 acc.Ac_IsPass = acc.Ac_IsUse = true; int id = Business.Do <IAccounts>().AccountsAdd(acc); LoginState.Accounts.Write(acc); Response.Write("{\"success\":\"1\",\"name\":\"" + acc.Ac_Name + "\",\"acid\":\"" + acc.Ac_ID + "\",\"state\":\"1\",\"btn\":\"" + btnName + "\"}"); } }
protected override void InitPageTemplate(HttpContext context) { if (Extend.LoginState.Accounts.IsLogin) { this.Response.Redirect("selfInfo.ashx"); } this.Document.Variables.SetValue("step", step); //第一步验证账号是否存在 if (step == 1) { if (string.IsNullOrWhiteSpace(acc)) { return; } Song.Entities.Accounts t = Business.Do <IAccounts>().IsAccountsExist(this.Organ.Org_ID, acc); if (t == null) { //账号不存在 this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "error=4", "step=1", "acc=" + acc)); } else { this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "step=2", "acc=" + acc)); } } //第二步,验证安全问题是否正确 if (step == 2) { string acc = WeiSha.Common.Request.QueryString["acc"].String; Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle(acc, this.Organ.Org_ID); this.Document.Variables.SetValue("st", st); if (string.IsNullOrWhiteSpace(answer)) { return; } Song.Entities.Accounts t = Business.Do <IAccounts>().IsAccountsExist(this.Organ.Org_ID, acc, answer); if (t == null) { //账号不存在 this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "error=6", "step=2", "acc=" + acc)); } else { this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "step=3", "acc=" + acc)); } } //第三步,设置新密码 if (step == 3) { string acc = WeiSha.Common.Request.QueryString["acc"].String; Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle(acc, this.Organ.Org_ID); this.Document.Variables.SetValue("st", st); if (string.IsNullOrWhiteSpace(pw)) { return; } if (!isCodeImg()) { this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "step=3", "error=2", "acc=" + acc)); } else { st.Ac_Pw = pw; st.Ac_Pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(st.Ac_Pw).MD5; Business.Do <IAccounts>().AccountsSave(st); this.Response.Redirect("SelfInfo.ashx"); } } }
protected override void InitPageTemplate(HttpContext context) { if (Extend.LoginState.Accounts.IsLogin) { this.Response.Redirect("/default.ashx"); } this.Document.Variables.SetValue("step", step); //第一步验证账号是否存在 if (step == 1) { if (string.IsNullOrWhiteSpace(acc)) { return; } Song.Entities.Accounts t = Business.Do <IAccounts>().IsAccountsExist(this.Organ.Org_ID, acc); if (t == null) { //账号不存在 this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "error=4", "step=1", "acc=" + acc)); } else { this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "step=2", "acc=" + acc)); } } //第二步,验证安全问题是否正确 if (step == 2) { string acc = WeiSha.Common.Request.QueryString["acc"].String; Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle(acc, this.Organ.Org_ID); this.Document.Variables.SetValue("st", st); if (string.IsNullOrWhiteSpace(answer)) { return; } Song.Entities.Accounts t = Business.Do <IAccounts>().IsAccountsExist(this.Organ.Org_ID, acc, answer); if (t == null) { //账号不存在 this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "error=6", "step=2", "acc=" + acc)); } else { int accid = t.Ac_ID; string encrypt = WeiSha.Common.DataConvert.EncryptForBase64(accid.ToString()); encrypt = System.Web.HttpUtility.UrlEncode(encrypt); HttpCookie cookie = new HttpCookie("findpw-acid", encrypt); cookie.Expires = DateTime.Now.AddHours(10); this.Response.Cookies.Add(cookie); this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "step=3", "acc=" + acc)); } } //第三步,设置新密码 if (step == 3) { //string acc = WeiSha.Common.Request.QueryString["acc"].String; int accid = WeiSha.Common.Request.Cookies["findpw-acid"].Decrypt().Int32 ?? 0; Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle(accid); this.Document.Variables.SetValue("st", st); if (string.IsNullOrWhiteSpace(pw)) { return; } if (!isCodeImg()) { this.Response.Redirect(addPara(context.Request.Url.PathAndQuery, "step=3", "error=2", "acc=" + acc)); } else { st.Ac_Pw = pw; st.Ac_Pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(st.Ac_Pw).MD5; Business.Do <IAccounts>().AccountsSave(st); this.Response.Redirect("/default.ashx"); } } }
/// <summary> /// 绑定已经存在账户,需要短信验证 /// </summary> private void bind2() { string token = WeiSha.Common.Request.QueryString["token"].String; string openid = WeiSha.Common.Request.QueryString["openid"].String; string mobi = WeiSha.Common.Request.Form["mobi"].String; //手机号 string vname = WeiSha.Common.Request.Form["vname"].String; string imgCode = WeiSha.Common.Request.Cookies[vname].ParaValue; //取图片验证码 string userCode = WeiSha.Common.Request.Form["vcode"].MD5; //取输入的验证码 string sms = WeiSha.Common.Request.Form["sms"].MD5; //输入的短信验证码 string photo = WeiSha.Common.Request.Form["photo"].String; //短信验证码Cookie名称 string smsName = WeiSha.Common.Request.Form["smsname"].String; string btnName = WeiSha.Common.Request.Form["smsbtn"].String; //验证图片验证码 if (imgCode != userCode) { Response.Write("{\"success\":\"-1\",\"state\":\"1\",\"btn\":\"" + btnName + "\"}"); //图片验证码不正确 return; } //验证短信验证码 bool isSmsCode = true; //是否短信验证; string smsCode = WeiSha.Common.Request.Cookies[smsName].ParaValue; if (isSmsCode && sms != smsCode) { Response.Write("{\"success\":\"-1\",\"state\":\"3\",\"btn\":\"" + btnName + "\"}"); //短信验证失败 return; } string unionid = string.Empty; Song.Entities.Accounts acctm = getUserInfo(token, openid, out unionid); if (acctm != null && !string.IsNullOrWhiteSpace(unionid)) { Song.Entities.Accounts acc = null; //验证手机号是否存在 if (!string.IsNullOrWhiteSpace(mobi)) { acc = Business.Do <IAccounts>().IsAccountsExist(-1, mobi, 1); if (acc == null) { Response.Write("{\"success\":\"-1\",\"state\":\"2\",\"btn\":\"" + btnName + "\"}"); //手机号不存在 return; } //是否已经绑过微信的openid if (!string.IsNullOrWhiteSpace(acc.Ac_WeixinOpenID)) { Response.Write("{\"success\":\"-1\",\"state\":\"4\"}"); //已经绑定过openid return; } } //绑定 if (acc != null) { if (string.IsNullOrWhiteSpace(acc.Ac_WeixinOpenID)) { acc.Ac_WeixinOpenID = unionid; //用户头像,如果没有上传,或图片不存在 if (string.IsNullOrEmpty(acc.Ac_Photo) || acc.Ac_Photo.Trim() == "" || !System.IO.File.Exists(Upload.Get["Accounts"].Physics + acc.Ac_Photo)) { string photoPath = Upload.Get["Accounts"].Physics + unionid + ".jpg"; WeiSha.Common.Request.LoadFile(photo, photoPath); acc.Ac_Photo = unionid + ".jpg"; } Business.Do <IAccounts>().AccountsSave(acc); LoginState.Accounts.Write(acc); //登录成功 Business.Do <IAccounts>().PointAdd4Login(acc, "电脑网页", "微信登录", ""); //增加登录积分 //string domain = getOrganDomain(getOrgan(-1)); Response.Write("{\"success\":\"1\",\"name\":\"" + acc.Ac_Name + "\",\"acpw\":\"" + acc.Ac_Pw + "\",\"acid\":\"" + acc.Ac_ID + "\",\"state\":\"1\",\"btn\":\"" + btnName + "\"}"); } else { Response.Write("{\"success\":\"-1\",\"state\":\"4\"}"); //已经绑定过微信号 } } } else { //没有获取到unionid,可能是公众号没有绑定微信开放平台 Response.Write("{\"success\":\"-1\",\"state\":\"100\"}"); } }
/// <summary> /// 修改学员性别 /// </summary> private void modify_sex() { Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser; st.Ac_Sex = WeiSha.Common.Request.Form["sex"].Int16 ?? 0; Business.Do <IAccounts>().AccountsSave(st); }
//修改学员姓名 private void modify_name() { Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser; st.Ac_Name = WeiSha.Common.Request.Form["stname"].String; Business.Do <IAccounts>().AccountsSave(st); }