protected void Page_Load(object sender, EventArgs e) { string strProductID = string.Empty; string strSiteCode = string.Empty; string strOpenID = string.Empty; if (null == Request.QueryString["id"]) { return; } if (null == Request.QueryString["sitecode"]) { return; } if (null == Request.QueryString["openid"]) { return; } strProductID = Common.Common.NoHtml(Request.QueryString["id"].ToString()); strSiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString()); if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25) { return; } else { strOpenID = Request.QueryString["openid"].ToString(); } DAL.MiniShop.MSProductDAL dal = new DAL.MiniShop.MSProductDAL(); DataSet ds = dal.GetProductByID(strProductID); Model.MiniShop.MSVProduct model = new Model.MiniShop.MSVProduct(); if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { model = DataConvert.DataRowToModel <Model.MiniShop.MSVProduct>(ds.Tables[0].Rows[0]); } //读取模板内容 string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Default/VProductDetail.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["sitecode"] = strSiteCode; context.TempData["openid"] = strOpenID; context.TempData["title"] = "商品详细信息"; context.TempData["pDetail"] = model; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
protected void Page_Load(object sender, EventArgs e) { string strSiteCode = string.Empty; string strOpenID = string.Empty; if (null == Request.QueryString["state"]) { return; } else { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); } 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; } } else { strOpenID = code; } } strOpenID = code; List <Model.MiniShop.MSVProduct> liProduct = new List <Model.MiniShop.MSVProduct>(); DAL.MiniShop.MSProductDAL dalProduct = new DAL.MiniShop.MSProductDAL(); DataSet ds = dalProduct.GetProductListBySiteCode(strSiteCode); foreach (DataRow row in ds.Tables[0].Rows) { Model.MiniShop.MSVProduct model = DataConvert.DataRowToModel <Model.MiniShop.MSVProduct>(row); liProduct.Add(model); } //读取模板内容 string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Default/VProductList.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["sitecode"] = strSiteCode; context.TempData["openid"] = strOpenID; context.TempData["product_list"] = liProduct; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }