Commit fd282313f770b8eb69e18bfefd679b0c7eda47d8

Authored by 后端研发-苏泰源
1 parent ffe816a6

服务卡购物车修改

Showing 1 changed file with 44 additions and 24 deletions
pages/cart/cart/cart.js
@@ -2099,34 +2099,54 @@ Page({ @@ -2099,34 +2099,54 @@ Page({
2099 if (th.data.sele_g.viplimited > 0) { 2099 if (th.data.sele_g.viplimited > 0) {
2100 var gd_buy_num = th.data.promcardbuynum; 2100 var gd_buy_num = th.data.promcardbuynum;
2101 2101
2102 - if(t.goods_num > th.data.sele_g.goods_num) {  
2103 - wx.showModal({  
2104 - title: '超出活动库存',  
2105 - }); 2102 + // 如果限购数量>活动库存数量,增加数量时会先超过库存数量,此时应该提示“超出活动库存”;
  2103 + // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量”
  2104 +
  2105 + if(th.data.sele_g.viplimited > th.data.sele_g.goods_num) {
  2106 + // 计算还可以购买的数量:库存量 - 已购数
  2107 + var num = th.data.sele_g.goods_num - gd_buy_num;
  2108 + if(num < 0) num = 0;
  2109 + if(t.goods_num > num) {
  2110 + wx.showModal({
  2111 + title: '超出活动库存',
  2112 + });
  2113 +
  2114 + // var num = th.data.sele_g.goods_num;
  2115 + th.setData({[txt]: num});
  2116 + // t.goods_num = num;
  2117 + // th.doCheckAll();
  2118 + // th.update_cart_ser(t, pitem, item);
  2119 + // return false;
  2120 +
  2121 + };
2106 2122
2107 - var num = th.data.sele_g.goods_num;  
2108 - th.setData({goodsInputNum: num})  
2109 - return false; 2123 + } else {
  2124 +
  2125 + if ((t.goods_num + gd_buy_num> th.data.sele_g.viplimited) && (t.goods_num <= th.data.sele_g.goods_num)) {
  2126 + wx.showModal({
  2127 + title: '超出活动限购数量',
  2128 + });
  2129 +
  2130 + var num = th.data.sele_g.viplimited - gd_buy_num;
  2131 + if (num <= 0) num = 1;
  2132 +
  2133 + th.setData({
  2134 + [txt]: num,
  2135 + gdnum: num,
  2136 + });
  2137 +
  2138 + // return false;
  2139 + }
2110 2140
2111 }; 2141 };
2112 2142
2113 - if ((t.goods_num + gd_buy_num> th.data.sele_g.viplimited) && (t.goods_num <= th.data.sele_g.goods_num)) {  
2114 - wx.showModal({  
2115 - title: '超出活动限购数量',  
2116 - });  
2117 -  
2118 - var num = th.data.sele_g.viplimited - gd_buy_num;  
2119 - if (num <= 0) num = 1;  
2120 -  
2121 - th.setData({  
2122 - [txt]: num,  
2123 - gdnum: num,  
2124 - });  
2125 - t.goods_num = num;  
2126 - th.doCheckAll();  
2127 - th.update_cart_ser(t, pitem, item);  
2128 - // return false;  
2129 - } 2143 +
  2144 + t.goods_num = num;
  2145 + th.doCheckAll();
  2146 + th.update_cart_ser(t, pitem, item);
  2147 +
  2148 +
  2149 +
2130 }; 2150 };
2131 2151
2132 }; 2152 };