浏览代码

Merge branch 'dev2.8' of http://192.168.3.207:10080/qmx/jy into dev2.8

zhangxinlei1996 6 年之前
父节点
当前提交
5a773b60d8

+ 1 - 1
src/jfw/front/ws_dataExport.go

@@ -75,7 +75,7 @@ func (w *WsDataExport) GetPayParm() error {
 
 	realToken := public.GetWaitPayToken(orderid, orderMoney, code, userid)
 	if realToken != token {
-		log.Println("token错误!", userid, realToken, token, code)
+		log.Println("token错误!", userid, realToken, token, code, orderMoney, orderid)
 		return nil
 	}
 	prepayTime, err := time.ParseInLocation(util.Date_Full_Layout, util.ObjToString((*Order)["prepay_time"]), time.Local)

+ 8 - 5
src/jfw/front/wxMyOrder.go

@@ -190,6 +190,7 @@ func (w *WxMyOrder) WxToOrderDetail() error {
 	} else {
 		return errors.New("未登录")
 	}
+	userid, _ := w.Session().Get("userId").(string)
 	orderCode := w.GetString("orderCode")
 	//分享
 	w.T["signature"] = wx.SignJSSDK(w.Site() + w.Url())
@@ -212,14 +213,9 @@ func (w *WxMyOrder) WxToOrderDetail() error {
 	if orderDetail["pay_money"] != nil {
 		orderDetail["pay_money"] = float64(orderDetail["pay_money"].(int64)) / 100
 	}
-	if orderDetail["order_money"] != nil {
-		orderDetail["order_money"] = float64(orderDetail["order_money"].(int64)) / 100
-	}
-	orderDetail["filter_id"] = util.SE.Encode2Hex(orderDetail["filter_id"].(string))
 	if orderDetail["filter"] != nil {
 		err := json.Unmarshal([]byte(orderDetail["filter"].(string)), &filter)
 		if err == nil {
-			//filter.Id = util.SE.Encode2Hex(filter.Id)
 			publishtime := filter.PublishTime
 			if publishtime != "" {
 				timeArr := strings.Split(publishtime, "_")
@@ -249,6 +245,13 @@ func (w *WxMyOrder) WxToOrderDetail() error {
 	} else {
 		orderDetail["applybill_status"] = "F" //未申请
 	}
+	orderMoney := orderDetail["order_money"]
+	if orderMoney != nil {
+		orderDetail["order_money"] = float64(orderMoney.(int64)) / 100
+	}
+	if orderDetail["id"] != nil && orderMoney != nil && orderDetail["order_code"] != nil {
+		orderDetail["token"] = public.GetWaitPayToken(orderDetail["id"].(int64), int(orderMoney.(int64)), orderDetail["order_code"].(string), userid)
+	}
 	//加密
 	orderDetail["filter_id"] = util.SE.Encode2Hex(orderDetail["filter_id"].(string))
 	orderStatus := util.IntAll((orderDetail)["order_status"])

+ 15 - 0
src/web/staticres/wx_dataExport/css/base.css

@@ -94,4 +94,19 @@ em,i{
 }
 .hide{
 	display: none;
+}
+
+.easyalert{
+	position: fixed;
+	background-color: rgba(0,0,0,0.7);
+	top: 50%;
+	color: #fff;
+	z-index: 999;
+	border-radius: 6px;
+	padding: 17px 20px;
+    font-size: 15px;
+	line-height: 22px;
+	max-width: 260px;
+	text-align: center;
+	display: none;
 }

+ 0 - 14
src/web/staticres/wx_dataExport/css/pay_order.css

@@ -477,20 +477,6 @@ letter-spacing: 0.02rem;
 	right: 2.3rem !important;
 }
 
-.easyalert{
-	position: fixed;
-	background-color: rgba(0,0,0,0.7);
-	top: 50%;
-	color: #fff;
-	z-index: 999;
-	border-radius: 6px;
-	padding: 17px 20px;
-    font-size: 15px;
-	line-height: 22px;
-	max-width: 260px;
-	text-align: center;
-	display: none;
-}
 
 body .loading_ {
     height: 100%;

+ 22 - 0
src/web/templates/weixin/dataExport/dataExport_toMyOrder.html

@@ -155,6 +155,28 @@
 					}
 				});
 			}
+			//提示框
+			var EasyAlert = {
+				timeout: null,
+				waitTime: 1000,
+				show: function(text,css,waitTime){
+					if(this.timeout != null){
+						clearTimeout(this.timeout);
+						this.hide();
+						this.timeout = null;
+					}
+					var thisClass = this;
+					this.timeout = setTimeout(function(){
+						thisClass.hide();
+						thisClass.timeout = null;
+					},waitTime?waitTime:this.waitTime);
+					$("body").append('<div class="easyalert" id="easyAlert">'+text+'</div>');
+					$("#easyAlert").css({"left":"50%","margin-top":-($("#easyAlert").outerHeight()/2),"margin-left":-($("#easyAlert").outerWidth()/2)}).show();
+				},
+				hide: function(){
+					$("#easyAlert").remove();
+				}
+			}
 		</script>
 	</head>
 	<body>

+ 87 - 6
src/web/templates/weixin/dataExport/dataExport_toOrderDetail.html

@@ -17,6 +17,91 @@
 	<body>
 		<script>
 			initShare({{.T.signature}},{{.T.openid}},2,"jy_wxmyorder",{{.T.nickname}},{{.T.avatar}});
+			
+			var signature = {{.T.signature}};
+			var isConfigSuccess = true;
+			var id = {{.T._id}}
+			if(signature && signature.length == 4){
+				wx.config({
+				    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+				    appId: signature[0], // 必填,公众号的唯一标识
+				    timestamp:signature[1], // 必填,生成签名的时间戳
+				    nonceStr: signature[2], // 必填,生成签名的随机串
+				    signature: signature[3],// 必填,签名,见附录1
+				    jsApiList: ['chooseWXPay','hideAllNonBaseMenuItem'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+				});
+				wx.ready(function () {
+					if(!isConfigSuccess){
+						return;
+					}
+					wx.hideAllNonBaseMenuItem();
+			    });
+				wx.error(function(res){
+				    //config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
+					isConfigSuccess = false;
+				});
+			}
+			//调用微信支付接口
+			function onBridgeReady(res){
+			   	WeixinJSBridge.invoke('getBrandWCPayRequest',{
+			    		"appId": res["appId"],
+			          	"timeStamp": res["timestamp"],
+			          	"nonceStr": res["nonceStr"],
+			          	"package": res["prepayId"],
+			          	"signType": res["signType"],
+			         	"paySign": res["sign"]
+					},
+					function(r){
+				        if(r.err_msg == "get_brand_wcpay_request:ok"){
+							$(".bottomButton").attr("id","buytwo").text("再次购买");
+						}else if(r.err_msg == "get_brand_wcpay_request:cancel"){
+							//取消支付 可以再次支付
+							canpay=true;
+							isReqing = false;
+						}else{
+							EasyAlert.show("系统异常,请稍微再试","",3000);
+					}
+				});
+			}
+			//
+			var isReqing = false;
+			function goPay(){
+				var filterid = {{.T.o.filter_id}};
+				var token = {{.T.o.token}};
+				if(isReqing){
+					return;
+				}
+				isReqing = true;
+				$.post("/front/wx_dataExport/getPayParm",{"id":filterid,"token":token},function(res){
+					isReqing = false;
+					if(res.status == 1){
+						onBridgeReady(res);
+					}
+				});
+			}
+			//提示框
+			var EasyAlert = {
+				timeout: null,
+				waitTime: 1000,
+				show: function(text,css,waitTime){
+					if(this.timeout != null){
+						clearTimeout(this.timeout);
+						this.hide();
+						this.timeout = null;
+					}
+					var thisClass = this;
+					this.timeout = setTimeout(function(){
+						thisClass.hide();
+						thisClass.timeout = null;
+					},waitTime?waitTime:this.waitTime);
+					$("body").append('<div class="easyalert" id="easyAlert">'+text+'</div>');
+					$("#easyAlert").css({"left":"50%","margin-top":-($("#easyAlert").outerHeight()/2),"margin-left":-($("#easyAlert").outerWidth()/2)}).show();
+				},
+				hide: function(){
+					$("#easyAlert").remove();
+				}
+			}
+			//
 			$(function(){
 				var filter={{.T.o.filter}};
 				if (filter){
@@ -149,10 +234,6 @@
 				}else{
 					$(".person_").show();
 				}
-				
-				 $("#buy").click(function(){
-	            	window.location.href="/weixin/pay/dataexport?id={{.T.o.filter_id}}&source=d";
-	            })
 			});
 			
 			
@@ -312,9 +393,9 @@
 						</div>
 					</div>
 					{{if .T.o.pay_time}}
-					<div class="button align" id="buytwo">再次购买</div>
+					<div class="button align bottomButton" id="buytwo">再次购买</div>
 					{{else}}
-					<div class="button align" id="buy">去支付</div>
+					<div class="button align bottomButton" id="buy" onclick="goPay()">去支付</div>
 					{{end}}
 				</div>
 			</main>