protected void Page_Load(object sender, EventArgs e) { string strMobile = string.Empty; string strPassWord = string.Empty; string strSiteCode = string.Empty; string strTitle = string.Empty; string strTheme = string.Empty; if (null == Session["strSiteCode"]) { return; } strSiteCode = Session["strSiteCode"].ToString(); if (null != Request.QueryString["action"]) { if (Request.QueryString["action"] == "login") { strMobile = Common.Common.NoHtml(Request.Form["mobile"].ToString()); strPassWord = Common.Common.NoHtml(Request.Form["password"].ToString()); DAL.SYS.CustomerDAL dal = new DAL.SYS.CustomerDAL(); DataSet ds = dal.GetCustomerData(strMobile, Common.Common.MD5(strPassWord), strSiteCode); if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { CustomerSession.strCustomerID = ds.Tables[0].Rows[0]["ID"].ToString(); CustomerSession.strMobile = ds.Tables[0].Rows[0]["Mobile"].ToString(); CustomerSession.strSiteCode = ds.Tables[0].Rows[0]["SiteCode"].ToString(); CustomerSession.strOpenID = ds.Tables[0].Rows[0]["OpenID"].ToString(); CustomerSession.strName = ds.Tables[0].Rows[0]["Name"].ToString(); Session["strName"] = CustomerSession.strName; Session["strCustomerID"] = CustomerSession.strCustomerID; Session["strSiteCode"] = CustomerSession.strSiteCode; Session["strOpenID"] = CustomerSession.strOpenID; } //Response.Redirect("ProductList.aspx?SiteCode=" + strSiteCode, false); Response.Redirect("LoginOK.aspx", false); } } DAL.SYS.AccountDAL dalAccount = new DAL.SYS.AccountDAL(); DataSet dsAccountExt = dalAccount.GetAExtDataBySiteCode(strSiteCode); if (null != dsAccountExt && dsAccountExt.Tables.Count > 0 && dsAccountExt.Tables[0].Rows.Count > 0) { strTheme = dsAccountExt.Tables[0].Rows[0]["Themes"].ToString(); strTitle = dsAccountExt.Tables[0].Rows[0]["Name"].ToString(); } string text = string.Empty; if (!File.Exists(Server.MapPath("Themes/" + strTheme + "/Login.html"))) { text = System.IO.File.ReadAllText(Server.MapPath("Themes/Default/Login.html")); } else { text = System.IO.File.ReadAllText(Server.MapPath("Themes/" + strTheme + "/Login.html")); } JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["title"] = "用户登录"; if (null == Session["strName"]) { context.TempData["username"] = "******"; } else { context.TempData["username"] = CustomerSession.strName; } if (null == Session["customerid"]) { context.TempData["customerid"] = null; } else { context.TempData["customerid"] = CustomerSession.strCustomerID; } context.TempData["sitename"] = strTitle; context.TempData["sitecode"] = strSiteCode; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!BeforeLoad()) { return; } string strTitle = string.Empty; string siteSettingJson = File.ReadAllText(Server.MapPath("/MicroSite/SiteSetting.json"), System.Text.Encoding.UTF8); SiteSetting siteSetting = JsonConvert.DeserializeObject <SiteSetting>(siteSettingJson); DAL.SYS.AccountDAL dalAccount = new DAL.SYS.AccountDAL(); DataSet ds; if (!string.IsNullOrEmpty(SiteCode)) { ds = dalAccount.GetAExtDataBySiteCode(SiteCode); } else { SiteID = null == Request.QueryString["ID"] ? siteSetting.DefaultSiteId : Mozart.Common.Common.NoHtml(Request.QueryString["ID"].ToString()); ds = dalAccount.GetAccountExtData(SiteID); } if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { var dynamicTable = ds.Tables[0].AsDynamicEnumerable(); var dynamicObj = dynamicTable.First(); Theme = dynamicObj.Themes; strTitle = dynamicObj.Name; SiteCode = dynamicObj.SiteCode; SiteID = dynamicObj.ID; } Session["siteid"] = SiteID; Session["strSiteCode"] = SiteCode; List <Module> modules = new List <Module>(); foreach (Category category in siteSetting.Categories) { modules.AddRange(category.Modules); } CurrentModule = modules.FirstOrDefault(w => w.Path == Request.Path); SetTemplatePath(); string templateModuleJsonPath = string.Format(CurrentModule.Setting, "/MicroSite/Themes/" + Theme + "/"); string ModuleJsonPath = string.Format(CurrentModule.Setting, "/MicroSite/Modules/"); if (CurrentModule.IsHomePage) { ModuleJsonPath = string.Format(CurrentModule.Setting, "/MicroSite/"); } string moduleJsonPhysicalPath = Server.MapPath(ModuleJsonPath); string templateModuleJsonPhysicalPath = Server.MapPath(templateModuleJsonPath); ModuleFields = new List <ModuleField>(); if (File.Exists(templateModuleJsonPhysicalPath)) { string moduleFieldJson = File.ReadAllText(templateModuleJsonPhysicalPath, System.Text.Encoding.UTF8); ModuleFields = JsonConvert.DeserializeObject <List <ModuleField> >(moduleFieldJson); } else { string moduleFieldJson = File.ReadAllText(moduleJsonPhysicalPath, System.Text.Encoding.UTF8); ModuleFields = JsonConvert.DeserializeObject <List <ModuleField> >(moduleFieldJson); } string text = System.IO.File.ReadAllText(Server.MapPath(TemplatePath)); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); foreach (Module module in modules) { context.TempData[module.Code] = module.Path + "?ID=" + SiteID; } foreach (ModuleField moduleField in ModuleFields) { if (moduleField.CanModified) { context.TempData[moduleField.Code] = moduleField.Value; } } context.TempData["siteid"] = SiteID; context.TempData["sitecode"] = SiteCode; context.TempData["SiteUrl"] = "/MicroSite/"; context.TempData["SiteModuleUrl"] = "/MicroSite/Modules/"; AddTempData(context); JinianNet.JNTemplate.Template template = new JinianNet.JNTemplate.Template(context, text); template.Render(Response.Output); }
protected void Page_Load(object sender, EventArgs e) { string strSiteID = string.Empty; string strSiteCode = string.Empty; string strTitle = string.Empty; string strTheme = string.Empty; string strAlbumTypeID = string.Empty; string strOpenID = string.Empty; //if (null == Request.QueryString["ID"]) //{ // return; //} //if (null == Request.QueryString["OpenID"]) //{ // return; //} //strSiteCode = Common.Common.NoHtml(Request.QueryString["ID"].ToString()); //if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25) //{ // strOpenID = Common.Common.NoHtml(Request.QueryString["openid"].ToString()); //} //else //{ // strOpenID = Request.QueryString["openid"].ToString(); //} if (null == Request["state"] || Request["state"] == "") { return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } } Session["OpenID"] = strOpenID; //取站点信息 DAL.SYS.AccountDAL dalAccount = new DAL.SYS.AccountDAL(); DAL.Album.PhotoList dalPhotoList = new DAL.Album.PhotoList(); DataSet dsAccount = dalAccount.GetAExtDataBySiteCode(strSiteCode); if (null != dsAccount && dsAccount.Tables.Count > 0 && dsAccount.Tables[0].Rows.Count > 0) { strTheme = dsAccount.Tables[0].Rows[0]["Themes"].ToString(); strTitle = dsAccount.Tables[0].Rows[0]["Name"].ToString(); strSiteCode = dsAccount.Tables[0].Rows[0]["SiteCode"].ToString(); strSiteID = dsAccount.Tables[0].Rows[0]["ID"].ToString(); Session["strSiteCode"] = dsAccount.Tables[0].Rows[0]["SiteCode"].ToString(); } //取站点相册列表 DataSet dsPhotoList = dalPhotoList.GetPhotoList(strSiteCode); List <Model.Album.PhotoList> liPhotoList = new List <Model.Album.PhotoList>(); if (null != dsPhotoList && dsPhotoList.Tables.Count > 0 && dsPhotoList.Tables[0].Rows.Count > 0) { foreach (DataRow row in dsPhotoList.Tables[0].Rows) { Model.Album.PhotoList model = DataConvert.DataRowToModel <Model.Album.PhotoList>(row); liPhotoList.Add(model); } } //读取模板内容 string text = string.Empty; if (!File.Exists(Server.MapPath("Themes/" + strTheme + "/PhotoWall.html"))) { text = System.IO.File.ReadAllText(Server.MapPath("Themes/PhotoWall/PhotoWall.html")); } else { text = System.IO.File.ReadAllText(Server.MapPath("Themes/" + strTheme + "/PhotoWall.html")); } JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["title"] = strTitle; context.TempData["siteid"] = strSiteID; context.TempData["footer"] = "奥琦微商易"; context.TempData["sitecode"] = strSiteCode; context.TempData["AlbumTypelist"] = liPhotoList; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
protected void Page_Load(object sender, EventArgs e) { string strTitle = string.Empty; string strTheme = string.Empty; string strCustID = string.Empty; if (null == Request.QueryString["sitecode"]) { return; } if (null == Request.QueryString["openid"]) { return; } string strSiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString()); string strOpenID = string.Empty; if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25) { strOpenID = Common.Common.NoHtml(Request.QueryString["openid"].ToString()); return; } else { strOpenID = Request.QueryString["openid"].ToString(); } DAL.SYS.AccountDAL dalAccount = new DAL.SYS.AccountDAL(); DataSet ds = dalAccount.GetAExtDataBySiteCode(strSiteCode); if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { strTheme = ds.Tables[0].Rows[0]["Themes"].ToString(); strTitle = ds.Tables[0].Rows[0]["Name"].ToString(); Session["strSiteCode"] = ds.Tables[0].Rows[0]["SiteCode"].ToString(); } //会员卡判断处理 DAL.SYS.CustomerDAL dalCust = new DAL.SYS.CustomerDAL(); DAL.Site.SiteMemberNoDAL dalMemNo = new DAL.Site.SiteMemberNoDAL(); string strCustNo = dalCust.GetCustMemberShipNo(strSiteCode, strOpenID); string strMemNO = string.Empty; if (strCustNo == "0" || strCustNo == "-1") { strMemNO = dalMemNo.GetMemberShipNo(strSiteCode); if (strCustNo == "-1") //没有用户记录 { //插入用户记录 Model.SYS.SYS_Customer modelAdd = new Model.SYS.SYS_Customer { ID = Guid.NewGuid().ToString("N").ToUpper(), Mobile = "", Name = "", PassWord = "", OpenID = strOpenID, SiteCode = strSiteCode, MemberShipNo = strMemNO }; if (!dalCust.AddCustomerData(modelAdd)) { return; } } if (strCustNo == "0") //有用户记录,没有会员账号 { //写入用户账号 strMemNO = dalMemNo.GetMemberShipNo(strSiteCode); dalCust.UpdateCutMemberShipNo(strSiteCode, strOpenID, strMemNO); } //修改站点账户状态 dalMemNo.UpdateMemNoState(strSiteCode, strMemNO, "1"); } if (strCustNo == "0" || strCustNo == "-1") { strCustNo = dalCust.GetCustMemberShipNo(strSiteCode, strOpenID); } //取最近的消费记录 //读取模板内容 string text = string.Empty; if (!File.Exists(Server.MapPath("Themes/" + strTheme + "/MemberShip.html"))) { text = System.IO.File.ReadAllText(Server.MapPath("Themes/MemberShip/MemberShip.html")); } else { text = System.IO.File.ReadAllText(Server.MapPath("Themes/" + strTheme + "/MemberShip.html")); } JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); Common.QRCode qr = new Common.QRCode(); //context.TempData["qrcode"] = qr.GetQRCode("http://114.215.108.27/WebService/CustMemNo.aspx?SiteCode=" + strSiteCode + "&MemNo=" + strCustNo + "&OpenId=" + strOpenID); context.TempData["qrcode"] = qr.GetImageQRCode("http://114.215.108.27/WebService/CustMemNo.aspx?SiteCode=" + strSiteCode + "&MemNo=" + strCustNo + "&OpenId=" + strOpenID); context.TempData["memno"] = strCustNo; context.TempData["title"] = strTitle; context.TempData["siteid"] = Session["siteid"]; context.TempData["footer"] = "奥琦微商易"; context.TempData["sitecode"] = Session["strSiteCode"].ToString(); JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }