private void Btn_getqrcode_Click(object sender, EventArgs e) { Facade.LoginFacde loginFacde = new Facade.LoginFacde(); LoginQrCode postData = new LoginQrCode() { ProxyIp = Config.ProxyConfig.Ip, DeviceId = Config.ProxyConfig.DeviceId, ProxyUserName = Config.ProxyConfig.UserName, ProxyPassword = Config.ProxyConfig.UserPwd }; Models.Response.LoginQrCode Responsemodel = new Models.Response.LoginQrCode(); if (!loginFacde.GetLoginQrCode(ref Responsemodel, postData)) { Log("网络异常请求失败!"); return; } if (!Responsemodel.Success) { Log(Responsemodel.Message + ":" + Responsemodel.Code); return; } Image qrcode = Tool.ImageHelper.resizeImage(Tool.ImageHelper.Base64StringToImage(Responsemodel.Data.QrBase64), 200, 200); this.pic_qrcode.Image = qrcode; Log("Uuid:"); Log(Responsemodel.Data.Uuid); Log("过期时间:"); Log(Responsemodel.Data.ExpiredTime); this.lb_Uuid.Text = Responsemodel.Data.Uuid; Timer_CheckLogin.Elapsed += Timer_CheckLogin_Elapsed; Timer_CheckLogin.Interval = 2000; Timer_CheckLogin.Start(); }
/// <summary> /// 技师编辑微信绑定 /// </summary> /// <param name="wxkey"></param> /// <returns></returns> public ActionResult WXBind(string wxkey) { LoginQrCode lcode = RedisUtil.Get <LoginQrCode>("SessionID:" + wxkey); if (string.IsNullOrEmpty(wxkey)) { return(Json(new { isok = false })); } if (lcode == null) { return(Json(new { isok = false })); } if (!lcode.IsLogin) { return(Json(new { isok = false })); } if (lcode.WxUser != null) { Account accountmodel = null; if (!string.IsNullOrEmpty(lcode.WxUser.openid)) { UserBaseInfo userInfo = UserBaseInfoBLL.SingleModel.GetModelByOpenId(lcode.WxUser.openid, lcode.WxUser.serverid); if (userInfo == null) { userInfo = new UserBaseInfo(); userInfo.openid = lcode.WxUser.openid; userInfo.nickname = lcode.WxUser.nickname; userInfo.headimgurl = lcode.WxUser.headimgurl; userInfo.sex = lcode.WxUser.sex; userInfo.country = lcode.WxUser.country; userInfo.city = lcode.WxUser.city; userInfo.province = lcode.WxUser.province; userInfo.unionid = lcode.WxUser.unionid; UserBaseInfoBLL.SingleModel.Add(userInfo); } accountmodel = AccountBLL.SingleModel.GetAccountByWeixinUser(lcode.WxUser); if (accountmodel == null) { return(Json(new { isok = false })); } Member member = MemberBLL.SingleModel.GetMemberByAccountId(accountmodel.Id.ToString()); member.LastModified = DateTime.Now;//记录登录时间 MemberBLL.SingleModel.Update(member); RedisUtil.Remove("SessionID:" + wxkey); //重置二维码 string sessonid = new Random().Next(1, 3) + DateTime.Now.ToString("mmssfffff"); if (null == RedisUtil.Get <LoginQrCode>("SessionID:" + sessonid)) { LoginQrCode newWxkey = new LoginQrCode(); newWxkey.SessionId = sessonid; newWxkey.IsLogin = false; RedisUtil.Set <LoginQrCode>("SessionID:" + sessonid, newWxkey); } return(Json(new { isok = true, unionId = userInfo.unionid, key = sessonid })); } } return(Json(new { isok = false })); }
// GET: footbath_technician:足浴版小程序-技师管理 #region 技师管理 /// <summary> /// 技师管理视图 /// </summary> /// <returns></returns> public ActionResult TechnicianList() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(View("PageError", new Return_Msg() { Msg = "参数错误!", code = "500" })); } ViewBag.appId = appId; if (dzaccount == null) { return(Redirect("/dzhome/login")); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(View("PageError", new Return_Msg() { Msg = "没有权限!", code = "403" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={appId}"); if (storeModel == null) { return(View("PageError", new Return_Msg() { Msg = "数据不存在!", code = "500" })); } List <EntGoods> serviceList = EntGoodsBLL.SingleModel.GetServicList(appId); //扫码绑定代码 string sessonid = new Random().Next(1, 3) + DateTime.Now.ToString("mmssfffff"); Session["qrcodekey"] = sessonid; if (null == RedisUtil.Get <LoginQrCode>("SessionID:" + sessonid)) { LoginQrCode wxkey = new LoginQrCode(); wxkey.SessionId = sessonid; wxkey.IsLogin = false; RedisUtil.Set <LoginQrCode>("SessionID:" + sessonid, wxkey); } return(View(serviceList)); }
/// <summary> /// 扫描微信二维码 /// </summary> public string GetQrdCode() { //扫码登陆代码 string sessonid = new Random().Next(1, 3) + DateTime.Now.ToString("mmssfffff"); Session["qrcodekey"] = sessonid; if (null == RedisUtil.Get <LoginQrCode>("SessionID:" + sessonid)) { LoginQrCode wxkey = new LoginQrCode(); wxkey.SessionId = sessonid; wxkey.IsLogin = false; RedisUtil.Set <LoginQrCode>("SessionID:" + sessonid, wxkey, TimeSpan.FromDays(1)); } return(sessonid); }
public ActionResult Login() { //扫码登陆代码 var sessonid = new Random().Next(1, 3) + DateTime.Now.ToString("mmssfffff"); Session["qrcodekey"] = sessonid; if (null == RedisUtil.Get <LoginQrCode>("SessionID:" + sessonid)) { LoginQrCode wxkey = new LoginQrCode(); wxkey.SessionId = sessonid; wxkey.IsLogin = false; RedisUtil.Set <LoginQrCode>("SessionID:" + sessonid, wxkey); } return(View()); }
public bool GetLoginQrCode(ref Models.Response.LoginQrCode Responsemodel, LoginQrCode postData) { try { string requsetjson = JsonConvert.SerializeObject(postData); string json = Tool.HttpHelper.HttpPost(AppConfig.BaseUrl + AppConfig.Login_GetQrCode, requsetjson); Responsemodel = JsonConvert.DeserializeObject <Models.Response.LoginQrCode>(json); return(true); } catch (Exception e) { return(false); } }
public ActionResult Index(int appId = 0, int storeId = 0) { if (appId <= 0) { return(View("ErrorMsg", new Return_Msg() { Msg = "非法操作!" })); } FootBath storeModel = new FootBath(); if (storeId > 0) { //表示门店 storeModel = FootBathBLL.SingleModel.GetModel(storeId); } else { //表示总店 storeModel = FootBathBLL.SingleModel.GetModel($"appId={appId} and HomeId=0"); } if (storeModel != null) { if (!string.IsNullOrEmpty(storeModel.SwitchConfig)) { try { storeModel.switchModel = JsonConvert.DeserializeObject <SwitchModel>(storeModel.SwitchConfig); } catch (Exception ex) { log4net.LogHelper.WriteError(this.GetType(), ex); return(View("ErrorMsg", new Return_Msg() { Msg = "系统繁忙Config_error!" })); } } else { storeModel.switchModel = new SwitchModel(); } //店铺Logo var LogoList = C_AttachmentBLL.SingleModel.GetListByCache(storeModel.Id, (int)AttachmentItemType.小程序多门店版门店logo); if (LogoList != null && LogoList.Count > 0) { ViewBag.Logo = new List <object>() { new { id = LogoList[0].id, url = LogoList[0].filepath } }; } //门店图片 //if (storePicList != null && storePicList.Count > 0) //{ // var storePicObjList = new List<object>(); // storePicList.ForEach(x => // { // storePicObjList.Add(new { id = x.id, url = x.filepath }); // }); // ViewBag.storePicList = storePicObjList; //} } else { return(View("ErrorMsg", new Return_Msg() { Msg = "请先开通多门店!" })); } ViewBag.storeId = storeModel.Id; ViewBag.appId = appId; ViewBag.SetStoreMaterialPages = string.IsNullOrEmpty(storeModel.StoreMaterialPages); ViewBag.HaveRole = UserRoleBLL.SingleModel.HavingRole(dzuserId, RoleType.总店管理员, appId); #region 扫码绑定门店管理员 var sessonid = new Random().Next(1, 3) + DateTime.Now.ToString("mmssfffff"); Session["qrcodekey"] = sessonid; if (null == RedisUtil.Get <LoginQrCode>("SessionID:" + sessonid)) { LoginQrCode wxkey = new LoginQrCode(); wxkey.SessionId = sessonid; wxkey.IsLogin = true; RedisUtil.Set <LoginQrCode>("SessionID:" + sessonid, wxkey); } Session["appId"] = storeModel.appId; Session["storeId"] = storeModel.Id; #endregion return(View(storeModel)); }
public ActionResult WXLogin(string wxkey = "") { LoginQrCode lcode = RedisUtil.Get <LoginQrCode>("SessionID:" + wxkey); if (string.IsNullOrEmpty(wxkey)) { return(Json(new { success = false, msg = "登录失败!" }, JsonRequestBehavior.AllowGet)); } if (lcode == null) { return(Json(new { success = false, msg = "登录失败!" }, JsonRequestBehavior.AllowGet)); } if (!lcode.IsLogin) { return(Json(new { success = false, msg = "登录失败!" }, JsonRequestBehavior.AllowGet)); } if (lcode.WxUser != null) { //已扫描 Account accountmodel = null; if (!string.IsNullOrEmpty(lcode.WxUser.openid)) { log4net.LogHelper.WriteInfo(this.GetType(), $"MiniappUserBaseInfo "); UserBaseInfo userInfo = UserBaseInfoBLL.SingleModel.GetModelByOpenId(lcode.WxUser.openid, lcode.WxUser.serverid); if (userInfo == null) { userInfo = new UserBaseInfo(); userInfo.openid = lcode.WxUser.openid; userInfo.nickname = lcode.WxUser.nickname; userInfo.headimgurl = lcode.WxUser.headimgurl; userInfo.sex = lcode.WxUser.sex; userInfo.country = lcode.WxUser.country; userInfo.city = lcode.WxUser.city; userInfo.province = lcode.WxUser.province; userInfo.unionid = lcode.WxUser.unionid; UserBaseInfoBLL.SingleModel.Add(userInfo); } accountmodel = AccountBLL.SingleModel.GetAccountByWeixinUser(lcode.WxUser); if (accountmodel == null) { return(Json(new { success = false, msg = "登录失败!" }, JsonRequestBehavior.AllowGet)); } Member member = MemberBLL.SingleModel.GetModel(string.Format("AccountId ='{0}'", accountmodel.Id.ToString())); member.LastModified = DateTime.Now;//记录登录时间 MemberBLL.SingleModel.Update(member); RedisUtil.Remove("SessionID:" + wxkey); //CookieHelper.Remove("agent_UserCookieNew"); //CookieHelper.Remove("dz_UserCookieNew"); //CookieHelper.Remove("regphoneuserid"); //Session["dz_MultiStoreAccountId"] = 0; //string cookiedomain = ".vzan.com"; //Session["dz_UserCookieNew"] = accountmodel.Id.ToString(); //CookieHelper.SetCookie("dz_UserCookieNew", accountmodel.Id.ToString(), cookiedomain, 60 * 24 * 10); return(Json(new { success = true, msg = accountmodel.Id.ToString() }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, msg = "登录失败!" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, msg = "登录失败!" }, JsonRequestBehavior.AllowGet)); }
public ActionResult StoreManagerBindWx(string wxkey = "") { LoginQrCode lcode = RedisUtil.Get <LoginQrCode>("SessionID:" + wxkey); if (string.IsNullOrEmpty(wxkey)) { return(Json(new { success = false, msg = "没有wxkey!" }, JsonRequestBehavior.AllowGet)); } if (lcode == null) { return(Json(new { success = false, msg = "lcode为NULL!" }, JsonRequestBehavior.AllowGet)); } if (!lcode.IsLogin) { return(Json(new { success = false, msg = "未登录!" }, JsonRequestBehavior.AllowGet)); } if (lcode.WxUser != null) { //已扫描 Account accountmodel = null; if (!string.IsNullOrEmpty(lcode.WxUser.openid)) { log4net.LogHelper.WriteInfo(this.GetType(), $"MiniappUserBaseInfo "); UserBaseInfo userInfo = UserBaseInfoBLL.SingleModel.GetModelByOpenId(lcode.WxUser.openid, lcode.WxUser.serverid); if (userInfo == null) { userInfo = new UserBaseInfo(); userInfo.openid = lcode.WxUser.openid; userInfo.nickname = lcode.WxUser.nickname; userInfo.headimgurl = lcode.WxUser.headimgurl; userInfo.sex = lcode.WxUser.sex; userInfo.country = lcode.WxUser.country; userInfo.city = lcode.WxUser.city; userInfo.province = lcode.WxUser.province; userInfo.unionid = lcode.WxUser.unionid; UserBaseInfoBLL.SingleModel.Add(userInfo); } accountmodel = AccountBLL.SingleModel.GetAccountByWeixinUser(lcode.WxUser); if (accountmodel == null) { return(Json(new { success = true, msg = "找不到绑定账号!" }, JsonRequestBehavior.AllowGet)); } Member member = MemberBLL.SingleModel.GetModel(string.Format("AccountId ='{0}'", accountmodel.Id.ToString())); member.LastModified = DateTime.Now;//记录登录时间 MemberBLL.SingleModel.Update(member); RedisUtil.Remove("SessionID:" + wxkey); Int32 appId = Convert.ToInt32(Session["appId"] ?? "0"); Int32 storeId = Convert.ToInt32(Session["storeId"] ?? "0"); bool havingRole = UserRoleBLL.SingleModel.HavingRole(RoleType.分店管理员, appId, storeId); if (havingRole) { return(Json(new { success = true, msg = "该店铺已经有管理者,请解绑后再重新绑定!", isBind = true }, JsonRequestBehavior.AllowGet)); } //添加当前扫码用户于当前店铺的管理权限 TransactionModel tran = new TransactionModel(); tran.Add(UserRoleBLL.SingleModel.BuildAddSql(new UserRole() { RoleId = (int)RoleType.分店管理员, AppId = appId, StoreId = storeId, State = 1, UserId = accountmodel.Id, CreateDate = DateTime.Now, UpdateDate = DateTime.Now })); FootBath store = FootBathBLL.SingleModel.GetModel(storeId); store.ShopManagerName = lcode.WxUser.nickname; store.ShopManager = accountmodel.LoginId; tran.Add(FootBathBLL.SingleModel.BuildUpdateSql(store)); bool isSuccess = UserRoleBLL.SingleModel.ExecuteTransactionDataCorect(tran.sqlArray); if (!isSuccess) { return(Json(new { success = true, msg = "加入数据库失败!" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = true, msg = "绑定成功!", ShopManagerName = store.ShopManagerName, ShopManager = store.ShopManager }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, msg = "找不到openid!" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, msg = "绑定失败!" }, JsonRequestBehavior.AllowGet)); } // return Json(new { success = false, msg = "绑定失败!" }, JsonRequestBehavior.AllowGet); }