Commit 65a855fba6d729ece97246f24272554847e1e4d4

Authored by yvan.ni
1 parent e4002f25

搭配购购买的时候,如何没有搭配商品,就按照普通商品计算能不能使用优化券

packageE/pages/cart/cart2/cart2.js
... ... @@ -1260,12 +1260,8 @@ Page({
1260 1260 et = 0;
1261 1261 break;
1262 1262 }
1263   -
1264   -
1265 1263 var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
1266 1264  
1267   -
1268   -
1269 1265 if (et == 0 && def_exp_code && !th.data.is_default_logistics) {
1270 1266 for (var k = 0; k < th.data.wu_arr.length; k++) {
1271 1267 var item = th.data.wu_arr[k];
... ... @@ -1429,10 +1425,10 @@ Page({
1429 1425 if (gg.prom_type == 5) {
1430 1426 t.data.data.prom_id = gg.prom_id;
1431 1427 t.data.data.prom_type = 5;
1432   - th.is_coupon = gg.is_coupon;
1433   - th.setData({
1434   - is_coupon: gg.is_coupon
1435   - });
  1428 + // th.is_coupon = gg.is_coupon;
  1429 + // th.setData({
  1430 + // is_coupon: gg.is_coupon
  1431 + // });
1436 1432 if (gg.room_id) {
1437 1433 t.data.data.room_id = gg.room_id;
1438 1434 }
... ... @@ -5277,7 +5273,7 @@ Page({
5277 5273 continue;
5278 5274 }
5279 5275  
5280   - if(gd.prom_type==5 && !th.data.coll_prom[gd.prom_id].is_coupon){
  5276 + if(gd.prom_type==5 && !th.data.coll_prom[gd.prom_id].is_coupon && th.has_dp(goodlist,gd.prom_id)){
5281 5277 continue;
5282 5278 }
5283 5279 //--如果是团购,要判断有没有限制使用优惠券
... ... @@ -5387,6 +5383,8 @@ Page({
5387 5383 arr[ind].ckeck_quan_price = ckeck_quan_price - (cut_price ? cut_price : 0);
5388 5384 arr[ind].check_quan_ware_list = check_quan_ware_list;
5389 5385 arr[ind].check_quan_price_list = check_quan_price_list;
  5386 + arr[ind].quan_list=null;
  5387 +
5390 5388 //-- 是否关闭使用优惠券,循环有找到商品 --
5391 5389 if (th.data.is_close_quan != 1 && check_quan_ware_list) {
5392 5390 //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
... ... @@ -5406,8 +5404,13 @@ Page({
5406 5404 }
5407 5405 })
5408 5406 }
  5407 +
  5408 +
5409 5409 }
5410 5410  
  5411 +
  5412 +
  5413 +
5411 5414 //如果是搭配购的立即购买的时候
5412 5415 if (th.data.is_b_now) {
5413 5416 if (arr && arr.length > 0) {
... ... @@ -6518,6 +6521,9 @@ Page({
6518 6521 var th = this;
6519 6522 //--按钮变灰色 --
6520 6523 th.setData({ submit: 1 });
  6524 + var txt = 'using_quan[' + th.data.bn_pick + ']';
  6525 + th.setData({[txt]: null})
  6526 +
6521 6527 //如果是选中
6522 6528 if (e.selected) {
6523 6529 var item = this.data.all_collocation_list[e.index];
... ... @@ -6558,6 +6564,7 @@ Page({
6558 6564  
6559 6565 th.setData({is_coupon:item.is_coupon})
6560 6566  
  6567 +
6561 6568 var coll_arr = [];
6562 6569 if (this.data.collocation_goods && this.data.collocation_goods.length) {
6563 6570 coll_arr = this.data.collocation_goods;
... ... @@ -6596,11 +6603,16 @@ Page({
6596 6603 if (!coll_arr || coll_arr.length < 1) {
6597 6604 //让主商品的活动变成0,取消搭配购
6598 6605 this.setData({ 'bn_goods.prom_type': 0, 'bn_goods.prom_id': 0, collocation_goods: [] });
  6606 +
  6607 + th.setData({is_coupon:1})
  6608 +
6599 6609 //计算价格
6600 6610 th.calculatePrice2();
6601 6611 //获取优惠券
6602 6612 th.get_buy_now_quan();
6603 6613  
  6614 +
  6615 +
6604 6616 } else {
6605 6617 this.setData({ collocation_goods: coll_arr });
6606 6618 //要进行深拷贝
... ... @@ -6626,6 +6638,11 @@ Page({
6626 6638 var txt = 'cartlist[' + cart_index + '].goods';
6627 6639 var txt2 = 'cartlist[' + cart_index + '].collocationList[' + index + '].selected';
6628 6640  
  6641 + //有改,都强制把券选择清理一下
  6642 + var pickup_id = this.data.cartlist[cart_index].pickup_id;
  6643 + var txt='using_quan['+pickup_id+']';
  6644 + th.setData({[txt]:null});
  6645 +
6629 6646 //-- 如果是选中 --
6630 6647 if (e.selected) {
6631 6648  
... ... @@ -6765,6 +6782,17 @@ Page({
6765 6782 }
6766 6783  
6767 6784 th.data.old_cartlist = cart_arr;
  6785 + },
  6786 +
  6787 + //-- 获取到搭配 --
  6788 + has_dp:function (list,prom_id){
  6789 + for (let i in list) {
  6790 + var it=list[i];
  6791 + if(it.prom_id==prom_id && it.is_collocation==1){
  6792 + return true;
  6793 + }
  6794 + }
  6795 + return false;
6768 6796 }
6769 6797  
6770 6798  
... ...