Commit 44d592d516cd07a7f450881f7de758336c1af954
1 parent
e927fc36
1. 即使不平摊 ,在计算使用优惠券时,商品的实收都要平摊来计算
2. 指定单品优惠券的使用优化
Showing
2 changed files
with
65 additions
and
15 deletions
pages/cart/cart2/c_filter.wxs
@@ -15,6 +15,7 @@ var filters = { | @@ -15,6 +15,7 @@ var filters = { | ||
15 | if(ind==2) return "blue"; | 15 | if(ind==2) return "blue"; |
16 | if(ind==11) return "green"; | 16 | if(ind==11) return "green"; |
17 | if(ind==12) return "blue"; | 17 | if(ind==12) return "blue"; |
18 | + if(ind==20) return "green"; | ||
18 | return ""; | 19 | return ""; |
19 | }, | 20 | }, |
20 | setbgcolor: function (ind) { | 21 | setbgcolor: function (ind) { |
@@ -23,6 +24,7 @@ var filters = { | @@ -23,6 +24,7 @@ var filters = { | ||
23 | if (ind == 2) return "#a3bcff"; | 24 | if (ind == 2) return "#a3bcff"; |
24 | if (ind == 11) return "#59e1d2"; | 25 | if (ind == 11) return "#59e1d2"; |
25 | if (ind == 12) return "#a3bcff"; | 26 | if (ind == 12) return "#a3bcff"; |
27 | + if (ind == 20) return "#6d87cd"; | ||
26 | return ""; | 28 | return ""; |
27 | }, | 29 | }, |
28 | 30 | ||
@@ -32,6 +34,7 @@ var filters = { | @@ -32,6 +34,7 @@ var filters = { | ||
32 | if (ind == 2) return "品类"; | 34 | if (ind == 2) return "品类"; |
33 | if (ind == 11) return "用途"; | 35 | if (ind == 11) return "用途"; |
34 | if (ind == 12) return "分类1"; | 36 | if (ind == 12) return "分类1"; |
37 | + if (ind == 20) return "指定单品"; | ||
35 | return ""; | 38 | return ""; |
36 | }, | 39 | }, |
37 | get_type_card:function(ind){ | 40 | get_type_card:function(ind){ |
@@ -40,6 +43,7 @@ var filters = { | @@ -40,6 +43,7 @@ var filters = { | ||
40 | if (ind == 2) return "指定品类"; | 43 | if (ind == 2) return "指定品类"; |
41 | if (ind == 11) return "指定用途"; | 44 | if (ind == 11) return "指定用途"; |
42 | if (ind == 12) return "指定分类1"; | 45 | if (ind == 12) return "指定分类1"; |
46 | + if (ind == 20) return "指定单品"; | ||
43 | return ""; | 47 | return ""; |
44 | }, | 48 | }, |
45 | format_huiche:function (text) { | 49 | format_huiche:function (text) { |
pages/cart/cart2/cart2.js
@@ -707,8 +707,7 @@ Page({ | @@ -707,8 +707,7 @@ Page({ | ||
707 | } | 707 | } |
708 | 708 | ||
709 | //-- 如果系统要平摊到单品 -- | 709 | //-- 如果系统要平摊到单品 -- |
710 | - if(!th.data.ispt_goods){ | ||
711 | - | 710 | + //if(!th.data.ispt_goods){ |
712 | var pt_data={ | 711 | var pt_data={ |
713 | 'prom_id':item_map.prom_id, | 712 | 'prom_id':item_map.prom_id, |
714 | 'dis': parseFloat((item_map.price-item_map.prom_price).toFixed(2)), | 713 | 'dis': parseFloat((item_map.price-item_map.prom_price).toFixed(2)), |
@@ -722,11 +721,15 @@ Page({ | @@ -722,11 +721,15 @@ Page({ | ||
722 | if(pt_res){ | 721 | if(pt_res){ |
723 | for (var io in item_map.goods){ | 722 | for (var io in item_map.goods){ |
724 | //平摊赋值 | 723 | //平摊赋值 |
725 | - item_map.goods[io].account=th.arr_get_goods(item_map.goods[io].goods_id,pt_res).fisrt_account; | ||
726 | - item_map.goods[io].account_yu=th.arr_get_goods(item_map.goods[io].goods_id,pt_res).fisrt_account_yu; | 724 | + item_map.goods[io].account_fir=th.arr_get_goods(item_map.goods[io].goods_id,pt_res).fisrt_account; |
725 | + item_map.goods[io].account_yu_fir=th.arr_get_goods(item_map.goods[io].goods_id,pt_res).fisrt_account_yu; | ||
726 | + if(!th.data.ispt_goods){ | ||
727 | + item_map.goods[io].account=item_map.goods[io].account_fir; | ||
728 | + item_map.goods[io].account_yu=item_map.goods[io].account_yu_fir; | ||
729 | + } | ||
727 | } | 730 | } |
728 | } | 731 | } |
729 | - } | 732 | + // } |
730 | 733 | ||
731 | o_price-=(item_map.price-item_map.prom_price); | 734 | o_price-=(item_map.price-item_map.prom_price); |
732 | //如果有限制使用优惠券,就要减掉参与的活动商品的钱 | 735 | //如果有限制使用优惠券,就要减掉参与的活动商品的钱 |
@@ -738,6 +741,8 @@ Page({ | @@ -738,6 +741,8 @@ Page({ | ||
738 | if(item[j].prom_type==3 && item[j].prom_id==item_map.prom_id){ | 741 | if(item[j].prom_type==3 && item[j].prom_id==item_map.prom_id){ |
739 | item[j].is_xz_yh= item_map.is_xz_yh; | 742 | item[j].is_xz_yh= item_map.is_xz_yh; |
740 | item[j].is_past= item_map.is_past; | 743 | item[j].is_past= item_map.is_past; |
744 | + item[j].account_fir= th.item_map_get_goods(item[j].goods_id,item_map).account_fir; | ||
745 | + item[j].account_yu_fir= th.item_map_get_goods(item[j].goods_id,item_map).account_yu_fir; | ||
741 | item[j].account= th.item_map_get_goods(item[j].goods_id,item_map).account; | 746 | item[j].account= th.item_map_get_goods(item[j].goods_id,item_map).account; |
742 | item[j].account_yu= th.item_map_get_goods(item[j].goods_id,item_map).account_yu; | 747 | item[j].account_yu= th.item_map_get_goods(item[j].goods_id,item_map).account_yu; |
743 | } | 748 | } |
@@ -2134,17 +2139,60 @@ Page({ | @@ -2134,17 +2139,60 @@ Page({ | ||
2134 | 2139 | ||
2135 | /*--点击选择券--*/ | 2140 | /*--点击选择券--*/ |
2136 | sele_quan_item:function(e) { | 2141 | sele_quan_item:function(e) { |
2142 | + | ||
2143 | + var ind = e.currentTarget.dataset.ind; | ||
2144 | + var quan_item=this.data.selected_quan_list[ind]; | ||
2145 | + var pickid=this.data.selected_quan_pick; //现在选择的是哪一个门店 | ||
2146 | + //--如果券是单品使用的时候-- | ||
2147 | + if(quan_item.UseObjectType=="20"){ | ||
2148 | + //---只有多件购买的时候才要计算,//购物车购买和搭配勾的时候--- | ||
2149 | + var gg=getApp().get_b_now(); | ||
2150 | + if(this.data.is_b_now==0 || this.data.gg.prom_type==5){ | ||
2151 | + var arr=this.data.order_prom_list_cart; | ||
2152 | + var t_pk_item=null; | ||
2153 | + for(var ii in arr){ | ||
2154 | + var ep=arr[ii]; | ||
2155 | + if(pickid==ep.pickup_id){ | ||
2156 | + t_pk_item=ep; break; | ||
2157 | + } | ||
2158 | + } | ||
2159 | + //--寻找券指定的商品-- | ||
2160 | + var gd=null; | ||
2161 | + if(t_pk_item){ | ||
2162 | + var goods=t_pk_item.goods; | ||
2163 | + for(var gid in goods){ | ||
2164 | + if(quan_item.UseObjectID==goods[gid].erpwareid){ gd=goods[gid]; } | ||
2165 | + } | ||
2166 | + } | ||
2167 | + if(!gd){ | ||
2168 | + getApp().my_warnning("未找到指定商品使用",0,this,600); | ||
2169 | + return false; | ||
2170 | + } | ||
2171 | + //计算价格,如果有平摊的实收要计算实收的金额 | ||
2172 | + var item_price=gd.goods_price*gd.goods_num; | ||
2173 | + //-- 如果有平摊下去,有实收价格的时候,就要用account_fir来计算价格 -- | ||
2174 | + if(gd.account_fir!=null && gd.account_fir!=undefined){ | ||
2175 | + item_price=gd.account_fir*gd.goods_num; | ||
2176 | + } | ||
2177 | + | ||
2178 | + if(item_price< parseFloat(quan_item.BuySum)){ | ||
2179 | + getApp().my_warnning("该单品金额没有大于等于"+quan_item.BuySum+"元时不能使用优惠券",0,this,600); | ||
2180 | + return false; | ||
2181 | + } | ||
2182 | + } | ||
2183 | + } | ||
2184 | + | ||
2137 | var no_use=e.currentTarget.dataset.no, quanlist=this.data.selected_quan_list; | 2185 | var no_use=e.currentTarget.dataset.no, quanlist=this.data.selected_quan_list; |
2138 | //---所有的券的显示红色选择都清理一遍--- | 2186 | //---所有的券的显示红色选择都清理一遍--- |
2139 | - for(var ind in quanlist){ | ||
2140 | - quanlist[ind].show_red=0; | 2187 | + for(var i in quanlist){ |
2188 | + quanlist[i].show_red=0; | ||
2141 | } | 2189 | } |
2142 | this.setData({selected_quan_list:quanlist}); | 2190 | this.setData({selected_quan_list:quanlist}); |
2143 | var by_quanlist=this.data.get_by_quan_list; | 2191 | var by_quanlist=this.data.get_by_quan_list; |
2144 | if(by_quanlist){ | 2192 | if(by_quanlist){ |
2145 | //---所有的券的显示红色选择都清理一遍--- | 2193 | //---所有的券的显示红色选择都清理一遍--- |
2146 | - for(var ind in by_quanlist){ | ||
2147 | - by_quanlist[ind].show_red=0; | 2194 | + for(var inb in by_quanlist){ |
2195 | + by_quanlist[inb].show_red=0; | ||
2148 | } | 2196 | } |
2149 | this.setData({get_by_quan_list:by_quanlist}); | 2197 | this.setData({get_by_quan_list:by_quanlist}); |
2150 | } | 2198 | } |
@@ -2173,11 +2221,9 @@ Page({ | @@ -2173,11 +2221,9 @@ Page({ | ||
2173 | return; | 2221 | return; |
2174 | } | 2222 | } |
2175 | 2223 | ||
2176 | - var ind = e.currentTarget.dataset.ind; | ||
2177 | - | ||
2178 | - var quan_item = this.data.selected_quan_list[ind]; | 2224 | + |
2225 | + | ||
2179 | var txt = "selected_quan_list[" + ind + "].show_red"; | 2226 | var txt = "selected_quan_list[" + ind + "].show_red"; |
2180 | - | ||
2181 | var obj = {}; | 2227 | var obj = {}; |
2182 | obj[txt] = 1; | 2228 | obj[txt] = 1; |
2183 | if (quan_item.show_red) { | 2229 | if (quan_item.show_red) { |
@@ -2527,8 +2573,8 @@ Page({ | @@ -2527,8 +2573,8 @@ Page({ | ||
2527 | is_xz_yh=0; | 2573 | is_xz_yh=0; |
2528 | var item_price=gd.goods_price*gd.goods_num; | 2574 | var item_price=gd.goods_price*gd.goods_num; |
2529 | //-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 -- | 2575 | //-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 -- |
2530 | - if(gd.account!=null && gd.account!=undefined){ | ||
2531 | - item_price=gd.account*gd.goods_num; | 2576 | + if(gd.account_fir!=null && gd.account_fir!=undefined){ |
2577 | + item_price=gd.account_fir*gd.goods_num; | ||
2532 | } | 2578 | } |
2533 | ckeck_quan_price+=item_price; | 2579 | ckeck_quan_price+=item_price; |
2534 | 2580 |