diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index 6d49c44..53edef6 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -418,6 +418,8 @@ Page({ th.calculatePrice2(); } else { + + gd.prom_id=gg.prom_id; //--阶梯团很特殊,不能用总表来拿价格-- getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, { success: function (tt) { @@ -458,6 +460,11 @@ Page({ if (pt_data.kttype == 3) { t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买 } + + t.data.data.prom_id = gd.prom_id; + t.data.data.prom_type = 6; + + } } else { t.data.data.prom_id = 0; diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index 0b207a9..4a1b10e 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -786,7 +786,7 @@ Page({ switch (ord_prom['type']) { case 0: allpice = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 - order_prom_amount = (o_condition - order_m).toFixed(2); + order_prom_amount = (o_condition - allpice).toFixed(2); break; case 1: //-- 如果有优惠促销倍减的时候 -- @@ -847,7 +847,7 @@ Page({ switch (ord_prom['type']) { case 0: allpice = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 - order_prom_amount = (o_condition - order_m).toFixed(2); + order_prom_amount = (o_condition - allpice).toFixed(2); break; case 1: //-- 如果有优惠促销倍减的时候 -- diff --git a/pages/user/order_detail/order_detail.js b/pages/user/order_detail/order_detail.js index 4d8d804..5e36889 100644 --- a/pages/user/order_detail/order_detail.js +++ b/pages/user/order_detail/order_detail.js @@ -543,12 +543,7 @@ Page({ //商品的普通购买 ,不要进行判断 if((good.prom_type==1 || good.prom_type==2 || good.prom_type==6 || good.prom_type==4) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal){ - if(gg.prom_type!=good.prom_type && gg.prom_type>0) { - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; - th.toast(content); - th.setData({paying:0}); - return false; - } + }else{ if((gg.prom_type==1 || gg.prom_type==3 || gg.prom_type==5 || gg.prom_type==6 || gg.prom_type==4) && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) { @@ -597,7 +592,7 @@ Page({ if(prom){ var t_now=ut.gettimestamp(); if(prom.is_end==0 && prom.start_timet_now){ - + var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; th.toast(content); th.setData({paying:0}); @@ -1160,94 +1155,105 @@ Page({ b_item.price=good[card_field]; } - var url="/api/weshop/activitylist/getGoodActInfo"; - var req_data={ - store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1,user_id:user_id + var url = "/api/weshop/activitylist/listGoodActInfo2New"; + var req_data = { + store_id: g_item.store_id, goods_id: g_item.goods_id, user_id: user_id }; - await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ - if(res.data.code==0){ - var list = res.data.data; - for(let i in list){ - let item=list[i]; - if(item.prom_type==1){ good.prom_type=1; good.prom_id=item.act_id; } + await getApp().request.promiseGet(url, { data: req_data }).then(res => { + if (res.data.code == 0) { + + var arr = res.data.data; + //-- 预热也要计算 -- + var arr2 = arr.filter(function (e) { + return e.s_time < ut.gettimestamp(); + }) + + if (arr2.length == 1) { + good.prom_type = 1; + good.prom_id = item.act_id; + + + + } + else if (arr2.length > 1) { + good.prom_type = g_item.prom_type; good.prom_id = g_item.prom_id; } } }) - if(!prom) { - //--判断商品当前的活动情况-- - switch (good.prom_type) { - case 1: - var flash = null; - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + good.prom_id, {}).then(res => { - if (res.data.code == 0) { - flash = res.data.data; - } - }) - //----已经结束----- - if (flash && flash.is_end == 0) { - - if( flash.end_time > timestamp && flash.start_time < timestamp){ - prom = flash; - prom.price = prom.user_price; - b_item.price = prom.price; - good.prom_type = 1; - good.prom_id = prom.id; - }else{ - if(g_item.prom_type==0 && !flash.is_shop_buy ){ - err_text+=g_item['goods_name']+"秒杀活动不允许普通价\n"; - continue; - } + //--判断商品当前的活动情况-- + switch (good.prom_type) { + case 1: + var flash = null; + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + good.prom_id, {}).then(res => { + if (res.data.code == 0) { + flash = res.data.data; + } + }) + //----已经结束----- + if (flash && flash.is_end == 0) { + + if( flash.end_time > timestamp && flash.start_time < timestamp){ + prom = flash; + prom.price = prom.user_price; + b_item.price = prom.price; + good.prom_type = 1; + good.prom_id = prom.id; + }else{ + if(g_item.prom_type==0 && !flash.is_shop_buy ){ + err_text+=g_item['goods_name']+"秒杀活动不允许普通价\n"; + continue; } + } + } + break; + case 2: + var group = null; + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + good.goods_id + "/" + good.prom_id, {}).then(res => { + if (res.data.code == 0) { + group = res.data.data; } - break; - case 2: - var group = null; - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + good.goods_id + "/" + good.prom_id, {}).then(res => { - if (res.data.code == 0) { - group = res.data.data; - } - }) - //----已经结束----- - if (group && group.is_end == 0 && group.end_time > timestamp && group.start_time < timestamp) { - prom = group; - prom.price = prom.price; - b_item.price = prom.price; - } - break; - case 6: - b_item.is_pd_normal = 1; - break; - case 7: - //如果有组合购 - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id; - await getApp().request.promiseGet(url, {}).then(res => { - if (res.data.code == 0 && res.data.data) { - if (res.data.data.is_show == 1 && res.data.data.is_end == 0 - && ut.gettimestamp() < res.data.data.end_time - && ut.gettimestamp() > res.data.data.start_time - ) { - b_item.prom_type = 7; - b_item.prom_id = res.data.data.id; - good.prom_type = 7; - good.prom_id = res.data.data.id; - } + }) + //----已经结束----- + if (group && group.is_end == 0 && group.end_time > timestamp && group.start_time < timestamp) { + prom = group; + prom.price = prom.price; + b_item.price = prom.price; + } + break; + case 6: + b_item.is_pd_normal = 1; + break; + case 7: + //如果有组合购 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id; + await getApp().request.promiseGet(url, {}).then(res => { + if (res.data.code == 0 && res.data.data) { + if (res.data.data.is_show == 1 && res.data.data.is_end == 0 + && ut.gettimestamp() < res.data.data.end_time + && ut.gettimestamp() > res.data.data.start_time + ) { + b_item.prom_type = 7; + b_item.prom_id = res.data.data.id; + good.prom_type = 7; + good.prom_id = res.data.data.id; } - }) - break; - case 10: - - var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${good.prom_id}`; - await getApp().request.promiseGet(url, {}).then(res => { - if (res.data.code == 0 && res.data.data && res.data.data.isuse && res.data.data.is_end == 0) { - b_item.prom_type = 10; - b_item.prom_id = res.data.data.id; - } - }) - break; - } + } + }) + break; + case 10: + + var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${good.prom_id}`; + await getApp().request.promiseGet(url, {}).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.isuse && res.data.data.is_end == 0) { + b_item.prom_type = 10; + b_item.prom_id = res.data.data.id; + } + }) + break; } + //如果有优惠促销的时候,要看下商品的优惠活动有没有过期 if((g_item.prom_type==3 || good.prom_type==3) && good.whsle_id<=0){ @@ -1603,12 +1609,33 @@ Page({ if (res.data.data.total > 0) { b_cart_goods= res.data.data.pageData[0]; } - }) + }) + + + //-- 判断购物车是不是有重复 -- + var is_has=0; + if(b_cart_goods) { + for (let jr = 0; jr < b_cart_goods.length; jr++) { + var b_cart_item = b_cart_goods[jr]; + if (g_item.prom_type == 0) { + if ([0, 3, 5, 7, 10].indexOf(b_cart_item.prom_type) > -1) { + is_has = b_cart_item.id; + break + } + } else { + if (b_cart_goods.prom_type == g_item.prom_type && b_cart_goods.prom_id == g_item.prom_id) { + is_has = b_cart_item.id; + break + } + } + } + } + //-- 如果就加入过购物车 -- - if(b_cart_goods){ + if(is_has){ var updata = { - id: b_cart_goods.id, + id: is_has, goods_num: newd.goods_num + b_cart_goods.goods_num, goods_price: newd.goods_price, member_goods_price:newd.goods_price, @@ -1688,7 +1715,15 @@ Page({ var user_id=getApp().globalData.user_id; if(!user_id) user_id=0; - var gd= e.currentTarget.dataset.gd; + var gd_item= e.currentTarget.dataset.gd; + var gd=gd_item.goods_id; + + if(gd_item.prom_type>0){ + good_url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gd + "&prom_id=" + gd_item.prom_id + "&prom_type="+gd_item.prom_type; + getApp().goto(good_url); + return false; + } + var good_url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + gd; var url="/api/weshop/activitylist/getGoodActInfo"; var req_data={ diff --git a/pages/user/order_detail/order_detail.wxml b/pages/user/order_detail/order_detail.wxml index 2863a9e..33fc66f 100644 --- a/pages/user/order_detail/order_detail.wxml +++ b/pages/user/order_detail/order_detail.wxml @@ -20,12 +20,12 @@ - + - + {{item.goods_name}} {{filters.show_gui_ge(item.goods_spec,item.goods_color)}} diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index c893087..9f32e13 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -882,12 +882,6 @@ Page({ //商品的普通购买 ,不要进行判断 if ((good.prom_type == 1 || good.prom_type == 2 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) { - if (gg.prom_type != good.prom_type && gg.prom_type > 0) { - var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; - th.toast(content); - th.setData({ paying: 0 }); - return false; - } } else { if ((gg.prom_type == 1 || good.prom_type == 2 || gg.prom_type == 3 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 4) @@ -1485,7 +1479,8 @@ Page({ }) if (arr2.length == 1) { - good.prom_type = 1; good.prom_id = item.act_id; + good.prom_type = item.prom_type; + good.prom_id = item.act_id; } else if (arr2.length > 1) { good.prom_type = g_item.prom_type; good.prom_id = g_item.prom_id; @@ -1549,8 +1544,6 @@ Page({ ) { b_item.prom_type = 7; b_item.prom_id = res.data.data.id; - good.prom_type = 7; - good.prom_id = b_item.prom_id; } } @@ -1926,23 +1919,27 @@ Page({ }).then(res => { //-------如果购物车中有相关的数据------- if (res.data.data.total > 0) { - b_cart_goods = res.data.data.pageData[0]; + b_cart_goods = res.data.data.pageData; } }) //-- 判断购物车是不是有重复 -- - var is_has=0; + var is_has=null; if(b_cart_goods) { + + for (let jr = 0; jr < b_cart_goods.length; jr++) { var b_cart_item = b_cart_goods[jr]; + + if (g_item.prom_type == 0) { if ([0, 3, 5, 7, 10].indexOf(b_cart_item.prom_type) > -1) { - is_has = b_cart_item.id; + is_has = b_cart_item; break } } else { - if (b_cart_goods.prom_type == g_item.prom_type && b_cart_goods.prom_id == g_item.prom_id) { - is_has = b_cart_item.id; + if (b_cart_item.prom_type == g_item.prom_type && b_cart_item.prom_id == g_item.prom_id) { + is_has = b_cart_item; break } } @@ -1952,8 +1949,8 @@ Page({ //-- 如果就加入过购物车 -- if (is_has) { var updata = { - id: is_has_cart, - goods_num: newd.goods_num + b_cart_goods.goods_num, + id: is_has.id, + goods_num: newd.goods_num + is_has.goods_num, goods_price: newd.goods_price, member_goods_price: newd.goods_price, store_id: os.stoid,