Commit fbbf06b5a456c6db4bc7781a6873308a890b2eca

Authored by yvan.ni
1 parent 3db133c6

小程序提示的优化

Showing 1 changed file with 31 additions and 6 deletions
pages/cart/cart/cart.js
@@ -3474,7 +3474,11 @@ Page({ @@ -3474,7 +3474,11 @@ Page({
3474 } 3474 }
3475 } 3475 }
3476 3476
3477 - if (i_arr[j].prom_type == 7 && i_arr[j].act && i_arr[j].act.buy_limit != 0) { 3477 +
  3478 +
  3479 +
  3480 +
  3481 + if (i_arr[j].prom_type == 7 && i_arr[j].act && (i_arr[j].act.buy_limit>0 || i_arr[j].act.zh_num>0) ) {
3478 let userbuynum = await this.getUserBuyPromNum(i_arr[j].prom_id); 3482 let userbuynum = await this.getUserBuyPromNum(i_arr[j].prom_id);
3479 3483
3480 if(!zh_buyed_m[i_arr[j].prom_id]) zh_buyed_m[i_arr[j].prom_id]=userbuynum; 3484 if(!zh_buyed_m[i_arr[j].prom_id]) zh_buyed_m[i_arr[j].prom_id]=userbuynum;
@@ -3483,7 +3487,11 @@ Page({ @@ -3483,7 +3487,11 @@ Page({
3483 } 3487 }
3484 3488
3485 console.log('活动次数:' + userbuynum); 3489 console.log('活动次数:' + userbuynum);
3486 - if (userbuynum >= i_arr[j].act.buy_limit && i_arr[j].act.buy_limit>0) { 3490 +
  3491 + if(userbuynum >= i_arr[j].act.zh_num && i_arr[j].act.zh_num>0){
  3492 + i_arr[j].out_all_num=1;
  3493 + checkArr7.push(i_arr[j])
  3494 + }else if (userbuynum >= i_arr[j].act.buy_limit && i_arr[j].act.buy_limit>0) {
3487 // i_arr[j].act.buy_userbuynum=true 3495 // i_arr[j].act.buy_userbuynum=true
3488 checkArr7.push(i_arr[j]) 3496 checkArr7.push(i_arr[j])
3489 }else{ 3497 }else{
@@ -3742,16 +3750,33 @@ Page({ @@ -3742,16 +3750,33 @@ Page({
3742 3750
3743 3751
3744 if (checkArr7.length > 0) { 3752 if (checkArr7.length > 0) {
3745 - let checkStr = [] 3753 +
  3754 + let checkStr = [];
  3755 + let checkStr2 = [];
  3756 +
3746 checkArr7.map(item => { 3757 checkArr7.map(item => {
3747 - checkStr.push(item.goods_name) 3758 + if(item.out_all_num){
  3759 + checkStr2.push(item.goods_name);
  3760 + }else{
  3761 + checkStr.push(item.goods_name)
  3762 + }
3748 }) 3763 })
3749 - let str = checkStr.join() 3764 +
  3765 + var msg_str='';
  3766 + if(checkStr.length){
  3767 + let str = checkStr.join();
  3768 + msg_str=`${str}超出组合购限购次数,将以普通商品购买`;
  3769 + }
  3770 + if(checkStr2.length){
  3771 + if(msg_str) msg_str+=",";
  3772 + msg_str+=checkStr2.join()+"超出组合购总数,将以普通商品购买";
  3773 + }
  3774 +
3750 wx.hideLoading() 3775 wx.hideLoading()
3751 wx.showModal({ 3776 wx.showModal({
3752 title: '提示', 3777 title: '提示',
3753 // content: `商品${str},组合购活动,购买次数已超,将以普通商品购买?`, 3778 // content: `商品${str},组合购活动,购买次数已超,将以普通商品购买?`,
3754 - content: `${str}超出组合购限购次数,将以普通商品购买`, 3779 + content: msg_str,
3755 success: res => { 3780 success: res => {
3756 wx.showLoading(); 3781 wx.showLoading();
3757 if (res.confirm) { 3782 if (res.confirm) {