Commit 1607bfaef591a893c4589302a9024fdc3d8ea5dd

Authored by yvan.ni
1 parent a644a95d

1、购物多活动的商品排序

packageE/pages/cart/cart2/cart2.js
@@ -797,7 +797,8 @@ Page({ @@ -797,7 +797,8 @@ Page({
797 a.get("/api/weshop/cart/list", { 797 a.get("/api/weshop/cart/list", {
798 data: { 798 data: {
799 user_id: to.globalData.user_id, selected: 1, state: state, 799 user_id: to.globalData.user_id, selected: 1, state: state,
800 - store_id: oo.stoid, pageSize: 600 800 + store_id: oo.stoid, pageSize: 600,
  801 + isorder:1
801 }, 802 },
802 success: async function (su) { 803 success: async function (su) {
803 804
@@ -820,7 +821,7 @@ Page({ @@ -820,7 +821,7 @@ Page({
820 } 821 }
821 }) 822 })
822 823
823 - th.data.cartlist_y = carr; //存储原始购物车列表 824 + th.data.cartlist_y =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表
824 825
825 wx.showLoading(); 826 wx.showLoading();
826 827
@@ -832,7 +833,7 @@ Page({ @@ -832,7 +833,7 @@ Page({
832 833
833 834
834 //-- is_change是有没有切换活动的意思 -- 835 //-- is_change是有没有切换活动的意思 --
835 - async get_cart_next(carr,is_change){ 836 + async get_cart_next(carr,is_change,old_prom){
836 837
837 //--- 切换的时候一定要把赠品去掉 --- 838 //--- 切换的时候一定要把赠品去掉 ---
838 if(is_change){ 839 if(is_change){
@@ -841,7 +842,14 @@ Page({ @@ -841,7 +842,14 @@ Page({
841 //-- 剔除赠品的数据,等到确定活动是优惠促销的时候,在显示赠品, 赠品直接删除 -- 842 //-- 剔除赠品的数据,等到确定活动是优惠促销的时候,在显示赠品, 赠品直接删除 --
842 var new_arr=[]; 843 var new_arr=[];
843 for (var ir = 0; ir < carr.length; ir++) { 844 for (var ir = 0; ir < carr.length; ir++) {
844 - if(carr[ir].is_gift && carr[ir].id) { 845 +
  846 + var c_ok=1;
  847 + if(old_prom && (carr[ir].prom_type!=old_prom.prom_type || carr[ir].prom_id!=old_prom.prom_id) ){
  848 + c_ok=0;
  849 + }
  850 +
  851 + if(carr[ir].is_gift && carr[ir].id && c_ok) {
  852 +
845 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + carr[ir].id; 853 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + carr[ir].id;
846 getApp().request.delete(url, { 854 getApp().request.delete(url, {
847 success: function (t) {} 855 success: function (t) {}
@@ -2118,37 +2126,43 @@ Page({ @@ -2118,37 +2126,43 @@ Page({
2118 cart_add_gift(item_map,pickid,i,ord_goods,get_data){ 2126 cart_add_gift(item_map,pickid,i,ord_goods,get_data){
2119 2127
2120 var th=this; 2128 var th=this;
2121 - var pos=this.find_pro_last(ord_goods,3,item_map.prom_id);  
2122 var is_has_gift=this.is_has_gift(ord_goods,item_map.prom_id) 2129 var is_has_gift=this.is_has_gift(ord_goods,item_map.prom_id)
2123 2130
2124 //-- 没有赠品的时候才添加,避免购物车重复出现 -- 2131 //-- 没有赠品的时候才添加,避免购物车重复出现 --
2125 - if(pos>-1 && !is_has_gift){  
2126 - var newd = {  
2127 - goods_id: get_data.goods_id,  
2128 - goods_num: get_data.bs * get_data.zp_num, //是赠品的翻倍  
2129 - pick_id: pickid,  
2130 - user_id: app.globalData.user_id,  
2131 - store_id: os.stoid,  
2132 - goods_price: 0,  
2133 - member_goods_price: 0,  
2134 - goods_name: get_data.goods_name,  
2135 - goods_sn: get_data.goodsinfo.goods_sn,  
2136 - sku: get_data.goodsinfo.sku,  
2137 - is_gift: 1,  
2138 - prom_id: item_map.prom_id,  
2139 - prom_type: 3,  
2140 - selected: 1,  
2141 - gift_id: get_data.gift_id,  
2142 - original_img: th.data.imgUrl + get_data.goodsinfo.original_img  
2143 - };  
2144 - var fd_gd=ord_goods[pos]  
2145 -  
2146 - newd.guide_id=fd_gd.guide_id;  
2147 - newd.guide_type=fd_gd.guide_type;  
2148 - newd.distr_type=fd_gd.distr_type; 2132 + if(!is_has_gift){
  2133 +
  2134 + //看一下要插入的位置
  2135 + var pos=this.find_pro_last(ord_goods,3,item_map.prom_id);
  2136 + var pos2=this.find_pro_last(th.data.old_cartlist[i].goods,3,item_map.prom_id);
  2137 +
  2138 + if(pos>-1){
  2139 + var newd = {
  2140 + goods_id: get_data.goods_id,
  2141 + goods_num: get_data.bs * get_data.zp_num, //是赠品的翻倍
  2142 + pick_id: pickid,
  2143 + user_id: app.globalData.user_id,
  2144 + store_id: os.stoid,
  2145 + goods_price: 0,
  2146 + member_goods_price: 0,
  2147 + goods_name: get_data.goods_name,
  2148 + goods_sn: get_data.goodsinfo.goods_sn,
  2149 + sku: get_data.goodsinfo.sku,
  2150 + is_gift: 1,
  2151 + prom_id: item_map.prom_id,
  2152 + prom_type: 3,
  2153 + selected: 1,
  2154 + gift_id: get_data.gift_id,
  2155 + original_img: th.data.imgUrl + get_data.goodsinfo.original_img
  2156 + };
  2157 + var fd_gd=ord_goods[pos]
2149 2158
2150 - ord_goods.splice(1,0,newd); 2159 + newd.guide_id=fd_gd.guide_id;
  2160 + newd.guide_type=fd_gd.guide_type;
  2161 + newd.distr_type=fd_gd.distr_type;
2151 2162
  2163 + ord_goods.splice(pos+1,0,newd);
  2164 + th.data.old_cartlist[i].goods.splice(pos2+1,0,newd);
  2165 + }
2152 2166
2153 } 2167 }
2154 2168
@@ -4799,7 +4813,7 @@ Page({ @@ -4799,7 +4813,7 @@ Page({
4799 4813
4800 //如果活动一样,那么商品的活动就要清理成0 4814 //如果活动一样,那么商品的活动就要清理成0
4801 var sh_can_cx=t_item.show_can_cx; 4815 var sh_can_cx=t_item.show_can_cx;
4802 - if(sh_can_cx){ 4816 + if(sh_can_cx && !g_item.is_zh_split){
4803 for (let kh in sh_can_cx) { 4817 for (let kh in sh_can_cx) {
4804 var cur=sh_can_cx[kh]?sh_can_cx[kh].cur_act:null; 4818 var cur=sh_can_cx[kh]?sh_can_cx[kh].cur_act:null;
4805 if(cur && cur.is_no_ok){ 4819 if(cur && cur.is_no_ok){
@@ -4845,7 +4859,7 @@ Page({ @@ -4845,7 +4859,7 @@ Page({
4845 } 4859 }
4846 4860
4847 var txt = goods.prom_id + ',' + goods.prom_type + ',' + goods.goods_id + ',' + goods.is_gift; 4861 var txt = goods.prom_id + ',' + goods.prom_type + ',' + goods.goods_id + ',' + goods.is_gift;
4848 - //--赠品的时候,阶梯促销会右重复的情况 -- 4862 + //--赠品的时候,阶梯促销会右重复的情况,还有组合购的时候拆分出去的 --
4849 if (check_map[txt] && goods.prom_type != 10) { 4863 if (check_map[txt] && goods.prom_type != 10) {
4850 getApp().confirmBox(goods.goods_name + "计算金额错误,请重新刷新"); 4864 getApp().confirmBox(goods.goods_name + "计算金额错误,请重新刷新");
4851 return false; 4865 return false;
@@ -7740,7 +7754,8 @@ Page({ @@ -7740,7 +7754,8 @@ Page({
7740 7754
7741 th.setData({ 7755 th.setData({
7742 send_lb:{}, 7756 send_lb:{},
7743 - month_lb:{} 7757 + month_lb:{},
  7758 + send_gf:{}
7744 }) 7759 })
7745 7760
7746 th.data.prom_goods_map={}; 7761 th.data.prom_goods_map={};
@@ -7789,7 +7804,7 @@ Page({ @@ -7789,7 +7804,7 @@ Page({
7789 mask: true 7804 mask: true
7790 }) 7805 })
7791 //-- 重新计算一下价格 -- 7806 //-- 重新计算一下价格 --
7792 - th.get_cart_next(null,1); 7807 + th.get_cart_next(null,1,cx_prom_group[fir_sele]);
7793 }else{ 7808 }else{
7794 wx.showToast({ 7809 wx.showToast({
7795 title: ck_res.msg, 7810 title: ck_res.msg,
packageE/pages/cart/cart2/cart2.wxml
@@ -114,10 +114,11 @@ @@ -114,10 +114,11 @@
114 </view> 114 </view>
115 </navigator> 115 </navigator>
116 </view> 116 </view>
  117 +
117 <!-- 验证活动是不是多个,要不要显示切换 --> 118 <!-- 验证活动是不是多个,要不要显示切换 -->
118 <!-- 新增促销多活动的排版 --> 119 <!-- 新增促销多活动的排版 -->
119 <block wx:if="{{(util.is_more_act(items,item.show_can_cx) && item.show_can_cx[items.goods_id] && item.show_can_cx[items.goods_id].act_arr.length>1)}}"> 120 <block wx:if="{{(util.is_more_act(items,item.show_can_cx) && item.show_can_cx[items.goods_id] && item.show_can_cx[items.goods_id].act_arr.length>1)}}">
120 - <view class="bdb16" wx:if="{{util.check_show(items,item.show_can_cx[items.goods_id].sele_prom_type)}}"> 121 + <view class="bdb16" wx:if="{{util.check_show(items,item.show_can_cx[items.goods_id].cur_act.prom_type)}}">
121 <view bindtap="switch_cx_group" 122 <view bindtap="switch_cx_group"
122 data-index="{{pidx}}" 123 data-index="{{pidx}}"
123 data-gd_key="{{items.goods_id}}" 124 data-gd_key="{{items.goods_id}}"
@@ -144,6 +145,7 @@ @@ -144,6 +145,7 @@
144 <!--此时是多个商品参与活动的切换 验证活动是不是多个,要不要显示切换 --> 145 <!--此时是多个商品参与活动的切换 验证活动是不是多个,要不要显示切换 -->
145 <!-- 新增促销多活动的排版 --> 146 <!-- 新增促销多活动的排版 -->
146 <block wx:if="{{item.show_can_cx}}"> 147 <block wx:if="{{item.show_can_cx}}">
  148 +
147 <block wx:for="{{item.show_can_cx}}" wx:for-item="pitem"> 149 <block wx:for="{{item.show_can_cx}}" wx:for-item="pitem">
148 <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1}}" > 150 <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1}}" >
149 <view bindtap="switch_cx_group" 151 <view bindtap="switch_cx_group"
packageE/pages/cart/cart2/filter.wxs
@@ -16,7 +16,7 @@ function is_more_act(items,show_can_cx){ @@ -16,7 +16,7 @@ function is_more_act(items,show_can_cx){
16 16
17 function check_show(items,sele_prom_type){ 17 function check_show(items,sele_prom_type){
18 if([7,10].indexOf(sele_prom_type)>-1){ 18 if([7,10].indexOf(sele_prom_type)>-1){
19 - if(!items.is_act_last) return false; 19 + if(items.is_act_last==0) return false;
20 } 20 }
21 return true; 21 return true;
22 } 22 }
packageE/pages/cart/cart2/zh_calculate.js
@@ -264,9 +264,12 @@ module.exports = { @@ -264,9 +264,12 @@ module.exports = {
264 }) 264 })
265 goods[idx].goods_num -= num; 265 goods[idx].goods_num -= num;
266 let new_g = JSON.parse(JSON.stringify(goods[idx])); 266 let new_g = JSON.parse(JSON.stringify(goods[idx]));
  267 +
  268 + if(new_g.more_cx) delete new_g.more_cx;
267 new_g.goods_num = num; 269 new_g.goods_num = num;
268 new_g.prom_type = 0; 270 new_g.prom_type = 0;
269 new_g.prom_id = 0; 271 new_g.prom_id = 0;
  272 + new_g.is_zh_split = 1; //-- 是组合购拆分出去的 --
270 goods.push(new_g); 273 goods.push(new_g);
271 274
272 //如果商品的数量已经为空了 275 //如果商品的数量已经为空了
pages/cart/cart/cart.js
@@ -2207,6 +2207,7 @@ Page({ @@ -2207,6 +2207,7 @@ Page({
2207 2207
2208 car[a].zh_map = null; 2208 car[a].zh_map = null;
2209 car[a].ladder_map = null; 2209 car[a].ladder_map = null;
  2210 + car[a].need_list = [];
2210 2211
2211 2212
2212 var item = car[a].goods, 2213 var item = car[a].goods,
@@ -4669,7 +4670,6 @@ Page({ @@ -4669,7 +4670,6 @@ Page({
4669 if (the_rs.code == 0) { 4670 if (the_rs.code == 0) {
4670 th.data.change_act = 1; 4671 th.data.change_act = 1;
4671 4672
4672 -  
4673 th.doCheckAll(async function () { 4673 th.doCheckAll(async function () {
4674 for (var i in th.data.requestData) { 4674 for (var i in th.data.requestData) {
4675 await th.check_prom_activity(i) 4675 await th.check_prom_activity(i)
utils/more_cx.js
@@ -65,10 +65,6 @@ module.exports = { @@ -65,10 +65,6 @@ module.exports = {
65 } 65 }
66 } 66 }
67 67
68 - if(!need_ok) {  
69 - item_act_map.is_no_ok = 1;  
70 - return true;  
71 - }  
72 //-- 判断组合购的限购是不是到了 -- 68 //-- 判断组合购的限购是不是到了 --
73 if(act.buy_limit>0){ 69 if(act.buy_limit>0){
74 var need_ck0=0; 70 var need_ck0=0;