Commit be958f846b5b6bdaee7bef8ec69886c1e41809b3

Authored by yvan.ni
1 parent 38b6f35f

测试返回的优化

packageE/pages/cart/cart2/cart2.js
... ... @@ -842,6 +842,7 @@ Page({
842 842 })
843 843 }
844 844 }
  845 +
845 846 //-- 判断一下,获取搭配购的消息 --
846 847 if ((item1.prom_type == 0 || item1.prom_type == 5) && (!carr[i].collocationList || !carr[i].collocationList.length)) {
847 848  
... ... @@ -1102,19 +1103,21 @@ Page({
1102 1103  
1103 1104 //每一个门店内的阶梯促销要进行拆分,
1104 1105 //还得把阶梯促销商品的多余商品的线下价格算一算
1105   - for (let var1 in arr) {
  1106 + for (let var2 in arr) {
  1107 + var u_item1 = arr[var2];
  1108 +
1106 1109 //把阶梯促销进行分组
1107   - var obj = ladder_calc.find_split(u_item);
  1110 + var obj = ladder_calc.find_split(u_item1);
1108 1111 if (!obj) continue;
1109 1112 //存储不同阶梯促销活动的商品列表
1110   - u_item.ladder_map = {};
  1113 + u_item1.ladder_map = {};
1111 1114 for (let var1 in obj) {
1112 1115 var h_item = obj[var1];
1113 1116 var act = th.data.ladder_map[h_item.prom_id];
1114 1117 //获取活动需要的商品列表
1115   - u_item.ladder_map[h_item.prom_id] = act;
  1118 + u_item1.ladder_map[h_item.prom_id] = act;
1116 1119 }
1117   - ladder_calc.fir_set_arr(u_item, th);
  1120 + ladder_calc.fir_set_arr(u_item1, th);
1118 1121 }
1119 1122  
1120 1123  
... ...
packageE/pages/cart/cart2/ladder_calculate.js
... ... @@ -15,6 +15,9 @@ module.exports = {
15 15 //组合活动,以及组合活动从表的商品
16 16 let ladder_map = c_item.ladder_map;
17 17 let goods = c_item.goods; //一个门店中所有的商品
  18 +
  19 +
  20 +
18 21 let tfeel = 0, cut_price = 0, offline_price = 0, offline_num = 0;
19 22 //多个活动要拿来循环一下
20 23 for (let i in ladder_map) {
... ... @@ -43,7 +46,9 @@ module.exports = {
43 46 offline_price: item.offline_price,
44 47 goods_id: item.goods_id,
45 48 shop_price: item.shop_price,
46   - item:item
  49 + item:item,
  50 + prom_id:act_item.id,
  51 + prom_type:10,
47 52 })
48 53 }
49 54 del_g.push(item);
... ... @@ -102,7 +107,7 @@ module.exports = {
102 107 let num = goods_map[j];
103 108 //找到相应的商品
104 109 let idx = goods.findIndex(function (ele) {
105   - return ele.goods_id == j;
  110 + return ele.goods_id == j && ele.prom_id==act_item.id && ele.prom_type==10
106 111 })
107 112 //goods[idx].goods_num -= num;
108 113 let new_g = JSON.parse(JSON.stringify(goods[idx]));
... ... @@ -118,7 +123,7 @@ module.exports = {
118 123 for(var h in del_g){
119 124 var it=del_g[h];
120 125 let idx = goods.findIndex(function (ele) {
121   - return ele.goods_id == it.goods_id
  126 + return ele.goods_id == it.goods_id && ele.prom_id==act_item.id && ele.prom_type==10
122 127 })
123 128 goods.splice(idx, 1);
124 129 }
... ...
pages/cart/cart/cart.js
... ... @@ -561,7 +561,7 @@ Page({
561 561 let prom_id = 0
562 562 if (prom) {
563 563 prom.map(item => {
564   - if (item.prom_type == 3 || item.prom_type == 7) {
  564 + if (item.prom_type == 3 || item.prom_type == 5 || item.prom_type == 7 || item.prom_type == 10) {
565 565 prom_true = item.prom_type
566 566 prom_id = item.act_id
567 567 }
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -1582,66 +1582,6 @@ Page({
1582 1582 if (th.data.sales_rules >= 2) {
1583 1583 var pick = th.get_pick_from_list(th.data.sto_sele_id)
1584 1584 //---通过接口获取门店的线下库存信息--
1585   - // getApp().request.get("/api/weshop/goods/getWareStorages", {
1586   - // data: {
1587   - // storageNos: pick.pickup_no,
1588   - // wareIds: encodeURIComponent(th.data.sele_g.erpwareid),
1589   - // storeId: os.stoid
1590   - // },
1591   - // success: function (res) {
1592   - // if (res.data.code == 0) {
1593   - // if (res.data.data.pageData.length > 0) {
1594   - // var CanOutQty = res.data.data.pageData[0].CanOutQty;
1595   - // if (CanOutQty < e.data.goodsInputNum) {
1596   - // wx.showToast({
1597   - // title: '库存不足!',
1598   - // icon: 'none',
1599   - // });
1600   - // return false;
1601   - // // return s.my_warnning("库存不足!", 0, th);
1602   - // }
1603   - // //在调一次接口,读取商品的预出库的数量,lock
1604   - // getApp().request.get("/api/weshop/order/ware/lock/page", {
1605   - // data: {
1606   - // store_id: os.stoid,
1607   - // wareId: th.data.sele_g.goods_id,
1608   - // storageId: pick.pickup_id,
1609   - // pageSize: 1000
1610   - // },
1611   - // success: function (res_data) {
1612   - // if (res_data.data.code == 0 && res_data.data.data.total > 0) {
1613   - //
1614   - // var lock = 0;
1615   - // for (var i in res_data.data.data.pageData) {
1616   - // lock += res_data.data.data.pageData[i].outQty;
1617   - // }
1618   - //
1619   - // if (CanOutQty <= lock) {
1620   - // wx.showToast({
1621   - // title: '库存不足!',
1622   - // icon: 'none',
1623   - // });
1624   - // return false;
1625   - // //return s.my_warnning("库存不足!", 0, th);
1626   - // }
1627   - // th.add_cart_next(e, t, a, o, newd, CanOutQty - lock);
1628   - // } else {
1629   - // th.add_cart_next(e, t, a, o, newd, CanOutQty);
1630   - // }
1631   - // }
1632   - // })
1633   - // } else {
1634   - // wx.showToast({
1635   - // title: '库存不足!',
1636   - // icon: 'none',
1637   - // });
1638   - // return false;
1639   - // // return s.my_warnning("库存不足!", 0, th);
1640   - // }
1641   - //
1642   - // }
1643   - // }
1644   - // })
1645 1585 th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) {
1646 1586 if (CanOutQty) {
1647 1587 if (CanOutQty < e.data.goodsInputNum) {
... ... @@ -1962,8 +1902,7 @@ Page({
1962 1902  
1963 1903 //---加入购物车的最后一步---
1964 1904 add_cart_next(e, t, a, o, newd, CanOutQty) {
1965   - var th = this,
1966   - i = getApp().request;
  1905 + var th = this, i = getApp().request;
1967 1906 //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------
1968 1907 if ((o.prom_type != 6 && o.prom_type != 4 && o.prom_type != 2 && o.prom_type != 1) || th.data.is_normal) {
1969 1908 var conf = th.data.bconfig;
... ... @@ -1992,11 +1931,10 @@ Page({
1992 1931 //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d);
1993 1932 if ("add" == t.currentTarget.dataset.action) {
1994 1933  
1995   - if (newd.prom_type==0 && th.data.prom_goods && !th.data.sele_g.whsle_id) {
1996   - newd.prom_type = 3;
1997   - newd.prom_id = th.data.prom_goods[0].prom_id;
1998   - }
1999   -
  1934 + // if (newd.prom_type==0 && th.data.prom_goods && !th.data.sele_g.whsle_id) {
  1935 + // newd.prom_type = 3;
  1936 + // newd.prom_id = th.data.prom_goods[0].prom_id;
  1937 + // }
2000 1938 if( [3,5,10].indexOf(newd.prom_type)>-1){
2001 1939 newd.prom_type=0;
2002 1940 newd.prom_id=0;
... ... @@ -2017,12 +1955,10 @@ Page({
2017 1955 var item=null;
2018 1956 //-------如果购物车中有相关的数据---------
2019 1957 if (re.data.data.total > 0) {
2020   -
2021   - for (var i=0; i<re.data.data.pageData.length; i++) {
2022   - if(th.check_is_like(re.data.data.pageData[i],newd)) continue;
2023   - item=re.data.data.pageData[i];
  1958 + for (var j=0; j<re.data.data.pageData.length; j++) {
  1959 + if(!th.check_is_like(re.data.data.pageData[j],newd)) continue;
  1960 + item=re.data.data.pageData[j];
2024 1961 break;
2025   -
2026 1962 }
2027 1963 }
2028 1964  
... ... @@ -2071,7 +2007,7 @@ Page({
2071 2007 }
2072 2008  
2073 2009  
2074   - i.put("/api/weshop/cart/update", {
  2010 + getApp().request.put("/api/weshop/cart/update", {
2075 2011 data: updata,
2076 2012 success: function (t) {
2077 2013 getApp().my_warnning('加入购物车成功', 1, th, 450);
... ... @@ -2083,7 +2019,7 @@ Page({
2083 2019 }
2084 2020 });
2085 2021 }else {
2086   - i.post("/api/weshop/cart/save", {
  2022 + getApp().request.post("/api/weshop/cart/save", {
2087 2023 data: newd,
2088 2024 success: function (t) {
2089 2025 getApp().my_warnning('加入购物车成功', 1, th, 450);
... ... @@ -2100,82 +2036,80 @@ Page({
2100 2036  
2101 2037 } else {
2102 2038  
2103   - //这一步主要是要让立即购买 走 购物车的逻辑 参与活动
2104   - if (newd.prom_type == 10 || newd.prom_type == 7) {
2105   - if(newd.prom_type==7 && 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){
2106   - wx.hideLoading()
2107   -
2108   - wx.showModal({
2109   - title: '提示',
2110   - // content: `商品${str},组合购活动,购买次数已超,将以普通商品购买?`,
2111   - content: `${th.data.data.goods_name}超出组合购限购次数,将以普通商品购买`,
2112   - success:res=>{
2113   - if (res.confirm) {
2114   - console.log('用户点击确定')
2115   - //----先看会员在购物车中是否加入了该商品,立即购买的-----
2116   - getApp().request.get("/api/weshop/cart/page", {
2117   - data: {
2118   - store_id: e.data.stoid,
2119   - user_id: oo.user_id,
2120   - state: 1
2121   - },
2122   - success: function (res) {
2123   - //-------如果购物车中有相关的数据---------
2124   - if (res.data.code == 0 && res.data.data.total > 0) {
2125   - for (let j in res.data.data.pageData) {
2126   - let item_j = res.data.data.pageData[j];
2127   - var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id;
2128   - getApp().request.delete(url, {});
2129   - }
2130   - }
2131   - newd.state = 1;
2132   - newd.prom_type=0;
2133   - newd.prom_id=0
2134   - getApp().request.post("/api/weshop/cart/save", {
2135   - data: newd,
2136   - success: function (t) {
2137   - th.closeSpecModal();
2138   - getApp().goto("/packageE/pages/cart/cart2/cart2?state=1");
2139   - }
2140   - });
2141   - }
2142   - })
2143   - } else if (res.cancel) {
  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: {
  2053 + store_id: e.data.stoid,
  2054 + user_id: oo.user_id,
  2055 + state: 1
  2056 + },
  2057 + success: function (res) {
  2058 + //-------如果购物车中有相关的数据---------
  2059 + 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 + }
  2065 + }
  2066 + newd.state = 1;
  2067 + newd.prom_type=0;
  2068 + newd.prom_id=0
  2069 + 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 + }
  2075 + });
  2076 + }
  2077 + })
  2078 + } else if (res.cancel) {
2144 2079  
2145   - console.log('用户点击取消')
2146   - }
2147   - }
2148   - })
2149   - return false
2150   - }else{
2151   - //----先看会员在购物车中是否加入了该商品,立即购买的-----
2152   - getApp().request.get("/api/weshop/cart/page", {
2153   - data: {
2154   - store_id: e.data.stoid,
2155   - user_id: oo.user_id,
2156   - state: 1
2157   - },
2158   - success: function (res) {
2159   - //-------如果购物车中有相关的数据---------
2160   - if (res.data.code == 0 && res.data.data.total > 0) {
2161   - for (let j in res.data.data.pageData) {
2162   - let item_j = res.data.data.pageData[j];
2163   - var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id;
2164   - getApp().request.delete(url, {});
2165   - }
  2080 + console.log('用户点击取消')
  2081 + }
  2082 + }
  2083 + })
  2084 + return false
  2085 + }else{
  2086 + //----先看会员在购物车中是否加入了该商品,立即购买的-----
  2087 + getApp().request.get("/api/weshop/cart/page", {
  2088 + data: {
  2089 + store_id: e.data.stoid,
  2090 + user_id: oo.user_id,
  2091 + state: 1
  2092 + },
  2093 + success: function (res) {
  2094 + //-------如果购物车中有相关的数据---------
  2095 + if (res.data.code == 0 && res.data.data.total > 0) {
  2096 + for (let j in res.data.data.pageData) {
  2097 + let item_j = res.data.data.pageData[j];
  2098 + var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id;
  2099 + getApp().request.delete(url, {});
2166 2100 }
2167   - newd.state = 1;
2168   - getApp().request.post("/api/weshop/cart/save", {
2169   - data: newd,
2170   - success: function (t) {
2171   - th.closeSpecModal();
2172   - getApp().goto("/packageE/pages/cart/cart2/cart2?state=1");
2173   - }
2174   - });
2175 2101 }
2176   - })
2177   - return false;
2178   - }
  2102 + newd.state = 1;
  2103 + getApp().request.post("/api/weshop/cart/save", {
  2104 + data: newd,
  2105 + success: function (t) {
  2106 + th.closeSpecModal();
  2107 + getApp().goto("/packageE/pages/cart/cart2/cart2?state=1");
  2108 + }
  2109 + });
  2110 + }
  2111 + })
  2112 + return false;
2179 2113 }
2180 2114  
2181 2115 if (th.data.prom_goods) {
... ... @@ -2198,7 +2132,12 @@ Page({
2198 2132 break;
2199 2133 }
2200 2134 }
  2135 + }
2201 2136  
  2137 + //如果有阶梯促销的时候
  2138 + if(th.data.jieti_prom){
  2139 + newd.prom_type = 7;
  2140 + newd.prom_id = th.data.ladder_act_id;
2202 2141 }
2203 2142  
2204 2143 newd['pick_name'] = th.data.sto_sele_name;
... ... @@ -2273,11 +2212,12 @@ Page({
2273 2212 })
2274 2213 } else {
2275 2214 //搭配购特殊处理
2276   - if(th.data.data.prom_type==5){
  2215 + if( [3,5,7,10].indexOf(th.data.data.prom_type)>-1){
2277 2216 e.prom_type=th.data.data.prom_type
2278 2217 e.prom_id=th.data.data.prom_id
2279 2218 e.collocation_goods=[]
2280 2219 }
  2220 +
2281 2221 s.set_b_now(e);
2282 2222 /*--
2283 2223 wx.redirectTo({
... ... @@ -7606,6 +7546,7 @@ Page({
7606 7546 th.setData({
7607 7547 zh_act: e.data.data
7608 7548 });
  7549 + th.getUserBuyPromNum(e.data.data.id)
7609 7550 }
7610 7551  
7611 7552 }
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -594,15 +594,23 @@
594 594 </view>
595 595 </block>
596 596 <!-- 判断是不是有秒杀 -->
  597 + <!-- 判断是不是有秒杀 -->
597 598 <block wx:if="{{more_flash}}">
598 599  
599 600 <block wx:for="{{more_flash}}">
600   - <view class="cx-frame flex" style="position: relative; height: auto" wx:if="{{item.prom_type==1}}">
601   - <view class="cx-sizs wsize" style="width: 144rpx">秒杀</view>
  601 +<!-- <view class="cx-frame flex" style="position: relative; height: auto" wx:if="{{item.prom_type==1}}">-->
  602 + <view class="cx-frame flex" style="position: relative; height: auto" >
  603 + <view wx:if="{{item.prom_type==1}}" class="cx-sizs wsize" style="width: 144rpx">秒杀</view>
  604 + <view wx:if="{{item.prom_type==2}}" class="cx-sizs wsize" style="width: 144rpx">团购</view>
  605 + <view wx:if="{{item.prom_type==4}}" class="cx-sizs wsize" style="width: 144rpx">积分购</view>
602 606 <!-- 中间显示层 -->
603   - <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_more_flash" data-id="{{item.act_id}}">
  607 + <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_more_flash" data-prom_type="{{item.prom_type}}" data-id="{{item.act_id}}">
604 608 <view class="flex">
605   - <view class="miao_lab">秒</view>
  609 +
  610 + <view wx:if="{{item.prom_type==1}}" class="miao_lab">秒</view>
  611 + <view wx:if="{{item.prom_type==2}}" class="miao_lab">团</view>
  612 + <view wx:if="{{item.prom_type==4}}" class="miao_lab">积</view>
  613 +
606 614 <view class="order_hui">
607 615 <view class="fs28 ellipsis-1">{{item.act_name}}</view>
608 616 <view class="fs26">
... ... @@ -617,6 +625,8 @@
617 625 </view>
618 626 </block>
619 627 </block>
  628 +
  629 +
620 630 <!-- 许程 7.24暂时注释 -->
621 631 <view class="bdt16" wx:if="{{ prom_type!=1 && prom_act.kttype!=3&&prom_act.kttype!=2&&prom_act.kttype!=1 && is_closecoupon!=1 && sele_g.is_xz_yh !=1}}">
622 632 <view data-coupon="1" bindtap="switchCoupon" class="cx-frame flex" style="position: relative" wx:if="{{fir_quan.length>0}}">
... ...