Commit e072f1d5feeb6cb6c50d00fb909b97bf6448e6ab
Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev
Showing
8 changed files
with
161 additions
and
14 deletions
pages/cart/cart/cart.js
| ... | ... | @@ -36,7 +36,8 @@ Page({ |
| 36 | 36 | |
| 37 | 37 | zhhe_prom:[], //组合活动需要显示差多少件 |
| 38 | 38 | zuhe_map:{}, |
| 39 | - zuhe_map_good:{} | |
| 39 | + zuhe_map_good:{}, | |
| 40 | + in_zhact_gdmap:{}, //不同门店参与同一活动的限购 | |
| 40 | 41 | }, |
| 41 | 42 | onLoad: function() { |
| 42 | 43 | var a = this,ee=a; |
| ... | ... | @@ -59,6 +60,8 @@ Page({ |
| 59 | 60 | |
| 60 | 61 | }, |
| 61 | 62 | onShow: function() { |
| 63 | + //每次显示都清空 | |
| 64 | + this.data.in_zhact_gdmap={}; | |
| 62 | 65 | |
| 63 | 66 | if (typeof this.getTabBar === 'function' && this.getTabBar()) { |
| 64 | 67 | var index=getApp().getPageIndex(this); |
| ... | ... | @@ -199,6 +202,7 @@ Page({ |
| 199 | 202 | //-----真的获取购物车-------- |
| 200 | 203 | get_cart: function() { |
| 201 | 204 | var th = this; |
| 205 | + th.data.in_zhact_gdmap={}; | |
| 202 | 206 | var rd = Math.random().toString(36).substr(2, 15); |
| 203 | 207 | var user_id=getApp().globalData.userInfo.user_id; |
| 204 | 208 | getApp().request.get("/api/weshop/cart/list", { |
| ... | ... | @@ -884,6 +888,7 @@ Page({ |
| 884 | 888 | |
| 885 | 889 | var offline_price=0; |
| 886 | 890 | var offline_num=0; |
| 891 | + th.data.in_zhact_gdmap={}; | |
| 887 | 892 | |
| 888 | 893 | |
| 889 | 894 | if(dda && dda.length>0){ |
| ... | ... | @@ -902,7 +907,8 @@ Page({ |
| 902 | 907 | |
| 903 | 908 | var obj=JSON.parse(JSON.stringify(item[j])); |
| 904 | 909 | //计算之前先移除 |
| 905 | - zh_calc.remove_zhprom(dda,i,obj); | |
| 910 | + if(obj.prom_type==7) | |
| 911 | + zh_calc.remove_zhprom(dda,i,obj); | |
| 906 | 912 | |
| 907 | 913 | |
| 908 | 914 | if (fir == 0) { |
| ... | ... | @@ -917,7 +923,8 @@ Page({ |
| 917 | 923 | var txt = "requestData[" + i + "].goods[" + j + "].selected"; |
| 918 | 924 | |
| 919 | 925 | if(e.data.checkAllToggle) obj.goods_num=0; |
| 920 | - zh_calc.add_zhprom(dda,i,obj); | |
| 926 | + if(obj.prom_type==7) | |
| 927 | + zh_calc.add_zhprom(dda,i,obj); | |
| 921 | 928 | |
| 922 | 929 | e.setData({ |
| 923 | 930 | [txt]: !e.data.checkAllToggle, |
| ... | ... | @@ -1265,6 +1272,7 @@ Page({ |
| 1265 | 1272 | |
| 1266 | 1273 | //-- 购物车 -- |
| 1267 | 1274 | if(car && car.length>0){ |
| 1275 | + th.data.in_zhact_gdmap={}; | |
| 1268 | 1276 | for (var a = 0; a < car.length; a++) { |
| 1269 | 1277 | var item = car[a].goods, |
| 1270 | 1278 | is_s_sele = 1; |
| ... | ... | @@ -1300,6 +1308,7 @@ Page({ |
| 1300 | 1308 | offline_num+=item[c].goods_num; |
| 1301 | 1309 | } |
| 1302 | 1310 | } |
| 1311 | + | |
| 1303 | 1312 | //总的价格,把组合商品的价格拿出来 |
| 1304 | 1313 | var zh_calc_res=zh_calc.calculate_zh(car,a,th); |
| 1305 | 1314 | tfeel+=zh_calc_res.tfeel; | ... | ... |
pages/cart/cart/zh_calculate.js
| ... | ... | @@ -130,7 +130,14 @@ module.exports = { |
| 130 | 130 | item.cart_num =cart_num; |
| 131 | 131 | //-- 当商品有购买的时候,以及有限购的时候 -- |
| 132 | 132 | if(item.buyqty>0){ |
| 133 | + | |
| 134 | + console.log(111,th.data.in_zhact_gdmap); | |
| 135 | + | |
| 133 | 136 | var cbuy=item.buyqty-zh_b_num; |
| 137 | + var key=item.goods_id+""+act.id; | |
| 138 | + if(th.data.in_zhact_gdmap[key]){ | |
| 139 | + var cbuy=item.buyqty-zh_b_num-th.data.in_zhact_gdmap[key]; | |
| 140 | + } | |
| 134 | 141 | //当可买的数量为0 |
| 135 | 142 | if(cbuy<=0){ |
| 136 | 143 | item.num=0; |
| ... | ... | @@ -158,7 +165,6 @@ module.exports = { |
| 158 | 165 | } |
| 159 | 166 | if (item.num) { |
| 160 | 167 | all_num += item.num; |
| 161 | - | |
| 162 | 168 | //当有起购数的控制的时候 |
| 163 | 169 | if (item.zhqty) { |
| 164 | 170 | all_zhqty += item.zhqty; |
| ... | ... | @@ -189,6 +195,22 @@ module.exports = { |
| 189 | 195 | |
| 190 | 196 | //当满足组合的要求:总数要满足,起购数要满足 |
| 191 | 197 | if (all_num >= act.zhbuyqty && !need_to_buy) { |
| 198 | + //商品的列表 | |
| 199 | + for (var u in goods) { | |
| 200 | + var ite=goods[u]; | |
| 201 | + if(ite.buyqty>0 && ite.num>0){ | |
| 202 | + | |
| 203 | + console.log(222,th.data.in_zhact_gdmap); | |
| 204 | + | |
| 205 | + var key=ite.goods_id+""+act.id; | |
| 206 | + if(th.data.in_zhact_gdmap[key]){ | |
| 207 | + th.data.in_zhact_gdmap[key]+=ite.num; | |
| 208 | + }else{ | |
| 209 | + th.data.in_zhact_gdmap[key]=ite.num; | |
| 210 | + } | |
| 211 | + } | |
| 212 | + } | |
| 213 | + | |
| 192 | 214 | function sortData(a, b) { |
| 193 | 215 | return a.price - b.price |
| 194 | 216 | } | ... | ... |
pages/cart/cart2/cart2.js
| ... | ... | @@ -120,6 +120,10 @@ Page({ |
| 120 | 120 | |
| 121 | 121 | tabs: ['门店自提', '快递邮寄'], |
| 122 | 122 | currentTabIndex: 1, |
| 123 | + | |
| 124 | + in_zhact_gdmap:{}, //不同门店参与同一活动的限购 | |
| 125 | + hid_inp:1, | |
| 126 | + user_note:{}, | |
| 123 | 127 | }, |
| 124 | 128 | onLoad: function (t) { |
| 125 | 129 | wx.setNavigationBarTitle({title: "填写订单",}) |
| ... | ... | @@ -413,6 +417,7 @@ Page({ |
| 413 | 417 | var arr = new Array(); |
| 414 | 418 | var carr = su.data.data.pageData; |
| 415 | 419 | th.data.cartlist_y = carr; //存储原始购物车列表 |
| 420 | + th.data.in_zhact_gdmap={}; | |
| 416 | 421 | |
| 417 | 422 | //---是不是购买等级卡成功的返回---等级卡显示的判断--- |
| 418 | 423 | var is_card_back = getApp().globalData.is_card_back; |
| ... | ... | @@ -651,6 +656,7 @@ Page({ |
| 651 | 656 | } |
| 652 | 657 | } |
| 653 | 658 | |
| 659 | + | |
| 654 | 660 | //每一个门店内的组合购要进行拆分, |
| 655 | 661 | //还得把组合商品的多余商品的线下价格算一算 |
| 656 | 662 | for (let var1 in arr) { |
| ... | ... | @@ -1009,8 +1015,11 @@ Page({ |
| 1009 | 1015 | }); |
| 1010 | 1016 | }, |
| 1011 | 1017 | keyUpChangeNum: function (t) { |
| 1018 | + var index = t.currentTarget.dataset.index; | |
| 1019 | + var txt="user_note."+index; | |
| 1012 | 1020 | this.setData({ |
| 1013 | - maxWord: t.detail.value.length | |
| 1021 | + maxWord: t.detail.value.length, | |
| 1022 | + [txt]: t.detail.value | |
| 1014 | 1023 | }); |
| 1015 | 1024 | }, |
| 1016 | 1025 | |
| ... | ... | @@ -3786,5 +3795,17 @@ Page({ |
| 3786 | 3795 | }); |
| 3787 | 3796 | }, |
| 3788 | 3797 | |
| 3798 | + set_hid_inp:function (e) { | |
| 3799 | + var index = e.currentTarget.dataset.index; | |
| 3800 | + var txt = "cartlist[" + index + "].focus"; | |
| 3801 | + this.setData({[txt]:1}) | |
| 3802 | + }, | |
| 3803 | + | |
| 3804 | + clear_hid_inp:function (e) { | |
| 3805 | + var index = e.currentTarget.dataset.index; | |
| 3806 | + var txt = "cartlist[" + index + "].focus"; | |
| 3807 | + this.setData({[txt]:0}) | |
| 3808 | + } | |
| 3809 | + | |
| 3789 | 3810 | |
| 3790 | 3811 | }); | ... | ... |
pages/cart/cart2/cart2.wxml
| ... | ... | @@ -76,7 +76,7 @@ |
| 76 | 76 | <!-- <view>门店:{{item.pname}}</view> --> |
| 77 | 77 | <view>{{item.pname}}</view> |
| 78 | 78 | </view> |
| 79 | - <view class="order-detail" wx:if="{{items.goods_num>0}}" wx:for="{{item.goods}}" wx:for-index="idx" wx:for-item="items"> | |
| 79 | + <view class="order-detail" wx:for="{{item.goods}}" wx:for-index="idx" wx:for-item="items"> | |
| 80 | 80 | <!----商品图片-----> |
| 81 | 81 | <view class="goods-img" style="position: relative"> |
| 82 | 82 | <image wx:if="{{items.is_gift}}" src="{{imgUrl}}/miniapp/images/giveaway.png" class="gift_image"></image> |
| ... | ... | @@ -104,7 +104,6 @@ |
| 104 | 104 | <view class="goods-num">x{{items.goods_num}}</view> |
| 105 | 105 | </view> |
| 106 | 106 | </navigator> |
| 107 | - | |
| 108 | 107 | </view> |
| 109 | 108 | |
| 110 | 109 | <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 --> |
| ... | ... | @@ -208,9 +207,14 @@ |
| 208 | 207 | <view class="coupon-mes flex-vertical"> |
| 209 | 208 | <view>留言</view> |
| 210 | 209 | <view class="leave-word"> |
| 211 | - <input placeholder-class="fs28" placeholder='给商家留言,最多100字' bindinput="keyUpChangeNum" disabled="{{disabled}}" | |
| 212 | - class="word-box" maxlength="100" name="user_note_{{item.pickup_id}}"></input> | |
| 210 | + <input hidden="{{!item.focus}}" bindinput="keyUpChangeNum" disabled="{{disabled}}" | |
| 211 | + data-index="{{index}}" bindblur="clear_hid_inp" focus="{{item.focus}}" value="{{user_note[index]}}" | |
| 212 | + class="word-box" maxlength="100" name="user_note_{{item.pickup_id}}" /> | |
| 213 | 213 | |
| 214 | + <view class="{{user_note[index]?'':'c-a'}}" style="width: 80%;font-size: 26rpx" data-index="{{index}}" | |
| 215 | + bindtap="set_hid_inp" wx:if="{{!item.focus}}"> | |
| 216 | + {{user_note[index]?user_note[index]:'给商家留言,最多100字'}} | |
| 217 | + </view> | |
| 214 | 218 | </view> |
| 215 | 219 | </view> |
| 216 | 220 | ... | ... |
pages/cart/cart2/cart2.wxss
pages/cart/cart2/zh_calculate.js
| ... | ... | @@ -2,7 +2,7 @@ var regeneratorRuntime = require('../../../utils/runtime.js'); |
| 2 | 2 | module.exports = { |
| 3 | 3 | //主要的作用,就是把组合购多余的商品进行拆分, |
| 4 | 4 | //如果没有达成组合购的要求,所有的商品都打回原价购买 |
| 5 | - fir_set_arr: function (c_item) { | |
| 5 | + fir_set_arr: function (c_item,th) { | |
| 6 | 6 | //组合活动,以及组合活动从表的商品 |
| 7 | 7 | let zh_prom_goods = c_item.zh_prom_goods; |
| 8 | 8 | let goods = c_item.goods; //一个门店中所有的商品 |
| ... | ... | @@ -47,7 +47,14 @@ module.exports = { |
| 47 | 47 | var cart_num=item.cart_num =item_j.goods_num; |
| 48 | 48 | var zh_b_num=item_j.promgoodsbuynum; |
| 49 | 49 | if(item.buyqty>0){ |
| 50 | + | |
| 51 | + var key=item.goods_id+""+act.id; | |
| 50 | 52 | var cbuy=item.buyqty-zh_b_num; |
| 53 | + if(th.data.in_zhact_gdmap[key]){ | |
| 54 | + var cbuy=item.buyqty-zh_b_num-th.data.in_zhact_gdmap[key]; | |
| 55 | + } | |
| 56 | + | |
| 57 | + | |
| 51 | 58 | //当可买的数量为0 |
| 52 | 59 | if(cbuy<=0){ |
| 53 | 60 | item.num=0; |
| ... | ... | @@ -97,6 +104,21 @@ module.exports = { |
| 97 | 104 | |
| 98 | 105 | //当满足组合的要求:总数要满足,起购数要满足 |
| 99 | 106 | if (all_num >= act.zhbuyqty && !need_to_buy) { |
| 107 | + | |
| 108 | + //商品的列表 | |
| 109 | + for (var u in act_goos) { | |
| 110 | + var ite=act_goos[u]; | |
| 111 | + if(ite.buyqty>0 && ite.num>0){ | |
| 112 | + var key=ite.goods_id+""+act.id; | |
| 113 | + if(th.data.in_zhact_gdmap[key]){ | |
| 114 | + th.data.in_zhact_gdmap[key]+=ite.num; | |
| 115 | + }else{ | |
| 116 | + th.data.in_zhact_gdmap[key]=ite.num; | |
| 117 | + } | |
| 118 | + } | |
| 119 | + } | |
| 120 | + | |
| 121 | + | |
| 100 | 122 | function sortData(a, b) { |
| 101 | 123 | return a.price - b.price |
| 102 | 124 | } | ... | ... |
pages/index/index/index.wxss
pages/user/order_detail/order_detail.js
| ... | ... | @@ -377,8 +377,74 @@ Page({ |
| 377 | 377 | th.toast(content); |
| 378 | 378 | return false; |
| 379 | 379 | } |
| 380 | - | |
| 381 | - //如果优惠促销和搭配购的时候 | |
| 380 | + | |
| 381 | + //当是组合优惠的时候 | |
| 382 | + if(good.prom_type==7){ | |
| 383 | + //如果有组合购 | |
| 384 | + var isok = 1; | |
| 385 | + var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+good.prom_id+"/"+getApp().globalData.userInfo.user_id; | |
| 386 | + await getApp().request.promiseGet(url, {}).then(res => { | |
| 387 | + if(res.data.code==0 && res.data.data){ | |
| 388 | + if(res.data.data.is_show!=1){ | |
| 389 | + isok=0; | |
| 390 | + } | |
| 391 | + //如果活动已经结束 | |
| 392 | + if(res.data.data.is_end==1){ | |
| 393 | + isok=0; | |
| 394 | + } | |
| 395 | + //已经结束 | |
| 396 | + if(ut.gettimestamp()>res.data.data.end_time){ | |
| 397 | + isok=0; | |
| 398 | + } | |
| 399 | + //还未开始 | |
| 400 | + if(ut.gettimestamp()<res.data.data.start_time){ | |
| 401 | + isok=0; | |
| 402 | + } | |
| 403 | + | |
| 404 | + }else{ | |
| 405 | + //未找到商品的活动 | |
| 406 | + isok = 0; | |
| 407 | + } | |
| 408 | + | |
| 409 | + }) | |
| 410 | + if (!isok){ | |
| 411 | + var content=gg.goods_name+'活动已经结束,请取消订单'; | |
| 412 | + th.toast(content); | |
| 413 | + return false; | |
| 414 | + } | |
| 415 | + | |
| 416 | + var url1 = "/api/weshop/prom/zhbuyGoods/page"; | |
| 417 | + var req_data = { | |
| 418 | + page: 1, | |
| 419 | + pageSize: 1, | |
| 420 | + store_id: os.stoid, | |
| 421 | + zh_id: good.prom_id, | |
| 422 | + goods_id:good.goods_id | |
| 423 | + } | |
| 424 | + await getApp().request.promiseGet(url1, { | |
| 425 | + data: req_data | |
| 426 | + }).then(res => { | |
| 427 | + if (ut.ajax_ok(res)) { | |
| 428 | + var gdlist = res.data.data.pageData[0]; | |
| 429 | + good.buyqty=gdlist.buyqty; | |
| 430 | + } | |
| 431 | + }) | |
| 432 | + | |
| 433 | + var num=good['buyqty']; | |
| 434 | + console.log(1111); | |
| 435 | + console.log(num); | |
| 436 | + //---- 要计算商品的限购 ----- | |
| 437 | + if(good['buyqty']>0){ | |
| 438 | + if(good.goods_num+promgoodsbuynum>good['buyqty']){ | |
| 439 | + | |
| 440 | + var content= good['goods_name']+"超出活动限购\n"; | |
| 441 | + th.toast(content); | |
| 442 | + return false; | |
| 443 | + } | |
| 444 | + } | |
| 445 | + } | |
| 446 | + | |
| 447 | + //如果优惠促销和搭配购的时候 | |
| 382 | 448 | if((good.prom_type==3 || good.prom_type==5) && good.is_collocation!=1 && good.is_gift!=1){ |
| 383 | 449 | var p_ok=1; |
| 384 | 450 | await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => { | ... | ... |