diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index 0367d4f..f9ae1e0 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -120,7 +120,8 @@ Page({ wx.setNavigationBarTitle({ title: "填写订单",}) var th = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,}); th.data.param=t; - + //清理一下,确保最新的系统配置 + getApp().globalData.config2=null; //清空is_pick_up getApp().request.put("/api/weshop/useraddress/updatePickUp", { data: {user_id: getApp().globalData.user_id, is_pickup: 0}, @@ -207,11 +208,13 @@ Page({ },500)--*/ }); - //--更新默认地址--,看一下是不是跳到地址页面 - if(!getApp().globalData.is_cart_old){ + var is_card_back=getApp().globalData.is_card_back; + //--更新默认地址--,看一下是不是跳到地址页面,同时也不是购买等级卡返回的,这里很重要,否则会重新更新收货物流公司 + if(!getApp().globalData.is_cart_old && !is_card_back && !getApp().globalData.plus_buy_back){ this.update_code(); }else{ getApp().globalData.is_cart_old=0; + getApp().globalData.plus_buy_back=0; } } @@ -984,7 +987,37 @@ Page({ var o_price=0; var o_shipping_price=0,goods_weight=-1, goods_piece=-1; var item=c_arr[i].goods; //就是每一单的从表的意思 - + + //---如果有选择优惠券的情况下--- + var quan_price=0; + var coupon_price=0; + var quan_no= null; + + if(th.data.using_quan[pickid]!=null && th.data.using_quan[pickid]!=undefined) + quan_no=th.data.using_quan[pickid].coupon_no; + + //普通券的时候 + if(quan_no && th.data.using_quan[pickid].isby!=1){ + //---获取优惠券优惠--- + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", { + data: { + storeId: oo.stoid, + CashRepNo: quan_no, + WaresSum: cart_item.check_quan_price_list, + WareIds: cart_item.check_quan_ware_list + } + }).then(res => { + if (res.data.code == 0 && res.data.data.length > 0) { + var q_data = res.data.data; + //--存储商品优惠的内容-- + cart_item.quan_youhui_list = q_data; + for (var k in q_data) + quan_price += q_data[k].WareCashSum; + } + }) + } + + //--------循环计算总价----------- for(var j=0;j0 && o_price>=freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list) ){ + //--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额-- + if(no_ex_id && freight_free>0 && (o_price-quan_price)>=freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list) ){ //如果有设置不包邮区域的时候 if(by_qc.region_list!="" && by_qc.region_list!=null && by_qc.region_list!=undefined ){ if(th.check_by_area(by_qc.region_list)){ @@ -1055,12 +1088,7 @@ Page({ }) } } - - var quan_no=null; - if(th.data.using_quan[pickid]){ - quan_no=th.data.using_quan[pickid].coupon_no; - } - + //如果是包邮券的时候,要看看券的情况 if(quan_no && th.data.using_quan[pickid].isby==1){ var quan=th.data.using_quan[pickid]; @@ -1101,7 +1129,7 @@ Page({ } //如果达到全场包邮的条件,同时,没有地区不包邮,或者商品不包邮 - if(o_price>=freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1){ + if(o_price-quan_price>=freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1){ continue; } @@ -1140,7 +1168,7 @@ Page({ code=th.data.wu_arr[cart_item.wind].code; cart_item.shipping_price = th.calculatewuliu(code, o_shipping_price, goods_weight, - goods_piece,th.data.user_addr, freight_free, o_price, rs); + goods_piece,th.data.user_addr, freight_free, o_price-quan_price, rs); if(!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby!=1){ if( cart_item.shipping_price ==0) th.data.is_by[pickid]=1; //已经全场包邮,就不要选择券了 @@ -1150,38 +1178,7 @@ Page({ } cart_item.shipping_price=cart_item.shipping_price.toFixed(2); - //---如果有选择优惠券的情况下--- - var quan_price=0; - var coupon_price=0; - var quan_no= null; - - if(th.data.using_quan[pickid]!=null && th.data.using_quan[pickid]!=undefined) - quan_no=th.data.using_quan[pickid].coupon_no; - - if(quan_no){ - //如果不是包邮券的时候 - if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby!=1) { - var ui=2; - //---获取优惠券优惠--- - await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", { - data: { - storeId: oo.stoid, - CashRepNo: quan_no, - WaresSum: cart_item.check_quan_price_list, - WareIds: cart_item.check_quan_ware_list - } - }).then(res => { - if (res.data.code == 0 && res.data.data.length > 0) { - var q_data = res.data.data; - //--存储商品优惠的内容-- - cart_item.quan_youhui_list = q_data; - for (var k in q_data) - quan_price += q_data[k].WareCashSum; - } - }) - } - } - + //总价计算,总价不包含运费 cart_item.order_amount= (o_price -quan_price).toFixed(2); cart_item.total_amount= f_o_price.toFixed(2); @@ -1368,12 +1365,32 @@ Page({ to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; + + //---如果有选择优惠券的情况下--- + var quan_price=0,bn_pick=th.data.bn_pick; + var quan_no=null; + if(th.data.using_quan[bn_pick]!=null && th.data.using_quan[bn_pick]!=undefined) + quan_no=th.data.using_quan[bn_pick].coupon_no; + + if(quan_no){ + if(th.data.using_quan[bn_pick].isby!=1){ + //---获取优惠券优惠--- + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice",{ + data:{storeId:oo.stoid,CashRepNo:quan_no, WaresSum:th.data.ckeck_quan_price, WareIds:th.data.check_quan_ware_list} + }).then(res=>{ + if(res.data.code==0){ + quan_price=res.data.data[0].WareCashSum; + } + }) + } + } + //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past!=1 ){ //看是不是有调用过包邮券 if(!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh!=1){ - var condition=allpice-cut_price; - //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额--- + var condition=allpice-cut_price-quan_price; + //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱--- getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{ data:{store_id:os.stoid,isuse:0,condition:condition,user_id:getApp().globalData.user_id,pageSize:2000} }).then(res=>{ @@ -1417,8 +1434,10 @@ Page({ var no_by_data=null; var gift_freight_free=freight_free; + + //有不包邮区域,且不免运费 - if(no_ex_id && freight_free>0 && freight_free<=allpice-cut_price){ + if(no_ex_id && freight_free>0 && freight_free<= parseFloat(allpice)-cut_price-quan_price){ //-----------获取不包邮区域,不包邮商品------- await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods",{ data:{store_id:os.stoid,id:no_ex_id} @@ -1447,11 +1466,11 @@ Page({ //--------------开始计算物流------------------ var shipping_price= th.calculatewuliu(code, o_shipping_price, goods_weight, - goods_piece, th.data.user_addr, freight_free, allpice-cut_price, rs); + goods_piece, th.data.user_addr, freight_free, parseFloat(allpice)-cut_price-quan_price, rs); //如果有赠品的时候,也要计算赠品的物流费用 if(th.data.buy_now_gift_goods){ - shipping_price=th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, allpice-cut_price, rs,shipping_price,no_by_data); + shipping_price=th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, parseFloat(allpice)-cut_price-quan_price, rs,shipping_price,no_by_data); } if(shipping_price<=0){ @@ -1466,26 +1485,12 @@ Page({ var wl_txt = "formData.shipping_price"; th.setData({ [wl_txt]: 0, }) } - //---如果有选择优惠券的情况下--- - var quan_price=0,bn_pick=th.data.bn_pick; - var quan_no=null; - if(th.data.using_quan[bn_pick]!=null && th.data.using_quan[bn_pick]!=undefined) - quan_no=th.data.using_quan[bn_pick].coupon_no; + if(quan_no){ - var aa=1; if(th.data.using_quan[bn_pick].isby==1){ shipping_price=0; var wl_txt = "formData.shipping_price"; th.setData({ [wl_txt]: 0, }) - }else{ - //---获取优惠券优惠--- - await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice",{ - data:{storeId:oo.stoid,CashRepNo:quan_no, WaresSum:th.data.ckeck_quan_price, WareIds:th.data.check_quan_ware_list} - }).then(res=>{ - if(res.data.code==0){ - quan_price=res.data.data[0].WareCashSum; - } - }) } } //-----------------支付价,优惠券不减物流----------------- diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 1b46abe..9b23572 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -2035,7 +2035,7 @@ Page({ if (e.data.code == 0) { //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 - if(dd.lat && !th.data.def_pick_store && th.data.bconfig.is_sort_storage){ + if(dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store)=='{}') && th.data.bconfig.is_sort_storage){ th.setData({ def_pick_store:e.data.data.pageData[0], sto_sele_name: e.data.data.pageData[0].pickup_name, @@ -2046,7 +2046,7 @@ Page({ } //-- 如果有默认选择门店的时候,要把默认门店放在第一位 -- - if (th.data.def_pick_store && (g_distr_type==0 || th.data.def_pick_store.distr_type==0 || th.data.def_pick_store.distr_type==g_distr_type )){ + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store)!='{}' && (g_distr_type==0 || th.data.def_pick_store.distr_type==0 || th.data.def_pick_store.distr_type==g_distr_type )){ for (var k = 0; k < e.data.data.pageData.length; k++) { if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { e.data.data.pageData.splice(k, 1); //删除 diff --git a/pages/user/order_list/order_list.wxml b/pages/user/order_list/order_list.wxml index a686d2a..ebe8cab 100644 --- a/pages/user/order_list/order_list.wxml +++ b/pages/user/order_list/order_list.wxml @@ -28,7 +28,7 @@ 查询 - 注:读取时段内仅{{total}}笔记录 + 注:读取时段内近10笔记录