plf 3 năm trước cách đây
mục cha
commit
80e4c22b39
1 tập tin đã thay đổi với 64 bổ sung69 xóa
  1. 64 69
      src/main/webapp/static/modules/bulkpurchase/orderForm.js

+ 64 - 69
src/main/webapp/static/modules/bulkpurchase/orderForm.js

@@ -12,15 +12,15 @@ var totalCoupons = [];
 // 当前商品可用优惠券
 var selectCoupons = [];
 // 勾选后的优惠金额
-var couponPrice = $("#couponAmount").val()*1;
+var couponPrice = 0;
 // 添加订单true,修改订单false
 var initFlag = true;
-var orderStatus = $("#orderStatus").val()? $("#orderStatus").val()*1 : 0;
-console.log(orderStatus);
+var orderStatus = 0;
 
+$(function() {
     /**  发票信息 start * */
-    // var invoiceTitle=$("#orderInvoice\\.invoiceTitle").val();
-    // if(invoiceTitle !='' && invoiceTitle !=null && invoiceTitle !='null'){
+        // var invoiceTitle=$("#orderInvoice\\.invoiceTitle").val();
+        // if(invoiceTitle !='' && invoiceTitle !=null && invoiceTitle !='null'){
     var type = $("#orderInvoice\\.type").val();
     if (type == '1') {
         $("#invoiceTable").show();
@@ -133,7 +133,8 @@ console.log(orderStatus);
     });
 
     /** 修改订单初始化 */
-    var orderId = $("#orderID").val()*1;
+    var orderId = $("#orderID").val();
+    orderStatus = $("#orderStatus").val();
     if (orderId && orderId > 0) {
         var userId = $("#inputForm").find("[name*='bpOrderUserinfo.userId']").val();
         // 获取用户总优惠券
@@ -220,7 +221,7 @@ console.log(orderStatus);
         });
         initFlag = true;
     }
-
+});
 
 /************************添加会所 start**********************************************************/
 /**
@@ -311,16 +312,13 @@ function setSingleSelect(items) {
 
 function getUserCoupons(userId) {
     totalCoupons = [];
-    // 待确认订单 或新订单 才能修改优惠券
-    if (orderStatus == 0) {
-        $.get($("#ctx").val() + "/order/clubCouponList?userId="+userId, function(data) {
-            if (data.code * 1 === 0) {
-                totalCoupons = data.couponList;
-                // 展示可选优惠券列表
-                getShownCouponList();
-            }
-        })
-    }
+    $.get($("#ctx").val() + "/order/clubCouponList?userId="+userId, function(data) {
+        if (data.code * 1 === 0) {
+            totalCoupons = data.couponList;
+            // 展示可选优惠券列表
+            getShownCouponList();
+        }
+    })
 }
 /************************添加会所 end**********************************************************/
 
@@ -329,27 +327,27 @@ $("#redeemCoupons").on("click",  function(){
     var userId = $("#inputForm").find("[name*='bpOrderUserinfo.userId']").val();
     if (userId && userId*1 > 0) {
         var html = '<div style="text-align:center;padding-top:12px;"><input id="couponsCode" name="couponsCode" type="text" maxlength="16" placeholder="请输入16位兑换码"></div>';
-            var submit = function (v, h, f) {
-                if (f.couponsCode == '' || isNaN(f.couponsCode)) {
-                    $.jBox.tip("请输入兑换码!", 'error', { focusId: "couponsCode" });
-                }
-                var bool = new RegExp("^[A-Za-z0-9]{16}$").test(f.couponsCode);
-                if (!bool) {
-                    // 16位数字和字母
-                    $.jBox.tip("请输入正确的兑换码!", 'error', { focusId: "couponsCode" });
-                }else{
-                    $.post($("#ctx").val() + "/coupon/cmCouponClub/redeem", {'redemptionCode': f.couponsCode, 'userId': userId}, function (data) {
-                        if (0 === data.code*1) {
-                            $.jBox.tip(data.msg, 'info');
-                            // 获取用户总优惠券
-                            getUserCoupons(userId);
-                        } else {
-                            $.jBox.tip(data.msg, 'error');
-                        }
-                    }, "JSON");
-                }
-            };
-            $.jBox(html, { title: "兑换优惠券", buttons: { '立即兑换': true }, submit: submit });
+        var submit = function (v, h, f) {
+            if (f.couponsCode == '' || isNaN(f.couponsCode)) {
+                $.jBox.tip("请输入兑换码!", 'error', { focusId: "couponsCode" });
+            }
+            var bool = new RegExp("^[A-Za-z0-9]{16}$").test(f.couponsCode);
+            if (!bool) {
+                // 16位数字和字母
+                $.jBox.tip("请输入正确的兑换码!", 'error', { focusId: "couponsCode" });
+            }else{
+                $.post($("#ctx").val() + "/coupon/cmCouponClub/redeem", {'redemptionCode': f.couponsCode, 'userId': userId}, function (data) {
+                    if (0 === data.code*1) {
+                        $.jBox.tip(data.msg, 'info');
+                        // 获取用户总优惠券
+                        getUserCoupons(userId);
+                    } else {
+                        $.jBox.tip(data.msg, 'error');
+                    }
+                }, "JSON");
+            }
+        };
+        $.jBox(html, { title: "兑换优惠券", buttons: { '立即兑换': true }, submit: submit });
     } else {
         alertx('请您先选择会所!');
     }
@@ -455,32 +453,29 @@ function getShownCouponList(){
 
 // 设置页面显示
 function setPageCoupon() {
-    // 非待确认订单,不设置优惠券显示
-    if (orderStatus == 0) {
-        var clubCouponId = $("#clubCouponId").val()*1;
-        var html = '<li><label><input type="radio" name="clubCouponId" value="0"><span class="couponDesc none">不使用优惠券</span></label></li>';
-        selectCoupons.forEach(function(item){
-            var checked = '';
-            var redemptionCode = '';
-            if (clubCouponId === item.clubCouponId) {
-                checked = 'checked="checked"';
-            }
-            if (!isNaN(item.redemptionCode)) {
-                redemptionCode = '<span>兑换码:'+item.redemptionCode+'</span>';
-            }
-            html += '<li><label>';
-            html += '       <input type="radio" name="clubCouponId" value="'+item.clubCouponId +'" '+checked+'>';
-            html += '       <span class="couponDesc">';
-            html += '            <span>'+item.couponName+'</span>';
-            html += redemptionCode;
-            html += '            <span>'+item.couponDesc+'</span>';
-            html += '            <span>有效期:'+item.startDate+' - '+item.endDate+'</span>';
-            html += '</span></label></li>';
-        });
-        $("#couponBox").find(".couponContent").html(html);
-        if (clubCouponId > 0) {
-            $("#couponBox").find("input[name=clubCouponId][checked=checked]").trigger("change");
+    var clubCouponId = $("#clubCouponId").val()*1;
+    var html = '<li><label><input type="radio" name="clubCouponId" value="0"><span class="couponDesc none">不使用优惠券</span></label></li>';
+    selectCoupons.forEach(function(item){
+        var checked = '';
+        var redemptionCode = '';
+        if (clubCouponId === item.clubCouponId) {
+            checked = 'checked="checked"';
+        }
+        if (!isNaN(item.redemptionCode)) {
+            redemptionCode = '<span>兑换码:'+item.redemptionCode+'</span>';
         }
+        html += '<li><label>';
+        html += '       <input type="radio" name="clubCouponId" value="'+item.clubCouponId +'" '+checked+'>';
+        html += '       <span class="couponDesc">';
+        html += '            <span>'+item.couponName+'</span>';
+        html += redemptionCode;
+        html += '            <span>'+item.couponDesc+'</span>';
+        html += '            <span>有效期:'+item.startDate+' - '+item.endDate+'</span>';
+        html += '</span></label></li>';
+    });
+    $("#couponBox").find(".couponContent").html(html);
+    if (clubCouponId > 0) {
+        $("#couponBox").find("input[name=clubCouponId][checked=checked]").trigger("change");
     }
 }
 
@@ -845,7 +840,7 @@ function setProductList(data) {
                     .cmPromotion.name + '</em>优惠价:' + data.cmPromotion.touchPrice + '</span>';
             } else if (data.cmPromotion.mode == 2) {
                 cmPromotion = '<span class="tag" data-id="' + tempId + '"><em style="background:#F60">' + data
-                    .cmPromotion.name + '</em>满' + data.cmPromotion.touchPrice + '减' + data.cmPromotion.reducedPrice +
+                        .cmPromotion.name + '</em>满' + data.cmPromotion.touchPrice + '减' + data.cmPromotion.reducedPrice +
                     '</span>';
             } else if (data.cmPromotion.mode == 3) {
                 cmPromotion = '<span class="tag" data-id="' + tempId + '"><em style="background:purple">' + data
@@ -861,7 +856,7 @@ function setProductList(data) {
                 var ladder = '<p><span>起订量</span><span>价格</span></p>';
                 for (var i = 0; i < data.ladderPriceList.length; i++) {
                     ladder += '<p data-num="' + data.ladderPriceList[i].buyNum + '"><span>' + data.ladderPriceList[i]
-                        .buyNumRangeShow + '</span><span class="price">' + data.ladderPriceList[i].buyPrice +
+                            .buyNumRangeShow + '</span><span class="price">' + data.ladderPriceList[i].buyPrice +
                         '</span></p>';
                 }
                 ladderPrice = '<br><a href="javascript:;" class="ladderPrice"><span>阶梯价格</span><div class="list">' +
@@ -869,7 +864,7 @@ function setProductList(data) {
             }
         }
     }
-    
+
     var cmCouponBtn = '---';
     if (data.couponsLogo*1 === 2) {
         cmCouponBtn = '<a href="javascript:;" onclick="showCouponDetail('+ userId +','+ data.productId +')">查看</a>';
@@ -887,7 +882,7 @@ function setProductList(data) {
         (data.discount * 1 === 100 && data.cmPromotion && data.cmPromotion.mode == 1 ? ("<td><del>" + data.price +
             "</del>") : ("<td>" + data.price)) +
         (data.includedTax == 1 ? "<label style='color: red'>(含税)</label>" : data.includedTax == 0 && (data
-                .invoiceType == 1 || data.invoiceType == 2) ? "<label style='color: red'>(不含税-能开票)</label>" : data
+            .invoiceType == 1 || data.invoiceType == 2) ? "<label style='color: red'>(不含税-能开票)</label>" : data
             .includedTax != '' && data.includedTax == 0 && data.invoiceType == 3 ?
             "<label style='color: red'>(不含税-不能开票)</label>" : "") +
         "</td>" +
@@ -1436,7 +1431,7 @@ function taxRateVal(index) {
     var discountPrice = $("#discountPrice" + index).val(); //折后单价
     var $checkItem = eval('(' + $("#check-item" + index).val() + ')');
     if ($checkItem["name"] == '' || $checkItem["name"] == null || $checkItem["name"] == 'null' || typeof($checkItem[
-            "name"]) == "undefined") {
+        "name"]) == "undefined") {
         $checkItem["name"] = $checkItem.purchaseProductName + "";
     }
     var mode = $("#mode" + index).val(); //是否参与优惠活动
@@ -1727,7 +1722,7 @@ function taxRateVal(index) {
                 var shouldPayTotalTax = 0;
                 //(未知商品/不含税可开发票的旧商品)将机构税率赋值给供应商税率
                 if (includedTax == '2' || includedTax == '' || (includedTax == '0' && (invoiceType == '1' ||
-                        invoiceType == '2') && oldProductFlag == '1')) {
+                    invoiceType == '2') && oldProductFlag == '1')) {
                     supplierTaxRate = taxRate;
                 }
                 if (supplierTaxRate > 0) {