Commit 4f8aacf965b38eae22bf4518a7f0ef085194966b

Authored by yvan.ni
1 parent 1e468dfc

组合购的商品,活动总数和限购次数在商品详情页面的时候,要提示

pages/goods/goodsInfo/goodsInfo.js
... ... @@ -1598,7 +1598,7 @@ Page({
1598 1598  
1599 1599 })
1600 1600 },
1601   - async getUserBuyPromNum(prom_id) {
  1601 + async getUserBuyPromNum(prom_id,is_zh) {
1602 1602 var userInfo = getApp().globalData.userInfo;
1603 1603 var url = `/api/weshop/ordergoods/getUserBuyPromNum?store_id=${os.stoid}&user_id=${userInfo.user_id}&prom_type=7&prom_id=${prom_id}`;
1604 1604 let res = await getApp().request.promiseGet(url, {
... ... @@ -1611,6 +1611,7 @@ Page({
1611 1611 this.setData({
1612 1612 userbuynum
1613 1613 })
  1614 + if(is_zh) this.data.user_zh_buy_num=userbuynum;
1614 1615 // return userbuynum
1615 1616 },
1616 1617  
... ... @@ -2183,6 +2184,7 @@ Page({
2183 2184 newd['pick_name'] = th.data.sto_sele_name;
2184 2185 newd['pick_dis'] = th.data.sto_sele_distr;
2185 2186 th.buyNow(newd);
  2187 +
2186 2188 }
2187 2189 },
2188 2190  
... ... @@ -2249,46 +2251,82 @@ Page({
2249 2251 s.set_b_now(e);
2250 2252 getApp().goto("/packageE/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id)
2251 2253 } else {
2252   -
2253   - //----其他就按照公众号的购物车立即购买形式来修改,先看会员在购物车中是否加入了该商品,立即购买的-----
2254   - getApp().request.get("/api/weshop/cart/page", {
2255   - data: {
2256   - store_id: os.stoid,
2257   - user_id: oo.user_id,
2258   - state: 1
2259   - },
2260   - success: function (res) {
2261   - //-------如果购物车中有相关的数据---------
2262   - if (res.data.code == 0 && res.data.data.total > 0) {
2263   - for (let j in res.data.data.pageData) {
2264   - let item_j = res.data.data.pageData[j];
2265   - var url = '/api/weshop/cart/del/' + os.stoid + '/' + item_j.id;
2266   - getApp().request.delete(url, {});
2267   - }
  2254 + //-- 如果是第一顺序是组合购的时候 --
  2255 + if(th.data.cx_prom_group && th.data.cx_prom_group.length && th.data.cx_prom_group[0].prom_type==7){
  2256 + if(!th.data.is_has_zh_num){
  2257 + th.data.adding=0;
  2258 + wx.hideLoading();
  2259 + wx.showModal({
  2260 + title: '提示',
  2261 + content: '超出组合购总数,将以普通商品购买',
  2262 + success (res) {
  2263 + if (res.confirm) {
  2264 + th.cart_next_next(e);
  2265 + }
  2266 + }
  2267 + })
  2268 + }else if(th.data.user_zh_buy_num>=th.data.zh_act.buy_limit && th.data.zh_act.buy_limit>0){
  2269 + th.data.adding=0;
  2270 + wx.hideLoading();
  2271 + wx.showModal({
  2272 + title: '提示',
  2273 + content: '超出组合购限购次数,将以普通商品购买',
  2274 + success (res) {
  2275 + if (res.confirm) {
  2276 + th.cart_next_next(e);
  2277 + }
  2278 + }
  2279 + })
  2280 + }else{
  2281 + th.cart_next_next(e);
2268 2282 }
  2283 + }
  2284 + else{
  2285 + th.cart_next_next(e);
  2286 + }
  2287 + }
2269 2288  
2270   - //-- 推迟一下,因为删除没有那么快 --
2271   - setTimeout(() => {
2272   - e.state = 1;
2273   - e.prom_type = 0;
2274   - e.prom_id = 0
2275   - getApp().request.post("/api/weshop/cart/save", {
2276   - data: e,
2277   - success: function (t) {
2278   - th.closeSpecModal();
2279   - getApp().goto("/packageE/pages/cart/cart2/cart2?state=1");
2280   - }
2281   - });
2282   - }, 500)
2283 2289  
2284   - }
2285   - })
2286   - }
  2290 + }
  2291 + },
  2292 +
2287 2293  
2288 2294  
  2295 + cart_next_next(e){
  2296 + var th=this;
  2297 + //----其他就按照公众号的购物车立即购买形式来修改,先看会员在购物车中是否加入了该商品,立即购买的-----
  2298 + getApp().request.get("/api/weshop/cart/page", {
  2299 + data: {
  2300 + store_id: os.stoid,
  2301 + user_id: oo.user_id,
  2302 + state: 1
  2303 + },
  2304 + success: function (res) {
  2305 + //-------如果购物车中有相关的数据---------
  2306 + if (res.data.code == 0 && res.data.data.total > 0) {
  2307 + for (let j in res.data.data.pageData) {
  2308 + let item_j = res.data.data.pageData[j];
  2309 + var url = '/api/weshop/cart/del/' + os.stoid + '/' + item_j.id;
  2310 + getApp().request.delete(url, {});
  2311 + }
  2312 + }
2289 2313  
  2314 + //-- 推迟一下,因为删除没有那么快 --
  2315 + setTimeout(() => {
  2316 + e.state = 1;
  2317 + e.prom_type = 0;
  2318 + e.prom_id = 0
  2319 + getApp().request.post("/api/weshop/cart/save", {
  2320 + data: e,
  2321 + success: function (t) {
  2322 + th.closeSpecModal();
  2323 + getApp().goto("/packageE/pages/cart/cart2/cart2?state=1");
  2324 + }
  2325 + });
  2326 + }, 500)
2290 2327  
2291   - }
  2328 + }
  2329 + })
2292 2330 },
2293 2331  
2294 2332 //----------增加购买数量-----------
... ... @@ -8724,12 +8762,13 @@ Page({
8724 8762  
8725 8763 //判断组合购总数够不够
8726 8764 var is_has_zh_num = (!e.data.data.zh_num || e.data.data.zh_buy_num < e.data.data.zh_num);
8727   - if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time && is_has_zh_num) {
  8765 + if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time ) {
8728 8766 //-- 获取商品列表 --
8729 8767 th.setData({
8730 8768 zh_act: e.data.data
8731 8769 });
8732   - th.getUserBuyPromNum(e.data.data.id)
  8770 + th.data.is_has_zh_num= is_has_zh_num;
  8771 + th.getUserBuyPromNum(e.data.data.id,1)
8733 8772 }
8734 8773 }
8735 8774  
... ...