protected override void AddTempData(JinianNet.JNTemplate.TemplateContext context) { CouponDAL dal = new CouponDAL(); DataSet ds = dal.GetCouponInfo(CouponID); MyCouponInfo model = new MyCouponInfo(); if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { model = DataConvert.DataRowToModel <MyCouponInfo>(ds.Tables[0].Rows[0]); } this.SetQRCode(context, model.ID); context.TempData["pDetail"] = model; if (model.CouponStatus == "已经使用") { context.TempData["RemainDay"] = ""; } else { if (int.Parse(model.RemainDay) > -1) { context.TempData["RemainDay"] = "有效期:还剩" + model.RemainDay + "天"; } else { context.TempData["RemainDay"] = "有效期:此券已经过期!"; } } }
protected void Page_Load(object sender, EventArgs e) { string strCouponID = string.Empty; string strSiteCode = string.Empty; string strAction = string.Empty; if (null == Request.QueryString["id"]) { return; } if (null != Request.QueryString["action"]) { strCouponID = Common.Common.NoHtml(Request.QueryString["id"].ToString()); strAction = Common.Common.NoHtml(Request.QueryString["action"].ToString()); if (strAction == "checkout") { CheckOutCoupon(strCouponID); } } strCouponID = Common.Common.NoHtml(Request.QueryString["id"].ToString()); CouponDAL dal = new CouponDAL(); DataSet ds = dal.GetCouponInfo(strCouponID); MyCouponInfo model = new MyCouponInfo(); if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { model = DataConvert.DataRowToModel <MyCouponInfo>(ds.Tables[0].Rows[0]); } string text = System.IO.File.ReadAllText(Server.MapPath("QRNotUse.html")); //读取模板内容 if (model.CouponStatus == "未使用") { text = System.IO.File.ReadAllText(Server.MapPath("QRNotUse.html")); } else { text = System.IO.File.ReadAllText(Server.MapPath("QRIsUse.html")); } JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["title"] = "奥琦微商易优惠券"; context.TempData["note"] = model.ActTitle; context.TempData["id"] = strCouponID; context.TempData["content"] = model.Remark; context.TempData["errinfo"] = strCouponInfo; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
protected override void AddTempData(JinianNet.JNTemplate.TemplateContext context) { base.AddTempData(context); CouponDAL dal = new CouponDAL(); DataSet ds = dal.GetCouponInfo(CouponID); MyCouponInfo model = new MyCouponInfo(); if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { model = DataConvert.DataRowToModel <MyCouponInfo>(ds.Tables[0].Rows[0]); } //读取模板内容 //string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Default/" + strReHtml)); //JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); if (strReHtml == "RushBuyOK.html" || strReHtml == "QJTVRushBuyOK.html") { this.SetQRCode(context, model.ID); context.TempData["pDetail"] = model; if (model.CouponStatus == "已经使用") { context.TempData["RemainDay"] = ""; } else { if (int.Parse(model.RemainDay) > -1) { context.TempData["RemainDay"] = "有效期:还剩" + model.RemainDay + "天"; } else { context.TempData["RemainDay"] = "有效期:此券已经过期!"; } } } else { #region 消费完成发生消息 string strAppID = string.Empty; string strSecret = string.Empty; Model.WeiXin.WXConfig wc = new Model.WeiXin.WXConfig(); WXConfigDAL wcdal = new WXConfigDAL(); wc = wcdal.GetWXConfigBySiteCode(SiteCode); if (null != wc) { strAppID = wc.WXAppID; strSecret = wc.WXAppSecret; } string strToken = WeiXinHelper.GetAccessToken(strAppID, strSecret); var KeyToken = new { access_token = "" }; var b = JsonConvert.DeserializeAnonymousType(strToken, KeyToken); string strRToken = b.access_token; WeiXinHelper.SendCustomTextMessage(strRToken, OpenID, strMessage); #endregion //Response.Write("<script>document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() { WeixinJSBridge.call('closeWindow');});</script>"); //Response.Redirect("MyCoupon.aspx?SiteCode=" + strSiteCode + "&OpenID=" + strOpenID); //return; } context.TempData["strmsg"] = strMessage; context.TempData["OpenID"] = OpenID; }