From fbbf06b5a456c6db4bc7781a6873308a890b2eca Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Thu, 23 Nov 2023 15:18:24 +0800 Subject: [PATCH] 小程序提示的优化 --- pages/cart/cart/cart.js | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index f24e241..75c72b6 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -3474,7 +3474,11 @@ Page({ } } - if (i_arr[j].prom_type == 7 && i_arr[j].act && i_arr[j].act.buy_limit != 0) { + + + + + 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) ) { let userbuynum = await this.getUserBuyPromNum(i_arr[j].prom_id); if(!zh_buyed_m[i_arr[j].prom_id]) zh_buyed_m[i_arr[j].prom_id]=userbuynum; @@ -3483,7 +3487,11 @@ Page({ } console.log('活动次数:' + userbuynum); - if (userbuynum >= i_arr[j].act.buy_limit && i_arr[j].act.buy_limit>0) { + + if(userbuynum >= i_arr[j].act.zh_num && i_arr[j].act.zh_num>0){ + i_arr[j].out_all_num=1; + checkArr7.push(i_arr[j]) + }else if (userbuynum >= i_arr[j].act.buy_limit && i_arr[j].act.buy_limit>0) { // i_arr[j].act.buy_userbuynum=true checkArr7.push(i_arr[j]) }else{ @@ -3742,16 +3750,33 @@ Page({ if (checkArr7.length > 0) { - let checkStr = [] + + let checkStr = []; + let checkStr2 = []; + checkArr7.map(item => { - checkStr.push(item.goods_name) + if(item.out_all_num){ + checkStr2.push(item.goods_name); + }else{ + checkStr.push(item.goods_name) + } }) - let str = checkStr.join() + + var msg_str=''; + if(checkStr.length){ + let str = checkStr.join(); + msg_str=`${str}超出组合购限购次数,将以普通商品购买`; + } + if(checkStr2.length){ + if(msg_str) msg_str+=","; + msg_str+=checkStr2.join()+"超出组合购总数,将以普通商品购买"; + } + wx.hideLoading() wx.showModal({ title: '提示', // content: `商品${str},组合购活动,购买次数已超,将以普通商品购买?`, - content: `${str}超出组合购限购次数,将以普通商品购买`, + content: msg_str, success: res => { wx.showLoading(); if (res.confirm) { -- libgit2 0.21.4