Commit b9b0bcfa2cb44473ce78dc6c82079847a204089d
1 parent
5356a473
小程序促销赠品数量的优化,和getphone/getphone 的优化
Showing
6 changed files
with
19 additions
and
10 deletions
components/diy_service/diy_service.js
packageA/pages/prom_list/prom_list.js
... | ... | @@ -627,7 +627,7 @@ Page({ |
627 | 627 | var user_info = getApp().globalData.userInfo; |
628 | 628 | if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { |
629 | 629 | wx.navigateTo({ |
630 | - url: '/pages/getphone/getphone', | |
630 | + url: '/pages/togoin/togoin', | |
631 | 631 | }) |
632 | 632 | return false; |
633 | 633 | } | ... | ... |
packageA/pages/quan_list/quan_list.js
... | ... | @@ -85,7 +85,7 @@ Page({ |
85 | 85 | var user_info = getApp().globalData.userInfo; |
86 | 86 | if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { |
87 | 87 | wx.navigateTo({ |
88 | - url: '/pages/getphone/getphone', | |
88 | + url: '/pages/togoin/togoin', | |
89 | 89 | }) |
90 | 90 | return false; |
91 | 91 | } | ... | ... |
packageA/pages/quan_pro/quan_pro.js
... | ... | @@ -80,7 +80,7 @@ Page({ |
80 | 80 | var user_info = getApp().globalData.userInfo; |
81 | 81 | if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { |
82 | 82 | wx.navigateTo({ |
83 | - url: '/pages/getphone/getphone', | |
83 | + url: '/pages/togoin/togoin', | |
84 | 84 | }) |
85 | 85 | return false; |
86 | 86 | } | ... | ... |
pages/cart/cart/cart.js
... | ... | @@ -1477,22 +1477,30 @@ Page({ |
1477 | 1477 | |
1478 | 1478 | list2.goods.push(newd); |
1479 | 1479 | var all_num=0; |
1480 | + var all_limit_num=0; | |
1481 | + | |
1480 | 1482 | for(var i in alllist){ |
1481 | 1483 | var list_item=alllist[i]; |
1482 | 1484 | for(var j in list_item.goods){ |
1483 | 1485 | //如果赠品的ID一样,要进行统计数量 |
1484 | 1486 | if(list_item.goods[j].is_gift==1 && list_item.goods[j].gift_id==newd.gift_id){ |
1485 | 1487 | all_num+= list_item.goods[j].goods_num; |
1486 | - } | |
1488 | + } | |
1489 | + if(list_item.goods[j].is_gift==1 && list_item.goods[j].gift_id==newd.gift_id && list_item.goods[j].prom_id==p_item[0]){ | |
1490 | + all_limit_num+= list_item.goods[j].goods_num; | |
1491 | + } | |
1492 | + | |
1487 | 1493 | } |
1488 | - } | |
1489 | - //-- 赠品的数量超出,这里是保证所有的赠品部会超出 -- | |
1490 | - if(discount.gift_storecount<all_num){ | |
1494 | + } | |
1495 | + | |
1496 | + //-- 赠品的数量超出库存数量和会员的限制,这里是保证所有的赠品部会超出 -- | |
1497 | + if(discount.gift_storecount<all_num || discount.limit_num<all_limit_num ){ | |
1491 | 1498 | no_gift_arr.push(discount.gift_id); |
1492 | 1499 | //--进入下一个循环 -- |
1493 | 1500 | continue; |
1494 | 1501 | } |
1495 | - | |
1502 | + | |
1503 | + | |
1496 | 1504 | var url="/api/weshop/cart/delGift?store_id="+newd.store_id+"&user_id=" |
1497 | 1505 | +newd.user_id+"&goods_id="+newd.goods_id+"&is_gift=1&pick_id="+newd.pick_id+"&prom_id="+newd.prom_id |
1498 | 1506 | await getApp().request.promiseDelete(url, {}) | ... | ... |
utils/auth.js
... | ... | @@ -105,7 +105,7 @@ module.exports = { |
105 | 105 | |
106 | 106 | app.globalData.getu = r; |
107 | 107 | wx.navigateTo({ |
108 | - url: '/pages/getphone/getphone', | |
108 | + url: '/pages/togoin/togoin', | |
109 | 109 | }) |
110 | 110 | }else{ |
111 | 111 | app.globalData.user_id = e.data.data.user_id; |
... | ... | @@ -128,6 +128,7 @@ module.exports = { |
128 | 128 | get_u(t){ |
129 | 129 | var app_d = this.app().globalData, oo = app_d.setting; |
130 | 130 | var ab = this.app().request; |
131 | + if(!app_d.user_id) return false; | |
131 | 132 | ab.get("/api/weshop/users/get/" + oo.stoid + "/" + app_d.user_id, { |
132 | 133 | data:{r:Math.random()}, |
133 | 134 | success: function (e) { | ... | ... |