Commit 627d556460f916cdabe13f3d30649dbc0f797a0c

Authored by yvan.ni
1 parent e29578e1

多促销的优化, 购物车的时候

pages/cart/cart/cart.js
... ... @@ -2844,6 +2844,30 @@ Page({
2844 2844 if (i_arr[j].is_pd_normal || i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3) {
2845 2845 normal_arr[i_arr[j].goods_id] = 1;
2846 2846 }
  2847 +
  2848 + //检查活动是不是满足了条件,或者要取满足条件的活动
  2849 + var fd1=null;
  2850 + if(this.data.requestData[i].show_can_cx && (i_arr[j].prom_type == 3 || i_arr[j].prom_type == 7) ){
  2851 + for(var ik in this.data.requestData[i].show_can_cx){
  2852 + var ch_map=this.data.requestData[i].show_can_cx[ik].ch_map;
  2853 + if(ch_map.indexOf(i_arr[j].goods_id)==-1) continue;
  2854 +
  2855 + var item_arr=this.data.requestData[i].show_can_cx[ik].act_arr;
  2856 + fd1=item_arr.find(function (hb){
  2857 + return !hb.is_no_ok;
  2858 + })
  2859 + if(fd1) break;
  2860 + }
  2861 + if(!fd1){
  2862 + i_arr[j].prom_id=0;
  2863 + i_arr[j].prom_type=0;
  2864 + }else{
  2865 + i_arr[j].prom_id=fd1.prom_id;
  2866 + i_arr[j].prom_type=fd1.prom_type;
  2867 + }
  2868 + }
  2869 +
  2870 +
2847 2871 if (i_arr[j].prom_type == 7 && (!this.data.requestData[i].need_list || (this.data.requestData[i].need_list && this.data.requestData[i].need_list.length == 0)) && i_arr[j].act && i_arr[j].act.buy_limit != 0) {
2848 2872 let userbuynum = await this.getUserBuyPromNum(i_arr[j].goods_prom_id)
2849 2873 console.log('活动次数:' + userbuynum);
... ...
utils/more_cx.js
... ... @@ -79,7 +79,7 @@ module.exports = {
79 79 }
80 80 }
81 81  
82   - if(!need_ok) return true;
  82 +
83 83 for (var i in goods) {
84 84 var item = goods[i];
85 85 var cart_num = get_num(item).goods_num;
... ... @@ -288,6 +288,12 @@ module.exports = {
288 288 item_act_map.in_zhact_gdmap=in_zhact_gdmap;
289 289 return true;
290 290 }
  291 +
  292 + if(!need_ok) {
  293 + item_act_map.is_no_ok=1;
  294 + return true;
  295 + }
  296 +
291 297 return false;
292 298 },
293 299 //-- 判读一下促销分组的问题 --
... ... @@ -436,10 +442,7 @@ module.exports = {
436 442 }
437 443 }
438 444  
439   - if(!need_ok){
440   - can_calc_cx.push(item_act_map);
441   - continue;
442   - }
  445 +
443 446  
444 447 var fir_act=item_act_map.act.fir_act;
445 448 var t_goods=item_act_map.goods;
... ... @@ -465,6 +468,11 @@ module.exports = {
465 468 //-- 如果有满足优惠条件的时候 --
466 469 if(yh_ok){
467 470 can_calc_cx.push(item_act_map)
  471 + }else{
  472 + if(!need_ok){
  473 + item_act_map.is_no_ok=1;
  474 + can_calc_cx.push(item_act_map);
  475 + }
468 476 }
469 477 break
470 478  
... ...