Commit ac9e5f465e35ef340d934dfb45f11fdb0c756343

Authored by yvan.ni
1 parent b52067b0

多活动的优化

packageE/pages/cart/cart2/cart2.js
@@ -5967,10 +5967,50 @@ Page({ @@ -5967,10 +5967,50 @@ Page({
5967 }, 5967 },
5968 5968
5969 setexptype2: function (e) { 5969 setexptype2: function (e) {
  5970 +
  5971 + if(this.data.all_collocation_list){
  5972 + var bn_coll= this.selectComponent('#bn_coll');
  5973 + bn_coll.clear_sele();
  5974 + this.setData({ collocation_goods: [] });
  5975 + //让主商品的活动变成5,搭配购
  5976 + this.setData({ 'bn_goods.prom_type': 0, 'bn_goods.prom_id': 0 });
  5977 + }
  5978 +
5970 this.debounce(this.setexptype.bind(this, e), 400)(); 5979 this.debounce(this.setexptype.bind(this, e), 400)();
  5980 +
5971 }, 5981 },
5972 5982
5973 setexptype_w2: function (e) { 5983 setexptype_w2: function (e) {
  5984 +
  5985 +
  5986 + for (let i = 0; i <this.data.cartlist ; i++) {
  5987 + var collocationList=this.data.cartlist[i].collocationList;
  5988 + if(collocationList){
  5989 +
  5990 + var txt2 = 'cartlist[' + cart_index + '].collocationList';
  5991 + for (let jy = 0; jy <collocationList.length ; jy++) {
  5992 + collocationList[jy].selected=0;
  5993 + }
  5994 + th.setData({[txt2]:collocationList})
  5995 +
  5996 +
  5997 + var bn_coll= this.selectComponent("#col"+i);
  5998 + bn_coll.clear_sele();
  5999 + var goods = this.data.cartlist[i].goods;
  6000 +
  6001 + var g_arr=[];
  6002 + for (var j = 0; j < goods.length; j++) {
  6003 + if(goods[j].is_collocation) continue;
  6004 + g_arr.push(goods[j]);
  6005 + }
  6006 + var txt = 'cartlist[' + cart_index + '].goods';
  6007 +
  6008 + th.setData({ [txt]: g_arr});
  6009 + }
  6010 + }
  6011 +
  6012 + this.data.old_cartlist = JSON.parse(JSON.stringify(this.data.cartlist));
  6013 +
5974 this.debounce(this.setexptype_w.bind(this, e), 400)(); 6014 this.debounce(this.setexptype_w.bind(this, e), 400)();
5975 }, 6015 },
5976 6016
@@ -6394,12 +6434,40 @@ Page({ @@ -6394,12 +6434,40 @@ Page({
6394 //如果是选中 6434 //如果是选中
6395 if (e.selected) { 6435 if (e.selected) {
6396 var item = this.data.all_collocation_list[e.index]; 6436 var item = this.data.all_collocation_list[e.index];
  6437 +
  6438 + //如果是自提的时候
  6439 + if(this.data.bn_exp_type==1){
  6440 +
  6441 + if(item.distr_type==2){
  6442 + wx.showToast({
  6443 + title: "商品的配送方式不一致",
  6444 + icon: 'none',
  6445 + duration: 2000
  6446 + })
  6447 + th.setData({ submit: 0 });
  6448 + return false;
  6449 + }
  6450 +
  6451 + }else{
  6452 + if(item.distr_type==1){
  6453 + wx.showToast({
  6454 + title: "商品的配送方式不一致",
  6455 + icon: 'none',
  6456 + duration: 2000
  6457 + })
  6458 + th.setData({ submit: 0 });
  6459 + return false;
  6460 + }
  6461 + }
  6462 +
  6463 + var bn_coll = th.selectComponent("#bn_coll"); //组件的id
  6464 + bn_coll.set_sele(e.index);
  6465 +
6397 item.goods_num = 1; 6466 item.goods_num = 1;
6398 item.goods_price = item.price; 6467 item.goods_price = item.price;
6399 item.is_collocation = 1; 6468 item.is_collocation = 1;
6400 item.prom_type = 5; 6469 item.prom_type = 5;
6401 6470
6402 -  
6403 var coll_arr = []; 6471 var coll_arr = [];
6404 if (this.data.collocation_goods && this.data.collocation_goods.length) { 6472 if (this.data.collocation_goods && this.data.collocation_goods.length) {
6405 coll_arr = this.data.collocation_goods; 6473 coll_arr = this.data.collocation_goods;
@@ -6451,6 +6519,7 @@ Page({ @@ -6451,6 +6519,7 @@ Page({
6451 } 6519 }
6452 } 6520 }
6453 }, 6521 },
  6522 +
6454 //购物车购买的时候,选中和不选中搭配商品 6523 //购物车购买的时候,选中和不选中搭配商品
6455 async select_coll_buy_cart(e) { 6524 async select_coll_buy_cart(e) {
6456 var th = this; 6525 var th = this;
@@ -6465,6 +6534,34 @@ Page({ @@ -6465,6 +6534,34 @@ Page({
6465 6534
6466 //-- 如果是选中 -- 6535 //-- 如果是选中 --
6467 if (e.selected) { 6536 if (e.selected) {
  6537 +
  6538 + var exp_type=this.data.order_prom_list_cart[cart_index].exp_type; //配送方式
  6539 + //如果是自提的时候
  6540 + if(exp_type==1){
  6541 +
  6542 + if(item.distr_type==2){
  6543 + wx.showToast({
  6544 + title: "商品的配送方式不一致",
  6545 + icon: 'none',
  6546 + duration: 2000
  6547 + })
  6548 + return false;
  6549 + }
  6550 +
  6551 + }else{
  6552 + if(item.distr_type==1){
  6553 + wx.showToast({
  6554 + title: "商品的配送方式不一致",
  6555 + icon: 'none',
  6556 + duration: 2000
  6557 + })
  6558 + return false;
  6559 + }
  6560 + }
  6561 +
  6562 + var bn_coll = th.selectComponent("#col"+cart_index); //组件的id
  6563 + bn_coll.set_sele(index);
  6564 +
6468 item.goods_num = 1; 6565 item.goods_num = 1;
6469 item.goods_price = item.price; 6566 item.goods_price = item.price;
6470 item.prom_type = 5; 6567 item.prom_type = 5;
packageE/pages/cart/cart2/cart2.wxml
@@ -109,7 +109,11 @@ @@ -109,7 +109,11 @@
109 </view> 109 </view>
110 110
111 <!-- 使用搭配 --> 111 <!-- 使用搭配 -->
112 - <cart_collect_temp bind:childFun="select_coll" sales_rules="{{sales_rules}}" pick="{{item.pickup_id}}" is_cart="1" cart_index="{{pidx}}" distr_t="{{item.distr_t}}" appoint_pick_keyid="{{appoint_pick_keyid}}" all_collocation_list="{{item.collocationList}}" /> 112 + <cart_collect_temp id="col{{pidx}}"
  113 + bind:childFun="select_coll" sales_rules="{{sales_rules}}"
  114 + pick="{{item.pickup_id}}" is_cart="1" cart_index="{{pidx}}"
  115 + distr_t="{{item.distr_t}}"
  116 + appoint_pick_keyid="{{appoint_pick_keyid}}" all_collocation_list="{{item.collocationList}}" />
113 117
114 <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 --> 118 <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 -->
115 <view class="plus_buy fs28" wx:if="{{item.card_cut_price>0}}"> 119 <view class="plus_buy fs28" wx:if="{{item.card_cut_price>0}}">
@@ -384,7 +388,9 @@ @@ -384,7 +388,9 @@
384 </block> 388 </block>
385 389
386 <!-- 使用搭配 --> 390 <!-- 使用搭配 -->
387 - <cart_collect_temp bind:childFun="select_coll" all_collocation_list="{{all_collocation_list}}" distr_t="{{bn_goods.distr_type}}" appoint_pick_keyid="{{appoint_pick_keyid}}" sales_rules="{{sales_rules}}" pick="{{bn_pick}}" /> 391 + <cart_collect_temp bind:childFun="select_coll" id="bn_coll"
  392 + all_collocation_list="{{all_collocation_list}}" distr_t="{{bn_goods.distr_type}}"
  393 + appoint_pick_keyid="{{appoint_pick_keyid}}" sales_rules="{{sales_rules}}" pick="{{bn_pick}}" />
388 394
389 395
390 <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 --> 396 <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 -->
pages/goods/goodsInfo/goodsInfo.js
@@ -2210,6 +2210,12 @@ Page({ @@ -2210,6 +2210,12 @@ Page({
2210 newd.prom_id = th.data.collocationGoods.id; 2210 newd.prom_id = th.data.collocationGoods.id;
2211 } 2211 }
2212 2212
  2213 + //如果有搭配购的时候的时候
  2214 + if(th.data.zh_act && newd.prom_type==0){
  2215 + newd.prom_type = 7;
  2216 + newd.prom_id = th.data.zh_act.id;
  2217 + }
  2218 +
2213 2219
2214 newd['pick_name'] = th.data.sto_sele_name; 2220 newd['pick_name'] = th.data.sto_sele_name;
2215 newd['pick_dis'] = th.data.sto_sele_distr; 2221 newd['pick_dis'] = th.data.sto_sele_distr;
@@ -2288,6 +2294,11 @@ Page({ @@ -2288,6 +2294,11 @@ Page({
2288 e.prom_id=th.data.data.prom_id 2294 e.prom_id=th.data.data.prom_id
2289 e.collocation_goods=[] 2295 e.collocation_goods=[]
2290 } 2296 }
  2297 +
  2298 + if(th.data.collocationGoods){
  2299 + e.prom_type=5
  2300 + e.prom_id=th.data.collocationGoods.id
  2301 + }
2291 2302
2292 s.set_b_now(e); 2303 s.set_b_now(e);
2293 /*-- 2304 /*--
@@ -7125,12 +7136,18 @@ Page({ @@ -7125,12 +7136,18 @@ Page({
7125 } else { 7136 } else {
7126 //调用接口判断订单优惠, 7137 //调用接口判断订单优惠,
7127 getApp().request.get("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + gid + "/0" + "/" + user_id, { 7138 getApp().request.get("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + gid + "/0" + "/" + user_id, {
7128 - success: function (res) { 7139 + success: async function (res) {
7129 if (res.data.code == 0 && res.data.data) { 7140 if (res.data.code == 0 && res.data.data) {
7130 var r_data = res.data.data; 7141 var r_data = res.data.data;
7131 - var max = 0,  
7132 - min = 0; 7142 + var max = 0, min = 0;
  7143 +
7133 7144
  7145 + //暂时积分够 不和 优惠,阶梯重叠
  7146 + if(th.data.has_jf || th.data.zh_act){
  7147 + r_data.collocationList=null;
  7148 + r_data.ladderLists=null;
  7149 + r_data.promGoodsLists=null;
  7150 + }
7134 7151
7135 if (r_data.collocationList) { 7152 if (r_data.collocationList) {
7136 for (var i in r_data.collocationList) { 7153 for (var i in r_data.collocationList) {
@@ -7152,7 +7169,7 @@ Page({ @@ -7152,7 +7169,7 @@ Page({
7152 if (r_data.ladderLists) { 7169 if (r_data.ladderLists) {
7153 var act_id = r_data.ladderLists[0].form_id; 7170 var act_id = r_data.ladderLists[0].form_id;
7154 //-- 判断会员能不能参与阶梯促销 -- 7171 //-- 判断会员能不能参与阶梯促销 --
7155 - getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => { 7172 + await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => {
7156 if (res.data.code == 0 && res.data.data) { 7173 if (res.data.code == 0 && res.data.data) {
7157 var prom_content = ""; 7174 var prom_content = "";
7158 7175
@@ -7161,6 +7178,10 @@ Page({ @@ -7161,6 +7178,10 @@ Page({
7161 return false; 7178 return false;
7162 } 7179 }
7163 7180
  7181 + if(res.data.data.good_object==1){
  7182 + r_data.promGoodsLists=null;
  7183 + }
  7184 +
7164 for (let jj in r_data.ladderLists) { 7185 for (let jj in r_data.ladderLists) {
7165 if (r_data.ladderLists[jj].discount == 10) { 7186 if (r_data.ladderLists[jj].discount == 10) {
7166 prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; 7187 prom_content += "第" + (parseInt(jj) + 1) + "件原价,";
@@ -7474,7 +7495,7 @@ Page({ @@ -7474,7 +7495,7 @@ Page({
7474 let item = arr_data[i]; 7495 let item = arr_data[i];
7475 //找不到活动要剔除 7496 //找不到活动要剔除
7476 if (!item.act_name) continue; 7497 if (!item.act_name) continue;
7477 - if ([1,2,6].indexOf(item.prom_type)==-1) continue; 7498 + if ([1,2,4,6].indexOf(item.prom_type)==-1) continue;
7478 new_arr.push(item); 7499 new_arr.push(item);
7479 } 7500 }
7480 7501
@@ -7609,6 +7630,10 @@ Page({ @@ -7609,6 +7630,10 @@ Page({
7609 return e.s_time < ut.gettimestamp() && e.prom_type==7; 7630 return e.s_time < ut.gettimestamp() && e.prom_type==7;
7610 }) 7631 })
7611 7632
  7633 + var arr4 = arr.filter(function (e) {
  7634 + return e.s_time < ut.gettimestamp() && e.prom_type==4;
  7635 + })
  7636 +
7612 //-- 如果只有一个活动的话 -- 7637 //-- 如果只有一个活动的话 --
7613 if (arr.length == 1) { 7638 if (arr.length == 1) {
7614 th.data.prom_type = arr[0].prom_type; 7639 th.data.prom_type = arr[0].prom_type;
@@ -7620,6 +7645,9 @@ Page({ @@ -7620,6 +7645,9 @@ Page({
7620 th.data.prom_id = arr2[0].act_id; 7645 th.data.prom_id = arr2[0].act_id;
7621 } 7646 }
7622 7647
  7648 + if(arr4.length>0){
  7649 + th.data.has_jf=1;
  7650 + }
7623 7651
7624 if(arr3 && arr3.length>0){ 7652 if(arr3 && arr3.length>0){
7625 //获取活动信息 7653 //获取活动信息
@@ -7640,13 +7668,18 @@ Page({ @@ -7640,13 +7668,18 @@ Page({
7640 } 7668 }
7641 7669
7642 } 7670 }
  7671 +
  7672 + //-- 调用回调 --
  7673 + func();
7643 } 7674 }
7644 }); 7675 });
  7676 + }else {
  7677 + //-- 调用回调 --
  7678 + func();
7645 } 7679 }
7646 7680
7647 } 7681 }
7648 - //-- 调用回调 --  
7649 - func(); 7682 +
7650 } 7683 }
7651 }); 7684 });
7652 }, 7685 },