Commit 160d21465236460e9f211b2278daeff9d7e4d950

Authored by yvan.ni
1 parent f6dc31cd

1. 优惠券要凸显数量,要测试多门店的选择券的显示效果, 优惠券和包邮券都要有

pages/cart/cart2/cart2.js
... ... @@ -1076,10 +1076,42 @@ Page({
1076 1076 [atxt7]: all_order_prom,
1077 1077 })
1078 1078 th.data.order_prom_list_cart=c_arr;
  1079 + th.set_can_num();
1079 1080  
1080 1081 });
1081 1082 });
1082 1083 },
  1084 +
  1085 + set_can_num:function(){
  1086 + var th=this;
  1087 + //-- 这个地方,循环计算几张优惠券可用--
  1088 + for ( var iter in th.data.cartlist){
  1089 + var num=0;
  1090 + var c_item=th.data.cartlist[iter];
  1091 + var pkid=c_item.pickup_id;
  1092 + //-- 普通券 --
  1093 + if(c_item.quan_list){
  1094 + for (var iter1 in c_item.quan_list){
  1095 + //判断是不是其他订单有选用
  1096 + var is_other_is_use=th.check_other_use(c_item.quan_list[iter1],pkid);
  1097 + if(!is_other_is_use) num++;
  1098 + }
  1099 + }
  1100 + //-- 包邮券 --
  1101 + var by_quan=th.data.get_by_quan_list_cart[pkid];
  1102 + if(by_quan){
  1103 + for (var iter2 in by_quan){
  1104 + //判断是不是其他订单有选用
  1105 + var is_other_is_use=th.check_other_use_by(by_quan[iter2],pkid);
  1106 + if(!is_other_is_use) num++;
  1107 + }
  1108 + }
  1109 + var set_txt="cartlist["+iter+"].can_num";
  1110 + th.setData({ [set_txt]: num});
  1111 + }
  1112 + },
  1113 +
  1114 +
1083 1115 //---------计算立即购买----------
1084 1116 calculatePrice2: function () {
1085 1117 var th = this, good = this.data.bn_goods;
... ... @@ -2103,16 +2135,22 @@ Page({
2103 2135  
2104 2136  
2105 2137 //对于在其他门店已经选择了的券 要判断是否显示到界面
  2138 + var t_user=th.data.using_quan[pickid];
  2139 +
2106 2140 for(var i in quanlist){
2107 2141 quanlist[i].is_using= th.check_in_sele(quanlist[i].CashRepNo,pickid);
  2142 + if(!t_user || quanlist[i].CashRepNo!=t_user.coupon_no) quanlist[i].show_red=0;
2108 2143 }
2109 2144  
2110 2145 if(get_by_quan_list_cart){
2111 2146 for(var i in get_by_quan_list_cart){
2112 2147 get_by_quan_list_cart[i].is_using= th.check_in_sele(get_by_quan_list_cart[i].no,pickid);
  2148 + if(!t_user || get_by_quan_list_cart[i].no!=t_user.coupon_no) get_by_quan_list_cart[i].show_red=0;
2113 2149 }
2114 2150 th.setData({by_quan_list_cart:get_by_quan_list_cart});
2115   - }
  2151 + }else {
  2152 + th.setData({by_quan_list_cart:null});
  2153 + }
2116 2154  
2117 2155 console.log("2222222券的列表", quanlist);
2118 2156 th.setData({ sele_cart_ind:cindx,sele_exp_type:exp_type,open_quan:1,selected_quan_pick:pickid,selected_quan_list:quanlist,disabled:1});
... ... @@ -2129,7 +2167,7 @@ Page({
2129 2167 if(th.data.using_quan.length<=0) return false;
2130 2168 for(var i in th.data.using_quan){
2131 2169 //--如果键值等于本身就要跳出--
2132   - if(i==pick_id) continue;
  2170 + if(parseInt(i)==parseInt(pick_id)) continue;
2133 2171 var item=th.data.using_quan[i];
2134 2172 if(item.coupon_no==no){
2135 2173 return true;
... ... @@ -2624,9 +2662,9 @@ Page({
2624 2662 th.setData({selected_quan_list:quanlist,cartlist:arr})
2625 2663 }else{
2626 2664 th.setData({cartlist:arr })
  2665 + th.set_can_num();
2627 2666 }
2628 2667  
2629   -
2630 2668 })
2631 2669 },
2632 2670  
... ... @@ -2869,7 +2907,38 @@ Page({
2869 2907 for(var i in arr){
2870 2908 if(arr[i].goods_id==goods_id) return arr[i];
2871 2909 }
  2910 + },
  2911 +
  2912 + //检查是不是有其他门店的订单在选择了券
  2913 + check_other_use:function (iter,pkid) {
  2914 + var using=this.data.using_quan;
  2915 + var is_use=0;
  2916 + if(using){
  2917 + for(var i in using){
  2918 + if(i==pkid) continue;
  2919 + if(iter.CashRepNo==using[i].coupon_no){
  2920 + is_use=1; break;
  2921 + }
  2922 + }
  2923 + }
  2924 + return is_use;
  2925 +
  2926 + },
  2927 + //检查是不是有其他门店的订单在选择了包邮券
  2928 + check_other_use_by:function (iter,pkid) {
  2929 + var using=this.data.using_quan;
  2930 + var is_use=0;
  2931 + if(using){
  2932 + for(var i in using){
  2933 + if(i==pkid) continue;
  2934 + if(iter.no==using[i].coupon_no){
  2935 + is_use=1; break;
  2936 + }
  2937 + }
  2938 + }
  2939 + return is_use;
2872 2940 }
2873 2941  
2874 2942  
  2943 +
2875 2944 });
... ...
pages/cart/cart2/cart2.wxml
... ... @@ -70,12 +70,12 @@
70 70 </navigator>
71 71  
72 72 </view>
73   - <view style="display: none;">!!!!---{{item.quan_list.length}}---!!!</view>
  73 +
74 74 <!-----使用优惠券------>
75 75 <view class="xc-coupon-frame flex-center" data-bn="0" bindtap="open_coupon_list"
76 76 wx:if="{{(item.quan_list && item.quan_list.length>0) || get_by_quan_list_cart[item.pickup_id]!=null}}" data-cind="{{pidx}}" data-pickid="{{item.pickup_id}}">
77 77 <view class="work-frame flex-space-between">
78   - <view class="work">优惠券</view>
  78 + <view class="work">优惠券<text class="quan_num_show fs20">{{item.can_num}}张可用</text></view>
79 79 <view class="xc-right-frame">
80 80 <text wx:if="{{using_quan[item.pickup_id].is_nouse}}">不使用</text>
81 81 <text wx:if="{{using_quan[item.pickup_id].money}}">¥{{using_quan[item.pickup_id].money}}元优惠券</text>
... ... @@ -249,7 +249,7 @@
249 249 wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
250 250 <view class="work-frame flex-space-between">
251 251 <view class="work">
252   - 优惠券
  252 + 优惠券 <text class="quan_num_show">{{(selected_quan_list?selected_quan_list.length:0)+ (get_by_quan_list?get_by_quan_list.length:0)}}张可用</text>
253 253 </view>
254 254 <view class="xc-right-frame">
255 255 <text wx:if="{{using_quan[bn_pick].is_nouse}}">不使用</text>
... ...
pages/cart/cart2/cart2.wxss
... ... @@ -819,4 +819,6 @@ margin-left: 20rpx;
819 819 color: #808080;
820 820 }
821 821 .n_guige{ display: inline-block; background:rgb(236, 236, 236); color: rgb(63,63,63); padding: 3rpx 10rpx; border-radius: 3rpx }
822   -.gift_image{ width: 60rpx; height: 60rpx; position: absolute; top: 0; left: 0}
823 822 \ No newline at end of file
  823 +.gift_image{ width: 60rpx; height: 60rpx; position: absolute; top: 0; left: 0}
  824 +
  825 +.quan_num_show{ padding: 6rpx 10rpx; background-color:#ea5551; color:#fff; border-radius: 6rpx }
824 826 \ No newline at end of file
... ...