Commit 2badbe81874fe3e595892b4887c8b38928b42eb5
1 parent
da9d6b70
秒杀和全场活动的叠加
Showing
4 changed files
with
115 additions
and
46 deletions
packageE/pages/cart/cart2/cart2.js
| ... | ... | @@ -1411,7 +1411,7 @@ Page({ |
| 1411 | 1411 | } |
| 1412 | 1412 | th.setData({ collocation_goods: gg.collocation_goods }); |
| 1413 | 1413 | |
| 1414 | - if (th.data.all_collocation_list) { | |
| 1414 | + if (th.data.all_collocation_list && gg.collocation_goods) { | |
| 1415 | 1415 | for (var i = 0; i < th.data.all_collocation_list.length; i++) { |
| 1416 | 1416 | var item0 = th.data.all_collocation_list[i]; |
| 1417 | 1417 | var idx = gg.collocation_goods.findIndex(function (e) { |
| ... | ... | @@ -1425,12 +1425,14 @@ Page({ |
| 1425 | 1425 | |
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | + if( gg.collocation_goods){ | |
| 1429 | + //var narr=gg.collocation_goods; | |
| 1430 | + //修改成深拷贝,确保返回是数据正确 | |
| 1431 | + var narr = JSON.parse(JSON.stringify(gg.collocation_goods)); | |
| 1432 | + narr.push(t.data.data); | |
| 1433 | + await th.get_collocation_list(narr); | |
| 1434 | + } | |
| 1428 | 1435 | |
| 1429 | - //var narr=gg.collocation_goods; | |
| 1430 | - //修改成深拷贝,确保返回是数据正确 | |
| 1431 | - var narr = JSON.parse(JSON.stringify(gg.collocation_goods)); | |
| 1432 | - narr.push(t.data.data); | |
| 1433 | - await th.get_collocation_list(narr); | |
| 1434 | 1436 | } |
| 1435 | 1437 | th.setData({ |
| 1436 | 1438 | bn_goods: gd, bn_pickname: gg.pick_name, index: m_wind, |
| ... | ... | @@ -1914,6 +1916,9 @@ Page({ |
| 1914 | 1916 | |
| 1915 | 1917 | |
| 1916 | 1918 | calclate_lbNum(r_data) { |
| 1919 | + | |
| 1920 | + if(!r_data) return false; | |
| 1921 | + | |
| 1917 | 1922 | let send_lb = this.data.send_lb; |
| 1918 | 1923 | //g_lb_num我的礼包 g_zxlb_num专享礼包 |
| 1919 | 1924 | r_data.forEach(r_d => { | ... | ... |
pages/cart/cart/cart.js
| ... | ... | @@ -427,6 +427,9 @@ Page({ |
| 427 | 427 | th.data.ladder_map = {}; |
| 428 | 428 | var rd = Math.random().toString(36).substr(2, 15); |
| 429 | 429 | var user_id = getApp().globalData.user_id; |
| 430 | + | |
| 431 | + wx.showLoading(); | |
| 432 | + | |
| 430 | 433 | getApp().request.get("/api/weshop/cart/list", { |
| 431 | 434 | data: { |
| 432 | 435 | user_id: app.globalData.user_id, |
| ... | ... | @@ -1161,6 +1164,8 @@ Page({ |
| 1161 | 1164 | }), |
| 1162 | 1165 | th.doCheckAll(), wx.stopPullDownRefresh(); |
| 1163 | 1166 | |
| 1167 | + wx.hideLoading(); | |
| 1168 | + | |
| 1164 | 1169 | } |
| 1165 | 1170 | }); |
| 1166 | 1171 | }, | ... | ... |
pages/goods/goodsInfo/goodsInfo.js
| ... | ... | @@ -987,8 +987,8 @@ Page({ |
| 987 | 987 | ee.data.prom_id = t.data.data.prom_id; |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | - | |
| 991 | 990 | //一件代发商品不去计算优惠 |
| 991 | + //if (!ee.data.fir_goods.whsle_id && ee.data.prom_type != 1 && ee.data.prom_type != 4 && ee.data.prom_type != 6 && ee.data.prom_type != 2) { | |
| 992 | 992 | if (!ee.data.fir_goods.whsle_id && ee.data.prom_type != 1 && ee.data.prom_type != 4 && ee.data.prom_type != 6 && ee.data.prom_type != 2) { |
| 993 | 993 | ee.check_is_youhui(ee.data.gid); |
| 994 | 994 | } |
| ... | ... | @@ -2037,51 +2037,89 @@ Page({ |
| 2037 | 2037 | } else { |
| 2038 | 2038 | |
| 2039 | 2039 | //-- 这一步主要是要让立即购买 走 购物车的逻辑 参与活动,如果有zh_act就强制组合购购买 -- |
| 2040 | - if(th.data.zh_act && th.data.zh_act.buy_limit !=0 && th.data.zh_act.buy_limit <= th.data.userbuynum && th.data.zh_act.zhbuyqty <= th.data.goodsInputNum){ | |
| 2041 | - wx.hideLoading() | |
| 2042 | - | |
| 2043 | - wx.showModal({ | |
| 2044 | - title: '提示', | |
| 2045 | - // content: `商品${str},组合购活动,购买次数已超,将以普通商品购买?`, | |
| 2046 | - content: `${th.data.data.goods_name}超出组合购限购次数,将以普通商品购买`, | |
| 2047 | - success:res=>{ | |
| 2048 | - if (res.confirm) { | |
| 2049 | - console.log('用户点击确定') | |
| 2050 | - //----先看会员在购物车中是否加入了该商品,立即购买的----- | |
| 2051 | - getApp().request.get("/api/weshop/cart/page", { | |
| 2052 | - data: { | |
| 2040 | + if(th.data.zh_act | |
| 2041 | + && th.data.zh_act.zhbuyqty <= th.data.goodsInputNum){ | |
| 2042 | + wx.hideLoading(); | |
| 2043 | + | |
| 2044 | + if((th.data.zh_act.buy_limit !=0 && th.data.zh_act.buy_limit <= th.data.userbuynum)){ | |
| 2045 | + wx.showModal({ | |
| 2046 | + title: '提示', | |
| 2047 | + // content: `商品${str},组合购活动,购买次数已超,将以普通商品购买?`, | |
| 2048 | + content: `${th.data.data.goods_name}超出组合购限购次数,将以普通商品购买`, | |
| 2049 | + success:res=>{ | |
| 2050 | + if (res.confirm) { | |
| 2051 | + console.log('用户点击确定') | |
| 2052 | + //----先看会员在购物车中是否加入了该商品,立即购买的----- | |
| 2053 | + getApp().request.get("/api/weshop/cart/page", { | |
| 2054 | + data: { | |
| 2053 | 2055 | store_id: e.data.stoid, |
| 2054 | 2056 | user_id: oo.user_id, |
| 2055 | 2057 | state: 1 |
| 2056 | - }, | |
| 2057 | - success: function (res) { | |
| 2058 | + }, | |
| 2059 | + success: function (res) { | |
| 2058 | 2060 | //-------如果购物车中有相关的数据--------- |
| 2059 | 2061 | if (res.data.code == 0 && res.data.data.total > 0) { |
| 2060 | - for (let j in res.data.data.pageData) { | |
| 2061 | - let item_j = res.data.data.pageData[j]; | |
| 2062 | - var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; | |
| 2063 | - getApp().request.delete(url, {}); | |
| 2064 | - } | |
| 2062 | + for (let j in res.data.data.pageData) { | |
| 2063 | + let item_j = res.data.data.pageData[j]; | |
| 2064 | + var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; | |
| 2065 | + getApp().request.delete(url, {}); | |
| 2066 | + } | |
| 2065 | 2067 | } |
| 2066 | 2068 | newd.state = 1; |
| 2067 | 2069 | newd.prom_type=0; |
| 2068 | 2070 | newd.prom_id=0 |
| 2069 | 2071 | getApp().request.post("/api/weshop/cart/save", { |
| 2070 | - data: newd, | |
| 2071 | - success: function (t) { | |
| 2072 | - th.closeSpecModal(); | |
| 2073 | - getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); | |
| 2074 | - } | |
| 2072 | + data: newd, | |
| 2073 | + success: function (t) { | |
| 2074 | + th.closeSpecModal(); | |
| 2075 | + getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); | |
| 2076 | + } | |
| 2075 | 2077 | }); |
| 2078 | + } | |
| 2079 | + }) | |
| 2080 | + } else if (res.cancel) { | |
| 2081 | + | |
| 2082 | + console.log('用户点击取消') | |
| 2083 | + } | |
| 2084 | + } | |
| 2085 | + }) | |
| 2086 | + }else{ | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + //----先看会员在购物车中是否加入了该商品,立即购买的----- | |
| 2090 | + getApp().request.get("/api/weshop/cart/page", { | |
| 2091 | + data: { | |
| 2092 | + store_id: e.data.stoid, | |
| 2093 | + user_id: oo.user_id, | |
| 2094 | + state: 1 | |
| 2095 | + }, | |
| 2096 | + success: function (res) { | |
| 2097 | + //-------如果购物车中有相关的数据,先清理掉--------- | |
| 2098 | + if (res.data.code == 0 && res.data.data.total > 0) { | |
| 2099 | + for (let j in res.data.data.pageData) { | |
| 2100 | + let item_j = res.data.data.pageData[j]; | |
| 2101 | + var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; | |
| 2102 | + getApp().request.delete(url, {}); | |
| 2076 | 2103 | } |
| 2077 | - }) | |
| 2078 | - } else if (res.cancel) { | |
| 2104 | + } | |
| 2105 | + | |
| 2106 | + newd.state = 1; | |
| 2107 | + newd.prom_type=7; | |
| 2108 | + newd.prom_id=th.data.zh_act.id; | |
| 2109 | + getApp().request.post("/api/weshop/cart/save", { | |
| 2110 | + data: newd, | |
| 2111 | + success: function (t) { | |
| 2112 | + th.closeSpecModal(); | |
| 2113 | + getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); | |
| 2114 | + } | |
| 2115 | + }); | |
| 2079 | 2116 | |
| 2080 | - console.log('用户点击取消') | |
| 2117 | + } | |
| 2118 | + }) | |
| 2081 | 2119 | } |
| 2082 | - } | |
| 2083 | - }) | |
| 2084 | - return false | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + return false | |
| 2085 | 2123 | }else{ |
| 2086 | 2124 | //----先看会员在购物车中是否加入了该商品,立即购买的----- |
| 2087 | 2125 | getApp().request.get("/api/weshop/cart/page", { |
| ... | ... | @@ -2128,11 +2166,19 @@ Page({ |
| 2128 | 2166 | } |
| 2129 | 2167 | |
| 2130 | 2168 | //如果有阶梯促销的时候 |
| 2131 | - if(th.data.jieti_prom){ | |
| 2169 | + if(th.data.jieti_prom && newd.prom_type==0){ | |
| 2132 | 2170 | newd.prom_type = 7; |
| 2133 | 2171 | newd.prom_id = th.data.ladder_act_id; |
| 2134 | 2172 | } |
| 2135 | 2173 | |
| 2174 | + | |
| 2175 | + //如果有搭配购的时候的时候 | |
| 2176 | + if(th.data.collocationGoods && newd.prom_type==0){ | |
| 2177 | + newd.prom_type = 5; | |
| 2178 | + newd.prom_id = th.data.collocationGoods.id; | |
| 2179 | + } | |
| 2180 | + | |
| 2181 | + | |
| 2136 | 2182 | newd['pick_name'] = th.data.sto_sele_name; |
| 2137 | 2183 | newd['pick_dis'] = th.data.sto_sele_distr; |
| 2138 | 2184 | th.buyNow(newd); |
| ... | ... | @@ -2585,7 +2631,7 @@ Page({ |
| 2585 | 2631 | callback(); |
| 2586 | 2632 | } else { |
| 2587 | 2633 | //-- 判断有没有优惠活动 -- |
| 2588 | - getApp().request.promiseGet("/api/weshop/goods/getGoodsPromListNew/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0" + "/" + usr.user_id, {}).then(res => { | |
| 2634 | + getApp().request.promiseGet("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0" + "/" + usr.user_id, {}).then(res => { | |
| 2589 | 2635 | if (res.data.code == 0) { |
| 2590 | 2636 | var r_data = res.data.data; |
| 2591 | 2637 | th.data.prom_goods = r_data.promGoodsLists; |
| ... | ... | @@ -7046,12 +7092,14 @@ Page({ |
| 7046 | 7092 | |
| 7047 | 7093 | } else { |
| 7048 | 7094 | //调用接口判断订单优惠, |
| 7049 | - getApp().request.get("/api/weshop/goods/getGoodsPromListNew/" + os.stoid + "/" + gid + "/0" + "/" + user_id, { | |
| 7095 | + getApp().request.get("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + gid + "/0" + "/" + user_id, { | |
| 7050 | 7096 | success: function (res) { |
| 7051 | 7097 | if (res.data.code == 0 && res.data.data) { |
| 7052 | 7098 | var r_data = res.data.data; |
| 7053 | 7099 | var max = 0, |
| 7054 | 7100 | min = 0; |
| 7101 | + | |
| 7102 | + | |
| 7055 | 7103 | if (r_data.collocationList) { |
| 7056 | 7104 | for (var i in r_data.collocationList) { |
| 7057 | 7105 | if (max == 0) max = r_data.collocationList[i].price; |
| ... | ... | @@ -7062,8 +7110,13 @@ Page({ |
| 7062 | 7110 | } |
| 7063 | 7111 | r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); |
| 7064 | 7112 | r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); |
| 7113 | + | |
| 7114 | + //如果有搭配促销先不和 阶梯促销和优惠测序重合,做到后台可以重合 | |
| 7115 | + r_data.ladderLists=null; | |
| 7116 | + r_data.promGoodsLists=null; | |
| 7065 | 7117 | } |
| 7066 | 7118 | |
| 7119 | + | |
| 7067 | 7120 | if (r_data.ladderLists) { |
| 7068 | 7121 | var act_id = r_data.ladderLists[0].form_id; |
| 7069 | 7122 | //-- 判断会员能不能参与阶梯促销 -- |
| ... | ... | @@ -7088,6 +7141,8 @@ Page({ |
| 7088 | 7141 | }) |
| 7089 | 7142 | } |
| 7090 | 7143 | |
| 7144 | + | |
| 7145 | + | |
| 7091 | 7146 | th.setData({ |
| 7092 | 7147 | order_prom: r_data.promOrder, |
| 7093 | 7148 | collocationGoods: r_data.collocationPromList, |
| ... | ... | @@ -7367,7 +7422,8 @@ Page({ |
| 7367 | 7422 | store_id: os.stoid, |
| 7368 | 7423 | goodsidlist: this.data.data.goods_id, |
| 7369 | 7424 | is_detail: 1, |
| 7370 | - user_id: user_id | |
| 7425 | + user_id: user_id, | |
| 7426 | + timetype:0 | |
| 7371 | 7427 | }; |
| 7372 | 7428 | //获取秒杀的多规格 |
| 7373 | 7429 | getApp().request.promiseGet(url, { |
| ... | ... | @@ -7470,7 +7526,7 @@ Page({ |
| 7470 | 7526 | }, |
| 7471 | 7527 | |
| 7472 | 7528 | //-- 检验商品的活动情况 -- |
| 7473 | - check_gd_prom_new: function (func) { | |
| 7529 | + check_gd_prom_new: async function (func) { | |
| 7474 | 7530 | |
| 7475 | 7531 | if([1,2,4,6,8,9].indexOf(parseInt(this.data.prom_type))>-1 ){ |
| 7476 | 7532 | func(); return false; |
| ... | ... | @@ -7480,7 +7536,7 @@ Page({ |
| 7480 | 7536 | var user_id = getApp().globalData.user_id; |
| 7481 | 7537 | if (!user_id) user_id = 0; |
| 7482 | 7538 | |
| 7483 | - var url = '/api/weshop/activitylist/listGoodActInfo2'; | |
| 7539 | + var url = '/api/weshop/activitylist/listGoodActInfo2New'; | |
| 7484 | 7540 | var req_d = { |
| 7485 | 7541 | "store_id": os.stoid, |
| 7486 | 7542 | "goods_id": this.data.gid, |
| ... | ... | @@ -7491,7 +7547,8 @@ Page({ |
| 7491 | 7547 | success: function (e) { |
| 7492 | 7548 | if (e.data.code == 0 && e.data.data && e.data.data.length > 0) { |
| 7493 | 7549 | var arr = e.data.data; |
| 7494 | - let times = new Date().getTime() | |
| 7550 | + let times = new Date().getTime(); | |
| 7551 | + | |
| 7495 | 7552 | arr.map(item=>{ |
| 7496 | 7553 | //如果是积分购的话,要进行活动时间判断 |
| 7497 | 7554 | if(item.prom_type==4){ |
| ... | ... | @@ -7505,8 +7562,9 @@ Page({ |
| 7505 | 7562 | } |
| 7506 | 7563 | }) |
| 7507 | 7564 | |
| 7565 | + //-- 预热也要计算 -- | |
| 7508 | 7566 | var arr2 = arr.filter(function (e) { |
| 7509 | - return e.s_time < ut.gettimestamp(); | |
| 7567 | + return e.s_time < ut.gettimestamp() || (e.warm_uptime && e.warm_uptime<ut.gettimestamp() ) | |
| 7510 | 7568 | }) |
| 7511 | 7569 | |
| 7512 | 7570 | var arr3 = arr.filter(function (e) { | ... | ... |