package front import ( "errors" "github.com/go-xweb/xweb" "jfw/wx" ) /* 微信公众号支付公共页面 */ type WxPayCommon struct { *xweb.Action toCreateOrderPage xweb.Mapper `xweb:"/weixin/pay/checkout_(.*)"` //微信数据导出-支付页面 paySuccess xweb.Mapper `xweb:"/weixin/(\\w+)/paySuccess"` //微信支付-支付完成 } func init() { xweb.AddAction(&WxPayCommon{}) } func (w *WxPayCommon) ToCreateOrderPage(doType string) error { orderCode := w.GetString("orderCode") if orderCode == "" || doType == "" { return errors.New("未知订单") } w.T["doType"] = doType w.T["orderCode"] = orderCode w.T["signature"] = wx.SignJSSDK(w.Site() + w.Url()) return w.Render("/weixin/commonPay/checkout.html", &w.T) } func (w *WxPayCommon) PaySuccess(doType string) error { //获取参数 w.T["orderCode"] = w.GetString("orderCode") w.T["payTime"] = w.GetString("payTime") w.T["email"] = w.GetString("email") if doType == "dataexport" { return w.Render("/weixin/dataExport/dataExport_paySuccess.html", &w.T) } w.T["doType"] = doType return w.Render("/weixin/commonPay/paySuccess.html", &w.T) }