diff --git a/packageA/pages/goodsInfo/goodsInfo.js b/packageA/pages/goodsInfo/goodsInfo.js index 936168b..3848073 100644 --- a/packageA/pages/goodsInfo/goodsInfo.js +++ b/packageA/pages/goodsInfo/goodsInfo.js @@ -4161,6 +4161,7 @@ Page({ user_id: oo.user_id, goods_id: a, pick_id: e.data.sto_sele_id, + prom_type:(newd.prom_type?newd.prom_type:0), state: 0 }, success: function (re) { diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index 694e364..58abd65 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -399,6 +399,7 @@ Page({ wx.hideLoading() return arr }, + //计算商品预存款请求方法------------------------------------ async getGoodsAdvancesum(storageid, listform, cartList) { let res = await getApp().request.promisePost(`/api/weshop/delphiapi/saveErpApi`, { @@ -712,15 +713,15 @@ Page({ //如果有购买活动 item1.promgoodsbuynum = promgoodsbuynum; - //如果是秒杀的时候 - if (item1.prom_type == 1) { - var url = "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid - + "/" + item1.goods_id + "/1/" + item1.prom_id + "/" + app.globalData.user_id; - await app.request.promiseGet(url, {}).then(res => { - if (res.data.code == 0) { - console.log(res.data.data, "111"); - item1.is_order_yh = res.data.data.is_order_yh; - item1.is_post_temp = res.data.data.is_post_temp; + //如果是秒杀,团购的时候 + if([1,2].indexOf(item1.prom_type)>-1){ + var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid + + "/" + item1.goods_id + "/"+item1.prom_type+"/" + item1.prom_id + "/" + app.globalData.user_id; + await app.request.promiseGet(url,{}).then(res=>{ + if(res.data.code==0){ + console.log(res.data.data,"111"); + item1.is_order_yh=res.data.data.is_order_yh; + item1.is_post_temp=res.data.data.is_post_temp; } }) } @@ -1467,7 +1468,7 @@ Page({ success: async function (tt) { if (tt.data.code == 0) { //t.data.data.shop_price = tt.data.data.prom_price; - t.data.data.shop_price = tt.data.data.prom_user_price; + gd.shop_price=t.data.data.shop_price = tt.data.data.prom_user_price; th.data.ckeck_quan_price = 0; gd.is_xz_yh = 1; @@ -1532,53 +1533,110 @@ Page({ getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gd.goods_id + "/" + gd.prom_id, { success: async function (tt) { if (tt.data.code == 0) { - //t.data.data.shop_price = tt.data.data.prom_price; - t.data.data.shop_price = tt.data.data.price; + //获取一下主表的信息 + ut.get_active_info(2,gd.prom_id,os.stoid,function(e){ + + //t.data.data.shop_price = tt.data.data.prom_price; + gd.shop_price=t.data.data.shop_price = tt.data.data.price; + + t.data.data.fir_rate = tt.data.data.fir_rate; + t.data.data.sec_rate = tt.data.data.sec_rate; + t.data.data.thi_rate = tt.data.data.thi_rate; + t.data.data.commission = tt.data.data.commission; + + if(e.is_order_yh){ + th.data.bn_is_order_yh=1; + }else{ + th.data.bn_is_order_yh=0; + } + if(e.is_post_temp){ + th.data.bn_is_post_temp=1; + }else{ + th.data.bn_is_post_temp=0; + } + + + //-- 计算获得佣金的金额 -- + if (getApp().globalData.userInfo.is_distribut + && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { + + var c_num = getApp().get_commission(th.data.dis_config, t.data.data, gg.goods_num); + + gd.use_commission = c_num; + t.data.data.use_commission = c_num; + + } + + + if (tt.data.data.isQuan) { + th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; + th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; + th.data.check_quan_ware_list = t.data.data.erpwareid + ""; + } else { + gd.is_xz_yh = 1; + } + + th.setData({ + bn_goods: gd, + bn_pickname: gg.pick_name, + bn_exp_type: et, + index: m_wind, + bn_pick: gg.pick_id, + bn_t_exp_t: distr_t, + bn_exp_type: et + }); + + //-- 计算价格 -- + th.calculatePrice2(); + //获取优惠券,如果有券的钱,就调用 + if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan(); + + }) - t.data.data.fir_rate = tt.data.data.fir_rate; - t.data.data.sec_rate = tt.data.data.sec_rate; - t.data.data.thi_rate = tt.data.data.thi_rate; - t.data.data.commission = tt.data.data.commission; } else { t.data.data.prom_id = 0; t.data.data.prom_type = 0; - } - //-- 计算获得佣金的金额 -- - if (getApp().globalData.userInfo.is_distribut - && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { - var c_num = getApp().get_commission2(th.data.dis_config, t.data.data, gg.goods_num); - gd.use_commission = c_num; - t.data.data.use_commission = c_num; + //-- 计算获得佣金的金额 -- + if (getApp().globalData.userInfo.is_distribut + && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { + var c_num = getApp().get_commission2(th.data.dis_config, t.data.data, gg.goods_num); - } + gd.use_commission = c_num; + t.data.data.use_commission = c_num; + } + + + if (tt.data.data.isQuan) { + th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; + th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; + th.data.check_quan_ware_list = t.data.data.erpwareid + ""; + } else { + gd.is_xz_yh = 1; + } + + th.setData({ + bn_goods: gd, + bn_pickname: gg.pick_name, + bn_exp_type: et, + index: m_wind, + bn_pick: gg.pick_id, + bn_t_exp_t: distr_t, + bn_exp_type: et + }); + + //-- 计算价格 -- + th.calculatePrice2(); + //获取优惠券,如果有券的钱,就调用 + if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan(); - if (tt.data.data.isQuan) { - th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; - th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; - th.data.check_quan_ware_list = t.data.data.erpwareid + ""; - } else { - gd.is_xz_yh = 1; } - th.setData({ - bn_goods: gd, - bn_pickname: gg.pick_name, - bn_exp_type: et, - index: m_wind, - bn_pick: gg.pick_id, - bn_t_exp_t: distr_t, - bn_exp_type: et - }); - //-- 计算价格 -- - th.calculatePrice2(); - //获取优惠券,如果有券的钱,就调用 - if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan(); } }); @@ -1855,7 +1913,6 @@ Page({ }, - calclate_lbNum(r_data) { let send_lb = this.data.send_lb; //g_lb_num我的礼包 g_zxlb_num专享礼包 @@ -2060,15 +2117,14 @@ Page({ } o_price += item[j].goods_price * item[j].goods_num; - //-- 秒杀的时候,判断有没有订单优惠和包邮模板的叠加 -- - if (item[j].prom_type == 1) { - if (!item[j].is_order_yh) - no_order_yh += item[j].goods_price * item[j].goods_num; - if (!item[j].is_post_temp) - no_post_temp += item[j].goods_price * item[j].goods_num; - } - + //-- 秒杀, 团购的时候,判断有没有订单优惠和包邮模板的叠加 -- + if( [1,2].indexOf(item[j].prom_type)>-1){ + if(!item[j].is_order_yh) + no_order_yh+=item[j].goods_price * item[j].goods_num; + if(!item[j].is_post_temp) + no_post_temp+=item[j].goods_price * item[j].goods_num; + } } //判断是不是有组合购的金额 var f_o_price = o_price; @@ -2370,6 +2426,7 @@ Page({ var order_m = 0; + //么有使用券,或者活动没有限制使用优惠券 if (ord_prom && (quan_price <= 0 || !ord_prom.is_xz_yh)) { order_prom_id = ord_prom['id']; @@ -2389,8 +2446,6 @@ Page({ } } - - cart_item.order_prom_amount = 0; //--订单优惠的显示-- if (order_prom_id > 0) { @@ -2743,7 +2798,6 @@ Page({ if (cut_price) { var c_txt = "formData.cut_price"; th.setData({ [c_txt]: cut_price, }); - } //如果有线下取价的时候 @@ -6454,6 +6508,4 @@ Page({ } - - }); diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index 5c71d4f..b77b224 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -1,10 +1,11 @@ var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"), - s = require("../../../utils/util.js"), ut = s, o = require("../../../utils/md5.js"), to = getApp(); + s = require("../../../utils/util.js"), ut = s, o = require("../../../utils/md5.js"), to = getApp(); var oo = t.globalData.setting, os = oo; var regeneratorRuntime = require('../../../utils/runtime.js'); var util_pay = require("../../../utils/pay.js"); Page({ + data: { url: t.globalData.setting.url, resourceUrl: t.globalData.setting.resourceUrl, @@ -439,6 +440,17 @@ Page({ t.data.data.thi_rate = tt.data.data.thi_rate; t.data.data.commission = tt.data.data.commission; + if(e.is_order_yh){ + th.data.bn_is_order_yh=1; + }else{ + th.data.bn_is_order_yh=0; + } + + if(e.is_post_temp){ + th.data.bn_is_post_temp=1; + }else{ + th.data.bn_is_post_temp=0; + } if (pt_data.kttype == 3) { t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买 @@ -632,8 +644,22 @@ Page({ var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 - //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { + //-- 判断订单优惠的叠加 -- + var ord_prom=null; + var o_condition=allpice; + if(th.data.bn_is_order_yh && th.data.kt_type != 3 ){ + + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { + data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } + }).then(res => { + if (res.data.code == 0) { + ord_prom = res.data.data; + } + }) + } + + //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { var user_addr = th.data.user_addr; var req_d = { @@ -641,11 +667,16 @@ Page({ wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid } var back_data = null; - await getApp().request.promisePost("/api/weshop/order/areaFreight", { - is_json: 1, data: req_d - }).then(rs => { - if (rs.data.code == 0) back_data = rs.data.data; - }); + + if(!ord_prom || ord_prom.bn_is_post_temp) { + if (th.data.bn_is_post_temp || th.data.bn_goods.is_normal == 1) { + await getApp().request.promisePost("/api/weshop/order/areaFreight", { + is_json: 1, data: req_d + }).then(rs => { + if (rs.data.code == 0) back_data = rs.data.data; + }); + } + } var gd_arr_list = []; gd_arr_list.push(good); @@ -771,6 +802,7 @@ Page({ goods_weight: gd_w } + var is_next = 1; //获取同城配送参数 await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { @@ -780,6 +812,7 @@ Page({ if (res.data.code == 0) { var wl_txt = "formData.shipping_price"; th.setData({ [wl_txt]: res.data.data, }) + } else { is_next = 0; wx.showToast({ @@ -902,6 +935,41 @@ Page({ + //-- 如果是订单优惠的时候,allpice要拿来减掉一些 -- + var order_prom_id=0; + var order_prom_amount=0; + if(ord_prom){ + order_prom_id = ord_prom['id']; + switch (ord_prom['type']) { + case 0: + allpice = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 + order_prom_amount = (o_condition - order_m).toFixed(2); + break; + case 1: + //-- 如果有优惠促销倍减的时候 -- + var bs = 1; + if (ord_prom.is_bz) { + bs = Math.floor(o_condition / ord_prom.money); + } + allpice = o_condition - bs * ord_prom['expression'];//满额优惠金额 + order_prom_amount = ord_prom['expression']; + break; + } + } + + //--订单优惠的显示-- + var order_prom_txt1 = "formData.order_prom_id"; + var order_prom_txt2 = "formData.order_prom_amount"; + if (order_prom_id > 0) { + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) + } else { + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) + } + + //-----------------总价----------------- + var total_m = parseFloat(allpice) + parseFloat(th.data.formData.shipping_price); + total_m = parseFloat(total_m).toFixed(2); + var txt = "formData.user_money"; var txt2 = "formData.order_amount"; var txt4 = "formData.use_commission"; @@ -1008,11 +1076,22 @@ Page({ 'order_goods': new Array(), }; - //如果不是阶梯团,或者是普通购买, - if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { - item['shipping_code'] = th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code; - item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name; - } + + //--判断有没有优惠活动-- + if (th.data.formData.order_prom_amount > 0) { + var order_prom_list = {}; + order_prom_list.order_prom_id = th.data.formData.order_prom_id; + order_prom_list.order_prom_amount = th.data.formData.order_prom_amount; + item.order_prom_list = order_prom_list; + } + + + + //如果不是阶梯团,或者是普通购买, + if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { + item['shipping_code'] = th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code; + item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name; + } if (!th.data.bn_goods.is_normal) { item.is_zsorder = th.data.kt_type + 1; //开团类型 @@ -1140,6 +1219,7 @@ Page({ getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {}); } } + var order_amount = 0; pdata.forEach(function (em, ind) { order_amount += em.order_amount; diff --git a/pages/cart/cart2_pt/cart2_pt.wxml b/pages/cart/cart2_pt/cart2_pt.wxml index 1e2dafa..81d96d5 100644 --- a/pages/cart/cart2_pt/cart2_pt.wxml +++ b/pages/cart/cart2_pt/cart2_pt.wxml @@ -160,7 +160,6 @@ 商品金额 ¥ {{formData.all_price}}元 - 定金金额 ¥ {{formData.all_price}}元 @@ -179,6 +178,11 @@ 使用余额 - ¥ {{formData.user_money}}元 + + + 订单优惠 + - ¥ {{filters.toFix(formData.order_prom_amount,2)}}元 + diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index bd956f9..0b207a9 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -44,7 +44,10 @@ Page({ show_submit:0, //不线上 dis_config: null, - bn_use_commission: 0 //是不是使用佣金 + bn_use_commission: 0, //是不是使用佣金 + + bn_is_order_yh:1, //是不是订单优惠 + bn_is_post_temp:1, //是不是进行计算包邮模板 }, /** @@ -256,7 +259,28 @@ Page({ }); + var act_set=null; + var url = '/api/weshop/activitylist/getActInfo1/'+os.stoid+'/6/'+order.pt_prom_id; + await getApp().promiseGet(url, {}).then(res => { + if(res.data.code==0){ + act_set=res.data.data; + } + }) + + + if(act_set.is_order_yh){ + th.data.bn_is_order_yh=1; + }else{ + th.data.bn_is_order_yh=0; + } + + if(act_set.is_post_temp){ + th.data.bn_is_post_temp=1; + }else{ + th.data.bn_is_post_temp=0; + } + var jsarr = JSON.parse(teamgroup.jt_json); var count = teamgroup.jt_ct_num; if(teamgroup.is_xuni_ct) count=teamlist.ct_num; @@ -315,8 +339,6 @@ Page({ } - - switch (distr_type) { case 0: exp_type = 1; @@ -371,27 +393,70 @@ Page({ }, - calculatePrice2:function(){ - wx.showLoading(); - var th=this; - th.setData({submit:1}) - //--计算物流-- - if (th.data.exp_type == 0) { - th.calculate_wuliu(); - } else { + calculatePrice2: async function () { + wx.showLoading(); + var th = this; + th.setData({submit: 1}) + var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money; + var o_condition = allpice; + var ord_prom=null; - var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money; - if(th.data.bn_use_commission){ - allpice-=th.data.goods.use_commission; - } - allpice = allpice.toFixed(2); + if (th.data.bn_is_order_yh) { + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { + data: {store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id} + }).then(res => { + if (res.data.code == 0) { + ord_prom = res.data.data; + } + }) + } + th.data.ord_prom=ord_prom; + //--计算物流-- + if (th.data.exp_type == 0) { + th.calculate_wuliu(); + } else { + + if (ord_prom) { + order_prom_id = ord_prom['id']; + switch (ord_prom['type']) { + case 0: + allpice = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 + order_prom_amount = (o_condition - order_m).toFixed(2); + break; + case 1: + //-- 如果有优惠促销倍减的时候 -- + var bs = 1; + if (ord_prom.is_bz) { + bs = Math.floor(o_condition / ord_prom.money); + } + allpice = o_condition - bs * ord_prom['expression'];//满额优惠金额 + order_prom_amount = ord_prom['expression']; + break; + } + } + + //--订单优惠的显示-- + var order_prom_txt1 = "formData.order_prom_id"; + var order_prom_txt2 = "formData.order_prom_amount"; + if (order_prom_id > 0) { + th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) + } else { + th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) + } - th.setData({ exp_price: 0, allpice: allpice,submit:0,show_submit:1 }) - wx.hideLoading(); + if (th.data.bn_use_commission) { + allpice -= th.data.goods.use_commission; } + + + allpice = allpice.toFixed(2); + + th.setData({exp_price: 0, allpice: allpice, submit: 0, show_submit: 1}) + wx.hideLoading(); + } }, //--图片失败,默认图片-- @@ -500,6 +565,17 @@ Page({ dd.use_commission=th.data.goods.use_commission; } + if(th.data.bn_use_commission){ + dd.use_commission=th.data.goods.use_commission; + } + + //--判断有没有优惠活动-- + if (th.data.formData.order_prom_amount > 0) { + var order_prom_list = {}; + order_prom_list.order_prom_id = th.data.formData.order_prom_id; + order_prom_list.order_prom_amount = th.data.formData.order_prom_amount; + dd.order_prom_list = order_prom_list; + } var arr = []; arr.push(dd); @@ -583,173 +659,243 @@ Page({ //----计算物流的钱---- async calculate_wuliu() { //让按钮变灰色 - this.setData({submit:1}); + this.setData({submit: 1}); var to = getApp(), th = this; //to.getwuliuprice(async function (rs) { - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1, good = th.data.goods; - var out_of_weight = null; //超出多少重量 + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1, good = th.data.goods; + var out_of_weight = null; //超出多少重量 + + good.buynum = th.data.order.order_goods['goods_num']; + var gd_arr_list = []; + gd_arr_list.push(good); + + var ord_prom = this.data.ord_prom; + var order_prom_id=0; + var order_prom_amount=0; + //--全部金额-- + var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money; + // if(th.data.bn_use_commission){ + // allpice-=th.data.goods.use_commission; + // } + var o_condition=allpice; + + //-----------当地址不为空,且是物流时,计算物流费用---------- + if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) { + + //订单促销的包邮模板 和 活动的包邮模板要一起判断 + if ((!ord_prom || ord_prom.is_post_temp) && th.data.bn_is_post_temp) { + var user_addr = th.data.user_addr; + var req_d = { + province: user_addr.province, city: user_addr.city, district: user_addr.district, + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid + } + var back_data = null; + await getApp().request.promisePost("/api/weshop/order/areaFreight", { + is_json: 1, data: req_d + }).then(rs => { + if (rs.data.code == 0) back_data = rs.data.data; + }); + } - good.buynum=th.data.order.order_goods['goods_num']; - var gd_arr_list = []; - gd_arr_list.push(good); + var cut_good_weight = 0; + for (let i in gd_arr_list) { + let item = gd_arr_list[i]; + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { + if (goods_weight < 0) goods_weight = 0; + goods_weight += item['weight'] * item['buynum']; + cut_good_weight += item['weight'] * item['buynum']; + } + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + continue; + } + switch (item['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += item['uniform_exp_sum']; + break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item['weight'] * item['buynum']; + + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + cut_good_weight += item['weight'] * item['buynum']; + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + } + break; + case 3: + if (goods_piece < 0) goods_piece = 0; + //累积商品数量 + goods_piece += item['buynum']; + break; + } + } - //--全部金额-- - var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money; - // if(th.data.bn_use_commission){ - // allpice-=th.data.goods.use_commission; - // } + //如果是正值的时候 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; + else out_of_weight = -back_data.weight_free * 1000; + + var code = th.data.wu_arr[th.data.index].code; + + //--------------开始计算物流------------------ + var shipping_price = 0; + // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + + var w_data = { + store_id: os.stoid, code: code, + o_shipping_price: o_shipping_price, + goods_weight: goods_weight, + out_of_weight: out_of_weight, goods_piece: goods_piece, + user_addr_province: th.data.user_addr.province, + user_addr_city: th.data.user_addr.city, + user_addr_district: th.data.user_addr.district, + is_by_all: back_data && back_data.is_by_all ? 1 : 0, + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, + } - //-----------当地址不为空,且是物流时,计算物流费用---------- - if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) { + var is_ok = 0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { + data: w_data, + is_json: 1 + }).then(res => { + if (res.data.code == 0) { + shipping_price = res.data.data; + is_ok = 1; + } else { + getApp().confirmBox("计算物流错误:" + res.data.msg); + } + }) + if (!is_ok) { + th.setData({show_submit: 1}); + wx.hideLoading(); + return false; + } - var user_addr=th.data.user_addr; - var req_d = { - province: user_addr.province, city: user_addr.city, district: user_addr.district, - wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid + //-- 计算一下订单促销 -- + if (ord_prom) { + order_prom_id = ord_prom['id']; + switch (ord_prom['type']) { + case 0: + allpice = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 + order_prom_amount = (o_condition - order_m).toFixed(2); + break; + case 1: + //-- 如果有优惠促销倍减的时候 -- + var bs = 1; + if (ord_prom.is_bz) { + bs = Math.floor(o_condition / ord_prom.money); } - var back_data = null; - await getApp().request.promisePost("/api/weshop/order/areaFreight", { - is_json: 1, data: req_d - }).then(rs => { - if (rs.data.code == 0) back_data = rs.data.data; - }); - - var cut_good_weight = 0; - for (let i in gd_arr_list) { - let item = gd_arr_list[i]; - - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { - if (goods_weight < 0) goods_weight = 0; - goods_weight += item['weight'] * item['buynum']; - cut_good_weight += item['weight'] * item['buynum']; - } - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; - } - continue; - } + allpice = o_condition - bs * ord_prom['expression'];//满额优惠金额 + order_prom_amount = ord_prom['expression']; + break; + } + } - switch (item['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += item['uniform_exp_sum']; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item['weight'] * item['buynum']; - - if (back_data && back_data.is_by_all && !back_data.no_free_goods) { - cut_good_weight += item['weight'] * item['buynum']; - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; - } - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += item['buynum']; - break; - } - } + //--订单优惠的显示-- + var order_prom_txt1 = "formData.order_prom_id"; + var order_prom_txt2 = "formData.order_prom_amount"; + if (order_prom_id > 0) { + th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) + } else { + th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) + } - //如果是正值的时候 - if (out_of_weight >= 0) out_of_weight = -cut_good_weight; - else out_of_weight = -back_data.weight_free * 1000; - - var code = th.data.wu_arr[th.data.index].code; - - //--------------开始计算物流------------------ - var shipping_price =0; - // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - // goods_piece, th.data.user_addr, back_data, rs); - - var w_data={ - store_id:os.stoid, code:code, - o_shipping_price:o_shipping_price, - goods_weight:goods_weight, - out_of_weight:out_of_weight,goods_piece:goods_piece, - user_addr_province:th.data.user_addr.province, - user_addr_city:th.data.user_addr.city, - user_addr_district:th.data.user_addr.district, - is_by_all:back_data && back_data.is_by_all?1:0, - no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0, - } - var is_ok=0; - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ - if(res.data.code==0){ - shipping_price=res.data.data; is_ok=1; - }else{ - getApp().confirmBox("计算物流错误:"+res.data.msg); - } - }) - if(!is_ok){ - th.setData({ show_submit:1 }); - wx.hideLoading(); - return false; - } + var exp_price = parseFloat(shipping_price).toFixed(2); + allpice = parseFloat(exp_price) + parseFloat(allpice); - var exp_price = parseFloat(shipping_price).toFixed(2); - allpice = parseFloat(exp_price) + parseFloat(allpice); + if (allpice < th.data.goods.use_commission) { + if (th.data.bn_use_commission) { + wx.showToast({ + title: '应付金额小于本单佣金,不可使用!', + icon: 'none', + duration: 2000 + }) + } - if( allpice 0) { + th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) + } else { + th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) + } - th.setData({ - bn_use_commission: 0 - }); - } - if(th.data.bn_use_commission){ - allpice-=th.data.goods.use_commission; - } - allpice = allpice.toFixed(2); - th.setData({ exp_price: 0, allpice: allpice,submit:0,show_submit:1}) + if (allpice < th.data.goods.use_commission) { + if (th.data.bn_use_commission) { + wx.showToast({ + title: '应付金额小于本单佣金,不可使用!', + icon: 'none', + duration: 2000 + }) } - wx.hideLoading(); - //}); + th.setData({ + bn_use_commission: 0 + }); + } + + if (th.data.bn_use_commission) { + allpice -= th.data.goods.use_commission; + } + + allpice = allpice.toFixed(2); + th.setData({exp_price: 0, allpice: allpice, submit: 0, show_submit: 1}) + } + + wx.hideLoading(); + //}); }, diff --git a/pages/cart/cart_wk/cart_wk.wxml b/pages/cart/cart_wk/cart_wk.wxml index c0a5814..8fbfebb 100644 --- a/pages/cart/cart_wk/cart_wk.wxml +++ b/pages/cart/cart_wk/cart_wk.wxml @@ -96,18 +96,24 @@ - - - 尾款金额 - ¥{{order.tail_money}} + + + 尾款金额 + + ¥{{order.tail_money}} + - - - - 配送费用 - ¥{{exp_price}} + + 配送费用 + + ¥{{exp_price}} + + + + + 订单优惠 + - ¥ {{filters.toFix(formData.order_prom_amount, 2)}} - @@ -128,7 +134,7 @@ 支付合计: ¥{{filters.toFix(order.tail_money+exp_price,2)}} --> - 支付合计:¥{{filters.toFix(order.tail_money+exp_price-(bn_use_commission?goods.use_commission:0) ,2)}} + 支付合计:¥{{filters.toFix(order.tail_money+exp_price-(bn_use_commission?goods.use_commission:0)-formData.order_prom_amount ,2)}} 支付尾款 diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 751aa77..23e208e 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -1782,7 +1782,7 @@ Page({ } }) - } else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5 || th.data.prom_type == 10) { + } else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 5 || th.data.prom_type == 10) { newd.prom_type = 0; newd.prom_id = 0; @@ -7380,7 +7380,7 @@ Page({ let item = arr_data[i]; //找不到活动要剔除 if (!item.act_name) continue; - if (item.prom_type != 1) continue; + if ([1,2,6].indexOf(item.prom_type)==-1) continue; new_arr.push(item); } @@ -7399,8 +7399,9 @@ Page({ //-- 跳转到秒杀商品详情页 -- go_more_flash: function (e) { var prom_id = e.currentTarget.dataset.id; + var prom_type = e.currentTarget.dataset.prom_type; var goods_id = this.data.data.goods_id; - var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + goods_id + "&prom_id=" + prom_id + "&prom_type=1"; + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + goods_id + "&prom_id=" + prom_id + "&prom_type="+prom_type; getApp().goto(url); }, diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index cb1c6c5..344866c 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -106,7 +106,7 @@ - + 开始时间 结束时间 @@ -600,9 +600,11 @@ - 秒杀 - 团购 + 秒杀 + 团购 积分购 + 天天拼单 + @@ -610,6 +612,8 @@ + + {{item.act_name}} @@ -1168,6 +1172,7 @@ + @@ -1189,13 +1194,13 @@ --> - + 即将开始 立即兑换 - 积分不足 + 积分不足 @@ -1552,7 +1557,7 @@ - + @@ -1734,7 +1739,7 @@ 提示 - + 该商品有参与{{item.act_name}} {{tool.act_type(item.prom_type)}} 活动 去参与 @@ -1749,6 +1754,7 @@ + 规则详情 diff --git a/pages/goods/goodsList/g_filter.wxs b/pages/goods/goodsList/g_filter.wxs deleted file mode 100644 index 36ab263..0000000 --- a/pages/goods/goodsList/g_filter.wxs +++ /dev/null @@ -1,104 +0,0 @@ -var g_filters = { - //-- 判断是不是有等级价 -- - is_has_rank:function(rank_switch,item){ - if(!rank_switch) return false; - if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true} - return false; - }, - - //-- 判断,不是等级会员时候,要显示的最低等级价和名称 -- - get_card_price:function(goods,all_card,type){ - var price1=parseFloat(goods['cardprice1']); - var price2=parseFloat(goods['cardprice2']); - var price3=parseFloat(goods['cardprice3']); - if(!all_card){ - if(type==0) return 0; - return ""; - } - - var arr=[]; - var min_price= 0; - var min_name=""; - - var min_price=null; - var min_name=null; - //---设置对应的价格名字---- - for(var i=0;i<3;i++) { - var vl=all_card[i]; - if(!vl) continue; - if(vl['CorrPrice']=="Price1" && price1>0) - { - if(min_price==null) { - min_price=price1;min_name=vl['CardName']; - } - else if(price10) - { - if(min_price==null) { - min_price=price2;min_name=vl['CardName']; - } - else if(price20) - { - if(min_price==null) { - min_price=price3;min_name=vl['CardName']; - } - else if(price34) min_name=min_name.substring(0, 8); - return min_name; - }, - - //跳转的接口 - get_goods_url:function(item){ - var url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id - - if(item.prom_type == 9) { - url1 = '/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=' + item.goods_id + '&group_id=' + item.prom_id; - } - if(item.prom_type==8){ - url1="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id - } - if(item.prom_type==1 && item.prom_id>0 ){ - url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id+"&prom_type=1"; - } - return url1; - } -} - -module.exports = { - is_has_rank:g_filters.is_has_rank, - get_card_price:g_filters.get_card_price, - get_goods_url:g_filters.get_goods_url, -} \ No newline at end of file diff --git a/pages/goods/goodsList/goodsList.wxml b/pages/goods/goodsList/goodsList.wxml index 14588ea..5f41d31 100644 --- a/pages/goods/goodsList/goodsList.wxml +++ b/pages/goods/goodsList/goodsList.wxml @@ -1,4 +1,4 @@ - + diff --git a/pages/goods/search/g_filter.wxs b/pages/goods/search/g_filter.wxs index 605179a..5e9e8d6 100644 --- a/pages/goods/search/g_filter.wxs +++ b/pages/goods/search/g_filter.wxs @@ -91,9 +91,11 @@ var g_filters = { url1 = "/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=" + item.goods_id + "&group_id=" + item.prom_id } - if (item.prom_type == 1 && item.prom_id > 0) { - url1 = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id + "&prom_id=" + item.prom_id + "&prom_type=1"; + if ([1,2,6].indexOf(item.prom_type)>-1 && item.prom_id > 0) { + url1 = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id + "&prom_id=" + item.prom_id + "&prom_type="+item.prom_type; } + + return url1; } } diff --git a/utils/util.js b/utils/util.js index 299a655..6022bbe 100644 --- a/utils/util.js +++ b/utils/util.js @@ -754,6 +754,15 @@ module.exports = { } }, + get_active_info:function(prom_type, prom_id,stoid,func) { + var url = '/api/weshop/activitylist/getActInfo1/'+stoid+'/'+prom_type+'/'+prom_id; + getApp().promiseGet(url, {}).then(res => { + if(res.data.code==0){ + func(res.data.data); + } + }) + }, + unserialize: unserialize, _throttle:_throttle, unserialize_o: unserialize_o,