wangshan 5 жил өмнө
parent
commit
ddbbfe30ae

+ 24 - 1
src/jfw/front/dataExport.go

@@ -40,6 +40,8 @@ type DataExport struct {
 	checkPhoneVerify  xweb.Mapper `xweb:"/front/dataExport/checkPhoneVerify"`       //验证手机号
 
 	fontSet xweb.Mapper `xweb:"/front/dataExport/fontSet/(.*)"`
+
+	cancelOrder xweb.Mapper `xweb:"/front/dataExport/cancelOrder"` //取消订单
 }
 
 var order_pageSize = 10
@@ -53,6 +55,7 @@ var (
 	orderStatus_unPaid  = "0"                //订单状态-待支付
 	orderStatus_paid    = "1"                //订单状态-已完成
 	orderStatus_deleted = "-1"               //订单状态-已删除
+	orderStatus_cancel  = "-2"               //订单状态-已取消
 	tableName_order     = "dataexport_order" //订单表
 )
 
@@ -167,7 +170,7 @@ func (d *DataExport) ToMyOrder() error {
 }
 
 func (d *DataExport) QueryOrder() error {
-	typ := d.GetString("type") //0-全部 1-待支付 2-已支付
+	typ := d.GetString("type") //0-全部 1-待支付 2-已支付 3-已取消
 	query := map[string]interface{}{}
 	if userId := d.GetSession("userId"); userId != nil {
 		query["user_id"] = userId.(string)
@@ -182,6 +185,8 @@ func (d *DataExport) QueryOrder() error {
 			status = orderStatus_unPaid
 		} else if typ == "2" {
 			status = orderStatus_paid
+		} else if typ == "3" {
+			status = orderStatus_cancel
 		}
 		query["order_status"] = status
 	} else {
@@ -237,6 +242,24 @@ func (d *DataExport) QueryOrder() error {
 
 /**
 
+根据 id+openid 取消订单
+*/
+func (d *DataExport) CancelOrder() error {
+	if userId := d.GetSession("userId"); userId != nil {
+		//	if openid := d.GetSession("s_m_openid"); openid != nil {
+		queryMap := map[string]interface{}{
+			"id":      d.GetString("id"),
+			"user_id": userId.(string),
+		}
+		boo := public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -2})
+		//取消订单
+		d.ServeJson(map[string]interface{}{"success": boo})
+	}
+	return nil
+}
+
+/**
+
 根据 id+openid 删除
 */
 func (d *DataExport) DeleteOrder() error {

+ 10 - 5
src/web/staticres/dataExport/css/drder_details.css

@@ -42,9 +42,9 @@
 
 #drder .list ul li .info a { font-size: 20px; color: #AAAAAA; width: 16px; height: 16px; margin-right: 20px; }
 
-#drder .list ul li .iner ul { height: 102px; box-sizing: border-box; overflow: hidden; border: 1px solid #ccc; margin-bottom: 20px; padding: 0 0 0 24px; font-size: 14px; color: #1d1d1d; }
+#drder .list ul li .iner ul { height: 125px; box-sizing: border-box; overflow: hidden; border: 1px solid #ccc; margin-bottom: 20px; padding: 0 0 0 24px; font-size: 14px; color: #1d1d1d; }
 
-#drder .list ul li .iner ul li { float: left; box-sizing: border-box; margin: 18px 0 18px 0; }
+#drder .list ul li .iner ul li { float: left; box-sizing: border-box; margin: 28px 0 28px 0; }
 
 #drder .list ul li .iner ul li:nth-of-type(1) { width: 360px; }
 
@@ -60,17 +60,17 @@
 
 #drder .list ul li .iner ul li:nth-of-type(4) { width: 190px; text-align: center; line-height: 66px; height: 66px; }
 
-#drder .list ul li .iner ul li:nth-of-type(5) { margin: 0; width: 150px; height: 100px; border-left: 1px solid #ccc; border-right: 1px solid #ccc; font-size: 16px; font-weight: bold; line-height: 100px; text-align: center; }
+#drder .list ul li .iner ul li:nth-of-type(5) { margin: 0; width: 150px; height: 125px; border-left: 1px solid #ccc; border-right: 1px solid #ccc; font-size: 16px; font-weight: bold; line-height: 125px; text-align: center; }
 
 #drder .list ul li .iner ul li:nth-of-type(6) { width: 150px; font-size: 14px; color: #1d1d1d; }
 
-#drder .list ul li .iner ul li:nth-of-type(6) p { width: 100%; text-align: center; margin-bottom: 8px; }
+#drder .list ul li .iner ul li:nth-of-type(6) p { width: 100%; text-align: center; margin-bottom: 8px;     margin-top: -10px;}
 
 #drder .list ul li .iner ul li:nth-of-type(6) .xq { width: 100%; display: block; text-align: center; font-size: 14px; color: #1d1d1d; margin-bottom: 4px; }
 
 #drder .list ul li .iner ul li:nth-of-type(6) .xq:hover { color: #2CB7CA; }
 
-#drder .list ul li .iner ul li:nth-of-type(6) .pay { text-align: center; width: 100%; display: block; font-size: 14px; color: #fff; width: 90px; height: 30px; line-height: 30px; background-color: #2CB7CA; text-align: center; border-radius: 4px; margin-left: 28px; }
+#drder .list ul li .iner ul li:nth-of-type(6) .pay { text-align: center; width: 100%; display: block; font-size: 14px; color: #fff; width: 90px; height: 30px; line-height: 30px; background-color: #2CB7CA; text-align: center; border-radius: 4px; margin-left: 28px;    margin-bottom: 5px; }
 
 #drder .list ul li .iner ul li:nth-of-type(6) .wc { font-size: 14px; color: #1d1d1d; margin-top: 12px; }
 
@@ -78,6 +78,11 @@
 
 #drder .list ul li .iner ul li:nth-of-type(6) .wcxq:hover { color: #2CB7CA; }
 
+#drder .list ul li .iner ul li:nth-of-type(6) .qx { width: 100%; display: block; text-align: center; font-size: 12px; color: #1d1d1d; }
+
+#drder .list ul li .iner ul li:nth-of-type(6) .qx:hover { color: #2CB7CA; }
+
+
 /*# sourceMappingURL=drder_details.css.map */
 
 /* 微信支付样式 */

+ 84 - 10
src/web/templates/pc/myOrder.html

@@ -146,6 +146,7 @@
 					<li class="active">全部</li>
 					<li>待付款</li>
 					<li>已完成</li>
+					<li>已取消</li>
 				</ul>
 			</div>
 			<div class="title-bar">
@@ -165,6 +166,8 @@
 				</ul>
 				<ul class="item clearfix">
 				</ul>
+				<ul class="item clearfix">
+				</ul>
 			</div>
 
 			<!--分页
@@ -277,7 +280,7 @@
 				"</div>" +
 				"</div>";
 
-			//ind 0-全部 1-待支付 2-已支付
+			//ind 0-全部 1-待支付 2-已支付 3-已取消
 			function queryOrder(ind, objD, pageNum) {
 				$.ajax({
 					type: "post",
@@ -353,16 +356,26 @@
 										"<p>待付款</p>" +
 										"<a class=\"xq\" onclick=\"toDetail('" + orderCode + "');\" target=\"_blank\">查看详情</a>" +
 										"<a class=\"pay\" orderCode='" + orderCode + "' money='" + orderMoney + "' payway='" + payway + "' code='" +
-										code + "' time='" + prepaytime + "' onclick=toPay(this)>去支付</a>";
+										code + "' time='" + prepaytime + "' onclick=toPay(this)>去支付</a>" +
+										"<a class=\"qx\" orderCode='" + orderCode + "' onclick=\"toCancel(" + id +
+										",this)\" target=\"_blank\">取消订单</a>";
 									cla = "nopay";
-									deleteOrderHtml = "<a class=\"fr iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id +
+									deleteOrderHtml = "<a class=\"fr iconfont  icon-shanchu\"  style=\"display:none\" title=\"删除订单\" onclick=\"deleteOrder(" + id +
 										",this)\"></a>";
 								} else if (orderStatus == 1) {
 									orderStatusHtml +=
 										"<p class=\"wc\">已完成</p>" +
 										"<a class=\"wcxq\" onclick=\"toDetail('" + orderCode + "');\" target=\"_blank\">查看详情</a>";
 									cla = "pay";
-									deleteOrderHtml = "<a class=\"fr iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id +
+									deleteOrderHtml = "<a class=\"fr iconfont  icon-shanchu\"  style=\"display:none\" title=\"删除订单\" onclick=\"deleteOrder(" + id +
+										",this)\"></a>";
+
+								}else if (orderStatus == -2) {
+									orderStatusHtml +=
+										"<p class=\"wc\">已取消</p>" +
+										"<a class=\"wcxq\" onclick=\"toDetail('" + orderCode + "');\" target=\"_blank\">查看详情</a>";
+									cla = "pay";
+									deleteOrderHtml = "<a class=\"fr iconfont  icon-shanchu\" style=\"display:none\" title=\"删除订单\" onclick=\"deleteOrder(" + id +
 										",this)\"></a>";
 
 								}
@@ -414,13 +427,26 @@
 							temp = noDataHtml;
 						}
 						objD.eq(ind).html(temp);
+						initHover();
 					},
 					error: function(xhr, type) {
 						console.log("query err");
 					}
 				});
 			}
-
+			//
+			function initHover(){
+				$(".list .item").each(function(){
+					$(this).children("li").each(function(){
+						$(this).hover(function(){
+									    $(this).find(".info a").fadeIn();
+									},function(){
+									    $(this).find(".info a").fadeOut();
+									});
+					})
+				})
+			}
+			//
 			function deleteOrder(id, obj) {
 				$.confirm({
 					title: '订单删除',
@@ -450,10 +476,10 @@
 														text: '确认',
 														btnClass: 'btn-primary-0',
 														action: function() {
-                              var $Index = $(".tab-bar .tab li.active").index();
-                      				var $list = $(".list .item");
-                              pageFlag=true;
-                      				queryOrder($Index, $list, 1);
+								                            var $Index = $(".tab-bar .tab li.active").index();
+								                      		var $list = $(".list .item");
+								                            pageFlag=true;
+								                      		queryOrder($Index, $list, 1);
 														}
 													}
 												}
@@ -492,7 +518,55 @@
 			function toDetail(orderCode) {
 				window.open("/front/dataExport/toOrderDetail/" + orderCode);
 			}
-
+			//取消订单
+			function toCancel(id, obj) {
+				orderCode = $(obj).attr("orderCode");
+				$.confirm({
+					title: '订单取消',
+					content: '您确定要取消该订单吗?',
+					buttons: {
+						ok: {
+							text: '确认',
+							btnClass: 'btn-primary-0',
+							action: function() {
+								$.ajax({
+									type: "post",
+									url: "/front/dataExport/cancelOrder",
+									data: {
+										"id": id
+									},
+									dataType: 'json',
+									success: function(data) {
+										if (data && data["success"]) {
+											var self = $(obj).parent();
+											self.html('<p class="wc">已取消</p><a class="wcxq" onclick="toDetail(\'' + orderCode + '\');" target="_blank">查看详情</a>');
+											$.alert({
+												title: "",
+												content: "取消成功!",
+												buttons: {
+													ok: {
+														text: '确认',
+														btnClass: 'btn-primary-0'
+													}
+												}
+											});
+										} else {
+											alertS("取消失败,请联系管理员!");
+										}
+									},
+									error: function(xhr, type) {
+										console.log("cancel err");
+									}
+								});
+							}
+						},
+						cancel: {
+							text: '取消',
+							btnClass: 'btn-primary-0'
+						}
+					}
+				});
+			}
 			function FormatNum(n) {
 				var isF = /^-?\d*\.\d+$/.test(n);
 				var n2 = "";