From 1672593197a2ac590ed7acd4fefb8fd31135d7e9 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Mon, 3 Jul 2023 20:32:53 +0800 Subject: [PATCH] 优惠促销优化显示 --- components/promate_pop/promate_pop.js | 1 - pages/goods/goodsInfo/goodsInfo.js | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/components/promate_pop/promate_pop.js b/components/promate_pop/promate_pop.js index 65c7b26..fb38f5e 100644 --- a/components/promate_pop/promate_pop.js +++ b/components/promate_pop/promate_pop.js @@ -40,7 +40,6 @@ Component({ copy_obj.more=ut.format_yh_act(prom_list[i]); copy_obj.is_no_sele=1; copy_obj.condition=prom_list[i].condition + (prom_list[i].prom_type == 1 ? '件' : '元'), - copy_obj.limit='每人' + (copy_obj.limit_num ? '限参与' + copy_obj.limit_num + '次' : '参与不限次'), copy_obj.yh_index=i; //优惠阶梯 cx_prom_group.splice(yh_index+i,0,copy_obj); } diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index f736a59..a5c6b98 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -267,7 +267,7 @@ Page({ base_nor_prom_type: 0, base_nor_prom_id: 0, base_nor_goods_id: 0, - user_pre_buynum: 0, //用户优惠促销参与次数 + user_pre_buynum: 0, //用户优惠促销参与次数,这个字段只针对优惠促销 keyword: '', //门店搜索 sec_i: -1, //选中分类门店 下标 cx_prom_group: [], //促销活动,用于显示和判断默认要用什么促销活动 @@ -909,6 +909,10 @@ Page({ getApp().check_can_share(this); + //-- 要清空,因为有回退。优惠促的数组,购买数量要清理成1 -- + this.data.cx_prom_group=[]; + this.data.goodsInputNum=1; + var goods_list = null, th = this, that = this; @@ -2629,10 +2633,10 @@ Page({ var th = this; var usr = getApp().globalData.userInfo; if (this.data.sele_g.prom_type != 0 && this.data.sele_g.prom_type != 3 && !this.data.sele_g.whsle_id) { - callback(); + callback(); } else { - //-- 判断有没有优惠活动 -- - getApp().request.promiseGet("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0" + "/" + usr.user_id, {}).then(async res => { + //-- 判断有没有优惠活动 -- + getApp().request.promiseGet("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0" + "/" + usr.user_id, {}).then(async res => { if (res.data.code == 0) { var r_data = res.data.data; @@ -2684,7 +2688,6 @@ Page({ } }, - //----获取线下价格------- get_off_price() { var th = this; @@ -7483,7 +7486,7 @@ Page({ //-- 计算一下限购,满足限购数才显示 -- if (fir_act.limit_num ) { await this.getUserBuyPromNum_pre(fir_act.prom_id); - if(th.data.user_pre_buynum < fir_act.limit_num){ + if(th.data.user_pre_buynum >= fir_act.limit_num){ is_yh_out_limit=1; } @@ -7582,7 +7585,7 @@ Page({ prom_goods: r_data.promGoodsLists, }) } - th.is_show_more_buy(); + } }) @@ -7634,6 +7637,8 @@ Page({ }) } + th.is_show_more_buy(); + //-- 如果有促销活动也算是有参与活动,参与活动的也统一不进行计算起订的数量 -- this.data.is_act = 0; if (this.data.zh_act || this.data.prom_goods || this.data.jieti_prom || this.data.collocationGoods) { @@ -7703,16 +7708,22 @@ Page({ id: 0 }; } + var prom = null; - //-- 看有没有选中的活动 -- - var fd = this.data.cx_prom_group.findIndex(function (a) { - return a.sele == 1; - }) + prom = JSON.parse(JSON.stringify(this.data.cx_prom_group[0])); + + //-- 要判断有没有超出限购 -- + if(prom.prom_type==3 && prom.is_yh_out_limit){ + if(this.data.cx_prom_group.length>1){ + prom=this.data.cx_prom_group[1]; + }else{ + prom.prom_type=0; + prom.id=0; + } + } - prom = this.data.cx_prom_group[0]; - if (fd > -1) prom = this.data.cx_prom_group[fd]; if (ind) { - return prom.prom_type; + return prom.prom_type; } return prom; }, @@ -7745,6 +7756,7 @@ Page({ if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) { per_price = this.data.sele_g[this.data.card_field]; } + var all_price = per_price * this.data.goodsInputNum; var con = null; for (var i in prom_goods) { -- libgit2 0.21.4