xuzhiheng 5 anni fa
parent
commit
240a15321e

+ 12 - 0
src/jfw/modules/datareport/src/service/reportOrder.go

@@ -2,6 +2,7 @@ package service
 
 import (
 	. "api"
+	"encoding/base64"
 	"encoding/json"
 	"entity"
 	"log"
@@ -10,6 +11,7 @@ import (
 	"time"
 	"util"
 
+	"github.com/SKatiyar/qr"
 	"github.com/go-xweb/xweb"
 )
 
@@ -49,6 +51,11 @@ func (this *ReportOrder) GetPayParam() {
 		if payStr != "" && payway == (*r)["pay_way"] {
 			prepayTime, err := time.ParseInLocation(qutil.Date_Full_Layout, qutil.ObjToString((*r)["prepay_time"]), time.Local)
 			surplus_second := prepayTime.Unix() + 7200 - time.Now().Unix()
+			if payway == "wx_pc" {
+				r, _ := qr.Encode(payStr.(string), qr.M)
+				pngdat := r.PNG()
+				payStr = base64.StdEncoding.EncodeToString(pngdat)
+			}
 			if err == nil && surplus_second > 0 {
 				return "", map[string]interface{}{
 					"payStr":  payStr,
@@ -62,6 +69,11 @@ func (this *ReportOrder) GetPayParam() {
 			log.Println(err)
 			return "创建订单出错", nil
 		}
+		if payway == "wx_pc" {
+			r, _ := qr.Encode(payStr.(string), qr.M)
+			pngdat := r.PNG()
+			payStr = base64.StdEncoding.EncodeToString(pngdat)
+		}
 		return "", map[string]interface{}{
 			"payStr":  payStr,
 			"timeout": 7200,

+ 4 - 3
src/web/templates/course/pc/orderPay.html

@@ -429,14 +429,14 @@
 							alert("请求有误")
 						}
 					})
-			}else if(pageName==="datarepot"){
+			}else if(pageName==="datareport"){
 				$(".t_left").text("订单已提交成功,请尽快支付")
 				$.post("/datareport/api/pay", {
 					payway: payWay,
 					ordercode: orderCode
 				}, function(r) {
-					if (r.error_code === 0) {
-						showCode(r.payUrl, r.timeout);
+					if (r.data) {
+						showCode(r.data.payStr, r.data.timeout);
 					}
 				})
 			}else{
@@ -454,6 +454,7 @@
 		}
 		//展示支付码 并倒计时
 		function showCode(code, prepaytime) {
+			console.log(code)
 			if (payWay == "wx_pc") {
 				$(".pay_content .con").eq(0).find(".qrcode_box").html("<img src='data:image/png;base64," + code + "'>");
 			} else {