Commit 73545a890a85f2ee2fe5978832f2d5ee9205050a
优惠促销解决冲突
Showing
24 changed files
with
4036 additions
and
1586 deletions
components/promate_pop/p_filter.wxs
0 → 100644
| 1 | +var g_filters = { | ||
| 2 | + //-- 判断是不是有等级价 -- | ||
| 3 | + set_tab_title: function (item) { | ||
| 4 | + switch (item.prom_type) { | ||
| 5 | + case 3: | ||
| 6 | + return '优惠'; | ||
| 7 | + case 5: | ||
| 8 | + return '搭配'; | ||
| 9 | + case 7: | ||
| 10 | + return '组合'; | ||
| 11 | + case 10: | ||
| 12 | + return '阶梯'; | ||
| 13 | + } | ||
| 14 | + return ''; | ||
| 15 | + }, | ||
| 16 | + set_title: function (item) { | ||
| 17 | + switch (item.prom_type) { | ||
| 18 | + case 3: | ||
| 19 | + return '优惠促销'; | ||
| 20 | + case 5: | ||
| 21 | + return '搭配促销'; | ||
| 22 | + case 7: | ||
| 23 | + return '组合购'; | ||
| 24 | + case 10: | ||
| 25 | + return '阶梯促销'; | ||
| 26 | + } | ||
| 27 | + return ''; | ||
| 28 | + }, | ||
| 29 | + | ||
| 30 | + | ||
| 31 | +} | ||
| 32 | +module.exports = { | ||
| 33 | + set_tab_title: g_filters.set_tab_title, | ||
| 34 | + set_title: g_filters.set_title, | ||
| 35 | +} | ||
| 0 | \ No newline at end of file | 36 | \ No newline at end of file |
components/promate_pop/promate_pop.js
0 → 100644
| 1 | +Component({ | ||
| 2 | + /*** 页面的初始数据***/ | ||
| 3 | + data: { | ||
| 4 | + type:0, //0只显示再商品详情页面 1显示再有选择按钮 | ||
| 5 | + pro_pop:0, //是否弹出 | ||
| 6 | + cx_prom_group:[], //弹出框的内容展示 | ||
| 7 | + is_cart:0 | ||
| 8 | + }, | ||
| 9 | + methods: { | ||
| 10 | + //-- 初始化弹出框 -- | ||
| 11 | + set_init(type,cx_prom_group,is_cart){ | ||
| 12 | + if(!type) type=0; | ||
| 13 | + if(!is_cart) is_cart=0; | ||
| 14 | + | ||
| 15 | + var fd=cx_prom_group.findIndex(function (gh){ | ||
| 16 | + return gh.sele | ||
| 17 | + }) | ||
| 18 | + if(fd==-1){ | ||
| 19 | + cx_prom_group[0].sele=1; | ||
| 20 | + } | ||
| 21 | + this.setData({ | ||
| 22 | + type:type,pro_pop:1,cx_prom_group,is_cart:is_cart | ||
| 23 | + }) | ||
| 24 | + }, | ||
| 25 | + | ||
| 26 | + /*----pop的开关,如果按钮是‘确定’,就要返回参数给父层组件---*/ | ||
| 27 | + close_pro_pop: async function (e) { | ||
| 28 | + this.setData({pro_pop: 0}); | ||
| 29 | + if(!this.data.type) return false; | ||
| 30 | + var idx=this.data.cx_prom_group.findIndex(function (e){ | ||
| 31 | + return e.sele==1; | ||
| 32 | + }) | ||
| 33 | + this.triggerEvent('sure_cx_group',{sele_idx:idx},{bubbles: true}); | ||
| 34 | + }, | ||
| 35 | + | ||
| 36 | + go_the_url:function (e){ | ||
| 37 | + var index=e.currentTarget.dataset.index; | ||
| 38 | + var item=this.data.cx_prom_group[index]; | ||
| 39 | + | ||
| 40 | + var prom_id = item.prom_id; | ||
| 41 | + var prom_type = item.prom_type; | ||
| 42 | + var url=''; | ||
| 43 | + switch (parseInt(prom_type)){ | ||
| 44 | + case 3: | ||
| 45 | + url = "/pages/goods/goodsList/goodsList?prom_type=3&prom_id=" + prom_id; | ||
| 46 | + break; | ||
| 47 | + case 5: | ||
| 48 | + url = "/packageA/pages/prom_list/prom_list?goods_id=" + item.main_gid; | ||
| 49 | + var room_id = getApp().globalData.room_id; | ||
| 50 | + if (room_id && this.data.gid == getApp().globalData.room_goods_id) { | ||
| 51 | + url += "&room_id=" + room_id; | ||
| 52 | + } | ||
| 53 | + break; | ||
| 54 | + case 7: | ||
| 55 | + url="/packageB/pages/zuhegou/index/index?id=" + prom_id | ||
| 56 | + break; | ||
| 57 | + case 10: | ||
| 58 | + url="/pages/goods/goodsList/goodsList?ladder_id=" + prom_id; | ||
| 59 | + break; | ||
| 60 | + } | ||
| 61 | + getApp().goto(url); | ||
| 62 | + }, | ||
| 63 | + | ||
| 64 | + //-- 选择活动 -- | ||
| 65 | + sele_act:function (e){ | ||
| 66 | + var index=e.currentTarget.dataset.index; | ||
| 67 | + var cx_prom_group=this.data.cx_prom_group; | ||
| 68 | + for (var idx=0;idx<cx_prom_group.length;idx++){ | ||
| 69 | + if(idx!=index) cx_prom_group[idx].sele=0; | ||
| 70 | + else cx_prom_group[idx].sele=1; | ||
| 71 | + } | ||
| 72 | + this.setData({cx_prom_group}) | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + } | ||
| 76 | +}) | ||
| 0 | \ No newline at end of file | 77 | \ No newline at end of file |
components/promate_pop/promate_pop.json
0 → 100644
components/promate_pop/promate_pop.wxml
0 → 100644
| 1 | +<wxs module="p_fil" src="p_filter.wxs"></wxs> | ||
| 2 | +<!-- --弹起领券-- --> | ||
| 3 | +<view wx:if='{{pro_pop==1}}'> | ||
| 4 | + <view class="cover-layer flex-center" bindtap="close_pro_pop"></view> | ||
| 5 | + <view class="cx-popup {{pro_pop== true ? 'up_pro' : 'down_pro'}} {{is_cart?'cart_show':''}}" style="z-index: 3500" > | ||
| 6 | + <view class="top-frame"> | ||
| 7 | + <view class="top t-c">促销列表</view> | ||
| 8 | + </view> | ||
| 9 | + | ||
| 10 | + <view class="xc-frame"> | ||
| 11 | + <view class="top-frame"> | ||
| 12 | + <view class="xc-coupon-frame "> | ||
| 13 | + <!-- for循环显示内容 --> | ||
| 14 | + <view wx:for="{{cx_prom_group}}" class="item_pro flex ai-center"> | ||
| 15 | + <view class="tab_bx fs24">{{p_fil.set_tab_title(item)}}</view> | ||
| 16 | + <view class="item_pro_left flex jc-center ai-center"> | ||
| 17 | + <view class="fs34 left_f_box" >{{p_fil.set_title(item)}}</view> | ||
| 18 | + </view> | ||
| 19 | + | ||
| 20 | + <view class="item_pro_right"> | ||
| 21 | + <view wx:if="{{item.prom_type!=3}}" class="fs26">{{item.title}}</view> | ||
| 22 | + <view wx:else class="fs26">{{item.title}} | ||
| 23 | + 消费满<text class="c-red">{{item.condition}}</text>享优惠({{item.limit}}) | ||
| 24 | + </view> | ||
| 25 | + <view wx:if="{{item.prom_type==5}}" class="fs26">搭配价:<text class="c-red">{{item.show_price}}</text></view> | ||
| 26 | + | ||
| 27 | + <view wx:if="{{item.prom_type!=3}}" class="fs22" style="color: #b9b6b6"> | ||
| 28 | + {{item.show_time}} | ||
| 29 | + </view> | ||
| 30 | + <view wx:else class="fs22" style="max-width: 430rpx; color: #b9b6b6"> | ||
| 31 | + <text wx:for="{{item.more}}" wx:for-item="bm" class="tick pdr20" >{{bm}}</text> | ||
| 32 | + </view> | ||
| 33 | + </view> | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + <view class="r_item_pro"> | ||
| 37 | + <view style="text-align: center"> | ||
| 38 | + <!-- 如果是弹出框进行选择的时候 --> | ||
| 39 | + <block wx:if="{{type==1}}"> | ||
| 40 | + <view wx:if="{{item.sele}}" class="circle white xc-hook on"> | ||
| 41 | + <text>Γ</text> | ||
| 42 | + </view> | ||
| 43 | + <view bindtap="sele_act" data-index="{{index}}" wx:else class="circle white xc-hook"></view> | ||
| 44 | + | ||
| 45 | + <view style="height: 12rpx"></view> | ||
| 46 | + </block> | ||
| 47 | + <view bindtap="go_the_url" data-index="{{index}}" class="xq_btn fs30">详情</view> | ||
| 48 | + </view> | ||
| 49 | + </view> | ||
| 50 | + | ||
| 51 | + </view> | ||
| 52 | + | ||
| 53 | + </view> | ||
| 54 | + </view> | ||
| 55 | + </view> | ||
| 56 | + | ||
| 57 | + <view class="cx-confirm pd20" bindtap="close_pro_pop"> | ||
| 58 | + <view wx:if="{{type==0}}" class="confirm t-c">我知道了</view> | ||
| 59 | + <view wx:if="{{type==1}}" class="confirm t-c">确定</view> | ||
| 60 | + </view> | ||
| 61 | + </view> | ||
| 62 | +</view> | ||
| 0 | \ No newline at end of file | 63 | \ No newline at end of file |
components/promate_pop/promate_pop.wxss
0 → 100644
| 1 | +/* 自定义弹出窗口 */ | ||
| 2 | +.cx-popup { | ||
| 3 | + width: 100%; | ||
| 4 | + background: #fff; | ||
| 5 | + z-index: 35; | ||
| 6 | + border-top-left-radius: 10rpx; | ||
| 7 | + border-top-right-radius: 10rpx; | ||
| 8 | + position: fixed; | ||
| 9 | + bottom: 0; | ||
| 10 | + left:0 | ||
| 11 | +} | ||
| 12 | +.cx-popup.cart_show{ | ||
| 13 | + bottom:100rpx | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +.cx-popup .top { | ||
| 17 | + font-size: 32rpx; | ||
| 18 | + padding: 20rpx 0; | ||
| 19 | + border-bottom: 2rpx solid #ebedf0; | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +.cx-popup .top-frame { | ||
| 23 | + /* width: 100%; | ||
| 24 | + display: flex; | ||
| 25 | + justify-content: center; | ||
| 26 | + overflow: hidden; */ | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +.xc-top-content { | ||
| 30 | + width: 88%; | ||
| 31 | + height: 85rpx; | ||
| 32 | + padding-top: 50rpx; | ||
| 33 | + font-size: 36rpx; | ||
| 34 | +} | ||
| 35 | +.xc-valid-coupon { | ||
| 36 | + width: 90%; | ||
| 37 | + height: 40rpx; | ||
| 38 | + padding-top: 24rpx; | ||
| 39 | + overflow: hidden; | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +.xc-frame .list-frame { | ||
| 43 | + width: 90%; | ||
| 44 | + height: 100%; | ||
| 45 | + overflow-y: scroll; | ||
| 46 | + margin-top: 20rpx; | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +.xc-close-frame { | ||
| 50 | + margin-top: 30rpx; | ||
| 51 | + width: 15%; | ||
| 52 | + display: flex; | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +.xc-close { | ||
| 56 | + width: 70rpx; | ||
| 57 | + height: 70rpx; | ||
| 58 | + border-radius: 50%; | ||
| 59 | + border: 5rpx solid #a5a5a7; | ||
| 60 | + text-align: center; | ||
| 61 | + line-height: 55rpx; | ||
| 62 | + font-size: 80rpx; | ||
| 63 | + color: #a5a5a7; | ||
| 64 | + font-family: "微软正黑体"; | ||
| 65 | + margin-top: 8rpx; | ||
| 66 | +} | ||
| 67 | +.xc-money { | ||
| 68 | + color: #ff0013; | ||
| 69 | +} | ||
| 70 | + | ||
| 71 | +.xc-coupon-effect { | ||
| 72 | + width: 99%; | ||
| 73 | + height: 128rpx; | ||
| 74 | + border-bottom: 3rpx solid #ddd; | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +.xc-goods-coupon { | ||
| 78 | + width: 80%; | ||
| 79 | + height: 100%; | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +.xc-title { | ||
| 83 | + width: 50%; | ||
| 84 | + margin-left: 222rpx; | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +.xc-coupon-money { | ||
| 88 | + color: #c91e31; | ||
| 89 | + font-size: 35rpx; | ||
| 90 | + margin-top: 20rpx; | ||
| 91 | + | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +.xc-coupon-time { | ||
| 95 | + height: 50rpx; | ||
| 96 | + font-size: 27rpx; | ||
| 97 | + color: #a4a4a4; | ||
| 98 | +} | ||
| 99 | + | ||
| 100 | +.xc-coupon-time .time { | ||
| 101 | + margin-left: 15rpx; | ||
| 102 | + font-size: 27rpx; | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +.xc-coupon-selection { | ||
| 106 | + width: 99%; | ||
| 107 | + height: 100%; | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +.xc-confirm { | ||
| 111 | + width: 90%; | ||
| 112 | + height: 75rpx; | ||
| 113 | + margin: 0 auto; | ||
| 114 | + background: #c41830; | ||
| 115 | + color: #fff; | ||
| 116 | + border-radius: 10rpx; | ||
| 117 | + font-size: 30rpx; | ||
| 118 | + margin-top: 50rpx; | ||
| 119 | +} | ||
| 120 | + | ||
| 121 | +.cx-confirm { | ||
| 122 | + width: 100%; | ||
| 123 | + padding: 20rpx; | ||
| 124 | + box-sizing: border-box; | ||
| 125 | + /* height: 160rpx; */ | ||
| 126 | + | ||
| 127 | +} | ||
| 128 | + | ||
| 129 | + | ||
| 130 | + | ||
| 131 | +.cx-confirm .confirm { | ||
| 132 | + /* width: 372rpx; | ||
| 133 | + height: 60rpx; */ | ||
| 134 | + background-color: #f40026; | ||
| 135 | + color: #fff; | ||
| 136 | + border-radius: 10rpx; | ||
| 137 | + line-height: 80rpx; | ||
| 138 | + font-size: 28rpx; | ||
| 139 | + | ||
| 140 | +} | ||
| 141 | + | ||
| 142 | +.xc-not-Selection { | ||
| 143 | + width: 60rpx; | ||
| 144 | + height: 60rpx; | ||
| 145 | + background: #eeeeee; | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +.up_pro { | ||
| 149 | + animation: up .7s; | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +.down_pro { | ||
| 153 | + animation: down 1s; | ||
| 154 | +} | ||
| 155 | + | ||
| 156 | +@keyframes up_pro { | ||
| 157 | + 0% { | ||
| 158 | + transform: translateY(550rpx); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + 100% { | ||
| 162 | + transform: translateY(0); | ||
| 163 | + } | ||
| 164 | +} | ||
| 165 | + | ||
| 166 | +@keyframes down_pro { | ||
| 167 | + 0% { | ||
| 168 | + transform: translateY(0); | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + 100% { | ||
| 172 | + transform: translateY(550rpx); | ||
| 173 | + } | ||
| 174 | +} | ||
| 175 | + | ||
| 176 | +.item_pro{ | ||
| 177 | + background-color: #fceeee;height: 170rpx; position: relative; | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | +.item_pro~.item_pro{ | ||
| 181 | + margin-top: 20rpx; | ||
| 182 | +} | ||
| 183 | + | ||
| 184 | +.item_pro .item_pro_left{ | ||
| 185 | + width:170rpx;flex-shrink: 0; position: relative; | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +.item_pro .item_pro_right{ | ||
| 189 | + position: relative; | ||
| 190 | +} | ||
| 191 | + | ||
| 192 | + | ||
| 193 | +.tick { | ||
| 194 | + position: relative; | ||
| 195 | +} | ||
| 196 | + | ||
| 197 | +.tick:before { | ||
| 198 | + content: ''; | ||
| 199 | + display: inline-block; | ||
| 200 | + vertical-align: middle; | ||
| 201 | + margin-top: -4rpx; | ||
| 202 | + margin-right: 8rpx; | ||
| 203 | + width: 22rpx; | ||
| 204 | + height: 22rpx; | ||
| 205 | + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABCUExURUdwTPInDPInDPgoDfMnDPYqEvInDPInDPInDP87NPUoDv8vEvMoDPInDPIoDPMnDvInDPInDPInDPIoDPQoDfInDEON4KMAAAAVdFJOUwD45yawG4zz3gQ0DmLOfECQZpPlS54kMQ4AAAC0SURBVBjTbZFREoMgDERDS0xQQNHu/a/alEGtaIYfHrBhs0S1pujVifo40VkhC+BUHSDzQTlBhjHY8bjogXmDZ+orJKwXwMUeUoa/0PeGbH8Q4Y5CJopYOjosiOQxdpRGk1UXOkrBKdkimtN8UrKrJBVXdzsllSYSjR/0J9JaGn81WluWtonYKQ0op51P3M2L2bmZN9n8MKoVqTph/RsseyjfYxAkfgot/82CpuJVLOLSIv4Cd5AJ37BgpFwAAAAASUVORK5CYII=) no-repeat; | ||
| 206 | + background-size: 22rpx auto; | ||
| 207 | +} | ||
| 208 | + | ||
| 209 | +.r_item_pro{ | ||
| 210 | + position: absolute; | ||
| 211 | + right: 18rpx; | ||
| 212 | + height: 100%; | ||
| 213 | + display: flex; | ||
| 214 | + align-items: center; | ||
| 215 | + justify-content: center; | ||
| 216 | +} | ||
| 217 | + | ||
| 218 | +.xq_btn{ | ||
| 219 | + width: 100rpx; | ||
| 220 | + height: 60rpx; | ||
| 221 | + background-color: #e03033; | ||
| 222 | + color: #fff; text-align: center; line-height: 60rpx; | ||
| 223 | + border-radius:10rpx ; | ||
| 224 | +} | ||
| 225 | +.left_f_box{ | ||
| 226 | + width:80rpx;font-weight: bolder; color:#d9001b; line-height: 44rpx;text-align: center; | ||
| 227 | +} | ||
| 228 | +.tab_bx{ | ||
| 229 | + position: absolute;top: 0; left: 0; width: 60rpx; height: 40rpx; | ||
| 230 | + background-color: #f5bcc1;color: #d9001b; display: flex; justify-content: center;align-items: center; | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | + | ||
| 234 | +/*选择的圆圈*/ | ||
| 235 | +.xc-hook { | ||
| 236 | + width: 30rpx; | ||
| 237 | + height: 30rpx; | ||
| 238 | + line-height: 30rpx; | ||
| 239 | + text-align: center; | ||
| 240 | + border: 1rpx solid #999; | ||
| 241 | + display: inline-block; | ||
| 242 | +} | ||
| 243 | +/*选中的时候*/ | ||
| 244 | +.xc-hook.on { | ||
| 245 | + transform: rotate(-135deg); | ||
| 246 | + background-color: #d60021; | ||
| 247 | +} | ||
| 248 | + | ||
| 249 | + | ||
| 250 | + | ||
| 251 | +@import '../../app.wxss'; |
packageE/pages/cart/cart2/cart2.js
| @@ -5,7 +5,12 @@ var regeneratorRuntime = require('../../../../utils/runtime.js'); | @@ -5,7 +5,12 @@ var regeneratorRuntime = require('../../../../utils/runtime.js'); | ||
| 5 | var util_pay = require("../../../../utils/pay.js"); | 5 | var util_pay = require("../../../../utils/pay.js"); |
| 6 | var zh_calc = require("zh_calculate.js"); | 6 | var zh_calc = require("zh_calculate.js"); |
| 7 | var ladder_calc = require("ladder_calculate.js"); | 7 | var ladder_calc = require("ladder_calculate.js"); |
| 8 | + | ||
| 8 | // 防抖函数用定时器 | 9 | // 防抖函数用定时器 |
| 10 | +//公共的函数合并在一起 | ||
| 11 | +const m_cx = require("../../../../utils/more_cx.js"); | ||
| 12 | + | ||
| 13 | +// 防抖函数用定时器 | ||
| 9 | let timer; | 14 | let timer; |
| 10 | Page({ | 15 | Page({ |
| 11 | data: { | 16 | data: { |
| @@ -126,7 +131,16 @@ Page({ | @@ -126,7 +131,16 @@ Page({ | ||
| 126 | tabs: ['门店自提', '快递邮寄'], | 131 | tabs: ['门店自提', '快递邮寄'], |
| 127 | currentTabIndex: 1, | 132 | currentTabIndex: 1, |
| 128 | 133 | ||
| 129 | - in_zhact_gdmap: {}, //不同门店参与同一活动的限购 | 134 | + in_zhact_gdmap: {}, //不同门店参与同一活动的限购,这些都是map表,很 |
| 135 | + in_zhact:{}, //组合购活动在列表中的显示 | ||
| 136 | + in_yhact:{}, //优惠活动在列表中的显示 | ||
| 137 | + | ||
| 138 | + in_zh_gd_buy_map:{}, //就是商品在组合购中的 | ||
| 139 | + | ||
| 140 | + in_zhact_gdmap_new: {}, //不同门店参与同一活动的限购,这些都是map表,是多促销互动专用,不能和in_zhact_gdmap重叠 | ||
| 141 | + in_zhact_new:{}, //组合购活动在列表中的显示 是多促销互动专用,不能和in_zhact重叠 | ||
| 142 | + in_yhact_new:{}, //组合购活动在列表中的显示 是多促销互动专用,不能和in_yhact重叠 | ||
| 143 | + | ||
| 130 | hid_inp: 1, | 144 | hid_inp: 1, |
| 131 | user_note: "", | 145 | user_note: "", |
| 132 | zhhe_act_map: {}, //组合活动的map表 | 146 | zhhe_act_map: {}, //组合活动的map表 |
| @@ -156,6 +170,7 @@ Page({ | @@ -156,6 +170,7 @@ Page({ | ||
| 156 | bconfig:null | 170 | bconfig:null |
| 157 | 171 | ||
| 158 | }, | 172 | }, |
| 173 | + | ||
| 159 | onLoad: function (t) { | 174 | onLoad: function (t) { |
| 160 | 175 | ||
| 161 | wx.setNavigationBarTitle({ title: "填写订单", }) | 176 | wx.setNavigationBarTitle({ title: "填写订单", }) |
| @@ -167,8 +182,7 @@ Page({ | @@ -167,8 +182,7 @@ Page({ | ||
| 167 | //清空is_pick_up | 182 | //清空is_pick_up |
| 168 | getApp().request.put("/api/weshop/useraddress/updatePickUp", { | 183 | getApp().request.put("/api/weshop/useraddress/updatePickUp", { |
| 169 | data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, | 184 | data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, |
| 170 | - success: function (s) { | ||
| 171 | - } | 185 | + success: function (s) {} |
| 172 | }); | 186 | }); |
| 173 | 187 | ||
| 174 | getApp().getConfig2(function (e) { | 188 | getApp().getConfig2(function (e) { |
| @@ -378,6 +392,8 @@ Page({ | @@ -378,6 +392,8 @@ Page({ | ||
| 378 | } | 392 | } |
| 379 | this.calculatePrice()//计算金额 | 393 | this.calculatePrice()//计算金额 |
| 380 | }, | 394 | }, |
| 395 | + | ||
| 396 | + | ||
| 381 | //直接购买预存开启关闭 | 397 | //直接购买预存开启关闭 |
| 382 | prestore2() { | 398 | prestore2() { |
| 383 | let txt = 'bn_goods.yck_off'; | 399 | let txt = 'bn_goods.yck_off'; |
| @@ -399,7 +415,6 @@ Page({ | @@ -399,7 +415,6 @@ Page({ | ||
| 399 | }else{ | 415 | }else{ |
| 400 | this.calculatePrice2()//计算金额 | 416 | this.calculatePrice2()//计算金额 |
| 401 | } | 417 | } |
| 402 | - | ||
| 403 | }, | 418 | }, |
| 404 | //计算商品预存款前置方法------------------------------------ | 419 | //计算商品预存款前置方法------------------------------------ |
| 405 | async beforAdvancesum(cartList) { | 420 | async beforAdvancesum(cartList) { |
| @@ -565,7 +580,7 @@ Page({ | @@ -565,7 +580,7 @@ Page({ | ||
| 565 | }); | 580 | }); |
| 566 | }, | 581 | }, |
| 567 | 582 | ||
| 568 | - //----------------展示页面,是再获取用户信息之后-------------- | 583 | + //---------------- 展示页面,是再获取用户信息之后 -------------- |
| 569 | async show_page() { | 584 | async show_page() { |
| 570 | var th = this, ta = this.data.param; | 585 | var th = this, ta = this.data.param; |
| 571 | //获取用户预存款 | 586 | //获取用户预存款 |
| @@ -699,6 +714,38 @@ Page({ | @@ -699,6 +714,38 @@ Page({ | ||
| 699 | 714 | ||
| 700 | }, | 715 | }, |
| 701 | 716 | ||
| 717 | + | ||
| 718 | + //-- 获取促销活动的组合 -- | ||
| 719 | + cx_prom_group(prom_list,item1){ | ||
| 720 | + var th=this; | ||
| 721 | + //需要读者系统顺序 | ||
| 722 | + var json_d =this.data.json_d; | ||
| 723 | + var auto_promote_sale=json_d.auto_promote_sale; | ||
| 724 | + var sort_type=''; | ||
| 725 | + | ||
| 726 | + if(!auto_promote_sale){ | ||
| 727 | + sort_type='prom_type'; | ||
| 728 | + }else{ | ||
| 729 | + var auto_promote_sale=auto_promote_sale.split(','); | ||
| 730 | + //--- 循环处理 --- | ||
| 731 | + prom_list.map(function (e){ | ||
| 732 | + var fd=auto_promote_sale.indexOf(e.prom_type+''); | ||
| 733 | + e.sort=fd; | ||
| 734 | + if(e.prom_type==item1.prom_type){ | ||
| 735 | + e.sele=1; | ||
| 736 | + } | ||
| 737 | + }) | ||
| 738 | + sort_type='sort'; | ||
| 739 | + } | ||
| 740 | + | ||
| 741 | + //-- 排序一下,进行升序 -- | ||
| 742 | + function comp(a, b) { | ||
| 743 | + return a[sort_type]-b[sort_type]; //升序 | ||
| 744 | + } | ||
| 745 | + //使用sort排序 | ||
| 746 | + prom_list.sort(comp); | ||
| 747 | + }, | ||
| 748 | + | ||
| 702 | //-----真的获取购物车,入口-------- | 749 | //-----真的获取购物车,入口-------- |
| 703 | get_cart: function () { | 750 | get_cart: function () { |
| 704 | var th = this, app = getApp(); | 751 | var th = this, app = getApp(); |
| @@ -710,10 +757,8 @@ Page({ | @@ -710,10 +757,8 @@ Page({ | ||
| 710 | store_id: oo.stoid, pageSize: 600 | 757 | store_id: oo.stoid, pageSize: 600 |
| 711 | }, | 758 | }, |
| 712 | success: async function (su) { | 759 | success: async function (su) { |
| 713 | - //按门店分类的数组 | ||
| 714 | - var arr = new Array(); | ||
| 715 | - var carr = su.data.data.pageData; | ||
| 716 | 760 | ||
| 761 | + var carr = su.data.data.pageData; | ||
| 717 | th.setData({ is_all_zt: 1 }); | 762 | th.setData({ is_all_zt: 1 }); |
| 718 | 763 | ||
| 719 | //-- 找出所有的门店 -- | 764 | //-- 找出所有的门店 -- |
| @@ -733,256 +778,246 @@ Page({ | @@ -733,256 +778,246 @@ Page({ | ||
| 733 | }) | 778 | }) |
| 734 | 779 | ||
| 735 | th.data.cartlist_y = carr; //存储原始购物车列表 | 780 | th.data.cartlist_y = carr; //存储原始购物车列表 |
| 736 | - th.data.in_zhact_gdmap = {}; | ||
| 737 | 781 | ||
| 738 | - //---是不是购买等级卡成功的返回---等级卡显示的判断--- | ||
| 739 | - var is_card_back = getApp().globalData.is_card_back; | 782 | + wx.showLoading(); |
| 740 | 783 | ||
| 784 | + th.get_cart_next(carr); | ||
| 741 | 785 | ||
| 742 | - //-- 判断组合购是总数量是不是存在 -- | ||
| 743 | - var no_zh_num={}; | 786 | + } |
| 787 | + }); | ||
| 788 | + }, | ||
| 744 | 789 | ||
| 745 | - for (var i = 0; i < carr.length; i++) { | ||
| 746 | - var item1 = carr[i]; | ||
| 747 | - //把已经购买了多少见的内容填入 | ||
| 748 | 790 | ||
| 749 | - var goodsbuynum = 0, promgoodsbuynum = 0; | ||
| 750 | - //--要获得商品,该用户买了多少件,同步应用-- | ||
| 751 | - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 752 | - data: { | ||
| 753 | - store_id: os.stoid, | ||
| 754 | - user_id: getApp().globalData.user_id, | ||
| 755 | - goods_id: item1.goods_id, | ||
| 756 | - prom_type: item1.prom_type, | ||
| 757 | - prom_id: item1.prom_id | ||
| 758 | - }, | ||
| 759 | - }).then(res => { | ||
| 760 | - var buy_num_data = res.data.data; | ||
| 761 | - if (buy_num_data.promgoodsbuynum) { | ||
| 762 | - promgoodsbuynum = buy_num_data.promgoodsbuynum; | ||
| 763 | - } | ||
| 764 | - goodsbuynum = buy_num_data.goodsbuynum; | ||
| 765 | - }) | ||
| 766 | - //如果有购买活动 | ||
| 767 | - item1.promgoodsbuynum = promgoodsbuynum; | ||
| 768 | - | ||
| 769 | - //默认是包邮和优惠的 | ||
| 770 | - item1.is_order_yh=1; | ||
| 771 | - item1.is_post_temp=1; | ||
| 772 | - | ||
| 773 | - //如果是秒杀,团购的时候 | ||
| 774 | - if([1,2,6].indexOf(item1.prom_type)>-1){ | ||
| 775 | - var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid | ||
| 776 | - + "/" + item1.goods_id + "/"+item1.prom_type+"/" + item1.prom_id + "/" + app.globalData.user_id; | ||
| 777 | - await app.request.promiseGet(url,{}).then(res=>{ | ||
| 778 | - if(res.data.code==0){ | ||
| 779 | - console.log(res.data.data,"111"); | ||
| 780 | - item1.is_order_yh=res.data.data.is_order_yh; | ||
| 781 | - item1.is_post_temp=res.data.data.is_post_temp; | ||
| 782 | - } | ||
| 783 | - }) | ||
| 784 | - } | ||
| 785 | - | ||
| 786 | - //要把优惠活动加入,prom_goods_map中,赠品不要运算,代发商品不算优惠 | ||
| 787 | - if (item1.prom_type == 3 && item1.is_gift != 1 && !item1.whsle_id) { | ||
| 788 | - // th.check_is_youhui(item1.goods_id, item1.pick_id); | ||
| 789 | - //增加优惠活动次数限制 | ||
| 790 | - let limit_num= await th.getprom(item1) //活动限制次数 | ||
| 791 | - | ||
| 792 | - if(!limit_num){ | ||
| 793 | - await th.add_prom_goods_map(item1); | ||
| 794 | - // item1.prom_id='' | ||
| 795 | - // item1.prom_type='' | ||
| 796 | - }else{ | ||
| 797 | - let user_pre_buynum = await th.getUserBuyPromNum_pre(item1.prom_id) //用户已经参与次数 | ||
| 798 | - if(user_pre_buynum<limit_num){ | ||
| 799 | - await th.add_prom_goods_map(item1); | ||
| 800 | - }else{ | ||
| 801 | - // await th.add_prom_goods_map(item1); | ||
| 802 | - item1.prom_id='' | ||
| 803 | - item1.prom_type='' | ||
| 804 | - } | ||
| 805 | - } | ||
| 806 | - } | ||
| 807 | - | ||
| 808 | - //-- 如果组合购的总数量不足的处理 -- | ||
| 809 | - if(no_zh_num[item1.prom_id] && item1.prom_type == 7){ | ||
| 810 | - item1.prom_type = 0; | ||
| 811 | - item1.prom_type1 = 0; | ||
| 812 | - item1.prom_id = 0; | ||
| 813 | - item1.prom_id1 = 0 | ||
| 814 | - } | ||
| 815 | - | ||
| 816 | - //要把组合购的东西拿出来算一下,同时组合购的总数量要有存在 | ||
| 817 | - if (item1.prom_type == 7) { | ||
| 818 | - if (!th.data.zuhe_map_good[item1.prom_id]) { | ||
| 819 | - var isok = 1; | ||
| 820 | - var is_flag = 1; | ||
| 821 | - var store_count_ok=1; | ||
| 822 | - //如果有组合购 | ||
| 823 | - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id + '/' + getApp().globalData.userInfo.user_id; | ||
| 824 | - await getApp().request.promiseGet(url, {}).then(res => { | ||
| 825 | - if (res.data.code == 0 && res.data.data) { | ||
| 826 | - //如果活动已经结束 | ||
| 827 | - if (res.data.data.is_end == 1) { | ||
| 828 | - isok = 0; | ||
| 829 | - } | ||
| 830 | - if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 831 | - isok = 0; | ||
| 832 | - } | ||
| 833 | - item1.act = res.data.data; | 791 | + async get_cart_next(carr,is_change){ |
| 834 | 792 | ||
| 835 | - //-- 在这里要判断一下活动的组合购总数量 -- | ||
| 836 | - if(item1.act.zh_num>0 && item1.act.zh_buy_num>=item1.act.zh_num){ | ||
| 837 | - store_count_ok = 0; | ||
| 838 | - no_zh_num[item1.prom_id]=1; | ||
| 839 | - //-- 清理一下活动的状态 -- | ||
| 840 | - item1.prom_type = 0; | ||
| 841 | - item1.prom_type1 = 0; | ||
| 842 | - item1.prom_id = 0; | ||
| 843 | - item1.prom_id1 = 0 | 793 | + if(is_change) carr=this.data.cartlist_y; |
| 794 | + //按门店分类的数组 | ||
| 795 | + var arr = new Array(); | ||
| 844 | 796 | ||
| 845 | - }else{ | ||
| 846 | - th.data.zhhe_act_map[item1.prom_id] = res.data.data; | ||
| 847 | - } | 797 | + var th=this; |
| 798 | + th.data.in_zhact_gdmap = {}; | ||
| 799 | + //---是不是购买等级卡成功的返回---等级卡显示的判断--- | ||
| 800 | + var is_card_back = getApp().globalData.is_card_back; | ||
| 848 | 801 | ||
| 849 | - } else { | ||
| 850 | - //未找到商品的活动 | ||
| 851 | - is_flag = 0; | ||
| 852 | - } | ||
| 853 | - }) | 802 | + //-- 判断组合购是总数量是不是存在 -- |
| 803 | + var no_zh_num={}; | ||
| 854 | 804 | ||
| 855 | - if (!isok) { | ||
| 856 | - getApp().my_warnning("组合购的活动已经过期", 0, th); | ||
| 857 | - return false; | 805 | + for (var i = 0; i < carr.length; i++) { |
| 806 | + var item1 = carr[i]; | ||
| 807 | + //-- 获取一下商品的所有活动 -- | ||
| 808 | + await th.buy_pro_group(item1); | ||
| 809 | + //把已经购买了多少见的内容填入 | ||
| 810 | + var goodsbuynum = 0, promgoodsbuynum = 0; | ||
| 811 | + //--要获得商品,该用户买了多少件,同步应用-- | ||
| 812 | + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 813 | + data: { | ||
| 814 | + store_id: os.stoid, | ||
| 815 | + user_id: getApp().globalData.user_id, | ||
| 816 | + goods_id: item1.goods_id, | ||
| 817 | + prom_type: item1.prom_type, | ||
| 818 | + prom_id: item1.prom_id | ||
| 819 | + }, | ||
| 820 | + }).then(res => { | ||
| 821 | + var buy_num_data = res.data.data; | ||
| 822 | + if (buy_num_data.promgoodsbuynum) { | ||
| 823 | + promgoodsbuynum = buy_num_data.promgoodsbuynum; | ||
| 824 | + } | ||
| 825 | + goodsbuynum = buy_num_data.goodsbuynum; | ||
| 826 | + }) | ||
| 827 | + //如果有购买活动 | ||
| 828 | + item1.promgoodsbuynum = promgoodsbuynum; | ||
| 829 | + | ||
| 830 | + //默认是包邮和优惠的 | ||
| 831 | + item1.is_order_yh=1; | ||
| 832 | + item1.is_post_temp=1; | ||
| 833 | + | ||
| 834 | + //如果是秒杀,团购的时候 | ||
| 835 | + if([1,2,6].indexOf(item1.prom_type)>-1){ | ||
| 836 | + var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid | ||
| 837 | + + "/" + item1.goods_id + "/"+item1.prom_type+"/" + item1.prom_id + "/" + app.globalData.user_id; | ||
| 838 | + await app.request.promiseGet(url,{}).then(res=>{ | ||
| 839 | + if(res.data.code==0){ | ||
| 840 | + console.log(res.data.data,"111"); | ||
| 841 | + item1.is_order_yh=res.data.data.is_order_yh; | ||
| 842 | + item1.is_post_temp=res.data.data.is_post_temp; | ||
| 843 | + } | ||
| 844 | + }) | ||
| 845 | + } | ||
| 846 | + | ||
| 847 | + //要把优惠活动加入,prom_goods_map中,赠品不要运算,代发商品不算优惠 | ||
| 848 | + if (item1.prom_type == 3 && item1.is_gift != 1 && !item1.whsle_id) { | ||
| 849 | + // th.check_is_youhui(item1.goods_id, item1.pick_id); | ||
| 850 | + //增加优惠活动次数限制 | ||
| 851 | + let limit_num= await th.getprom(item1) //活动限制次数 | ||
| 852 | + | ||
| 853 | + if(!limit_num){ | ||
| 854 | + await th.add_prom_goods_map(item1); | ||
| 855 | + // item1.prom_id='' | ||
| 856 | + // item1.prom_type='' | ||
| 857 | + }else{ | ||
| 858 | + let user_pre_buynum = await th.getUserBuyPromNum_pre(item1.prom_id) //用户已经参与次数 | ||
| 859 | + if(user_pre_buynum<limit_num){ | ||
| 860 | + await th.add_prom_goods_map(item1); | ||
| 861 | + }else{ | ||
| 862 | + // await th.add_prom_goods_map(item1); | ||
| 863 | + item1.prom_id='' | ||
| 864 | + item1.prom_type='' | ||
| 865 | + } | ||
| 866 | + } | ||
| 867 | + } | ||
| 868 | + | ||
| 869 | + //-- 如果组合购的总数量不足的处理 -- | ||
| 870 | + if(no_zh_num[item1.prom_id] && item1.prom_type == 7){ | ||
| 871 | + item1.prom_type = 0; | ||
| 872 | + item1.prom_type1 = 0; | ||
| 873 | + item1.prom_id = 0; | ||
| 874 | + item1.prom_id1 = 0 | ||
| 875 | + } | ||
| 876 | + | ||
| 877 | + //要把组合购的东西拿出来算一下,同时组合购的总数量要有存在 | ||
| 878 | + if (item1.prom_type == 7) { | ||
| 879 | + if (!th.data.zuhe_map_good[item1.prom_id]) { | ||
| 880 | + var isok = 1; | ||
| 881 | + var is_flag = 1; | ||
| 882 | + var store_count_ok=1; | ||
| 883 | + //如果有组合购 | ||
| 884 | + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id + '/' + getApp().globalData.userInfo.user_id; | ||
| 885 | + await getApp().request.promiseGet(url, {}).then(res => { | ||
| 886 | + if (res.data.code == 0 && res.data.data) { | ||
| 887 | + //如果活动已经结束 | ||
| 888 | + if (res.data.data.is_end == 1) { | ||
| 889 | + isok = 0; | ||
| 858 | } | 890 | } |
| 891 | + if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 892 | + isok = 0; | ||
| 893 | + } | ||
| 894 | + item1.act = res.data.data; | ||
| 895 | + | ||
| 896 | + //-- 在这里要判断一下活动的组合购总数量 -- | ||
| 897 | + if(item1.act.zh_num>0 && item1.act.zh_buy_num>=item1.act.zh_num){ | ||
| 898 | + store_count_ok = 0; | ||
| 899 | + no_zh_num[item1.prom_id]=1; | ||
| 900 | + //-- 清理一下活动的状态 -- | ||
| 901 | + item1.prom_type = 0; | ||
| 902 | + item1.prom_type1 = 0; | ||
| 903 | + item1.prom_id = 0; | ||
| 904 | + item1.prom_id1 = 0 | ||
| 859 | 905 | ||
| 860 | - //------ 先增组合活动的总数量的时候 ------- | ||
| 861 | - if(store_count_ok) { | ||
| 862 | - var url1 = "/api/weshop/prom/zhbuyGoods/page"; | ||
| 863 | - var req_data = { | ||
| 864 | - page: 1, | ||
| 865 | - pageSize: 2000, | ||
| 866 | - store_id: os.stoid, | ||
| 867 | - zh_id: item1.prom_id, | ||
| 868 | - } | ||
| 869 | - await getApp().request.promiseGet(url1, { | ||
| 870 | - data: req_data | ||
| 871 | - }).then(res => { | ||
| 872 | - if (ut.ajax_ok(res)) { | ||
| 873 | - var gdlist = res.data.data.pageData; | ||
| 874 | - gdlist.forEach(i => { | ||
| 875 | - if (item1.goods_id == i.goods_id && !is_flag) { | ||
| 876 | - item1.prom_type = 0; | ||
| 877 | - item1.prom_type1 = 0; | ||
| 878 | - item1.prom_id = 0; | ||
| 879 | - item1.prom_id1 = 0 | ||
| 880 | - } | ||
| 881 | - }) | ||
| 882 | - th.data.zuhe_map_good[item1.prom_id] = gdlist; | ||
| 883 | - } | ||
| 884 | - }) | 906 | + }else{ |
| 907 | + th.data.zhhe_act_map[item1.prom_id] = res.data.data; | ||
| 885 | } | 908 | } |
| 886 | 909 | ||
| 910 | + } else { | ||
| 911 | + //未找到商品的活动 | ||
| 912 | + is_flag = 0; | ||
| 913 | + } | ||
| 914 | + }) | ||
| 887 | 915 | ||
| 916 | + if (!isok) { | ||
| 917 | + getApp().my_warnning("组合购的活动已经过期", 0, th); | ||
| 918 | + return false; | ||
| 919 | + } | ||
| 888 | 920 | ||
| 921 | + //------ 先增组合活动的总数量的时候 ------- | ||
| 922 | + if(store_count_ok) { | ||
| 923 | + var url1 = "/api/weshop/prom/zhbuyGoods/page"; | ||
| 924 | + var req_data = { | ||
| 925 | + page: 1, | ||
| 926 | + pageSize: 2000, | ||
| 927 | + store_id: os.stoid, | ||
| 928 | + zh_id: item1.prom_id, | ||
| 889 | } | 929 | } |
| 890 | - else { | ||
| 891 | - item1.act = th.data.zhhe_act_map[item1.prom_id]; | ||
| 892 | - } | ||
| 893 | - } | ||
| 894 | - if (item1.prom_type == 10) { | ||
| 895 | - if (!th.data.ladder_map[item1.prom_id]) { | ||
| 896 | - //如果有预售 | ||
| 897 | - var isok = 1; | ||
| 898 | - var is_flag = 1; | ||
| 899 | - var act = null; | ||
| 900 | - var url = "/api/weshop/prom/ladderForm/get/" + os.stoid + "/" + item1.prom_id; | ||
| 901 | - await getApp().request.promiseGet(url, {}).then(res => { | ||
| 902 | - console.log(res, 1000); | ||
| 903 | - if (res.data.code == 0 && res.data.data) { | ||
| 904 | - if (res.data.data.isuse != 1) { | ||
| 905 | - isok = 0; | ||
| 906 | - } | ||
| 907 | - //如果活动已经结束 | ||
| 908 | - if (res.data.data.is_end == 1) { | ||
| 909 | - isok = 0; | ||
| 910 | - } | ||
| 911 | - //已经结束 | ||
| 912 | - if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 913 | - isok = 0; | ||
| 914 | - } | ||
| 915 | - //还未开始 | ||
| 916 | - if (ut.gettimestamp() < res.data.data.start_time) { | ||
| 917 | - isok = 0; | 930 | + await getApp().request.promiseGet(url1, { |
| 931 | + data: req_data | ||
| 932 | + }).then(res => { | ||
| 933 | + if (ut.ajax_ok(res)) { | ||
| 934 | + var gdlist = res.data.data.pageData; | ||
| 935 | + gdlist.forEach(i => { | ||
| 936 | + if (item1.goods_id == i.goods_id && !is_flag) { | ||
| 937 | + item1.prom_type = 0; | ||
| 938 | + item1.prom_type1 = 0; | ||
| 939 | + item1.prom_id = 0; | ||
| 940 | + item1.prom_id1 = 0 | ||
| 918 | } | 941 | } |
| 919 | - act = res.data.data; | ||
| 920 | - | ||
| 921 | - } else { | ||
| 922 | - //未找到商品的活动 | ||
| 923 | - is_flag = 0; | ||
| 924 | - } | ||
| 925 | - }) | ||
| 926 | - if (!isok) { | ||
| 927 | - var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item1.id; | ||
| 928 | - getApp().request.delete(url, {}); | ||
| 929 | - th.data.ladder_map[item1.prom_id] = -1; | ||
| 930 | - continue; | ||
| 931 | - } | ||
| 932 | - th.data.ladder_map[item1.prom_id] = act; | ||
| 933 | - | ||
| 934 | - //-- 获取阶梯规则 -- | ||
| 935 | - var url1 = "/api/weshop/prom/ladderList/list"; | ||
| 936 | - var req_data = { | ||
| 937 | - store_id: os.stoid, | ||
| 938 | - form_id: item1.prom_id, | 942 | + }) |
| 943 | + th.data.zuhe_map_good[item1.prom_id] = gdlist; | ||
| 939 | } | 944 | } |
| 940 | - await getApp().request.promiseGet(url1, { | ||
| 941 | - data: req_data | ||
| 942 | - }).then(rs1 => { | ||
| 943 | - if (rs1.data.code == 0 && rs1.data.data) { | ||
| 944 | - var gdlist = rs1.data.data; | ||
| 945 | - th.data.ladder_map[item1.prom_id].ladder_list = gdlist; | ||
| 946 | - } | ||
| 947 | - }) | ||
| 948 | - } | 945 | + }) |
| 949 | } | 946 | } |
| 950 | 947 | ||
| 951 | - //-- 判断一下,获取搭配购的消息 -- | ||
| 952 | - if ((item1.prom_type == 0 || item1.prom_type == 5) && (!carr[i].collocationList || !carr[i].collocationList.length)) { | ||
| 953 | 948 | ||
| 954 | - await th.set_collection(item1, carr, i); | ||
| 955 | - } | 949 | + |
| 956 | } | 950 | } |
| 951 | + else { | ||
| 952 | + item1.act = th.data.zhhe_act_map[item1.prom_id]; | ||
| 953 | + } | ||
| 954 | + } | ||
| 955 | + if (item1.prom_type == 10) { | ||
| 956 | + if (!th.data.ladder_map[item1.prom_id]) { | ||
| 957 | + //如果有预售 | ||
| 958 | + var isok = 1; | ||
| 959 | + var is_flag = 1; | ||
| 960 | + var act = null; | ||
| 961 | + var url = "/api/weshop/prom/ladderForm/get/" + os.stoid + "/" + item1.prom_id; | ||
| 962 | + await getApp().request.promiseGet(url, {}).then(res => { | ||
| 963 | + console.log(res, 1000); | ||
| 964 | + if (res.data.code == 0 && res.data.data) { | ||
| 965 | + if (res.data.data.isuse != 1) { | ||
| 966 | + isok = 0; | ||
| 967 | + } | ||
| 968 | + //如果活动已经结束 | ||
| 969 | + if (res.data.data.is_end == 1) { | ||
| 970 | + isok = 0; | ||
| 971 | + } | ||
| 972 | + //已经结束 | ||
| 973 | + if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 974 | + isok = 0; | ||
| 975 | + } | ||
| 976 | + //还未开始 | ||
| 977 | + if (ut.gettimestamp() < res.data.data.start_time) { | ||
| 978 | + isok = 0; | ||
| 979 | + } | ||
| 980 | + act = res.data.data; | ||
| 957 | 981 | ||
| 958 | - //在分组的时候,就不要再调用接口,await | ||
| 959 | - for (var i = 0; i < carr.length; i++) { | ||
| 960 | - var item = carr[i]; | ||
| 961 | - //-- 如果是等级会员注册返回 -- | ||
| 962 | - if (is_card_back) { | ||
| 963 | - th.data.card_name = th.data.userinfo.card_field; | ||
| 964 | - //如果是秒杀的返回,就要把活动弄回0 | ||
| 965 | - if (item['prom_type'] == 1) { | ||
| 966 | - item['prom_type'] = 0; | ||
| 967 | - item['prom_id'] = 0; | 982 | + } else { |
| 983 | + //未找到商品的活动 | ||
| 984 | + is_flag = 0; | ||
| 968 | } | 985 | } |
| 969 | - // 拼团,搭配购不计算,赠品也不计算 | ||
| 970 | - if (item['prom_type'] != 5 && item['prom_type'] != 6 && !item.is_gift && !item['is_collocation'] && item.goods_price > item[th.data.card_name]) { | ||
| 971 | - item.goods_price = item[th.data.card_name]; | ||
| 972 | - carr[i].goods_price = item[th.data.card_name]; | 986 | + }) |
| 987 | + if (!isok) { | ||
| 988 | + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item1.id; | ||
| 989 | + getApp().request.delete(url, {}); | ||
| 990 | + th.data.ladder_map[item1.prom_id] = -1; | ||
| 991 | + continue; | ||
| 992 | + } | ||
| 993 | + th.data.ladder_map[item1.prom_id] = act; | ||
| 973 | 994 | ||
| 995 | + //-- 获取阶梯规则 -- | ||
| 996 | + var url1 = "/api/weshop/prom/ladderList/list"; | ||
| 997 | + var req_data = { | ||
| 998 | + store_id: os.stoid, | ||
| 999 | + form_id: item1.prom_id, | ||
| 1000 | + } | ||
| 1001 | + await getApp().request.promiseGet(url1, { | ||
| 1002 | + data: req_data | ||
| 1003 | + }).then(rs1 => { | ||
| 1004 | + if (rs1.data.code == 0 && rs1.data.data) { | ||
| 1005 | + var gdlist = rs1.data.data; | ||
| 1006 | + th.data.ladder_map[item1.prom_id].ladder_list = gdlist; | ||
| 974 | } | 1007 | } |
| 975 | - } else { | ||
| 976 | - // 拼团,搭配购不计算,赠品也不计算,同时会员还未购买等级会员 | ||
| 977 | - if (item[th.data.card_name] > 0 && item['prom_type'] != 5 && item['prom_type'] != 6 && !th.data.userinfo.card_field | ||
| 978 | - && !item.is_gift && !item['is_collocation'] && item.goods_price > item[th.data.card_name]) { | ||
| 979 | - item.cut_price1 = item.goods_price - item[th.data.card_name]; | ||
| 980 | - carr[i].cut_price1 = (item.goods_price - item[th.data.card_name]) * item.goods_num; | ||
| 981 | - } | 1008 | + }) |
| 1009 | + } | ||
| 1010 | + } | ||
| 982 | 1011 | ||
| 983 | - } | 1012 | + if(is_change){ |
| 1013 | + carr[i].collocationList=null; | ||
| 1014 | + } | ||
| 984 | 1015 | ||
| 985 | - item.original_img = oo.imghost + item.original_img; | 1016 | + //-- 判断一下,获取搭配购的消息,只有prom_type==5才会判断优惠活动 -- |
| 1017 | + if ( item1.prom_type == 5 && (!carr[i].collocationList || !carr[i].collocationList.length)) { | ||
| 1018 | + await th.set_collection(item1, carr, i); | ||
| 1019 | + } | ||
| 1020 | + } | ||
| 986 | 1021 | ||
| 987 | var car_item = item; | 1022 | var car_item = item; |
| 988 | /*----接口要弄出来的,先顶着-----*/ | 1023 | /*----接口要弄出来的,先顶着-----*/ |
| @@ -1019,32 +1054,51 @@ Page({ | @@ -1019,32 +1054,51 @@ Page({ | ||
| 1019 | //-- 把等级卡会优惠多少钱装进去 -- | 1054 | //-- 把等级卡会优惠多少钱装进去 -- |
| 1020 | if (car_item.cut_price1) arr[j].card_cut_price += car_item.cut_price1; | 1055 | if (car_item.cut_price1) arr[j].card_cut_price += car_item.cut_price1; |
| 1021 | 1056 | ||
| 1022 | - arr[j].goods.push(car_item); | ||
| 1023 | - if (car_item.collocationList) { | 1057 | + //在分组的时候,就不要再调用接口,await |
| 1058 | + for (var i = 0; i < carr.length; i++) { | ||
| 1059 | + var item = carr[i]; | ||
| 1060 | + //-- 如果是等级会员注册返回 -- | ||
| 1061 | + if (is_card_back) { | ||
| 1062 | + th.data.card_name = th.data.userinfo.card_field; | ||
| 1063 | + //如果是秒杀的返回,就要把活动弄回0 | ||
| 1064 | + if (item['prom_type'] == 1) { | ||
| 1065 | + item['prom_type'] = 0; | ||
| 1066 | + item['prom_id'] = 0; | ||
| 1067 | + } | ||
| 1068 | + // 拼团,搭配购不计算,赠品也不计算 | ||
| 1069 | + if (item['prom_type'] != 5 && item['prom_type'] != 6 && !item.is_gift && !item['is_collocation'] && item.goods_price > item[th.data.card_name]) { | ||
| 1070 | + item.goods_price = item[th.data.card_name]; | ||
| 1071 | + carr[i].goods_price = item[th.data.card_name]; | ||
| 1024 | 1072 | ||
| 1025 | - if (!arr[j].collocationList) arr[j].collocationList = car_item.collocationList; | ||
| 1026 | - else { | ||
| 1027 | - var arr_new = [...arr[j].collocationList, ...car_item.collocationList]; | ||
| 1028 | - arr[j].collocationList = arr_new; | ||
| 1029 | - } | ||
| 1030 | - } | 1073 | + } |
| 1074 | + } else { | ||
| 1075 | + // 拼团,搭配购不计算,赠品也不计算,同时会员还未购买等级会员 | ||
| 1076 | + if (item[th.data.card_name] > 0 && item['prom_type'] != 5 && item['prom_type'] != 6 && !th.data.userinfo.card_field | ||
| 1077 | + && !item.is_gift && !item['is_collocation'] && item.goods_price > item[th.data.card_name]) { | ||
| 1078 | + item.cut_price1 = item.goods_price - item[th.data.card_name]; | ||
| 1079 | + carr[i].cut_price1 = (item.goods_price - item[th.data.card_name]) * item.goods_num; | ||
| 1080 | + } | ||
| 1031 | 1081 | ||
| 1082 | + } | ||
| 1032 | 1083 | ||
| 1033 | 1084 | ||
| 1034 | - find = 1; | ||
| 1035 | - break; | ||
| 1036 | - } | ||
| 1037 | - } | ||
| 1038 | - } | ||
| 1039 | - //------如果没有找到----- | ||
| 1040 | - if (find == 0) { | ||
| 1041 | - var pikname = '', sto = null; | ||
| 1042 | - //----找到门店名称----- | ||
| 1043 | - for (var k = 0; k < th.data.allsto.length; k++) { | ||
| 1044 | - if (pcid == th.data.allsto[k].pickup_id) { | ||
| 1045 | - pikname = th.data.allsto[k].pickup_name; | ||
| 1046 | - sto = th.data.allsto[k]; | ||
| 1047 | - break; | 1085 | + //商品的图片不能重复的赋值 |
| 1086 | + if(item.original_img.indexOf(oo.imghost)==-1) | ||
| 1087 | + item.original_img = oo.imghost + item.original_img; | ||
| 1088 | + | ||
| 1089 | + var car_item = item; | ||
| 1090 | + /*----接口要弄出来的,先顶着-----*/ | ||
| 1091 | + var pcid = car_item.pick_id; | ||
| 1092 | + var find = 0; | ||
| 1093 | + //----如果有就加进去,没有就新增一个---- | ||
| 1094 | + //-----------循环查找门店------------- | ||
| 1095 | + if (arr.length > 0) { | ||
| 1096 | + for (var j = 0; j < arr.length; j++) { | ||
| 1097 | + if (arr[j].pickup_id == pcid) { | ||
| 1098 | + if (item.is_gift != 1) { | ||
| 1099 | + //确定配送方式 | ||
| 1100 | + if (arr[j].distr_t == 0) { | ||
| 1101 | + arr[j].distr_t = car_item.distr_type; | ||
| 1048 | } | 1102 | } |
| 1049 | } | 1103 | } |
| 1050 | var e_t = 0, dis_t = 0;//物流方式,配送方式 | 1104 | var e_t = 0, dis_t = 0;//物流方式,配送方式 |
| @@ -1081,53 +1135,40 @@ Page({ | @@ -1081,53 +1135,40 @@ Page({ | ||
| 1081 | if (def_exp_code == item.code) { | 1135 | if (def_exp_code == item.code) { |
| 1082 | m_wind = k; | 1136 | m_wind = k; |
| 1083 | } | 1137 | } |
| 1138 | + | ||
| 1084 | } | 1139 | } |
| 1140 | + arr[j].exp_type = e_t; | ||
| 1141 | + if (e_t == 0) th.setData({ is_all_zt: 0 }); | ||
| 1142 | + //else if (e_t == 1) th.setData({ is_all_zt: 1 }); | ||
| 1085 | } | 1143 | } |
| 1086 | 1144 | ||
| 1087 | - | ||
| 1088 | - var ie = { | ||
| 1089 | - pickup_id: pcid, | ||
| 1090 | - pname: pikname, | ||
| 1091 | - goods: narr, | ||
| 1092 | - wind: m_wind, | ||
| 1093 | - distr_t: dis_t, | ||
| 1094 | - card_cut_price: 0, | ||
| 1095 | - exp_type: e_t, | ||
| 1096 | - goods_price: 0, | ||
| 1097 | - shipping_price: 0, | ||
| 1098 | - user_money: 0, | ||
| 1099 | - total_amount: 0, | ||
| 1100 | - order_amount: 0, | ||
| 1101 | - user_note: "", | ||
| 1102 | - sto: sto | ||
| 1103 | - }; | ||
| 1104 | - | ||
| 1105 | //-- 把等级卡会优惠多少钱装进去 -- | 1145 | //-- 把等级卡会优惠多少钱装进去 -- |
| 1106 | - if (car_item.cut_price1) ie.card_cut_price += car_item.cut_price1; | 1146 | + if (car_item.cut_price1) arr[j].card_cut_price += car_item.cut_price1; |
| 1107 | 1147 | ||
| 1148 | + arr[j].goods.push(car_item); | ||
| 1108 | if (car_item.collocationList) { | 1149 | if (car_item.collocationList) { |
| 1109 | 1150 | ||
| 1110 | - ie.collocationList = car_item.collocationList; | 1151 | + if (!arr[j].collocationList) arr[j].collocationList = car_item.collocationList; |
| 1152 | + else { | ||
| 1153 | + var arr_new = [...arr[j].collocationList, ...car_item.collocationList]; | ||
| 1154 | + arr[j].collocationList = arr_new; | ||
| 1155 | + } | ||
| 1111 | } | 1156 | } |
| 1112 | 1157 | ||
| 1113 | - | ||
| 1114 | - arr.push(ie); | 1158 | + find = 1; |
| 1159 | + break; | ||
| 1115 | } | 1160 | } |
| 1116 | } | 1161 | } |
| 1117 | - //-- 如果是回退回来的情况 -- | ||
| 1118 | - if (th.data.cartlist && th.data.cartlist.length > 0) { | ||
| 1119 | - for (var kj in th.data.cartlist) { | ||
| 1120 | - for (var ih in arr) { | ||
| 1121 | - var ie = arr[ih]; | ||
| 1122 | - if (ie.pickup_id == th.data.cartlist[kj].pickup_id) { | ||
| 1123 | - ie.exp_type = parseInt(th.data.cartlist[kj].exp_type); | ||
| 1124 | - ie.wind = parseInt(th.data.cartlist[kj].wind); | ||
| 1125 | - | ||
| 1126 | - //-- 是不是全部自提清空 -- | ||
| 1127 | - if (ie.exp_type == 0 || ie.exp_type == 2) th.setData({ is_all_zt: 0 }); | ||
| 1128 | - break; | ||
| 1129 | - } | ||
| 1130 | - } | 1162 | + } |
| 1163 | + //------如果没有找到----- | ||
| 1164 | + if (find == 0) { | ||
| 1165 | + var pikname = '', sto = null; | ||
| 1166 | + //----找到门店名称----- | ||
| 1167 | + for (var k = 0; k < th.data.allsto.length; k++) { | ||
| 1168 | + if (pcid == th.data.allsto[k].pickup_id) { | ||
| 1169 | + pikname = th.data.allsto[k].pickup_name; | ||
| 1170 | + sto = th.data.allsto[k]; | ||
| 1171 | + break; | ||
| 1131 | } | 1172 | } |
| 1132 | }else{ | 1173 | }else{ |
| 1133 | 1174 | ||
| @@ -1140,110 +1181,116 @@ Page({ | @@ -1140,110 +1181,116 @@ Page({ | ||
| 1140 | th.setData({ is_all_zt: is_a_zt}); | 1181 | th.setData({ is_all_zt: is_a_zt}); |
| 1141 | 1182 | ||
| 1142 | } | 1183 | } |
| 1184 | + var e_t = 0, dis_t = 0;//物流方式,配送方式 | ||
| 1185 | + if (item.distr_type == 0) { | ||
| 1186 | + dis_t = sto.distr_type; | ||
| 1187 | + } else { | ||
| 1188 | + dis_t = item.distr_type; | ||
| 1189 | + } | ||
| 1190 | + switch (dis_t) { | ||
| 1191 | + case 0: | ||
| 1192 | + e_t = 1; | ||
| 1193 | + //-- 系统后台有设置要默认的 -- | ||
| 1194 | + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0; | ||
| 1195 | + break; | ||
| 1196 | + case 1: | ||
| 1197 | + e_t = 1; | ||
| 1198 | + break; | ||
| 1199 | + case 2: | ||
| 1200 | + e_t = 0; | ||
| 1201 | + break; | ||
| 1202 | + } | ||
| 1203 | + //如果是物流的话,全部自提的控制要弄成0 | ||
| 1204 | + if (e_t == 0) th.setData({ is_all_zt: 0 }); | ||
| 1205 | + //else th.setData({ is_all_zt: 1 }); | ||
| 1143 | 1206 | ||
| 1144 | - var cart_commission = 0; | ||
| 1145 | - //-- 循环计算一下线下取价 -- | ||
| 1146 | - for (var k = 0; k < arr.length; k++) { | ||
| 1147 | - var c_item = arr[k]; | ||
| 1148 | - var item = arr[k].goods; | ||
| 1149 | - var offline_price = 0; | ||
| 1150 | - var offline_num = 0; | ||
| 1151 | - //计算佣金的商品 | ||
| 1152 | - var commission_gds = []; | ||
| 1153 | - for (var c = 0; c < item.length; c++) { | ||
| 1154 | - | ||
| 1155 | - if (!item[c].is_gift) { | ||
| 1156 | - var hr = { | ||
| 1157 | - goods_id: item[c].goods_id, | ||
| 1158 | - goods_num: item[c].goods_num, | ||
| 1159 | - prom_type: item[c].prom_type, | ||
| 1160 | - prom_id: item[c].prom_id, | ||
| 1161 | - } | ||
| 1162 | - let req_d1 = { | ||
| 1163 | - user_id: getApp().globalData.user_id, goods_ids: [hr], store_id: os.stoid | ||
| 1164 | - } | ||
| 1165 | - | ||
| 1166 | - await getApp().request.promisePost("/api/weshop/order/getrebateSum", { | ||
| 1167 | - is_json: 1, data: req_d1 | ||
| 1168 | - }).then(grs => { | ||
| 1169 | - if (grs.data.code == 0) item[c].use_commission = grs.data.data; | ||
| 1170 | - }); | ||
| 1171 | - commission_gds.push(hr); | ||
| 1172 | - } | ||
| 1173 | - if (th.data.sales_rules != 2) { | ||
| 1174 | - item[c].offline_price = 0; | ||
| 1175 | - } | ||
| 1176 | - //-- 如果这个商品是线下取价的时候 -- | ||
| 1177 | - if (item[c].offline_price > 0 && item[c].prom_type != 7) { | ||
| 1178 | - offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num; | ||
| 1179 | - offline_num += item[c].goods_num; | 1207 | + var narr = new Array(); |
| 1208 | + narr.push(car_item); | ||
| 1209 | + | ||
| 1210 | + //-----------拼装购物车结算的数组,如果有默认物流时要用默认物流编号,计算默认的物流,不管是不是自提都算一下----------------- | ||
| 1211 | + var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; | ||
| 1212 | + if (def_exp_code && !th.data.is_default_logistics) { | ||
| 1213 | + for (var k = 0; k < th.data.wu_arr.length; k++) { | ||
| 1214 | + var item = th.data.wu_arr[k]; | ||
| 1215 | + if (def_exp_code == item.code) { | ||
| 1216 | + m_wind = k; | ||
| 1180 | } | 1217 | } |
| 1181 | } | 1218 | } |
| 1182 | - if (offline_price > 0) { | ||
| 1183 | - c_item.offline_price = offline_price; | ||
| 1184 | - c_item.offline_num = offline_num; | ||
| 1185 | - c_item.is_offline = 1; | ||
| 1186 | - } | ||
| 1187 | - | ||
| 1188 | - //获取购物车的佣金,此处要优化调用接口,获取佣金 | ||
| 1189 | - var req_d = { | ||
| 1190 | - user_id: getApp().globalData.user_id, goods_ids: commission_gds, store_id: os.stoid | ||
| 1191 | - } | ||
| 1192 | - var back_data = null; | ||
| 1193 | - await getApp().request.promisePost("/api/weshop/order/getrebateSum", { | ||
| 1194 | - is_json: 1, data: req_d | ||
| 1195 | - }).then(rs => { | ||
| 1196 | - | ||
| 1197 | - if (rs.data.code == 0) back_data = rs.data.data; | ||
| 1198 | - }); | 1219 | + } |
| 1220 | + | ||
| 1199 | 1221 | ||
| 1200 | if (back_data && parseFloat(back_data)) { | 1222 | if (back_data && parseFloat(back_data)) { |
| 1201 | c_item.can_usecommise = parseFloat(parseFloat(back_data).toFixed(2)); | 1223 | c_item.can_usecommise = parseFloat(parseFloat(back_data).toFixed(2)); |
| 1202 | cart_commission += c_item.can_usecommise; | 1224 | cart_commission += c_item.can_usecommise; |
| 1203 | } | 1225 | } |
| 1204 | 1226 | ||
| 1205 | - } | 1227 | + var ie = { |
| 1228 | + pickup_id: pcid, | ||
| 1229 | + pname: pikname, | ||
| 1230 | + goods: narr, | ||
| 1231 | + wind: m_wind, | ||
| 1232 | + distr_t: dis_t, | ||
| 1233 | + card_cut_price: 0, | ||
| 1234 | + exp_type: e_t, | ||
| 1235 | + goods_price: 0, | ||
| 1236 | + shipping_price: 0, | ||
| 1237 | + user_money: 0, | ||
| 1238 | + total_amount: 0, | ||
| 1239 | + order_amount: 0, | ||
| 1240 | + user_note: "", | ||
| 1241 | + sto: sto | ||
| 1242 | + }; | ||
| 1206 | 1243 | ||
| 1207 | - if (cart_commission) { | ||
| 1208 | - th.setData({ cart_commission }); | 1244 | + //-- 把等级卡会优惠多少钱装进去 -- |
| 1245 | + if (car_item.cut_price1) ie.card_cut_price += car_item.cut_price1; | ||
| 1246 | + if (car_item.collocationList) { | ||
| 1247 | + ie.collocationList = car_item.collocationList; | ||
| 1209 | } | 1248 | } |
| 1210 | 1249 | ||
| 1211 | - //每一个门店内的组合购要进行拆分, | ||
| 1212 | - //还得把组合商品的多余商品的线下价格算一算 | ||
| 1213 | - for (let var1 in arr) { | ||
| 1214 | - var u_item = arr[var1]; | ||
| 1215 | - //把组合购进行分组 | ||
| 1216 | - var obj = zh_calc.find_split(u_item); | ||
| 1217 | - if (!obj) continue; | ||
| 1218 | - //存储不同活动的商品列表 | ||
| 1219 | - u_item.zh_prom_goods = {}; | ||
| 1220 | - for (let var1 in obj) { | ||
| 1221 | - var h_item = obj[var1]; | ||
| 1222 | - var gdlist = th.data.zuhe_map_good[h_item.prom_id]; | ||
| 1223 | - //获取活动需要的商品列表 | ||
| 1224 | - u_item.zh_prom_goods[h_item.prom_id] = { gdlist: gdlist, act: h_item.act }; | 1250 | + |
| 1251 | + arr.push(ie); | ||
| 1252 | + } | ||
| 1253 | + } | ||
| 1254 | + //-- 如果是回退回来的情况 -- | ||
| 1255 | + if (th.data.cartlist && th.data.cartlist.length > 0) { | ||
| 1256 | + for (var kj in th.data.cartlist) { | ||
| 1257 | + for (var ih in arr) { | ||
| 1258 | + var ie = arr[ih]; | ||
| 1259 | + if (ie.pickup_id == th.data.cartlist[kj].pickup_id) { | ||
| 1260 | + ie.exp_type = parseInt(th.data.cartlist[kj].exp_type); | ||
| 1261 | + ie.wind = parseInt(th.data.cartlist[kj].wind); | ||
| 1262 | + | ||
| 1263 | + //-- 是不是全部自提清空 -- | ||
| 1264 | + if (ie.exp_type == 0 || ie.exp_type == 2) th.setData({ is_all_zt: 0 }); | ||
| 1265 | + break; | ||
| 1225 | } | 1266 | } |
| 1226 | - zh_calc.fir_set_arr(u_item, th); | ||
| 1227 | } | 1267 | } |
| 1268 | + } | ||
| 1269 | + } | ||
| 1228 | 1270 | ||
| 1229 | - //每一个门店内的阶梯促销要进行拆分, | ||
| 1230 | - //还得把阶梯促销商品的多余商品的线下价格算一算 | ||
| 1231 | - for (let var2 in arr) { | ||
| 1232 | - var u_item1 = arr[var2]; | ||
| 1233 | - | ||
| 1234 | - //把阶梯促销进行分组 | ||
| 1235 | - var obj = ladder_calc.find_split(u_item1); | ||
| 1236 | - if (!obj) continue; | ||
| 1237 | - //存储不同阶梯促销活动的商品列表 | ||
| 1238 | - u_item1.ladder_map = {}; | ||
| 1239 | - for (let var1 in obj) { | ||
| 1240 | - var h_item = obj[var1]; | ||
| 1241 | - var act = th.data.ladder_map[h_item.prom_id]; | ||
| 1242 | - //获取活动需要的商品列表 | ||
| 1243 | - u_item1.ladder_map[h_item.prom_id] = act; | 1271 | + var cart_commission = 0; |
| 1272 | + //-- 循环计算一下线下取价 -- | ||
| 1273 | + for (var k = 0; k < arr.length; k++) { | ||
| 1274 | + var c_item = arr[k]; | ||
| 1275 | + if(!is_change){ | ||
| 1276 | + //-- 要进行归类一下活动 -- | ||
| 1277 | + await m_cx.cart_cx_group(th,arr[k].goods,c_item,1,1,(show_can_cx)=>{ | ||
| 1278 | + arr[k].show_can_cx=show_can_cx; | ||
| 1279 | + }) | ||
| 1280 | + }else{ | ||
| 1281 | + var show_can_cx=this.data.cartlist[k].show_can_cx; | ||
| 1282 | + //-- 多促销活动的优化 -- | ||
| 1283 | + if(show_can_cx){ | ||
| 1284 | + arr[k].show_can_cx=show_can_cx; | ||
| 1244 | } | 1285 | } |
| 1245 | - ladder_calc.fir_set_arr(u_item1, th); | ||
| 1246 | - } | 1286 | + } |
| 1287 | + | ||
| 1288 | + var item = arr[k].goods; | ||
| 1289 | + var offline_price = 0; | ||
| 1290 | + var offline_num = 0; | ||
| 1291 | + //计算佣金的商品 | ||
| 1292 | + var commission_gds = []; | ||
| 1293 | + for (var c = 0; c < item.length; c++) { | ||
| 1247 | 1294 | ||
| 1248 | 1295 | ||
| 1249 | //-- 要判断总开关有没有同城配送 -- | 1296 | //-- 要判断总开关有没有同城配送 -- |
| @@ -1262,35 +1309,136 @@ Page({ | @@ -1262,35 +1309,136 @@ Page({ | ||
| 1262 | } | 1309 | } |
| 1263 | 1310 | ||
| 1264 | } | 1311 | } |
| 1312 | + | ||
| 1313 | + if (!item[c].is_gift) { | ||
| 1314 | + var hr = { | ||
| 1315 | + goods_id: item[c].goods_id, | ||
| 1316 | + goods_num: item[c].goods_num, | ||
| 1317 | + prom_type: item[c].prom_type, | ||
| 1318 | + prom_id: item[c].prom_id, | ||
| 1319 | + | ||
| 1320 | + } | ||
| 1321 | + let req_d1 = { | ||
| 1322 | + user_id: getApp().globalData.user_id, goods_ids: [hr], store_id: os.stoid | ||
| 1265 | } | 1323 | } |
| 1324 | + | ||
| 1325 | + await getApp().request.promisePost("/api/weshop/order/getrebateSum", { | ||
| 1326 | + is_json: 1, data: req_d1 | ||
| 1327 | + }).then(grs => { | ||
| 1328 | + if (grs.data.code == 0) item[c].use_commission = grs.data.data; | ||
| 1329 | + }); | ||
| 1330 | + commission_gds.push(hr); | ||
| 1331 | + } | ||
| 1332 | + if (th.data.sales_rules != 2) { | ||
| 1333 | + item[c].offline_price = 0; | ||
| 1334 | + } | ||
| 1335 | + //-- 如果这个商品是线下取价的时候 -- | ||
| 1336 | + if (item[c].offline_price > 0 && item[c].prom_type != 7) { | ||
| 1337 | + offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num; | ||
| 1338 | + offline_num += item[c].goods_num; | ||
| 1266 | } | 1339 | } |
| 1340 | + } | ||
| 1341 | + if (offline_price > 0) { | ||
| 1342 | + c_item.offline_price = offline_price; | ||
| 1343 | + c_item.offline_num = offline_num; | ||
| 1344 | + c_item.is_offline = 1; | ||
| 1345 | + } | ||
| 1346 | + | ||
| 1347 | + //获取购物车的佣金,此处要优化调用接口,获取佣金 | ||
| 1348 | + var req_d = { | ||
| 1349 | + user_id: getApp().globalData.user_id, goods_ids: commission_gds, store_id: os.stoid | ||
| 1350 | + } | ||
| 1351 | + var back_data = null; | ||
| 1352 | + await getApp().request.promisePost("/api/weshop/order/getrebateSum", { | ||
| 1353 | + is_json: 1, data: req_d | ||
| 1354 | + }).then(rs => { | ||
| 1355 | + if (rs.data.code == 0) back_data = rs.data.data; | ||
| 1356 | + }); | ||
| 1267 | 1357 | ||
| 1358 | + if (back_data && parseFloat(back_data)) { | ||
| 1359 | + c_item.can_usecommise = parseFloat(back_data); | ||
| 1360 | + cart_commission += c_item.can_usecommise; | ||
| 1361 | + } | ||
| 1268 | 1362 | ||
| 1363 | + } | ||
| 1269 | 1364 | ||
| 1270 | - //深拷贝 | ||
| 1271 | - th.data.old_cartlist = JSON.parse(JSON.stringify(arr)); | ||
| 1272 | - th.setData({ | ||
| 1273 | - cartlist: arr, | ||
| 1274 | - }); | 1365 | + if (cart_commission) { |
| 1366 | + th.setData({ cart_commission }); | ||
| 1367 | + } | ||
| 1275 | 1368 | ||
| 1276 | - //--- 获取一下看有没有优惠券 ---- | ||
| 1277 | - setTimeout(function () { | ||
| 1278 | - var frozenQuan = null; | ||
| 1279 | - var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; | ||
| 1280 | - app.request.promiseGet(url0, { 1: 1 }).then(res => { | ||
| 1281 | - if (res.data.code == 0) { | ||
| 1282 | - frozenQuan = res.data.data; | ||
| 1283 | - th.data.frozenQuan = frozenQuan; | ||
| 1284 | - } | ||
| 1285 | - th.calculatePrice(); | ||
| 1286 | - th.get_cart_quan(); | ||
| 1287 | - }) | ||
| 1288 | - }, 500) | 1369 | + //每一个门店内的组合购要进行拆分, |
| 1370 | + //还得把组合商品的多余商品的线下价格算一算 | ||
| 1371 | + for (let var1 in arr) { | ||
| 1372 | + var u_item = arr[var1]; | ||
| 1373 | + //把组合购进行分组 | ||
| 1374 | + var obj = zh_calc.find_split(u_item); | ||
| 1375 | + if (!obj) continue; | ||
| 1376 | + //存储不同活动的商品列表 | ||
| 1377 | + u_item.zh_prom_goods = {}; | ||
| 1378 | + for (let var1 in obj) { | ||
| 1379 | + var h_item = obj[var1]; | ||
| 1380 | + var gdlist = th.data.zuhe_map_good[h_item.prom_id]; | ||
| 1381 | + //获取活动需要的商品列表 | ||
| 1382 | + u_item.zh_prom_goods[h_item.prom_id] = { gdlist: gdlist, act: h_item.act }; | ||
| 1383 | + } | ||
| 1384 | + zh_calc.fir_set_arr(u_item, th); | ||
| 1385 | + } | ||
| 1386 | + | ||
| 1387 | + //每一个门店内的阶梯促销要进行拆分, | ||
| 1388 | + //还得把阶梯促销商品的多余商品的线下价格算一算 | ||
| 1389 | + for (let var2 in arr) { | ||
| 1390 | + var u_item1 = arr[var2]; | ||
| 1391 | + | ||
| 1392 | + //把阶梯促销进行分组 | ||
| 1393 | + var obj = ladder_calc.find_split(u_item1); | ||
| 1394 | + if (!obj) continue; | ||
| 1395 | + //存储不同阶梯促销活动的商品列表 | ||
| 1396 | + u_item1.ladder_map = {}; | ||
| 1397 | + for (let var1 in obj) { | ||
| 1398 | + var h_item = obj[var1]; | ||
| 1399 | + var act = th.data.ladder_map[h_item.prom_id]; | ||
| 1400 | + //获取活动需要的商品列表 | ||
| 1401 | + u_item1.ladder_map[h_item.prom_id] = act; | ||
| 1402 | + } | ||
| 1403 | + ladder_calc.fir_set_arr(u_item1, th); | ||
| 1404 | + } | ||
| 1405 | + | ||
| 1406 | + //-- 要判断总开关有没有同城配送 -- | ||
| 1407 | + if(th.data.is_same_city) { | ||
| 1408 | + //----- 判断每一个商品的配送方式,和门店的配送方式 ------- | ||
| 1409 | + for (var ik = 0; ik < arr.length; ik++) { | ||
| 1410 | + if (!arr[ik].sto.is_same_city) continue; | ||
| 1411 | + var fd = arr[ik].goods.filter(function (e) { | ||
| 1412 | + return e.is_same_city != 1 || e.whsle_id > 0 | ||
| 1413 | + }) | ||
| 1414 | + if (!fd || fd.length == 0) { | ||
| 1415 | + arr[ik].show_same_city = 1; | ||
| 1416 | + } | ||
| 1289 | } | 1417 | } |
| 1418 | + } | ||
| 1419 | + | ||
| 1420 | + //深拷贝 | ||
| 1421 | + th.data.old_cartlist = JSON.parse(JSON.stringify(arr)); | ||
| 1422 | + th.setData({ | ||
| 1423 | + cartlist: arr, | ||
| 1290 | }); | 1424 | }); |
| 1425 | + | ||
| 1426 | + //--- 获取一下看有没有优惠券 ---- | ||
| 1427 | + setTimeout(function () { | ||
| 1428 | + var frozenQuan = null; | ||
| 1429 | + var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; | ||
| 1430 | + app.request.promiseGet(url0, { 1: 1 }).then(res => { | ||
| 1431 | + if (res.data.code == 0) { | ||
| 1432 | + frozenQuan = res.data.data; | ||
| 1433 | + th.data.frozenQuan = frozenQuan; | ||
| 1434 | + } | ||
| 1435 | + th.calculatePrice(); | ||
| 1436 | + th.get_cart_quan(); | ||
| 1437 | + }) | ||
| 1438 | + }, 500) | ||
| 1291 | }, | 1439 | }, |
| 1292 | 1440 | ||
| 1293 | - //-----获取立即购买的商品信息,入口---- | 1441 | + //-----单个商品购买的入口判断---- |
| 1294 | get_buy_goods: function (e) { | 1442 | get_buy_goods: function (e) { |
| 1295 | var th = this; | 1443 | var th = this; |
| 1296 | var gg = to.get_b_now(); | 1444 | var gg = to.get_b_now(); |
| @@ -1401,8 +1549,6 @@ Page({ | @@ -1401,8 +1549,6 @@ Page({ | ||
| 1401 | th.setData({ card_cut_price: cut_p }); | 1549 | th.setData({ card_cut_price: cut_p }); |
| 1402 | } | 1550 | } |
| 1403 | } | 1551 | } |
| 1404 | - | ||
| 1405 | - | ||
| 1406 | 1552 | ||
| 1407 | //-- 当是搭配购的时候 -- | 1553 | //-- 当是搭配购的时候 -- |
| 1408 | gd.prom_type = gg.prom_type ? gg.prom_type : 0; | 1554 | gd.prom_type = gg.prom_type ? gg.prom_type : 0; |
| @@ -1803,6 +1949,51 @@ Page({ | @@ -1803,6 +1949,51 @@ Page({ | ||
| 1803 | } | 1949 | } |
| 1804 | }, | 1950 | }, |
| 1805 | 1951 | ||
| 1952 | + //-- 立即购买的时候,获取商品优惠活动,is_state判断是不是单个商品购买, | ||
| 1953 | + // 很多活动需要判断会员的plus等级, 权益登陆,user_id调用接口是必须的 -- | ||
| 1954 | + //先用着,后面会用接口来代替 | ||
| 1955 | + async buy_pro_group(item1, is_state) { | ||
| 1956 | + //-- 代发商品不参与任何活动 -- | ||
| 1957 | + if (item1.whsle_id) return false; | ||
| 1958 | + var th=this; | ||
| 1959 | + var req_d = { | ||
| 1960 | + store_id: os.stoid, | ||
| 1961 | + user_id: getApp().globalData.user_id, | ||
| 1962 | + goods_id: item1.goods_id, | ||
| 1963 | + goods_num: item1.goods_num, | ||
| 1964 | + goods_price: item1.goods_price, | ||
| 1965 | + } | ||
| 1966 | + //--- 调用接口获取活动 --- | ||
| 1967 | + await getApp().promiseGet('/api/weshop/goods/getGoodsPromInfo', {data:req_d}).then(res => { | ||
| 1968 | + if(res.data.code==0){ | ||
| 1969 | + var more_cx=res.data.data.more_cx; | ||
| 1970 | + for(var i=0;i<more_cx.length;i++){ | ||
| 1971 | + if(more_cx[i].prom_type==5){ | ||
| 1972 | + more_cx[i].main_gid= more_cx[i].collocation.main_goods_id; | ||
| 1973 | + var min=more_cx[i].collocation_main_price+more_cx[i].collocation_min_price; | ||
| 1974 | + var max=more_cx[i].collocation_main_price+more_cx[i].collocation_max_price; | ||
| 1975 | + more_cx[i].show_price="¥"+min+"-"+max; | ||
| 1976 | + } | ||
| 1977 | + } | ||
| 1978 | + item1.more_cx=more_cx; | ||
| 1979 | + | ||
| 1980 | + if(res.data.data.zh_pro){ | ||
| 1981 | + th.data.zhhe_act_map[res.data.data.zh_pro.id]=res.data.data.zh_pro; | ||
| 1982 | + } | ||
| 1983 | + if(res.data.data.ladder_pro){ | ||
| 1984 | + var ladder_pro=res.data.data.ladder_pro; | ||
| 1985 | + th.data.ladder_map[ladder_pro.id]=ladder_pro; | ||
| 1986 | + var fd=res.data.data.more_cx.find(function (e){ | ||
| 1987 | + return e.prom_type==10; | ||
| 1988 | + }) | ||
| 1989 | + if(fd){ | ||
| 1990 | + th.data.ladder_map[ladder_pro.id].ladder_list=fd.ladder_list; | ||
| 1991 | + } | ||
| 1992 | + } | ||
| 1993 | + } | ||
| 1994 | + }) | ||
| 1995 | + }, | ||
| 1996 | + | ||
| 1806 | //---------------检查是否有收货地址------------------- | 1997 | //---------------检查是否有收货地址------------------- |
| 1807 | checkAddressList: function () { | 1998 | checkAddressList: function () { |
| 1808 | var t = this; | 1999 | var t = this; |
| @@ -1866,8 +2057,10 @@ Page({ | @@ -1866,8 +2057,10 @@ Page({ | ||
| 1866 | var ob = th.data.prom_goods_map[pickid]; | 2057 | var ob = th.data.prom_goods_map[pickid]; |
| 1867 | for (var ii in ob) { | 2058 | for (var ii in ob) { |
| 1868 | var item_map = ob[ii]; | 2059 | var item_map = ob[ii]; |
| 1869 | - if (item_map.bs == undefined || item_map.bs == null) { | ||
| 1870 | - //等待,获取一下优惠活动的信息 | 2060 | + //if (item_map.bs == undefined || item_map.bs == null) { |
| 2061 | + if (!item_map.hasOwnProperty('cy_cx')) { | ||
| 2062 | + //等待,获取一下优惠活动的信息 | ||
| 2063 | + | ||
| 1871 | await getApp().request.promiseGet("/api/weshop/goods/getDiscount", { | 2064 | await getApp().request.promiseGet("/api/weshop/goods/getDiscount", { |
| 1872 | data: { | 2065 | data: { |
| 1873 | price: parseFloat(item_map.price).toFixed(2), prom_id: item_map.prom_id, | 2066 | price: parseFloat(item_map.price).toFixed(2), prom_id: item_map.prom_id, |
| @@ -1877,6 +2070,7 @@ Page({ | @@ -1877,6 +2070,7 @@ Page({ | ||
| 1877 | }).then(res => { | 2070 | }).then(res => { |
| 1878 | if (res.data.code == 0 && res.data.data.condition) { | 2071 | if (res.data.code == 0 && res.data.data.condition) { |
| 1879 | var get_data = res.data.data; | 2072 | var get_data = res.data.data; |
| 2073 | + item_map.cy_cx=1; | ||
| 1880 | item_map.is_bz = get_data.is_bz; //是不是倍增 | 2074 | item_map.is_bz = get_data.is_bz; //是不是倍增 |
| 1881 | item_map.bs = get_data.bs; //是不是倍数 | 2075 | item_map.bs = get_data.bs; //是不是倍数 |
| 1882 | item_map.is_past = get_data.is_past; //是不是包邮 | 2076 | item_map.is_past = get_data.is_past; //是不是包邮 |
| @@ -1946,6 +2140,7 @@ Page({ | @@ -1946,6 +2140,7 @@ Page({ | ||
| 1946 | } | 2140 | } |
| 1947 | } | 2141 | } |
| 1948 | } | 2142 | } |
| 2143 | + else item_map.cy_cx=0; | ||
| 1949 | }) | 2144 | }) |
| 1950 | } | 2145 | } |
| 1951 | 2146 | ||
| @@ -2001,6 +2196,7 @@ Page({ | @@ -2001,6 +2196,7 @@ Page({ | ||
| 2001 | if (!item_map.is_xz_yh) q_conditin = o_price; | 2196 | if (!item_map.is_xz_yh) q_conditin = o_price; |
| 2002 | } | 2197 | } |
| 2003 | 2198 | ||
| 2199 | + | ||
| 2004 | //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- | 2200 | //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- |
| 2005 | for (var j = 0; j < ord_goods.length; j++) { | 2201 | for (var j = 0; j < ord_goods.length; j++) { |
| 2006 | if (ord_goods[j].whsle_id) continue; | 2202 | if (ord_goods[j].whsle_id) continue; |
| @@ -2012,12 +2208,28 @@ Page({ | @@ -2012,12 +2208,28 @@ Page({ | ||
| 2012 | ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir; | 2208 | ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir; |
| 2013 | ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; | 2209 | ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; |
| 2014 | ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; | 2210 | ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; |
| 2211 | + | ||
| 2212 | + //-- 如果有参与促销才来进行计算 -- | ||
| 2213 | + if(item_map.cy_cx) { | ||
| 2214 | + //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- | ||
| 2215 | + for (var j = 0; j < ord_goods.length; j++) { | ||
| 2216 | + if (ord_goods[j].is_gift) continue; | ||
| 2217 | + if (ord_goods[j].whsle_id) continue; | ||
| 2218 | + if (ord_goods[j].prom_type == 3 && ord_goods[j].prom_id == item_map.prom_id) { | ||
| 2219 | + ord_goods[j].is_xz_yh = ord_goods[j].is_xz_yh ? ord_goods[j].is_xz_yh : item_map.is_xz_yh; | ||
| 2220 | + ord_goods[j].is_past = item_map.is_past; | ||
| 2221 | + ord_goods[j].is_order_yh = item_map.is_order_yh; | ||
| 2222 | + ord_goods[j].is_post_temp = item_map.is_post_temp; | ||
| 2223 | + | ||
| 2224 | + ord_goods[j].account_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_fir; | ||
| 2225 | + ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir; | ||
| 2226 | + ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; | ||
| 2227 | + ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; | ||
| 2228 | + } | ||
| 2015 | } | 2229 | } |
| 2016 | } | 2230 | } |
| 2017 | 2231 | ||
| 2018 | 2232 | ||
| 2019 | - | ||
| 2020 | - //-- -- | ||
| 2021 | if (item_map.price != undefined && item_map.price != null | 2233 | if (item_map.price != undefined && item_map.price != null |
| 2022 | && item_map.prom_price != undefined && item_map.prom_price != null) | 2234 | && item_map.prom_price != undefined && item_map.prom_price != null) |
| 2023 | cart_item.cut_price += (item_map.price - item_map.prom_price); | 2235 | cart_item.cut_price += (item_map.price - item_map.prom_price); |
| @@ -2261,7 +2473,7 @@ Page({ | @@ -2261,7 +2473,7 @@ Page({ | ||
| 2261 | var cart_item = c_arr[i]; //就是每一单的意思 | 2473 | var cart_item = c_arr[i]; //就是每一单的意思 |
| 2262 | var pickid = cart_item.pickup_id; | 2474 | var pickid = cart_item.pickup_id; |
| 2263 | var o_price = 0; | 2475 | var o_price = 0; |
| 2264 | - var o_price_no_zh = 0; //参与订单优惠叠加--组合购的金额汇总 | 2476 | + var o_price_no_zh = 0; //参与订单优惠累积的金额 |
| 2265 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; | 2477 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; |
| 2266 | var item = c_arr[i].goods; //就是每一单的从表的意思 | 2478 | var item = c_arr[i].goods; //就是每一单的从表的意思 |
| 2267 | 2479 | ||
| @@ -2351,12 +2563,12 @@ Page({ | @@ -2351,12 +2563,12 @@ Page({ | ||
| 2351 | var is_no_zh = 0; | 2563 | var is_no_zh = 0; |
| 2352 | if (item[jc].prom_type != 7 && item[jc].prom_type != 10) is_no_zh = 1; | 2564 | if (item[jc].prom_type != 7 && item[jc].prom_type != 10) is_no_zh = 1; |
| 2353 | 2565 | ||
| 2354 | - //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 | 2566 | + //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加,就要累积组合购的金额 |
| 2355 | if (item[jc].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[jc].prom_id] | 2567 | if (item[jc].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[jc].prom_id] |
| 2356 | && th.data.zhhe_act_map[item[jc].prom_id].is_orderyh) { | 2568 | && th.data.zhhe_act_map[item[jc].prom_id].is_orderyh) { |
| 2357 | is_no_zh = 1; | 2569 | is_no_zh = 1; |
| 2358 | } | 2570 | } |
| 2359 | - //阶梯购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 | 2571 | + //阶梯购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加,就要累积阶梯促销的金额 |
| 2360 | if (item[jc].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[jc].prom_id] | 2572 | if (item[jc].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[jc].prom_id] |
| 2361 | && th.data.ladder_map[item[jc].prom_id].is_useorderyh) { | 2573 | && th.data.ladder_map[item[jc].prom_id].is_useorderyh) { |
| 2362 | is_no_zh = 1; | 2574 | is_no_zh = 1; |
| @@ -2370,14 +2582,18 @@ Page({ | @@ -2370,14 +2582,18 @@ Page({ | ||
| 2370 | o_price += item[jc].goods_price * item[jc].goods_num; | 2582 | o_price += item[jc].goods_price * item[jc].goods_num; |
| 2371 | 2583 | ||
| 2372 | //--- 秒杀, 团购的时候,判断有没有订单优惠和包邮模板的叠加 --- | 2584 | //--- 秒杀, 团购的时候,判断有没有订单优惠和包邮模板的叠加 --- |
| 2373 | - if( [1,2,6].indexOf(item[jc].prom_type)>-1){ | 2585 | + if( [1,2,3,6].indexOf(item[jc].prom_type)>-1){ |
| 2586 | + | ||
| 2587 | + var gd_price=item[jc].goods_price; | ||
| 2588 | + if(item[jc].account_fir) gd_price=item[jc].account_fir; | ||
| 2589 | + | ||
| 2374 | if(!item[jc].is_order_yh && !item[jc].whsle_id){ | 2590 | if(!item[jc].is_order_yh && !item[jc].whsle_id){ |
| 2375 | - no_order_yh+=item[jc].goods_price * item[jc].goods_num; | 2591 | + no_order_yh+=gd_price * item[jc].goods_num; |
| 2376 | if(item[jc].quan_num) no_order_yh-=item[jc].quan_num; //券要把他补回去 | 2592 | if(item[jc].quan_num) no_order_yh-=item[jc].quan_num; //券要把他补回去 |
| 2377 | 2593 | ||
| 2378 | } | 2594 | } |
| 2379 | if(!item[jc].is_post_temp){ | 2595 | if(!item[jc].is_post_temp){ |
| 2380 | - no_post_temp+=item[jc].goods_price * item[jc].goods_num; | 2596 | + no_post_temp+=gd_price * item[jc].goods_num; |
| 2381 | if(item[jc].quan_num) no_post_temp-=item[jc].quan_num; //券要把他补回去 | 2597 | if(item[jc].quan_num) no_post_temp-=item[jc].quan_num; //券要把他补回去 |
| 2382 | } | 2598 | } |
| 2383 | } | 2599 | } |
| @@ -5611,7 +5827,7 @@ Page({ | @@ -5611,7 +5827,7 @@ Page({ | ||
| 5611 | for (var i in goodlist) { | 5827 | for (var i in goodlist) { |
| 5612 | var gd = goodlist[i]; | 5828 | var gd = goodlist[i]; |
| 5613 | //--如果是秒杀就跳出,如果是赠品,如果是组合购限制使用优惠券-- | 5829 | //--如果是秒杀就跳出,如果是赠品,如果是组合购限制使用优惠券-- |
| 5614 | - if (gd.whsle_id == 1 || gd.prom_type == 1 || gd.is_gift || (gd.prom_type == 7 && gd.act.is_xz_yh) || gd.is_xz_yh == 1) { | 5830 | + if (gd.whsle_id == 1 || gd.prom_type == 1 || gd.is_gift || (gd.prom_type == 7 && gd.act && gd.act.is_xz_yh) || gd.is_xz_yh == 1) { |
| 5615 | continue; | 5831 | continue; |
| 5616 | } | 5832 | } |
| 5617 | 5833 | ||
| @@ -5858,6 +6074,7 @@ Page({ | @@ -5858,6 +6074,7 @@ Page({ | ||
| 5858 | 6074 | ||
| 5859 | if (res.data.code == 0) { | 6075 | if (res.data.code == 0) { |
| 5860 | prom = res.data.data; | 6076 | prom = res.data.data; |
| 6077 | + | ||
| 5861 | if(prom && prom.limit_num*1){ | 6078 | if(prom && prom.limit_num*1){ |
| 5862 | let user_pre_buynum=await th.getUserBuyPromNum_pre(prom.id) | 6079 | let user_pre_buynum=await th.getUserBuyPromNum_pre(prom.id) |
| 5863 | if (user_pre_buynum>=prom.limit_num) { | 6080 | if (user_pre_buynum>=prom.limit_num) { |
| @@ -5946,6 +6163,11 @@ Page({ | @@ -5946,6 +6163,11 @@ Page({ | ||
| 5946 | if (res.data.code == 0) { | 6163 | if (res.data.code == 0) { |
| 5947 | 6164 | ||
| 5948 | var get_data = res.data.data; | 6165 | var get_data = res.data.data; |
| 6166 | + | ||
| 6167 | + //只有在活动已经开始参与优惠促销的时候 | ||
| 6168 | + th.data.bn_is_order_yh=prom.is_order_yh; | ||
| 6169 | + th.data.bn_is_post_temp=prom.is_post_temp; | ||
| 6170 | + | ||
| 5949 | arr.is_bz = prom.is_bz; //是不是倍增 | 6171 | arr.is_bz = prom.is_bz; //是不是倍增 |
| 5950 | arr.is_xz_yh = arr.is_xz_yh ? arr.is_xz_yh : prom.is_xz_yh; //是不是优惠 | 6172 | arr.is_xz_yh = arr.is_xz_yh ? arr.is_xz_yh : prom.is_xz_yh; //是不是优惠 |
| 5951 | arr.bs = get_data.bs; //是不是倍数 | 6173 | arr.bs = get_data.bs; //是不是倍数 |
| @@ -6127,6 +6349,9 @@ Page({ | @@ -6127,6 +6349,9 @@ Page({ | ||
| 6127 | ob.goods_num = item.goods_num; | 6349 | ob.goods_num = item.goods_num; |
| 6128 | ob.is_bz = prom.is_bz; | 6350 | ob.is_bz = prom.is_bz; |
| 6129 | ob.is_xz_yh = prom.is_xz_yh; | 6351 | ob.is_xz_yh = prom.is_xz_yh; |
| 6352 | + ob.is_xz_yh = prom.is_xz_yh; | ||
| 6353 | + ob.is_order_yh = prom.is_order_yh; | ||
| 6354 | + ob.is_post_temp = prom.is_post_temp; | ||
| 6130 | ob.goods = new Array(); | 6355 | ob.goods = new Array(); |
| 6131 | ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | 6356 | ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); |
| 6132 | map[pickid][item.prom_id] = ob; | 6357 | map[pickid][item.prom_id] = ob; |
| @@ -6172,6 +6397,8 @@ Page({ | @@ -6172,6 +6397,8 @@ Page({ | ||
| 6172 | ob.goods_num = item.goods_num; | 6397 | ob.goods_num = item.goods_num; |
| 6173 | ob.is_bz = prom.is_bz; | 6398 | ob.is_bz = prom.is_bz; |
| 6174 | ob.is_xz_yh = prom.is_xz_yh; | 6399 | ob.is_xz_yh = prom.is_xz_yh; |
| 6400 | + ob.is_order_yh = prom.is_order_yh; | ||
| 6401 | + ob.is_post_temp = prom.is_post_temp; | ||
| 6175 | ob.goods = new Array(); | 6402 | ob.goods = new Array(); |
| 6176 | ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | 6403 | ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); |
| 6177 | var obj = {}; | 6404 | var obj = {}; |
| @@ -7276,7 +7503,6 @@ Page({ | @@ -7276,7 +7503,6 @@ Page({ | ||
| 7276 | if (cart_commission) { | 7503 | if (cart_commission) { |
| 7277 | th.setData({ cart_commission }); | 7504 | th.setData({ cart_commission }); |
| 7278 | } | 7505 | } |
| 7279 | - | ||
| 7280 | th.data.old_cartlist = cart_arr; | 7506 | th.data.old_cartlist = cart_arr; |
| 7281 | }, | 7507 | }, |
| 7282 | 7508 | ||
| @@ -7289,6 +7515,208 @@ Page({ | @@ -7289,6 +7515,208 @@ Page({ | ||
| 7289 | } | 7515 | } |
| 7290 | } | 7516 | } |
| 7291 | return false; | 7517 | return false; |
| 7518 | + }, | ||
| 7519 | + | ||
| 7520 | + | ||
| 7521 | + //-- 开始显示活动的弹出 -- | ||
| 7522 | + switch_cx_group:function (e){ | ||
| 7523 | + var idx=e.currentTarget.dataset.index; | ||
| 7524 | + var gd_key=e.currentTarget.dataset.gd_key; | ||
| 7525 | + this.data.sele_cx_group_cidx=idx; | ||
| 7526 | + this.data.cx_group_gd_key=gd_key; | ||
| 7527 | + //-- 获取到-- | ||
| 7528 | + var cx_prom_group=this.data.cartlist[idx].show_can_cx[gd_key].act_arr; | ||
| 7529 | + | ||
| 7530 | + var cx_arr=[]; | ||
| 7531 | + | ||
| 7532 | + for (var h=0;h<cx_prom_group.length;h++){ | ||
| 7533 | + cx_prom_group[h].act.sele=0; | ||
| 7534 | + //-- 看有没有选中的活动 -- | ||
| 7535 | + if(cx_prom_group[h].sele){ | ||
| 7536 | + cx_prom_group[h].act.sele=1; | ||
| 7537 | + } | ||
| 7538 | + cx_arr.push(cx_prom_group[h].act); | ||
| 7539 | + } | ||
| 7540 | + //-- 如果没有,就默认第一个为选中 -- | ||
| 7541 | + //-- if(!find_sele) cx_arr[0].sele=1; -- | ||
| 7542 | + var cp_arr=JSON.parse(JSON.stringify(cx_arr)); | ||
| 7543 | + var pro_pop = this.selectComponent("#pro_pop"); //组件的id | ||
| 7544 | + pro_pop.set_init(1,cp_arr); | ||
| 7545 | + }, | ||
| 7546 | + | ||
| 7547 | + //--- 选择回来时候的选择 --- | ||
| 7548 | + sure_cx_group:function(e){ | ||
| 7549 | + var th=this; | ||
| 7550 | + var sele_idx=e.detail.sele_idx; | ||
| 7551 | + var idx=this.data.sele_cx_group_cidx; | ||
| 7552 | + var gd_key= this.data.cx_group_gd_key; | ||
| 7553 | + //-- 获取到-- | ||
| 7554 | + var cx_prom_group=this.data.cartlist[idx].show_can_cx[gd_key].act_arr; | ||
| 7555 | + var pk=this.data.cartlist[idx].pickup_id; | ||
| 7556 | + | ||
| 7557 | + var fir_sele=0; | ||
| 7558 | + for(var dx=0;dx<cx_prom_group.length;dx++){ | ||
| 7559 | + if(cx_prom_group[dx].sele) fir_sele=dx; | ||
| 7560 | + if(dx!=sele_idx) cx_prom_group[dx].sele=0; | ||
| 7561 | + else cx_prom_group[dx].sele=1; | ||
| 7562 | + } | ||
| 7563 | + //选择后就要把活动确定下来 | ||
| 7564 | + //确定一下活动,先看一下有没有选择的活动 | ||
| 7565 | + var ck_prom_type=cx_prom_group.find(function (el){ | ||
| 7566 | + return el.sele; | ||
| 7567 | + }) | ||
| 7568 | + | ||
| 7569 | + | ||
| 7570 | + this.cx_check_ok2(function (ck_res){ | ||
| 7571 | + | ||
| 7572 | + if(ck_res.code==0){ | ||
| 7573 | + th.data.cartlist[idx].show_can_cx[gd_key].sele_prom_type=ck_prom_type.prom_type; | ||
| 7574 | + var goods= th.data.cartlist_y | ||
| 7575 | + //-- 此时要把购物车中的商品确定活动 -- | ||
| 7576 | + for (var b=0; b<ck_prom_type.goods.length;b++){ | ||
| 7577 | + //-- 开始查找 -- | ||
| 7578 | + var fg=goods.findIndex(function (g_item){ | ||
| 7579 | + return g_item.goods_id==ck_prom_type.goods[b].goods_id | ||
| 7580 | + && [0,3,5,7,10].indexOf(g_item.prom_type)>-1 | ||
| 7581 | + && g_item.pick_id==pk | ||
| 7582 | + }) | ||
| 7583 | + if(fg>-1){ | ||
| 7584 | + goods[fg].prom_type=ck_prom_type.prom_type; | ||
| 7585 | + goods[fg].prom_id=ck_prom_type.prom_id; | ||
| 7586 | + th.data.cartlist_y[idx].goods[fg].prom_type= goods[fg].prom_type; | ||
| 7587 | + th.data.cartlist_y[idx].goods[fg].prom_id= goods[fg].prom_id; | ||
| 7588 | + | ||
| 7589 | + } | ||
| 7590 | + } | ||
| 7591 | + | ||
| 7592 | + wx.showLoading({ | ||
| 7593 | + title: "处理中.", | ||
| 7594 | + mask: true | ||
| 7595 | + }) | ||
| 7596 | + //-- 重新计算一下价格 -- | ||
| 7597 | + th.get_cart_next(null,1); | ||
| 7598 | + }else{ | ||
| 7599 | + wx.showToast({ | ||
| 7600 | + title: ck_res.msg, | ||
| 7601 | + icon: 'none', | ||
| 7602 | + duration:2500 | ||
| 7603 | + }); | ||
| 7604 | + | ||
| 7605 | + for(var dx=0;dx<cx_prom_group.length;dx++){ | ||
| 7606 | + if(dx!=fir_sele) cx_prom_group[dx].sele=0; | ||
| 7607 | + else cx_prom_group[dx].sele=1; | ||
| 7608 | + } | ||
| 7609 | + } | ||
| 7610 | + }) | ||
| 7611 | + | ||
| 7612 | + }, | ||
| 7613 | + | ||
| 7614 | + | ||
| 7615 | + //--- 在点击商品和或者门店的时候调用,这个可以在活动切换的时候调用,也可以被单个选择调用--- | ||
| 7616 | + async cx_check_ok2(func,car) { | ||
| 7617 | + //如果购物车没有带入,要进行赋值 | ||
| 7618 | + if(!car) { | ||
| 7619 | + car = JSON.parse(JSON.stringify(this.data.cartlist)); | ||
| 7620 | + } | ||
| 7621 | + | ||
| 7622 | + var nei_in_zhact_gdmap = {}; | ||
| 7623 | + var nei_in_zhact = {}; | ||
| 7624 | + var nei_in_yhact = {}; | ||
| 7625 | + for (var i = 0; i < car.length; i++) { | ||
| 7626 | + var show_can_cx = car[i].show_can_cx; | ||
| 7627 | + for (var j in show_can_cx) { | ||
| 7628 | + var sele_act = show_can_cx[j].act_arr.find(function (m) { | ||
| 7629 | + return m.sele == 1; | ||
| 7630 | + }) | ||
| 7631 | + | ||
| 7632 | + if (!sele_act) continue; | ||
| 7633 | + var pid = sele_act['prom_id']; | ||
| 7634 | + if (sele_act['prom_type'] == 3) { | ||
| 7635 | + if(!nei_in_yhact[pid]) nei_in_yhact[pid] = 0; | ||
| 7636 | + nei_in_yhact[pid]++; | ||
| 7637 | + } | ||
| 7638 | + if (sele_act['prom_type'] == 7) { | ||
| 7639 | + if(!nei_in_zhact[pid]) nei_in_zhact[pid] = 0; | ||
| 7640 | + nei_in_zhact[pid] += sele_act['act_num']; | ||
| 7641 | + } | ||
| 7642 | + var in_zhact_gdmap1 = sele_act['in_zhact_gdmap']; | ||
| 7643 | + for (var vg in in_zhact_gdmap1) { | ||
| 7644 | + if (!nei_in_zhact_gdmap[vg]) nei_in_zhact_gdmap[vg] = 0; | ||
| 7645 | + nei_in_zhact_gdmap[vg] += in_zhact_gdmap1[vg]; | ||
| 7646 | + } | ||
| 7647 | + } | ||
| 7648 | + } | ||
| 7649 | + | ||
| 7650 | + //-- 判断优惠促销是不是超出限购 -- | ||
| 7651 | + if (nei_in_yhact && Object.keys(nei_in_yhact).length) { | ||
| 7652 | + for (var ky0 in nei_in_yhact) { | ||
| 7653 | + var num = nei_in_yhact[ky0]; | ||
| 7654 | + | ||
| 7655 | + var fd=null; | ||
| 7656 | + var fd_res = await getApp().request.promiseGet('/api/weshop/promgoods/get/'+os.stoid+'/'+ky0,{}) | ||
| 7657 | + if(fd_res && fd_res.data.code==0 ){ | ||
| 7658 | + fd=fd_res.data.data; | ||
| 7659 | + } | ||
| 7660 | + if (fd && fd['limit_num'] > 0 && num > fd['limit_num']) { | ||
| 7661 | + func({'code': -1, 'msg': '超出优惠促销活动的限购'}); | ||
| 7662 | + return false; | ||
| 7663 | + } | ||
| 7664 | + } | ||
| 7665 | + } | ||
| 7666 | + | ||
| 7667 | + //-- 判断组合促销是不是超出活动总数量 -- | ||
| 7668 | + if (nei_in_zhact && Object.keys(nei_in_zhact).length) { | ||
| 7669 | + for (var ky in nei_in_zhact) { | ||
| 7670 | + | ||
| 7671 | + var num0 = nei_in_zhact[ky]; | ||
| 7672 | + var zh = this.data.zhhe_act_map[ky]; | ||
| 7673 | + var buyed=0; | ||
| 7674 | + | ||
| 7675 | + //获取已经购买了多少件 | ||
| 7676 | + var z_url = "/api/weshop/ordergoods/getUserBuyPromNum?store_id="+os.stoid+"user_id="+getApp().globalData.user_id+"prom_type=7&prom_id="+ky; | ||
| 7677 | + var zbuy=await getApp().request.promiseGet(z_url,{}); | ||
| 7678 | + if(zbuy && zbuy.data.code==0){ | ||
| 7679 | + buyed=zbuy.data.data.userbuynum; | ||
| 7680 | + } | ||
| 7681 | + if (zh['zh_num'] > 0 && zh['zh_buy_num'] + num0 > zh['zh_num']) { | ||
| 7682 | + func({'code': -1, 'msg': '超出组合购活动总数量'}); | ||
| 7683 | + return false; | ||
| 7684 | + } | ||
| 7685 | + } | ||
| 7686 | + } | ||
| 7687 | + | ||
| 7688 | + //-- 判断组合促销是不是超出活动总数量 -- | ||
| 7689 | + if (nei_in_zhact_gdmap && Object.keys(nei_in_zhact_gdmap).length) { | ||
| 7690 | + for (var key in nei_in_zhact_gdmap) { | ||
| 7691 | + | ||
| 7692 | + var num1 = nei_in_zhact_gdmap[key]; | ||
| 7693 | + var key_a = key.split('.'); | ||
| 7694 | + var gid = key_a[0]; | ||
| 7695 | + var pid = key_a[1]; | ||
| 7696 | + | ||
| 7697 | + //-- 商品的限购 -- | ||
| 7698 | + var promgoodsbuynum = 0; | ||
| 7699 | + var rq = { | ||
| 7700 | + 'store_id': os.stoid, 'user_id': getApp().globalData.user_id, 'goods_id': gid, | ||
| 7701 | + 'prom_type': 7, 'prom_id': pid | ||
| 7702 | + }; | ||
| 7703 | + | ||
| 7704 | + var res = await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {data: rq}); | ||
| 7705 | + if (res && res.data.code == 0) { | ||
| 7706 | + promgoodsbuynum = res.data.data.promgoodsbuynum; | ||
| 7707 | + } | ||
| 7708 | + | ||
| 7709 | + var gdlist_arr = this.data.zuhe_map_good[pid]; | ||
| 7710 | + var gdlist = gdlist_arr.find(function (e) { | ||
| 7711 | + return e.goods_id == gid; | ||
| 7712 | + }) | ||
| 7713 | + if (gdlist['buyqty'] > 0 && num1 + promgoodsbuynum > gdlist['buyqty']) { | ||
| 7714 | + func({'code': -1, 'msg': '超出组合购商品的限购'}); | ||
| 7715 | + return false; | ||
| 7716 | + } | ||
| 7717 | + } | ||
| 7718 | + } | ||
| 7719 | + func({'code': 0, 'msg': '成功'}) | ||
| 7292 | } | 7720 | } |
| 7293 | 7721 | ||
| 7294 | 7722 |
packageE/pages/cart/cart2/cart2.json
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | "enablePullDownRefresh": false, | 3 | "enablePullDownRefresh": false, |
| 4 | "usingComponents": { | 4 | "usingComponents": { |
| 5 | "warn": "/components/long_warn/long_warn", | 5 | "warn": "/components/long_warn/long_warn", |
| 6 | - "cart_collect_temp": "/components/cart_collect_temp/cart_collect_temp" | 6 | + "cart_collect_temp": "/components/cart_collect_temp/cart_collect_temp", |
| 7 | + "pro_pop": "/components/promate_pop/promate_pop" | ||
| 7 | } | 8 | } |
| 8 | } | 9 | } |
| 9 | \ No newline at end of file | 10 | \ No newline at end of file |
packageE/pages/cart/cart2/cart2.wxml
| 1 | +<!-- 促销弹出框 --> | ||
| 2 | +<pro_pop id="pro_pop" bind:sure_cx_group="sure_cx_group"></pro_pop> | ||
| 3 | + | ||
| 1 | <wxs module="filter" src="c_filter.wxs"></wxs> | 4 | <wxs module="filter" src="c_filter.wxs"></wxs> |
| 2 | <wxs src="filter.wxs" module="util"></wxs> | 5 | <wxs src="filter.wxs" module="util"></wxs> |
| 3 | <wxs module="filters" src="../../../../utils/filter.wxs"></wxs> | 6 | <wxs module="filters" src="../../../../utils/filter.wxs"></wxs> |
| @@ -82,32 +85,89 @@ | @@ -82,32 +85,89 @@ | ||
| 82 | <!-- <view>门店:{{item.pname}}</view> --> | 85 | <!-- <view>门店:{{item.pname}}</view> --> |
| 83 | <view>{{item.pname}}</view> | 86 | <view>{{item.pname}}</view> |
| 84 | </view> | 87 | </view> |
| 85 | - <view class="order-detail" wx:for="{{item.goods}}" wx:for-index="idx" wx:for-item="items"> | ||
| 86 | - <!----商品图片-----> | ||
| 87 | - <view class="goods-img" style="position: relative; overflow: hidden" bindtap="go_url" data-url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}&prom_type={{items.prom_type}}&prom_id={{items.prom_id}}"> | ||
| 88 | - <image wx:if="{{items.is_gift}}" src="{{imgUrl}}/miniapp/images/giveaway.png" class="gift_image"></image> | ||
| 89 | - <text class="zuhe" wx:if="{{items.prom_type==7}}">组合购</text> | ||
| 90 | - <image class="wh100 bdr14" src="{{items.original_img}}" binderror='cart_set_err' data-err='cartlist[{{pidx}}].goods[{{idx}}].original_img'></image> | ||
| 91 | - </view> | ||
| 92 | - <!----商品名称规格----> | ||
| 93 | - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}&prom_type={{items.prom_type}}&prom_id={{items.prom_id}}"> | ||
| 94 | - <view class="goods-name ellipsis-2">{{items.goods_name}}</view> | ||
| 95 | - <!-- 商品属性 --> | ||
| 96 | - <view class="flex-vertical fs28 color-gray n_guige"> | ||
| 97 | - <view class="goods-color"> | ||
| 98 | - <block><text>{{filters.show_gui_ge(items.goods_spec,items.goods_color)}}</text></block> | 88 | + |
| 89 | + <!-- for循环使用 --> | ||
| 90 | + <block wx:for="{{item.goods}}" wx:for-index="idx" wx:for-item="items"> | ||
| 91 | + <view class="order-detail" > | ||
| 92 | + <!----商品图片-----> | ||
| 93 | + <view class="goods-img" style="position: relative; overflow: hidden" bindtap="go_url" data-url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}&prom_type={{items.prom_type}}&prom_id={{items.prom_id}}"> | ||
| 94 | + <image wx:if="{{items.is_gift}}" src="{{imgUrl}}/miniapp/images/giveaway.png" class="gift_image"></image> | ||
| 95 | + <text class="zuhe" wx:if="{{items.prom_type==7}}">组合购</text> | ||
| 96 | + <image class="wh100 bdr14" src="{{items.original_img}}" binderror='cart_set_err' data-err='cartlist[{{pidx}}].goods[{{idx}}].original_img'></image> | ||
| 99 | </view> | 97 | </view> |
| 98 | + <!----商品名称规格----> | ||
| 99 | + <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}&prom_type={{items.prom_type}}&prom_id={{items.prom_id}}"> | ||
| 100 | + <view class="goods-name ellipsis-2">{{items.goods_name}}</view> | ||
| 101 | + <!-- 商品属性 --> | ||
| 102 | + <view class="flex-vertical fs28 color-gray n_guige"> | ||
| 103 | + <view class="goods-color"> | ||
| 104 | + <block><text>{{filters.show_gui_ge(items.goods_spec,items.goods_color)}}</text></block> | ||
| 105 | + </view> | ||
| 106 | + </view> | ||
| 107 | + | ||
| 108 | + <!-----商品名称规格------> | ||
| 109 | + <view class="order-num flex-space-between"> | ||
| 110 | + <view wx:if="{{items.prom_type==10}}" class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text><text>({{items.discount}}折)</text></view> | ||
| 111 | + <view wx:else class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view> | ||
| 112 | + <view style="color: red;" wx:if="{{items.use_commission && items.use_commission*1>0}}">佣金:{{filters.toFix(items.use_commission/items.goods_num,2)}}*{{items.goods_num}}</view> | ||
| 113 | + <view class="goods-num">x{{items.goods_num}}</view> | ||
| 114 | + </view> | ||
| 115 | + </navigator> | ||
| 100 | </view> | 116 | </view> |
| 117 | + <!-- 验证活动是不是多个,要不要显示切换 --> | ||
| 118 | + <!-- 新增促销多活动的排版 --> | ||
| 119 | + | ||
| 120 | + <block wx:if="{{(util.is_more_act(items,item.show_can_cx) && item.show_can_cx[items.goods_id] && item.show_can_cx[items.goods_id].act_arr.length>1)}}"> | ||
| 121 | + <view class="bdb16" wx:if="{{util.check_show(items,item.show_can_cx[items.goods_id].sele_prom_type)}}"> | ||
| 122 | + <view bindtap="switch_cx_group" | ||
| 123 | + data-index="{{pidx}}" | ||
| 124 | + data-gd_key="{{items.goods_id}}" | ||
| 125 | + class="cx-frame flex" style="position: relative"> | ||
| 126 | + <view class="cx-sizs fs30">促销</view> | ||
| 127 | + <view class="flex ai_c f1 pdh20"> | ||
| 128 | + <view class="xc-coupon-fram" wx:for="{{item.show_can_cx[items.goods_id].act_arr}}" > | ||
| 129 | + <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word">优惠促销</view> | ||
| 130 | + <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word">搭配促销</view> | ||
| 131 | + <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word">组合购</view> | ||
| 132 | + <view wx:if="{{item.prom_type==10}}" class="xc-coupon t-c four-level-word">阶梯促销</view> | ||
| 133 | + </view> | ||
| 134 | + </view> | ||
| 135 | + <view class="cx-obtain-coupon wsize"> | ||
| 136 | + <text class="bg_jj"></text> | ||
| 137 | + </view> | ||
| 138 | + </view> | ||
| 139 | + </view> | ||
| 140 | + </block> | ||
| 101 | 141 | ||
| 102 | - <!-----商品名称规格------> | ||
| 103 | - <view class="order-num flex-space-between"> | ||
| 104 | - <view wx:if="{{items.prom_type==10}}" class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text><text>({{items.discount}}折)</text></view> | ||
| 105 | - <view wx:else class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view> | ||
| 106 | - <view style="color: red;" wx:if="{{items.use_commission && items.use_commission*1>0}}">佣金:{{filters.toFix(items.use_commission/items.goods_num,2)}}*{{items.goods_num}}</view> | ||
| 107 | - <view class="goods-num">x{{items.goods_num}}</view> | 142 | + |
| 143 | + </block> | ||
| 144 | + | ||
| 145 | + <!--此时是多个商品参与活动的切换 验证活动是不是多个,要不要显示切换 --> | ||
| 146 | + <!-- 新增促销多活动的排版 --> | ||
| 147 | + <block wx:if="{{item.show_can_cx}}"> | ||
| 148 | + <block wx:for="{{item.show_can_cx}}" wx:for-item="pitem"> | ||
| 149 | + <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1}}" > | ||
| 150 | + <view bindtap="switch_cx_group" | ||
| 151 | + data-index="{{pidx}}" | ||
| 152 | + data-gd_key="{{index}}" | ||
| 153 | + class="cx-frame flex" style="position: relative"> | ||
| 154 | + <view class="cx-sizs fs30">促销</view> | ||
| 155 | + <view class="flex ai_c f1 pdh20"> | ||
| 156 | + <view class="xc-coupon-fram" wx:for="{{pitem.act_arr}}" > | ||
| 157 | + <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word">优惠促销</view> | ||
| 158 | + <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word">搭配促销</view> | ||
| 159 | + <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word">组合购</view> | ||
| 160 | + <view wx:if="{{item.prom_type==10}}" class="xc-coupon t-c four-level-word">阶梯促销</view> | ||
| 161 | + </view> | ||
| 162 | + </view> | ||
| 163 | + <view class="cx-obtain-coupon wsize"> | ||
| 164 | + <text class="bg_jj"></text> | ||
| 165 | + </view> | ||
| 166 | + </view> | ||
| 108 | </view> | 167 | </view> |
| 109 | - </navigator> | ||
| 110 | - </view> | 168 | + </block> |
| 169 | + </block> | ||
| 170 | + | ||
| 111 | 171 | ||
| 112 | <!-- 使用搭配 --> | 172 | <!-- 使用搭配 --> |
| 113 | <cart_collect_temp id="col{{pidx}}" | 173 | <cart_collect_temp id="col{{pidx}}" |
| @@ -121,7 +181,7 @@ | @@ -121,7 +181,7 @@ | ||
| 121 | <view class="flex"> | 181 | <view class="flex"> |
| 122 | <view class="card_bg ellipsis-1" style="margin-right: 10rpx;"> | 182 | <view class="card_bg ellipsis-1" style="margin-right: 10rpx;"> |
| 123 | <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"> | 183 | <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"> |
| 124 | - </ image> | 184 | + </image> |
| 125 | <text class="card_name">{{show_card.CardName}}</text> | 185 | <text class="card_name">{{show_card.CardName}}</text> |
| 126 | </view> | 186 | </view> |
| 127 | <view>立减 <text style="color:#f23030;">{{filters.toFix(item.card_cut_price,2) }}</text> 元</view> | 187 | <view>立减 <text style="color:#f23030;">{{filters.toFix(item.card_cut_price,2) }}</text> 元</view> |
packageE/pages/cart/cart2/cart2.wxss
| @@ -540,9 +540,9 @@ transform: rotate(-135deg); | @@ -540,9 +540,9 @@ transform: rotate(-135deg); | ||
| 540 | line-height: 35rpx; | 540 | line-height: 35rpx; |
| 541 | text-align: center; | 541 | text-align: center; |
| 542 | margin-right: 20rpx | 542 | margin-right: 20rpx |
| 543 | +} | ||
| 543 | 544 | ||
| 544 | 545 | ||
| 545 | -} | ||
| 546 | .xc-hooks { | 546 | .xc-hooks { |
| 547 | width: 30rpx; | 547 | width: 30rpx; |
| 548 | height: 30rpx; | 548 | height: 30rpx; |
| @@ -1143,3 +1143,81 @@ margin-left: 20rpx; | @@ -1143,3 +1143,81 @@ margin-left: 20rpx; | ||
| 1143 | font-size: 28rpx; | 1143 | font-size: 28rpx; |
| 1144 | } | 1144 | } |
| 1145 | 1145 | ||
| 1146 | + | ||
| 1147 | +.cx-frame { | ||
| 1148 | + /* border-top:3rpx solid #eee; */ | ||
| 1149 | + /* width:99%; | ||
| 1150 | + height: 95rpx; | ||
| 1151 | + line-height: 95rpx; | ||
| 1152 | + padding-left:24rpx; */ | ||
| 1153 | + padding: 20rpx; | ||
| 1154 | + background-color: #fff; | ||
| 1155 | +} | ||
| 1156 | + | ||
| 1157 | +.cx-frame .cx-sizs { | ||
| 1158 | + /* width: 68rpx; */ | ||
| 1159 | + /* height: 100%; */ | ||
| 1160 | + /* line-height: 100rpx; */ | ||
| 1161 | + /* overflow: hidden; */ | ||
| 1162 | + /* margin-left: 10rpx; */ | ||
| 1163 | +} | ||
| 1164 | + | ||
| 1165 | +.xc-coupon-fram { | ||
| 1166 | + position: relative; | ||
| 1167 | + margin-right: 11rpx; | ||
| 1168 | + /* width:200rpx; */ | ||
| 1169 | + /* padding-top:30rpx; */ | ||
| 1170 | + | ||
| 1171 | +} | ||
| 1172 | + | ||
| 1173 | +.xc-coupon-fram .xc-coupon { | ||
| 1174 | + /* width:175rpx ; | ||
| 1175 | + height: 40rpx; | ||
| 1176 | + line-height: 40rpx; */ | ||
| 1177 | + background-color: #d60021; | ||
| 1178 | + /* margin:0 auto; */ | ||
| 1179 | + color: #fff; | ||
| 1180 | + padding: 6rpx 16rpx; | ||
| 1181 | + | ||
| 1182 | +} | ||
| 1183 | + | ||
| 1184 | +.xc-coupon-fram .xc-circular { | ||
| 1185 | + width: 16rpx; | ||
| 1186 | + height: 16rpx; | ||
| 1187 | + background-color: white; | ||
| 1188 | + position: absolute; | ||
| 1189 | + top: 50%; | ||
| 1190 | + /* left: -10rpx; */ | ||
| 1191 | + transform: translateY(-50%); | ||
| 1192 | +} | ||
| 1193 | + | ||
| 1194 | +.cx-obtain-coupon { | ||
| 1195 | + /* width: 65rpx; | ||
| 1196 | + height: 100%; | ||
| 1197 | + padding-left:15rpx; */ | ||
| 1198 | + color: #d70025; | ||
| 1199 | + display: flex; | ||
| 1200 | + align-items: center; | ||
| 1201 | + /* position: absolute; | ||
| 1202 | + right: 5rpx; */ | ||
| 1203 | +} | ||
| 1204 | + | ||
| 1205 | +.bg_jj { | ||
| 1206 | + width: 14rpx; | ||
| 1207 | + height: 14rpx; | ||
| 1208 | + border-top: 2rpx solid #d70026; | ||
| 1209 | + border-right: 2rpx solid #d70026; | ||
| 1210 | + transform: rotateZ(45deg); | ||
| 1211 | + display: inline-block; | ||
| 1212 | + margin-bottom: 3rpx; | ||
| 1213 | +} | ||
| 1214 | + | ||
| 1215 | +.bg_jj.down { | ||
| 1216 | + transform: rotateZ(135deg); | ||
| 1217 | +} | ||
| 1218 | + | ||
| 1219 | +.bg_jj.up { | ||
| 1220 | + transform: rotateZ(-45deg); | ||
| 1221 | + margin-top: 6rpx; | ||
| 1222 | +} | ||
| 1223 | + |
packageE/pages/cart/cart2/filter.wxs
| @@ -6,6 +6,23 @@ var format = function (text) { | @@ -6,6 +6,23 @@ var format = function (text) { | ||
| 6 | return text.replace(reg, '\n') | 6 | return text.replace(reg, '\n') |
| 7 | } | 7 | } |
| 8 | 8 | ||
| 9 | + | ||
| 10 | +//判断商品是不是有活动切换 | ||
| 11 | +function is_more_act(items,show_can_cx){ | ||
| 12 | + if([1,2,4,6,8,9].indexOf(items.prom_type)>-1) return false; | ||
| 13 | + if(!show_can_cx) return false; | ||
| 14 | + return true; | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +function check_show(items,sele_prom_type){ | ||
| 18 | + if([7,10].indexOf(sele_prom_type)>-1){ | ||
| 19 | + if(!items.is_act_last) return false; | ||
| 20 | + } | ||
| 21 | + return true; | ||
| 22 | +} | ||
| 23 | + | ||
| 9 | module.exports = { | 24 | module.exports = { |
| 10 | - format: format | 25 | + format: format, |
| 26 | + is_more_act:is_more_act, | ||
| 27 | + check_show:check_show | ||
| 11 | } | 28 | } |
packageE/pages/cart/cart2/ladder_calculate.js
| @@ -129,8 +129,12 @@ module.exports = { | @@ -129,8 +129,12 @@ module.exports = { | ||
| 129 | goods.splice(idx, 1); | 129 | goods.splice(idx, 1); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | + | ||
| 133 | + | ||
| 132 | //-- 只统计是参与活动的商品 -- | 134 | //-- 只统计是参与活动的商品 -- |
| 133 | for (var ij in goods) { | 135 | for (var ij in goods) { |
| 136 | + goods[ij].is_act_last=0; | ||
| 137 | + | ||
| 134 | var iter = goods[ij]; | 138 | var iter = goods[ij]; |
| 135 | if (iter.prom_type != 10 || iter.prom_id != act_item.id) { | 139 | if (iter.prom_type != 10 || iter.prom_id != act_item.id) { |
| 136 | continue; | 140 | continue; |
| @@ -138,6 +142,8 @@ module.exports = { | @@ -138,6 +142,8 @@ module.exports = { | ||
| 138 | all_price0 += iter.goods_num * iter.goods_price; | 142 | all_price0 += iter.goods_num * iter.goods_price; |
| 139 | } | 143 | } |
| 140 | 144 | ||
| 145 | + goods[goods.length-1].is_act_last=1; | ||
| 146 | + | ||
| 141 | if(!c_item.ladder_prom_goods) c_item.ladder_prom_goods={}; | 147 | if(!c_item.ladder_prom_goods) c_item.ladder_prom_goods={}; |
| 142 | if(!c_item.ladder_prom_goods[act_item.id]) c_item.ladder_prom_goods[act_item.id]={}; | 148 | if(!c_item.ladder_prom_goods[act_item.id]) c_item.ladder_prom_goods[act_item.id]={}; |
| 143 | 149 |
packageE/pages/cart/cart2/zh_calculate.js
| @@ -58,13 +58,12 @@ module.exports = { | @@ -58,13 +58,12 @@ module.exports = { | ||
| 58 | var zh_b_num = item_j.promgoodsbuynum; | 58 | var zh_b_num = item_j.promgoodsbuynum; |
| 59 | if (item.buyqty > 0) { | 59 | if (item.buyqty > 0) { |
| 60 | 60 | ||
| 61 | - var key = item.goods_id + "" + act.id; | 61 | + var key = item.goods_id + "." + act.id; |
| 62 | var cbuy = item.buyqty - zh_b_num; | 62 | var cbuy = item.buyqty - zh_b_num; |
| 63 | if (th.data.in_zhact_gdmap[key]) { | 63 | if (th.data.in_zhact_gdmap[key]) { |
| 64 | var cbuy = item.buyqty - zh_b_num - th.data.in_zhact_gdmap[key]; | 64 | var cbuy = item.buyqty - zh_b_num - th.data.in_zhact_gdmap[key]; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | - | ||
| 68 | //当可买的数量为0 | 67 | //当可买的数量为0 |
| 69 | if (cbuy <= 0) { | 68 | if (cbuy <= 0) { |
| 70 | item.num = 0; | 69 | item.num = 0; |
| @@ -129,7 +128,7 @@ module.exports = { | @@ -129,7 +128,7 @@ module.exports = { | ||
| 129 | for (var u in act_goos) { | 128 | for (var u in act_goos) { |
| 130 | var ite = act_goos[u]; | 129 | var ite = act_goos[u]; |
| 131 | if (ite.buyqty > 0 && ite.num > 0) { | 130 | if (ite.buyqty > 0 && ite.num > 0) { |
| 132 | - var key = ite.goods_id + "" + act.id; | 131 | + var key = ite.goods_id + "." + act.id; |
| 133 | if (th.data.in_zhact_gdmap[key]) { | 132 | if (th.data.in_zhact_gdmap[key]) { |
| 134 | th.data.in_zhact_gdmap[key] += ite.num; | 133 | th.data.in_zhact_gdmap[key] += ite.num; |
| 135 | } else { | 134 | } else { |
| @@ -165,7 +164,7 @@ module.exports = { | @@ -165,7 +164,7 @@ module.exports = { | ||
| 165 | 164 | ||
| 166 | if(be) { | 165 | if(be) { |
| 167 | if (act.is_bzyh && zhqty_bz.length > 0) { | 166 | if (act.is_bzyh && zhqty_bz.length > 0) { |
| 168 | - if (zhqty_bz.length > 1) { | 167 | + |
| 169 | let zhqty_bz_arr = []; | 168 | let zhqty_bz_arr = []; |
| 170 | let zhqty_bz_flag = this.zhqty_bz_fun(zhqty_bz, be, zhqty_bz_arr); | 169 | let zhqty_bz_flag = this.zhqty_bz_fun(zhqty_bz, be, zhqty_bz_arr); |
| 171 | if (zhqty_bz_flag) { | 170 | if (zhqty_bz_flag) { |
| @@ -184,28 +183,12 @@ module.exports = { | @@ -184,28 +183,12 @@ module.exports = { | ||
| 184 | } else { | 183 | } else { |
| 185 | zhqty_len = 1; | 184 | zhqty_len = 1; |
| 186 | let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) { | 185 | let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) { |
| 187 | - return o['num']; | 186 | + return o['be']; |
| 188 | })); | 187 | })); |
| 189 | let new_arr = zhqty_bz_arr.filter(ii => { | 188 | let new_arr = zhqty_bz_arr.filter(ii => { |
| 190 | - return ii['num'] == min_bz_num; | 189 | + return ii['be'] == min_bz_num; |
| 191 | }) | 190 | }) |
| 192 | - var vv = new_arr[0]; | ||
| 193 | - var bz_num = be * new_arr[0].zhqty; //超量倍增 | ||
| 194 | - var num = min_bz_num - new_arr[0].zhqty; //购买数量减去超量 | ||
| 195 | - bz_num_ok = bz_num - num; | ||
| 196 | - if (bz_num_ok <= 0) { | ||
| 197 | - //超量倍增满足,超量倍增就等于倍数 | ||
| 198 | - bz_num_ok = bz_num; | ||
| 199 | - } else { | ||
| 200 | - //超量倍增不满足,倍数要减去多出得 | ||
| 201 | - // be=be-bz_num_ok; | ||
| 202 | - if (num % vv.zhqty == 0) { | ||
| 203 | - be = num / vv.zhqty; | ||
| 204 | - } else { | ||
| 205 | - be = Math.floor(num / vv.zhqty) | ||
| 206 | - } | ||
| 207 | - bz_num_ok = be * vv.zhqty; | ||
| 208 | - } | 191 | + be = new_arr[0].be; |
| 209 | 192 | ||
| 210 | for (let i = 0; i < zhqty_bz.length; i++) { | 193 | for (let i = 0; i < zhqty_bz.length; i++) { |
| 211 | let item1 = zhqty_bz[i]; | 194 | let item1 = zhqty_bz[i]; |
| @@ -221,42 +204,11 @@ module.exports = { | @@ -221,42 +204,11 @@ module.exports = { | ||
| 221 | } | 204 | } |
| 222 | aprice += be * aprice; | 205 | aprice += be * aprice; |
| 223 | } | 206 | } |
| 224 | - } else { | ||
| 225 | - var vv = zhqty_bz[0]; | ||
| 226 | - var bz_num = be * vv.zhqty; //超量倍增 | ||
| 227 | - var num = vv['num'] - vv.zhqty; //购买数量减去超量 | ||
| 228 | - if (num > 0) { | ||
| 229 | - bz_num_ok = bz_num - num; | ||
| 230 | - if (bz_num_ok <= 0) { | ||
| 231 | - //超量倍增满足,超量倍增就等于倍数 | ||
| 232 | - bz_num_ok = bz_num; | ||
| 233 | - } else { | ||
| 234 | - //超量倍增不满足,倍数要减去多出得 | ||
| 235 | - // be=be-bz_num_ok; | ||
| 236 | - if (num % vv.zhqty == 0) { | ||
| 237 | - be = num / vv.zhqty; | ||
| 238 | - } else { | ||
| 239 | - be = Math.floor(num / vv.zhqty) | ||
| 240 | - } | ||
| 241 | - bz_num_ok = be * vv.zhqty; | ||
| 242 | - } | ||
| 243 | - for (let j = 0; j < bz_num_ok; j++) { | ||
| 244 | - let index = no_in_arr.findIndex(i => { | ||
| 245 | - return vv.goods_id === i.goods_id | ||
| 246 | - }) | ||
| 247 | - if (index > -1) { | ||
| 248 | - delete_num++ | ||
| 249 | - no_in_arr.splice(index, 1) | ||
| 250 | - } | ||
| 251 | - } | ||
| 252 | - } else { | ||
| 253 | - zhqty_len = 1; | ||
| 254 | - } | ||
| 255 | - } | 207 | + |
| 256 | } | 208 | } |
| 257 | if (!zhqty_len) { | 209 | if (!zhqty_len) { |
| 258 | - aprice += be * act.zhprice; | ||
| 259 | - let pop_num = be * act.zhbuyqty - delete_num; | 210 | + aprice += be1 * act.zhprice; |
| 211 | + let pop_num = be1 * act.zhbuyqty - delete_num; | ||
| 260 | for (var m = 0; m < pop_num; m++) { | 212 | for (var m = 0; m < pop_num; m++) { |
| 261 | no_in_arr.pop(); | 213 | no_in_arr.pop(); |
| 262 | } | 214 | } |
| @@ -327,12 +279,16 @@ module.exports = { | @@ -327,12 +279,16 @@ module.exports = { | ||
| 327 | 279 | ||
| 328 | //-- 只统计是参与活动的商品 -- | 280 | //-- 只统计是参与活动的商品 -- |
| 329 | for (var ij in goods) { | 281 | for (var ij in goods) { |
| 282 | + goods[ij].is_act_last=0; | ||
| 330 | var iter = goods[ij]; | 283 | var iter = goods[ij]; |
| 331 | if (iter.prom_type != 7 || iter.prom_id != act.id) { | 284 | if (iter.prom_type != 7 || iter.prom_id != act.id) { |
| 332 | continue; | 285 | continue; |
| 333 | } | 286 | } |
| 334 | all_price0 += iter.goods_num * iter.goods_price; | 287 | all_price0 += iter.goods_num * iter.goods_price; |
| 335 | } | 288 | } |
| 289 | + | ||
| 290 | + goods[goods.length-1].is_act_last=1; | ||
| 291 | + | ||
| 336 | //-- 活动的条件已经满足 -- | 292 | //-- 活动的条件已经满足 -- |
| 337 | c_item.zh_prom_goods[act.id].is_has_zh = 1; | 293 | c_item.zh_prom_goods[act.id].is_has_zh = 1; |
| 338 | c_item.is_has_zh = 1; | 294 | c_item.is_has_zh = 1; |
| @@ -524,8 +480,8 @@ module.exports = { | @@ -524,8 +480,8 @@ module.exports = { | ||
| 524 | } | 480 | } |
| 525 | } | 481 | } |
| 526 | 482 | ||
| 527 | - | ||
| 528 | }, | 483 | }, |
| 484 | + | ||
| 529 | zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){ | 485 | zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){ |
| 530 | let zhqty_bz_flag =true; | 486 | let zhqty_bz_flag =true; |
| 531 | for(let i=0;i<zhqty_bz.length;i++){ | 487 | for(let i=0;i<zhqty_bz.length;i++){ |
| @@ -534,11 +490,289 @@ module.exports = { | @@ -534,11 +490,289 @@ module.exports = { | ||
| 534 | let num = item['num'] - item['zhqty']; //购买数量减去超量 | 490 | let num = item['num'] - item['zhqty']; //购买数量减去超量 |
| 535 | if (bz_num > num) { | 491 | if (bz_num > num) { |
| 536 | zhqty_bz_flag=false; | 492 | zhqty_bz_flag=false; |
| 493 | + | ||
| 494 | + var be=0; | ||
| 495 | + if (num % vv.zhqty == 0) { | ||
| 496 | + be = num / vv.zhqty; | ||
| 497 | + } else { | ||
| 498 | + be = Math.floor(num / vv.zhqty) | ||
| 499 | + } | ||
| 500 | + item.be=item; | ||
| 501 | + | ||
| 537 | zhqty_bz_arr.push(item); | 502 | zhqty_bz_arr.push(item); |
| 538 | // zhqty_bz.splice(i,1) | 503 | // zhqty_bz.splice(i,1) |
| 539 | } | 504 | } |
| 540 | } | 505 | } |
| 541 | return zhqty_bz_flag; | 506 | return zhqty_bz_flag; |
| 507 | + }, | ||
| 508 | + | ||
| 509 | + //-- 判断组合购有没有满足,只有在检查的时候,要用新的 --- | ||
| 510 | + ch_zh_ok(act,gdlist,c_goods,th,item_act_map,is_need_ck_num){ | ||
| 511 | + | ||
| 512 | + //-- 寻找一下 -- | ||
| 513 | + function get_num(ite) { | ||
| 514 | + for (let v1 in c_goods) { | ||
| 515 | + var vh = c_goods[v1]; | ||
| 516 | + if (vh.goods_id == ite.goods_id) { | ||
| 517 | + return vh; | ||
| 518 | + } | ||
| 519 | + } | ||
| 520 | + return 0; | ||
| 521 | + } | ||
| 522 | + var goods =gdlist; | ||
| 523 | + var all_num=0; | ||
| 524 | + var need_to_buy=0; | ||
| 525 | + var all_zhqty=0; | ||
| 526 | + //-- 是综合考虑到组合购的总数量和限购数量 -- | ||
| 527 | + var min_can_buy=-1; | ||
| 528 | + var aid=act.id; | ||
| 529 | + | ||
| 530 | + let no_in_arr = []; //剩余的未加入组合购 | ||
| 531 | + let out_arr = []; //超出活动限购的商品放入 | ||
| 532 | + | ||
| 533 | + //-- 判断组合购的总数量是不是到了 -- | ||
| 534 | + if(act.zh_num>0){ | ||
| 535 | + //如果是在全选的情况下,那么就需要in_zhact_new来控制数量 | ||
| 536 | + var need_ck=0; | ||
| 537 | + if(is_need_ck_num){ | ||
| 538 | + need_ck=th.data.in_zhact_new[aid]?th.data.in_zhact_new[aid]:0; | ||
| 539 | + } | ||
| 540 | + if(need_ck+act.zh_buy_num>=act.zh_num ){ | ||
| 541 | + return false; | ||
| 542 | + }else{ | ||
| 543 | + min_can_buy= act.zh_num-act.zh_buy_num-need_ck; | ||
| 544 | + } | ||
| 545 | + } | ||
| 546 | + | ||
| 547 | + //-- 判断组合购的限购是不是到了 -- | ||
| 548 | + if(act.buy_limit>0){ | ||
| 549 | + var need_ck0=0; | ||
| 550 | + if(is_need_ck_num){ | ||
| 551 | + need_ck0=th.data.in_zhact_new[aid]?th.data.in_zhact_new[aid]:0; | ||
| 552 | + } | ||
| 553 | + var min_can_buy0=0; | ||
| 554 | + if(need_ck+item_act_map.buyed>=act.buy_limit ){ | ||
| 555 | + return false; | ||
| 556 | + }else{ | ||
| 557 | + min_can_buy0=act.buy_limit-item_act_map.buyed-need_ck; | ||
| 558 | + } | ||
| 559 | + if(min_can_buy>0){ | ||
| 560 | + if(min_can_buy0<min_can_buy) min_can_buy=min_can_buy0; | ||
| 561 | + }else{ | ||
| 562 | + min_can_buy=min_can_buy0; | ||
| 563 | + } | ||
| 564 | + } | ||
| 565 | + | ||
| 566 | + for (var i in goods) { | ||
| 567 | + var item = goods[i]; | ||
| 568 | + var cart_num = get_num(item).goods_num; | ||
| 569 | + var zh_b_num = get_num(item).zh_b_num; | ||
| 570 | + if (!cart_num) { | ||
| 571 | + if (item.zhqty) { | ||
| 572 | + need_to_buy += item.zhqty; | ||
| 573 | + } | ||
| 574 | + continue; | ||
| 575 | + } | ||
| 576 | + | ||
| 577 | + item.cart_num = cart_num; | ||
| 578 | + //-- 当商品有购买的时候,以及有限购的时候 -- | ||
| 579 | + if (item.buyqty > 0) { | ||
| 580 | + var cbuy = item.buyqty - zh_b_num; | ||
| 581 | + var key = item.goods_id + "." + act.id; | ||
| 582 | + if (is_need_ck_num && th.data.in_zhact_gdmap_new[key]) { | ||
| 583 | + var cbuy = item.buyqty - zh_b_num - th.data.in_zhact_gdmap_new[key]; | ||
| 584 | + } | ||
| 585 | + //当可买的数量为0 | ||
| 586 | + if (cbuy <= 0) { | ||
| 587 | + item.num = 0; | ||
| 588 | + out_arr.push({ | ||
| 589 | + goods_id: item.goods_id, | ||
| 590 | + num: cart_num | ||
| 591 | + }) | ||
| 592 | + } else { | ||
| 593 | + if (cbuy >= cart_num) item.num = cart_num; | ||
| 594 | + else { | ||
| 595 | + item.num = cbuy; | ||
| 596 | + out_arr.push({ | ||
| 597 | + goods_id: item.goods_id, | ||
| 598 | + num: cart_num - cbuy | ||
| 599 | + }) | ||
| 600 | + } | ||
| 601 | + } | ||
| 602 | + } else { | ||
| 603 | + item.num = cart_num; | ||
| 604 | + } | ||
| 605 | + | ||
| 606 | + if (item.num) { | ||
| 607 | + all_num += item.num; | ||
| 608 | + //当有起购数的控制的时候 | ||
| 609 | + if (item.zhqty) { | ||
| 610 | + all_zhqty += item.zhqty; | ||
| 611 | + if (item.num < item.zhqty) { | ||
| 612 | + need_to_buy += item.zhqty - item.num; | ||
| 613 | + } | ||
| 614 | + if (item.num > item.zhqty) { | ||
| 615 | + for (let i = 0; i < item.num - item.zhqty; i++) { | ||
| 616 | + no_in_arr.push({ | ||
| 617 | + goods_id: item.goods_id, | ||
| 618 | + }) | ||
| 619 | + } | ||
| 620 | + } | ||
| 621 | + } | ||
| 622 | + else { | ||
| 623 | + for (let j = 0; j < item.num; j++) { | ||
| 624 | + no_in_arr.push({ | ||
| 625 | + goods_id: item.goods_id, | ||
| 626 | + }) | ||
| 627 | + } | ||
| 628 | + } | ||
| 629 | + } else { | ||
| 630 | + if (item.zhqty) { | ||
| 631 | + need_to_buy += item.zhqty; | ||
| 632 | + } | ||
| 633 | + } | ||
| 634 | + } | ||
| 635 | + | ||
| 636 | + //当满足组合的要求:总数要满足,起购数要满足 | ||
| 637 | + if (all_num >= act.zhbuyqty && !need_to_buy) { | ||
| 638 | + //默认数量是1 | ||
| 639 | + var act_num=1; | ||
| 640 | + function sortData(a, b) { | ||
| 641 | + return a.price - b.price | ||
| 642 | + } | ||
| 643 | + if (no_in_arr.length > 0) no_in_arr.sort(sortData); | ||
| 644 | + if (act.zhbuyqty > all_zhqty) { | ||
| 645 | + for (let n = 0; n < act.zhbuyqty - all_zhqty; n++) { | ||
| 646 | + no_in_arr.pop(); | ||
| 647 | + } | ||
| 648 | + } | ||
| 649 | + | ||
| 650 | + //看一下剩下的数量有没有满足组合购的要求,以及要不要倍增 | ||
| 651 | + if (act.is_bz && no_in_arr.length >= act.zhbuyqty) { | ||
| 652 | + | ||
| 653 | + var bz_num_ok = 0; //超量倍增是否满足 | ||
| 654 | + var zhqty_len = 0; //几个超量倍增 | ||
| 655 | + var delete_num = 0; | ||
| 656 | + //看一下是几倍 | ||
| 657 | + let be = parseInt(no_in_arr.length / act.zhbuyqty); | ||
| 658 | + //如果有总数控制的时候 | ||
| 659 | + if (min_can_buy>0) { | ||
| 660 | + var be1 = min_can_buy - 1; | ||
| 661 | + if (be1 < be) be = be1; | ||
| 662 | + } | ||
| 663 | + if(be) { | ||
| 664 | + if (act.is_bzyh && zhqty_bz.length > 0) { | ||
| 665 | + | ||
| 666 | + let zhqty_bz_arr = []; | ||
| 667 | + let zhqty_bz_flag = this.zhqty_bz_fun(zhqty_bz, be, zhqty_bz_arr); | ||
| 668 | + if (zhqty_bz_flag) { | ||
| 669 | + for (let i = 0; i < zhqty_bz.length; i++) { | ||
| 670 | + var vv = zhqty_bz[i]; | ||
| 671 | + for (let j = 0; j < be * vv['zhqty']; j++) { | ||
| 672 | + let index = no_in_arr.findIndex(i => { | ||
| 673 | + return vv.goods_id === i.goods_id | ||
| 674 | + }) | ||
| 675 | + if (index > -1) { | ||
| 676 | + delete_num++ | ||
| 677 | + no_in_arr.splice(index, 1) | ||
| 678 | + } | ||
| 679 | + } | ||
| 680 | + } | ||
| 681 | + } else { | ||
| 682 | + zhqty_len = 1; | ||
| 683 | + let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) { | ||
| 684 | + return o['be']; | ||
| 685 | + })); | ||
| 686 | + let new_arr = zhqty_bz_arr.filter(ii => { | ||
| 687 | + return ii['be'] == min_bz_num; | ||
| 688 | + }) | ||
| 689 | + //-- 要看一下倍数还有没有 --- | ||
| 690 | + be = new_arr[0].be; | ||
| 691 | + //如果有总数控制的时候 | ||
| 692 | + if (min_can_buy>0) { | ||
| 693 | + var be1 = min_can_buy - 1; | ||
| 694 | + if (be1 < be) be = be1; | ||
| 695 | + } | ||
| 696 | + if(be){ | ||
| 697 | + for (let i = 0; i < zhqty_bz.length; i++) { | ||
| 698 | + let item1 = zhqty_bz[i]; | ||
| 699 | + for (let j = 0; j < be * item1['zhqty']; j++) { | ||
| 700 | + let index = no_in_arr.findIndex(i => { | ||
| 701 | + return item1.goods_id === i.goods_id | ||
| 702 | + }) | ||
| 703 | + if (index > -1) { | ||
| 704 | + no_in_arr.splice(index, 1) | ||
| 705 | + } | ||
| 706 | + } | ||
| 707 | + } | ||
| 708 | + act_num+=be; | ||
| 709 | + } | ||
| 710 | + } | ||
| 711 | + } | ||
| 712 | + if (!zhqty_len) { | ||
| 713 | + let pop_num = be * act.zhbuyqty - delete_num; | ||
| 714 | + for (var m = 0; m < pop_num; m++) { | ||
| 715 | + no_in_arr.pop(); | ||
| 716 | + } | ||
| 717 | + act_num+=be; | ||
| 718 | + } | ||
| 719 | + } | ||
| 720 | + } | ||
| 721 | + | ||
| 722 | + //-- 参与活动的金额要返回回去 -- | ||
| 723 | + item_act_map.act_num=act_num; | ||
| 724 | + let goods_map = {}; | ||
| 725 | + //算一下剩余的商品 | ||
| 726 | + if (no_in_arr.length) { | ||
| 727 | + for (let ii in no_in_arr) { | ||
| 728 | + let item = no_in_arr[ii]; | ||
| 729 | + if (goods_map[item.goods_id]) { | ||
| 730 | + var num = goods_map[item.goods_id]; | ||
| 731 | + goods_map[item.goods_id] = ++num; | ||
| 732 | + } else { | ||
| 733 | + goods_map[item.goods_id] = 1; | ||
| 734 | + } | ||
| 735 | + } | ||
| 736 | + } | ||
| 737 | + //超量的部分也要计算一下 | ||
| 738 | + if (out_arr.length) { | ||
| 739 | + for (var m in out_arr) { | ||
| 740 | + if (goods_map[item.goods_id]) { | ||
| 741 | + var num = goods_map[item.goods_id]; | ||
| 742 | + num += item.num | ||
| 743 | + goods_map[item.goods_id] = num; | ||
| 744 | + } else { | ||
| 745 | + goods_map[item.goods_id] = item.num; | ||
| 746 | + } | ||
| 747 | + } | ||
| 748 | + } | ||
| 749 | + | ||
| 750 | + //-- 组合购的商品限购的数组控制 -- | ||
| 751 | + var in_zhact_gdmap={}; | ||
| 752 | + //商品的列表 | ||
| 753 | + for (var u in goods) { | ||
| 754 | + var ite = goods[u]; | ||
| 755 | + var cart_num = get_num(ite).goods_num; | ||
| 756 | + | ||
| 757 | + if (ite.buyqty > 0 && cart_num > 0) { | ||
| 758 | + var key = ite.goods_id + "." + act.id; | ||
| 759 | + if(goods_map[ite.goods_id]){ | ||
| 760 | + cart_num-=goods_map[ite.goods_id]; | ||
| 761 | + } | ||
| 762 | + if(cart_num>0){ | ||
| 763 | + if (in_zhact_gdmap[key]) { | ||
| 764 | + in_zhact_gdmap[key] += ite.num; | ||
| 765 | + } else { | ||
| 766 | + in_zhact_gdmap[key] = ite.num; | ||
| 767 | + } | ||
| 768 | + } | ||
| 769 | + | ||
| 770 | + } | ||
| 771 | + } | ||
| 772 | + item_act_map.in_zhact_gdmap=in_zhact_gdmap; | ||
| 773 | + return true; | ||
| 774 | + } | ||
| 775 | + return false; | ||
| 542 | } | 776 | } |
| 543 | 777 | ||
| 544 | 778 |
pages/cart/cart/cart.js
| @@ -8,7 +8,9 @@ var t = getApp(), | @@ -8,7 +8,9 @@ var t = getApp(), | ||
| 8 | zh_calc = require("zh_calculate.js"), | 8 | zh_calc = require("zh_calculate.js"), |
| 9 | ladder_calc = require("ladder_calculate.js"); | 9 | ladder_calc = require("ladder_calculate.js"); |
| 10 | var regeneratorRuntime = require('../../../utils/runtime.js'); | 10 | var regeneratorRuntime = require('../../../utils/runtime.js'); |
| 11 | - | 11 | +const e = require("../../../utils/common.js"); |
| 12 | +//公共的函数合并在一起 | ||
| 13 | +const m_cx = require("../../../utils/more_cx.js"); | ||
| 12 | 14 | ||
| 13 | Page({ | 15 | Page({ |
| 14 | data: { | 16 | data: { |
| @@ -40,23 +42,77 @@ Page({ | @@ -40,23 +42,77 @@ Page({ | ||
| 40 | zhhe_prom: [], //组合活动需要显示差多少件 | 42 | zhhe_prom: [], //组合活动需要显示差多少件 |
| 41 | zuhe_map: {}, | 43 | zuhe_map: {}, |
| 42 | zuhe_map_good: {}, | 44 | zuhe_map_good: {}, |
| 45 | + | ||
| 43 | in_zhact_gdmap: {}, //不同门店参与同一活动的限购 | 46 | in_zhact_gdmap: {}, //不同门店参与同一活动的限购 |
| 47 | + in_zhact:{}, //组合购活动在列表中的显示 | ||
| 48 | + in_yhact:{}, //优惠活动在列表中的显示 | ||
| 49 | + in_zh_gd_buy_map:{}, //就是商品在组合购中的 | ||
| 44 | 50 | ||
| 45 | ladder_map: {}, //阶梯促销需要的map | 51 | ladder_map: {}, //阶梯促销需要的map |
| 46 | 52 | ||
| 47 | promgoods_map: {}, | 53 | promgoods_map: {}, |
| 48 | - promgoods_list: {} | 54 | + promgoods_list: {}, |
| 55 | + | ||
| 56 | + in_zhact_gdmap_new: {}, //不同门店参与同一活动的限购,这些都是map表,是多促销互动专用,不能和in_zhact_gdmap重叠 | ||
| 57 | + in_zhact_new:{}, //组合购活动在列表中的显示 是多促销互动专用,不能和in_zhact重叠 | ||
| 58 | + in_yhact_new:{}, //组合购活动在列表中的显示 是多促销互动专用,不能和in_yhact重叠 | ||
| 59 | + | ||
| 60 | + }, | ||
| 61 | + | ||
| 62 | + //-- 立即购买的时候,获取商品优惠活动,is_state判断是不是单个商品购买, | ||
| 63 | + // 很多活动需要判断会员的plus等级, 权益登陆,user_id调用接口是必须的 -- | ||
| 64 | + //先用着,后面会用接口来代替 | ||
| 65 | + async buy_pro_group(item1, is_state) { | ||
| 66 | + //-- 代发商品不参与任何活动 -- | ||
| 67 | + if(item1.whsle_id) return false; | ||
| 68 | + | ||
| 69 | + var th=this; | ||
| 70 | + var req_d = { | ||
| 71 | + store_id: os.stoid, | ||
| 72 | + user_id: getApp().globalData.user_id, | ||
| 73 | + goods_id: item1.goods_id, | ||
| 74 | + goods_num: item1.goods_num, | ||
| 75 | + goods_price: item1.goods_price, | ||
| 76 | + } | ||
| 77 | + //--- 调用接口获取活动 --- | ||
| 78 | + await getApp().promiseGet('/api/weshop/goods/getGoodsPromInfo', {data:req_d}).then(res => { | ||
| 79 | + if(res.data.code==0){ | ||
| 80 | + | ||
| 81 | + var more_cx=res.data.data.more_cx; | ||
| 82 | + for(var i=0;i<more_cx.length;i++){ | ||
| 83 | + if(more_cx[i].prom_type==5){ | ||
| 84 | + more_cx[i].main_gid= more_cx[i].collocation.main_goods_id; | ||
| 85 | + var min=more_cx[i].collocation_main_price+more_cx[i].collocation_min_price; | ||
| 86 | + var max=more_cx[i].collocation_main_price+more_cx[i].collocation_max_price; | ||
| 87 | + more_cx[i].show_price="¥"+min+"-"+max; | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + item1.more_cx=more_cx | ||
| 91 | + if(res.data.data.zh_pro){ | ||
| 92 | + th.data.zuhe_map[res.data.data.zh_pro.id]=res.data.data.zh_pro; | ||
| 93 | + } | ||
| 94 | + if(res.data.data.ladder_pro){ | ||
| 95 | + var ladder_pro=res.data.data.ladder_pro; | ||
| 96 | + th.data.ladder_map[ladder_pro.id]=ladder_pro; | ||
| 97 | + var fd=res.data.data.more_cx.find(function (e){ | ||
| 98 | + return e.prom_type==10; | ||
| 99 | + }) | ||
| 100 | + if(fd){ | ||
| 101 | + th.data.ladder_map[ladder_pro.id].ladder_list=fd.ladder_list; | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + }) | ||
| 49 | 106 | ||
| 50 | }, | 107 | }, |
| 51 | - onLoad: function () { | ||
| 52 | 108 | ||
| 109 | + onLoad: function () { | ||
| 53 | var a = this, | 110 | var a = this, |
| 54 | ee = a; | 111 | ee = a; |
| 55 | 112 | ||
| 56 | wx.setNavigationBarTitle({ | 113 | wx.setNavigationBarTitle({ |
| 57 | title: "购物车", | 114 | title: "购物车", |
| 58 | }) | 115 | }) |
| 59 | - | ||
| 60 | //判断是否有登录 | 116 | //判断是否有登录 |
| 61 | t.auth.hadAuth() && t.getUserInfo(function () { | 117 | t.auth.hadAuth() && t.getUserInfo(function () { |
| 62 | //a.getCardList(); | 118 | //a.getCardList(); |
| @@ -75,11 +131,9 @@ Page({ | @@ -75,11 +131,9 @@ Page({ | ||
| 75 | this.getTabBar().setData({ | 131 | this.getTabBar().setData({ |
| 76 | active: index //数字是当前页面在tabbar的索引 | 132 | active: index //数字是当前页面在tabbar的索引 |
| 77 | }) | 133 | }) |
| 78 | - | ||
| 79 | getApp().requestCardNum(this); | 134 | getApp().requestCardNum(this); |
| 80 | } | 135 | } |
| 81 | 136 | ||
| 82 | - | ||
| 83 | var th = this; | 137 | var th = this; |
| 84 | this.setData({ | 138 | this.setData({ |
| 85 | requestData: null, | 139 | requestData: null, |
| @@ -93,6 +147,7 @@ Page({ | @@ -93,6 +147,7 @@ Page({ | ||
| 93 | var is_open_offline = json_d.is_pricing_open; | 147 | var is_open_offline = json_d.is_pricing_open; |
| 94 | th.setData({ | 148 | th.setData({ |
| 95 | bconfig: e, | 149 | bconfig: e, |
| 150 | + json_d:json_d, | ||
| 96 | freight_free: e.freight_free, | 151 | freight_free: e.freight_free, |
| 97 | weight_free: e.weight_free, | 152 | weight_free: e.weight_free, |
| 98 | sales_rules: e.sales_rules, | 153 | sales_rules: e.sales_rules, |
| @@ -426,6 +481,9 @@ Page({ | @@ -426,6 +481,9 @@ Page({ | ||
| 426 | var th = this; | 481 | var th = this; |
| 427 | th.data.in_zhact_gdmap = {}; | 482 | th.data.in_zhact_gdmap = {}; |
| 428 | th.data.ladder_map = {}; | 483 | th.data.ladder_map = {}; |
| 484 | + th.data.zuhe_map={}; | ||
| 485 | + th.data.zuhe_map_good={}; | ||
| 486 | + | ||
| 429 | var rd = Math.random().toString(36).substr(2, 15); | 487 | var rd = Math.random().toString(36).substr(2, 15); |
| 430 | var user_id = getApp().globalData.user_id; | 488 | var user_id = getApp().globalData.user_id; |
| 431 | 489 | ||
| @@ -444,13 +502,10 @@ Page({ | @@ -444,13 +502,10 @@ Page({ | ||
| 444 | //按门店分类的数组 | 502 | //按门店分类的数组 |
| 445 | var arr = new Array(), carr = su.data.data.pageData; | 503 | var arr = new Array(), carr = su.data.data.pageData; |
| 446 | var all_num = 0; | 504 | var all_num = 0; |
| 447 | - | ||
| 448 | - | 505 | + |
| 449 | if (carr && carr.length > 0) { | 506 | if (carr && carr.length > 0) { |
| 450 | var g_arr = []; | 507 | var g_arr = []; |
| 451 | for (var i = 0; i < carr.length; i++) { | 508 | for (var i = 0; i < carr.length; i++) { |
| 452 | - | ||
| 453 | - | ||
| 454 | //-- 清理购物车的选中状态 -- | 509 | //-- 清理购物车的选中状态 -- |
| 455 | var url = '/api/weshop/cart/update'; | 510 | var url = '/api/weshop/cart/update'; |
| 456 | getApp().request.put(url, { | 511 | getApp().request.put(url, { |
| @@ -495,8 +550,6 @@ Page({ | @@ -495,8 +550,6 @@ Page({ | ||
| 495 | var item = carr[i]; | 550 | var item = carr[i]; |
| 496 | var good = item; | 551 | var good = item; |
| 497 | 552 | ||
| 498 | - | ||
| 499 | - | ||
| 500 | if (item.is_gift) { | 553 | if (item.is_gift) { |
| 501 | var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | 554 | var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; |
| 502 | getApp().request.delete(url, { | 555 | getApp().request.delete(url, { |
| @@ -550,82 +603,36 @@ Page({ | @@ -550,82 +603,36 @@ Page({ | ||
| 550 | } | 603 | } |
| 551 | 604 | ||
| 552 | //-- 如果有优惠促销,和阶梯促销,要看下有没有组合购,搭配购,看一下优惠促销和阶梯促销谁是指定商品参与的 -- | 605 | //-- 如果有优惠促销,和阶梯促销,要看下有没有组合购,搭配购,看一下优惠促销和阶梯促销谁是指定商品参与的 -- |
| 553 | - if(item.prom_type==0 || item.prom_type==3 || item.prom_type==10){ | ||
| 554 | - | 606 | + if(item.prom_type==3 || item.prom_type==5 || item.prom_type==7 || item.prom_type==10){ |
| 555 | var c_prom_type=0; | 607 | var c_prom_type=0; |
| 556 | var c_prom_id=0; | 608 | var c_prom_id=0; |
| 557 | 609 | ||
| 558 | - //因为有全场优惠活动,商品参加的活动还未开始 | ||
| 559 | - var url_ch_more_act = "/api/weshop/activitylist/getGoodActInfo"; | ||
| 560 | - var req_data_m = { | ||
| 561 | - store_id: os.stoid, goodsidlist: item.goods_id, is_detail: 1, user_id: user_id | ||
| 562 | - }; | ||
| 563 | - await getApp().request.promiseGet(url_ch_more_act, { data: req_data_m }).then(async function (res) { | ||
| 564 | - if (res.data.code == 0 && res.data.data && res.data.data.length) { | ||
| 565 | - //-- 先看一下有没有组合购 -- | ||
| 566 | - var zh_fd=res.data.data.filter(function (e) { | ||
| 567 | - return e.prom_type==7; | ||
| 568 | - }) | ||
| 569 | - if(zh_fd && zh_fd.length){ | ||
| 570 | - c_prom_type=zh_fd[0].prom_type; | ||
| 571 | - c_prom_id=zh_fd[0].act_id; | ||
| 572 | - return; | ||
| 573 | - } | ||
| 574 | - | ||
| 575 | - //-- 先看一下有没有搭配购 -- | ||
| 576 | - var dp_fd=res.data.data.filter(function (e) { | ||
| 577 | - return e.prom_type==5; | ||
| 578 | - }) | ||
| 579 | - if(dp_fd && dp_fd.length){ | ||
| 580 | - c_prom_type=dp_fd[0].prom_type; | ||
| 581 | - c_prom_id=dp_fd[0].act_id; | ||
| 582 | - return; | ||
| 583 | - } | ||
| 584 | - | ||
| 585 | - //-- 先看一下有没有指定优惠促销 -- | ||
| 586 | - var yh_fd=res.data.data.filter(function (e) { | ||
| 587 | - return e.prom_type==3 && e.good_object==1; | ||
| 588 | - }) | ||
| 589 | - if(yh_fd && yh_fd.length){ | ||
| 590 | - c_prom_type=yh_fd[0].prom_type; | ||
| 591 | - c_prom_id=yh_fd[0].act_id; | ||
| 592 | - return; | ||
| 593 | - } | 610 | + item.prom_type=c_prom_type; |
| 611 | + item.prom_id=c_prom_id; | ||
| 594 | 612 | ||
| 595 | - //-- 先看一下有没有指定阶梯促销 -- | ||
| 596 | - var jt_fd=res.data.data.filter(function (e) { | ||
| 597 | - return e.prom_type==10 && e.good_object==1; | ||
| 598 | - }) | ||
| 599 | - if(jt_fd && jt_fd.length){ | ||
| 600 | - c_prom_type=jt_fd[0].prom_type; | ||
| 601 | - c_prom_id=jt_fd[0].act_id; | ||
| 602 | - } | 613 | + if (th.data.card_field && good[th.data.card_field]) { |
| 614 | + item.goods_price = good[th.data.card_field]; //要同步下线商品的id | ||
| 615 | + } else { | ||
| 616 | + item.goods_price = good.shop_price; | ||
| 617 | + } | ||
| 603 | 618 | ||
| 604 | - } | 619 | + //-- 购物车更新 -- |
| 620 | + var updata1 = { | ||
| 621 | + id: item.id, | ||
| 622 | + prom_type: c_prom_type, | ||
| 623 | + prom_id:c_prom_id, | ||
| 624 | + store_id: os.stoid, | ||
| 625 | + user_id: getApp().globalData.userInfo.user_id | ||
| 626 | + }; | ||
| 627 | + getApp().request.put("/api/weshop/cart/update", { | ||
| 628 | + data: updata1, | ||
| 605 | }) | 629 | }) |
| 606 | 630 | ||
| 607 | - if(c_prom_type && (c_prom_type!=item.prom_type || c_prom_id!=item.prom_id )){ | ||
| 608 | - item.prom_type=c_prom_type; | ||
| 609 | - item.prom_id=c_prom_id; | ||
| 610 | - //-- 购物车更新 -- | ||
| 611 | - var updata1 = { | ||
| 612 | - id: item.id, | ||
| 613 | - prom_type: c_prom_type, | ||
| 614 | - prom_id:c_prom_id, | ||
| 615 | - store_id: os.stoid, | ||
| 616 | - user_id: getApp().globalData.userInfo.user_id | ||
| 617 | - }; | ||
| 618 | - getApp().request.put("/api/weshop/cart/update", { | ||
| 619 | - data: updata1, | ||
| 620 | - }) | ||
| 621 | - } | ||
| 622 | - | ||
| 623 | } | 631 | } |
| 624 | 632 | ||
| 625 | //判断如果是普通商品,后面参加活动了,变成失效商品 | 633 | //判断如果是普通商品,后面参加活动了,变成失效商品 |
| 626 | if (item.prom_type == 0 ) { | 634 | if (item.prom_type == 0 ) { |
| 627 | 635 | ||
| 628 | - | ||
| 629 | var prom = null; | 636 | var prom = null; |
| 630 | var now = ut.gettimestamp(); | 637 | var now = ut.gettimestamp(); |
| 631 | await getApp().request.promiseGet(`/api/weshop/activitylist/listGoodActInfo2New`, { | 638 | await getApp().request.promiseGet(`/api/weshop/activitylist/listGoodActInfo2New`, { |
| @@ -644,41 +651,20 @@ Page({ | @@ -644,41 +651,20 @@ Page({ | ||
| 644 | prom.push(a_item); | 651 | prom.push(a_item); |
| 645 | } | 652 | } |
| 646 | } | 653 | } |
| 647 | - | ||
| 648 | - | ||
| 649 | } | 654 | } |
| 650 | }) | 655 | }) |
| 651 | - let prom_true = 0 | ||
| 652 | - let prom_id = 0 | ||
| 653 | - if (prom) { | ||
| 654 | - prom.map(item => { | ||
| 655 | - if (item.prom_type == 3 || item.prom_type == 5 || item.prom_type == 7 || item.prom_type == 10) { | ||
| 656 | - prom_true = item.prom_type | ||
| 657 | - prom_id = item.act_id | ||
| 658 | - } | ||
| 659 | - }) | ||
| 660 | - } | ||
| 661 | - if (prom_true) { | ||
| 662 | - //-- 购物车更新 -- | ||
| 663 | - var updata1 = { | ||
| 664 | - id: item.id, | ||
| 665 | - prom_type: prom_true, | ||
| 666 | - prom_id, | ||
| 667 | - store_id: os.stoid, | ||
| 668 | - user_id: getApp().globalData.userInfo.user_id | ||
| 669 | - }; | ||
| 670 | - item.prom_id = prom_id | ||
| 671 | - item.prom_type = prom_true | ||
| 672 | - getApp().request.put("/api/weshop/cart/update", { | ||
| 673 | - data: updata1, | ||
| 674 | - }) | ||
| 675 | 656 | ||
| 676 | - } else { | ||
| 677 | - if (prom && !item.is_integral_normal && !item.is_pd_normal && prom[0].prom_type != 5) { | ||
| 678 | - th.disInvalid(item); | 657 | + //只有一种活动,但是又是秒杀之类是互动,就要失效。不能是普通购买 |
| 658 | + if (prom.length==1 && [1,2,4,6,8,9].indexOf(prom.prom_type)>-1 && !prom.is_integral_normal && !prom.is_pd_normal) { | ||
| 659 | + th.disInvalid(item); | ||
| 660 | + continue; | ||
| 661 | + } | ||
| 662 | + //只有秒杀和积分购的时候,不能是普通购买 | ||
| 663 | + if (prom.length==2 && [1,4].indexOf(prom.prom_type)>-1 && [1,4].indexOf(prom.prom_type)>-1 && !prom.is_integral_normal && !prom.is_pd_normal) { | ||
| 664 | + th.disInvalid(item); | ||
| 679 | continue; | 665 | continue; |
| 680 | - } | ||
| 681 | } | 666 | } |
| 667 | + | ||
| 682 | } | 668 | } |
| 683 | 669 | ||
| 684 | 670 | ||
| @@ -699,7 +685,6 @@ Page({ | @@ -699,7 +685,6 @@ Page({ | ||
| 699 | }) | 685 | }) |
| 700 | } | 686 | } |
| 701 | 687 | ||
| 702 | - | ||
| 703 | //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着 | 688 | //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着 |
| 704 | if (item.prom_type == 1) { | 689 | if (item.prom_type == 1) { |
| 705 | var prom = null; | 690 | var prom = null; |
| @@ -784,392 +769,7 @@ Page({ | @@ -784,392 +769,7 @@ Page({ | ||
| 784 | 769 | ||
| 785 | 770 | ||
| 786 | } | 771 | } |
| 787 | - //--判断优惠活动有没有过期,-- | ||
| 788 | - else if (item.prom_type == 3) { | ||
| 789 | - var isok = 1, is_g_prom = 0; | ||
| 790 | - | ||
| 791 | - //因为有全场优惠活动,商品参加的活动还未开始 | ||
| 792 | - var url = "/api/weshop/activitylist/getGoodActInfo"; | ||
| 793 | - var req_data = { | ||
| 794 | - store_id: os.stoid, goodsidlist: item.goods_id, is_detail: 1, user_id: user_id | ||
| 795 | - }; | ||
| 796 | - await getApp().request.promiseGet(url, { data: req_data }).then(async function (res) { | ||
| 797 | - if (res.data.code == 0 && res.data.data && res.data.data.length) { | ||
| 798 | - for (let i in res.data.data) { | ||
| 799 | - let item = res.data.data[i]; | ||
| 800 | - if (item.prom_type == 3) { | ||
| 801 | - is_g_prom = 1; break; | ||
| 802 | - } | ||
| 803 | - } | ||
| 804 | - } | ||
| 805 | - }) | ||
| 806 | - | ||
| 807 | - if (is_g_prom) { | ||
| 808 | - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromListNew/" + os.stoid + "/" + item.goods_id + "/1" + "/" + getApp().globalData.user_id, {}).then(res => { | ||
| 809 | - if (res.data.code == 0) { | ||
| 810 | - var r_data = res.data.data; | ||
| 811 | - if (!r_data.promGoodsLists) { | ||
| 812 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 813 | - // getApp().request.delete(url, {}); | ||
| 814 | - //商品已经无活动 | ||
| 815 | - // th.disInvalid(item); | ||
| 816 | - // isok = 0; | ||
| 817 | - item.prom_type = 0 | ||
| 818 | - //购物车更新 | ||
| 819 | - th.cartUpFn(item) | ||
| 820 | - } else { | ||
| 821 | - //如果活动的ID不一样,说明原先的活动已经没有参与了或者过期了 | ||
| 822 | - if (item.prom_id != r_data.promGoodsLists[0].prom_id) { | ||
| 823 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 824 | - // getApp().request.delete(url, {}); | ||
| 825 | - //商品已经下架 | ||
| 826 | - // th.disInvalid(item); | ||
| 827 | - // isok = 0; | ||
| 828 | - item.prom_type = 0 | ||
| 829 | - //购物车更新 | ||
| 830 | - th.cartUpFn(item) | ||
| 831 | - } | ||
| 832 | - } | ||
| 833 | - | ||
| 834 | - } else { | ||
| 835 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 836 | - // getApp().request.delete(url, {}); | ||
| 837 | - // th.disInvalid(item); | ||
| 838 | - // //商品已经下架 | ||
| 839 | - // isok = 0; | ||
| 840 | - item.prom_type = 0 | ||
| 841 | - //购物车更新 | ||
| 842 | - th.cartUpFn(item) | ||
| 843 | - } | ||
| 844 | - }) | ||
| 845 | - | ||
| 846 | - } else { | ||
| 847 | - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + item.goods_id, {}).then(res => { | ||
| 848 | - if (res.data.code == 0) { | ||
| 849 | - var r_data = res.data.data; | ||
| 850 | - if (!r_data.promGoodsLists) { | ||
| 851 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 852 | - // getApp().request.delete(url, {}); | ||
| 853 | - // th.disInvalid(item); | ||
| 854 | - // //商品已经无活动 | ||
| 855 | - // isok = 0; | ||
| 856 | - item.prom_type = 0 | ||
| 857 | - //购物车更新 | ||
| 858 | - th.cartUpFn(item) | ||
| 859 | - } else { | ||
| 860 | - //如果活动的ID不一样,说明原先的活动已经没有参与了或者过期了 | ||
| 861 | - if (item.prom_id != r_data.promGoodsLists[0].prom_id) { | ||
| 862 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 863 | - // getApp().request.delete(url, {}); | ||
| 864 | - // th.disInvalid(item); | ||
| 865 | - // //商品已经下架 | ||
| 866 | - // isok = 0; | ||
| 867 | - item.prom_type = 0 | ||
| 868 | - //购物车更新 | ||
| 869 | - th.cartUpFn(item) | ||
| 870 | - } | ||
| 871 | - } | ||
| 872 | - | ||
| 873 | - } else { | ||
| 874 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 875 | - // getApp().request.delete(url, {}); | ||
| 876 | - // th.disInvalid(item,1); | ||
| 877 | - // //商品已经下架 | ||
| 878 | - // isok = 0; | ||
| 879 | - item.prom_type = 0 | ||
| 880 | - //购物车更新 | ||
| 881 | - th.cartUpFn(item) | ||
| 882 | - } | ||
| 883 | - }) | ||
| 884 | - } | ||
| 885 | - // if (!isok) continue; | ||
| 886 | - } | ||
| 887 | - else if (item.prom_type == 7) { | ||
| 888 | - console.log('组合购------------'); | ||
| 889 | - if (!th.data.zuhe_map[item.prom_id]) { | ||
| 890 | - console.log('组1') | ||
| 891 | - //如果有组合购 | ||
| 892 | - var isok = 1; | ||
| 893 | - var is_flag = 1; | ||
| 894 | - var act = null; | ||
| 895 | - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item.prom_id + "/" + getApp().globalData.user_id; | ||
| 896 | - await getApp().request.promiseGet(url, {}).then(res => { | ||
| 897 | - console.log(res); | ||
| 898 | - if (res.data.code == 0 && res.data.data) { | ||
| 899 | - if (res.data.data.is_show != 1) { | ||
| 900 | - isok = 0; | ||
| 901 | - } | ||
| 902 | - //如果活动已经结束 | ||
| 903 | - if (res.data.data.is_end == 1) { | ||
| 904 | - isok = 0; | ||
| 905 | - } | ||
| 906 | - //已经结束 | ||
| 907 | - if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 908 | - isok = 0; | ||
| 909 | - } | ||
| 910 | - //还未开始 | ||
| 911 | - if (ut.gettimestamp() < res.data.data.start_time) { | ||
| 912 | - isok = 0; | ||
| 913 | - } | ||
| 914 | - if(res.data.data.zh_num>0 && res.data.data.zh_num<=res.data.data.zh_buy_num){ | ||
| 915 | - isok = 0; | ||
| 916 | - } | ||
| 917 | - | ||
| 918 | - act = res.data.data; | ||
| 919 | - | ||
| 920 | - } else { | ||
| 921 | - //未找到商品的活动 | ||
| 922 | - is_flag = 0; | ||
| 923 | - } | ||
| 924 | - }) | ||
| 925 | - if (!isok) { | ||
| 926 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 927 | - // getApp().request.delete(url, {}); | ||
| 928 | - //组合购失效不处理 | ||
| 929 | - // th.disInvalid(item); | ||
| 930 | - // th.data.zuhe_map[item.prom_id] = -1; | ||
| 931 | - // continue; | ||
| 932 | - item.prom_type = 0 | ||
| 933 | - //购物车更新 | ||
| 934 | - th.cartUpFn(item) | ||
| 935 | - } else { | ||
| 936 | - th.data.zuhe_map[item.prom_id] = act; | ||
| 937 | - var url1 = "/api/weshop/prom/zhbuyGoods/page"; | ||
| 938 | - var req_data = { | ||
| 939 | - page: 1, | ||
| 940 | - pageSize: 2000, | ||
| 941 | - store_id: os.stoid, | ||
| 942 | - zh_id: item.prom_id, | ||
| 943 | - } | ||
| 944 | - await getApp().request.promiseGet(url1, { | ||
| 945 | - data: req_data | ||
| 946 | - }).then(res => { | ||
| 947 | - console.log(res, 2000); | ||
| 948 | - if (ut.ajax_ok(res)) { | ||
| 949 | - var gdlist = res.data.data.pageData; | ||
| 950 | - gdlist.forEach(i => { | ||
| 951 | - if (item.goods_id == i.goods_id && !is_flag) { | ||
| 952 | - item.prom_type = 0; | ||
| 953 | - item.prom_type1 = 0; | ||
| 954 | - item.prom_id = 0; | ||
| 955 | - item.prom_id1 = 0 | ||
| 956 | - } | ||
| 957 | - }) | ||
| 958 | - th.data.zuhe_map_good[item.prom_id] = gdlist; | ||
| 959 | - } | ||
| 960 | - }) | ||
| 961 | - } | ||
| 962 | - } | ||
| 963 | - console.log('组2') | ||
| 964 | - if (th.data.zuhe_map[item.prom_id] && th.data.zuhe_map[item.prom_id] != -1) { | ||
| 965 | - console.log('组3') | ||
| 966 | - var gdlist = th.data.zuhe_map_good[item.prom_id]; | ||
| 967 | - var t_item = gdlist.find(function (ele) { | ||
| 968 | - return ele.goods_id == item.goods_id | ||
| 969 | - }) | ||
| 970 | - if (!t_item) { | ||
| 971 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 972 | - // getApp().request.delete(url, {}); | ||
| 973 | - //组合购不处理 | ||
| 974 | - // th.disInvalid(item,1); | ||
| 975 | - // th.data.zuhe_map[item.prom_id] = -1; | ||
| 976 | - // continue; | ||
| 977 | - item.prom_type = 0 | ||
| 978 | - //购物车更新 | ||
| 979 | - th.cartUpFn(item) | ||
| 980 | - } else { | ||
| 981 | - let act =th.data.zuhe_map[item.prom_id] | ||
| 982 | - //判断是否超出组合购次数限制 | ||
| 983 | - | ||
| 984 | - if(act.buy_limit !=0){ | ||
| 985 | - let userbuynum = await th.getUserBuyPromNum(item.goods_prom_id) | ||
| 986 | - if(userbuynum>=act.buy_limit){ | ||
| 987 | - item.goods_prom_type = 0 | ||
| 988 | - item.goods_prom_id = 0 | ||
| 989 | - item.prom_type = 0 | ||
| 990 | - item.prom_id = 0 | ||
| 991 | - //购物车更新 | ||
| 992 | - th.cartUpFn(item) | ||
| 993 | - }else{ | ||
| 994 | - item.buyqty = t_item.buyqty; | ||
| 995 | - item.zh_b_num = promgoodsbuynum; | ||
| 996 | - item.act = th.data.zuhe_map[item.prom_id]; | ||
| 997 | - } | ||
| 998 | - }else{ | ||
| 999 | - item.buyqty = t_item.buyqty; | ||
| 1000 | - item.zh_b_num = promgoodsbuynum; | ||
| 1001 | - item.act = th.data.zuhe_map[item.prom_id]; | ||
| 1002 | - } | ||
| 1003 | - } | ||
| 1004 | - } //else{ | ||
| 1005 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 1006 | - // getApp().request.delete(url, {}); | ||
| 1007 | - // th.data.zuhe_map[item.prom_id]=-1; | ||
| 1008 | - // continue; | ||
| 1009 | - // } | ||
| 1010 | - } | ||
| 1011 | - else if (item.prom_type == 10) { | ||
| 1012 | - if (!th.data.ladder_map[item.prom_id]) { | ||
| 1013 | - //如果有阶梯购 | ||
| 1014 | - var isok = 1; | ||
| 1015 | - var is_flag = 1; | ||
| 1016 | - var act = null; | ||
| 1017 | - var url = "/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + item.prom_id; | ||
| 1018 | - await getApp().request.promiseGet(url, {}).then(res => { | ||
| 1019 | - console.log(res, 1000); | ||
| 1020 | - if (res.data.code == 0 && res.data.data) { | ||
| 1021 | - if (res.data.data.isuse != 1) { | ||
| 1022 | - isok = 0; | ||
| 1023 | - } | ||
| 1024 | - //如果活动已经结束 | ||
| 1025 | - if (res.data.data.is_end == 1) { | ||
| 1026 | - isok = 0; | ||
| 1027 | - } | ||
| 1028 | - //已经结束 | ||
| 1029 | - if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 1030 | - isok = 0; | ||
| 1031 | - } | ||
| 1032 | - //还未开始 | ||
| 1033 | - if (ut.gettimestamp() < res.data.data.start_time) { | ||
| 1034 | - isok = 0; | ||
| 1035 | - } | ||
| 1036 | - act = res.data.data; | ||
| 1037 | - | ||
| 1038 | - } else { | ||
| 1039 | - //未找到商品的活动 | ||
| 1040 | - isok = 0; | ||
| 1041 | - } | ||
| 1042 | - }) | ||
| 1043 | - if (!isok) { | ||
| 1044 | - // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; | ||
| 1045 | - // getApp().request.delete(url, {}); | ||
| 1046 | - th.disInvalid(item, 1); | ||
| 1047 | - th.data.ladder_map[item.prom_id] = -1; | ||
| 1048 | - continue; | ||
| 1049 | - } | ||
| 1050 | - th.data.ladder_map[item.prom_id] = act; | ||
| 1051 | - | ||
| 1052 | - //-- 获取阶梯规则 -- | ||
| 1053 | - var url1 = "/api/weshop/prom/ladderList/list"; | ||
| 1054 | - var req_data = { | ||
| 1055 | - store_id: os.stoid, | ||
| 1056 | - form_id: item.prom_id, | ||
| 1057 | - } | ||
| 1058 | - await getApp().request.promiseGet(url1, { | ||
| 1059 | - data: req_data | ||
| 1060 | - }).then(rs1 => { | ||
| 1061 | - if (rs1.data.code == 0 && rs1.data.data) { | ||
| 1062 | - var gdlist = rs1.data.data; | ||
| 1063 | - th.data.ladder_map[item.prom_id].ladder_list = gdlist; | ||
| 1064 | - } | ||
| 1065 | - }) | ||
| 1066 | - } | ||
| 1067 | - //直接把活动赋值给元素 | ||
| 1068 | - if (th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id] != -1) { | ||
| 1069 | - item.act = th.data.ladder_map[item.prom_id]; | ||
| 1070 | - } | ||
| 1071 | - | ||
| 1072 | - } | ||
| 1073 | - //判断不是代发的商品 | ||
| 1074 | - else if (item.prom_type == 0 && !item.whsle_id) { | ||
| 1075 | - | ||
| 1076 | - //如果有优惠活动,要更新活动 | ||
| 1077 | - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1" + "/" + getApp().globalData.user_id, {}).then(res => { | ||
| 1078 | - if (res.data.code == 0 && res.data.data) { | ||
| 1079 | - var r_data = res.data.data; | ||
| 1080 | - if (r_data.promGoodsLists) { | ||
| 1081 | - var url = '/api/weshop/cart/update'; | ||
| 1082 | - getApp().request.put(url, { | ||
| 1083 | - data: { | ||
| 1084 | - id: item.id, | ||
| 1085 | - store_id: oo.stoid, | ||
| 1086 | - prom_type: 3, | ||
| 1087 | - prom_id: r_data.promGoodsLists[0].prom_id | ||
| 1088 | - } | ||
| 1089 | - }); | ||
| 1090 | - item.prom_type = 3; | ||
| 1091 | - item.prom_id = r_data.promGoodsLists[0].prom_id; | ||
| 1092 | - } else if (r_data.ladderLists) { | ||
| 1093 | 772 | ||
| 1094 | - item.prom_type = 10; | ||
| 1095 | - item.prom_id = r_data.ladderLists[0].form_id; | ||
| 1096 | - | ||
| 1097 | - } | ||
| 1098 | - } | ||
| 1099 | - }) | ||
| 1100 | - | ||
| 1101 | - //如果是阶梯购的时候 | ||
| 1102 | - if (item.prom_type == 10) { | ||
| 1103 | - | ||
| 1104 | - | ||
| 1105 | - if (!th.data.ladder_map[item.prom_id]) { | ||
| 1106 | - //如果有阶梯购,要判断身份 | ||
| 1107 | - var isok = 1; | ||
| 1108 | - var is_flag = 1; | ||
| 1109 | - var act = null; | ||
| 1110 | - var url = "/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + item.prom_id; | ||
| 1111 | - await getApp().request.promiseGet(url, {}).then(res => { | ||
| 1112 | - console.log(res, 1000); | ||
| 1113 | - if (res.data.code == 0 && res.data.data) { | ||
| 1114 | - if (res.data.data.isuse != 1) { | ||
| 1115 | - isok = 0; | ||
| 1116 | - } | ||
| 1117 | - //如果活动已经结束 | ||
| 1118 | - if (res.data.data.is_end == 1) { | ||
| 1119 | - isok = 0; | ||
| 1120 | - } | ||
| 1121 | - //已经结束 | ||
| 1122 | - if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 1123 | - isok = 0; | ||
| 1124 | - } | ||
| 1125 | - //还未开始 | ||
| 1126 | - if (ut.gettimestamp() < res.data.data.start_time) { | ||
| 1127 | - isok = 0; | ||
| 1128 | - } | ||
| 1129 | - act = res.data.data; | ||
| 1130 | - | ||
| 1131 | - } else { | ||
| 1132 | - //未找到商品的活动 | ||
| 1133 | - isok = 0; | ||
| 1134 | - } | ||
| 1135 | - }) | ||
| 1136 | - if (!isok) { | ||
| 1137 | - item.prom_type = 0; | ||
| 1138 | - item.prom_id = 0; | ||
| 1139 | - } else { | ||
| 1140 | - | ||
| 1141 | - th.data.ladder_map[item.prom_id] = act; | ||
| 1142 | - //-- 获取阶梯规则 -- | ||
| 1143 | - var url1 = "/api/weshop/prom/ladderList/list"; | ||
| 1144 | - var req_data = { | ||
| 1145 | - store_id: os.stoid, | ||
| 1146 | - form_id: item.prom_id, | ||
| 1147 | - } | ||
| 1148 | - await getApp().request.promiseGet(url1, { | ||
| 1149 | - data: req_data | ||
| 1150 | - }).then(rs1 => { | ||
| 1151 | - if (rs1.data.code == 0 && rs1.data.data) { | ||
| 1152 | - var gdlist = rs1.data.data; | ||
| 1153 | - th.data.ladder_map[item.prom_id].ladder_list = gdlist; | ||
| 1154 | - } | ||
| 1155 | - }) | ||
| 1156 | - } | ||
| 1157 | - | ||
| 1158 | - } | ||
| 1159 | - //直接把活动赋值给元素 | ||
| 1160 | - if (th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id] != -1) { | ||
| 1161 | - item.act = th.data.ladder_map[item.prom_id]; | ||
| 1162 | - | ||
| 1163 | - //如果有活动,就更新商品的活动那个 | ||
| 1164 | - var url = '/api/weshop/cart/update'; | ||
| 1165 | - getApp().request.put(url, { | ||
| 1166 | - data: { id: item.id, store_id: oo.stoid, prom_type: 10, prom_id: item.prom_id } | ||
| 1167 | - }); | ||
| 1168 | - | ||
| 1169 | - } | ||
| 1170 | - } | ||
| 1171 | - | ||
| 1172 | - } | ||
| 1173 | 773 | ||
| 1174 | all_num += item.goods_num; | 774 | all_num += item.goods_num; |
| 1175 | item.original_img = oo.imghost + item.original_img; | 775 | item.original_img = oo.imghost + item.original_img; |
| @@ -1177,26 +777,9 @@ Page({ | @@ -1177,26 +777,9 @@ Page({ | ||
| 1177 | item.erpwareid = good.erpwareid; //要同步下线商品的id | 777 | item.erpwareid = good.erpwareid; //要同步下线商品的id |
| 1178 | item.shop_price = good.shop_price; //要同步下线商品的id | 778 | item.shop_price = good.shop_price; //要同步下线商品的id |
| 1179 | 779 | ||
| 1180 | - //当商品要计算等级价的售 | ||
| 1181 | - if (item.prom_type == 0 || item.prom_type == 3 || item.prom_type == 5 || item.prom_type == 7) { | ||
| 1182 | - if (th.data.card_field && good[th.data.card_field]) { | ||
| 1183 | - item.goods_price = good[th.data.card_field]; //要同步下线商品的id | ||
| 1184 | - } else { | ||
| 1185 | - item.goods_price = good.shop_price; | ||
| 1186 | - } | ||
| 1187 | - | ||
| 1188 | - var t = { | ||
| 1189 | - id: item.id, | ||
| 1190 | - store_id: os.stoid, | ||
| 1191 | - user_id: getApp().globalData.userInfo.user_id, | ||
| 1192 | - goods_price: item.goods_price | ||
| 1193 | - } | ||
| 1194 | - getApp().request.put("/api/weshop/cart/update", { | ||
| 1195 | - isShowLoading: 0, | ||
| 1196 | - data: t, | ||
| 1197 | - }) | ||
| 1198 | - | ||
| 1199 | - } | 780 | + //-- 读出每一种商品的所有的活动,方便后面的活动切换使用 -- |
| 781 | + if(item.prom_type==0) | ||
| 782 | + th.buy_pro_group(item,0); | ||
| 1200 | 783 | ||
| 1201 | var pcid = item.pick_id; | 784 | var pcid = item.pick_id; |
| 1202 | var find = 0; | 785 | var find = 0; |
| @@ -1251,21 +834,6 @@ Page({ | @@ -1251,21 +834,6 @@ Page({ | ||
| 1251 | } | 834 | } |
| 1252 | } | 835 | } |
| 1253 | } | 836 | } |
| 1254 | - | ||
| 1255 | - for (let u1 in arr) { | ||
| 1256 | - var u_item = arr[u1]; | ||
| 1257 | - //把组合购进行分组 | ||
| 1258 | - var obj = zh_calc.find_split(u_item); | ||
| 1259 | - if (!obj) continue; | ||
| 1260 | - //存储不同活动的商品列表 | ||
| 1261 | - u_item.zh_prom_goods = {}; | ||
| 1262 | - for (let var1 in obj) { | ||
| 1263 | - var h_item = obj[var1]; | ||
| 1264 | - var gdlist = th.data.zuhe_map_good[h_item.prom_id]; | ||
| 1265 | - //获取活动需要的商品列表 | ||
| 1266 | - u_item.zh_prom_goods[h_item.prom_id] = gdlist; | ||
| 1267 | - } | ||
| 1268 | - } | ||
| 1269 | 837 | ||
| 1270 | th.setData({ | 838 | th.setData({ |
| 1271 | requestData: arr, | 839 | requestData: arr, |
| @@ -1533,7 +1101,6 @@ Page({ | @@ -1533,7 +1101,6 @@ Page({ | ||
| 1533 | } | 1101 | } |
| 1534 | }, | 1102 | }, |
| 1535 | 1103 | ||
| 1536 | - | ||
| 1537 | //删除商品 | 1104 | //删除商品 |
| 1538 | delete_th_item: function (t) { | 1105 | delete_th_item: function (t) { |
| 1539 | var e = this; | 1106 | var e = this; |
| @@ -1571,6 +1138,8 @@ Page({ | @@ -1571,6 +1138,8 @@ Page({ | ||
| 1571 | var th = this; | 1138 | var th = this; |
| 1572 | 1139 | ||
| 1573 | if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) { | 1140 | if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) { |
| 1141 | + this.clear_req(); | ||
| 1142 | + | ||
| 1574 | var s = { | 1143 | var s = { |
| 1575 | goods_num: a, | 1144 | goods_num: a, |
| 1576 | goods_id: e.goods_id, | 1145 | goods_id: e.goods_id, |
| @@ -1582,7 +1151,17 @@ Page({ | @@ -1582,7 +1151,17 @@ Page({ | ||
| 1582 | }, | 1151 | }, |
| 1583 | 1152 | ||
| 1584 | //-------------加数量--------------------- | 1153 | //-------------加数量--------------------- |
| 1154 | + clear_req:function (){ | ||
| 1155 | + var carr=this.data.requestData; | ||
| 1156 | + for(var i=0;i<carr.length;i++){ | ||
| 1157 | + var txt='requestData['+i+'].show_can_cx' | ||
| 1158 | + this.setData({[txt]:null}); | ||
| 1159 | + } | ||
| 1160 | + }, | ||
| 1161 | + | ||
| 1162 | + //-------------加数量------------- | ||
| 1585 | addNum:async function (t) { | 1163 | addNum:async function (t) { |
| 1164 | + | ||
| 1586 | if (!this.data.is_load) return false; | 1165 | if (!this.data.is_load) return false; |
| 1587 | if (this.data.up_dating == 1) return false; | 1166 | if (this.data.up_dating == 1) return false; |
| 1588 | this.data.up_dating = 1; | 1167 | this.data.up_dating = 1; |
| @@ -1621,6 +1200,8 @@ Page({ | @@ -1621,6 +1200,8 @@ Page({ | ||
| 1621 | } | 1200 | } |
| 1622 | } | 1201 | } |
| 1623 | 1202 | ||
| 1203 | + this.clear_req(); | ||
| 1204 | + | ||
| 1624 | var e = { | 1205 | var e = { |
| 1625 | goods_num: a.goods_num + add_num, | 1206 | goods_num: a.goods_num + add_num, |
| 1626 | id: a.id, | 1207 | id: a.id, |
| @@ -1647,6 +1228,7 @@ Page({ | @@ -1647,6 +1228,7 @@ Page({ | ||
| 1647 | return false; | 1228 | return false; |
| 1648 | } | 1229 | } |
| 1649 | 1230 | ||
| 1231 | + if (1 != a.goods_num) { | ||
| 1650 | 1232 | ||
| 1651 | var add_num=1; | 1233 | var add_num=1; |
| 1652 | if([0,3,5,7,10].indexOf(a.prom_type) > -1){ | 1234 | if([0,3,5,7,10].indexOf(a.prom_type) > -1){ |
| @@ -1657,18 +1239,24 @@ Page({ | @@ -1657,18 +1239,24 @@ Page({ | ||
| 1657 | } | 1239 | } |
| 1658 | } | 1240 | } |
| 1659 | 1241 | ||
| 1660 | - var e = { | ||
| 1661 | - goods_num: a.goods_num - add_num, | ||
| 1662 | - id: a.id, | ||
| 1663 | - goods_id: a.goods_id, | ||
| 1664 | - store_id: oo.stoid | ||
| 1665 | - }; | 1242 | + |
| 1666 | 1243 | ||
| 1667 | if(e.goods_num<=0){ | 1244 | if(e.goods_num<=0){ |
| 1668 | this.data.up_dating = 0; | 1245 | this.data.up_dating = 0; |
| 1669 | return false; | 1246 | return false; |
| 1247 | + this.clear_req(); | ||
| 1670 | } | 1248 | } |
| 1671 | - this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); | 1249 | + |
| 1250 | + var e = { | ||
| 1251 | + goods_num: a.goods_num - add_num, | ||
| 1252 | + id: a.id, | ||
| 1253 | + goods_id: a.goods_id, | ||
| 1254 | + store_id: oo.stoid | ||
| 1255 | + }; | ||
| 1256 | + this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); | ||
| 1257 | + | ||
| 1258 | + | ||
| 1259 | + | ||
| 1672 | 1260 | ||
| 1673 | }, | 1261 | }, |
| 1674 | 1262 | ||
| @@ -1822,16 +1410,19 @@ Page({ | @@ -1822,16 +1410,19 @@ Page({ | ||
| 1822 | 1410 | ||
| 1823 | this.data.btn_click = 1; | 1411 | this.data.btn_click = 1; |
| 1824 | 1412 | ||
| 1825 | - | ||
| 1826 | - | ||
| 1827 | var offline_price = 0; | 1413 | var offline_price = 0; |
| 1828 | var offline_num = 0; | 1414 | var offline_num = 0; |
| 1829 | th.data.in_zhact_gdmap = {}; | 1415 | th.data.in_zhact_gdmap = {}; |
| 1830 | - var pro_off=false | 1416 | + var pro_off=false; |
| 1831 | 1417 | ||
| 1832 | if (dda && dda.length > 0) { | 1418 | if (dda && dda.length > 0) { |
| 1833 | for (var i = 0; i < dda.length; i++) { | 1419 | for (var i = 0; i < dda.length; i++) { |
| 1834 | var item = dda[i].goods; | 1420 | var item = dda[i].goods; |
| 1421 | + var txt0 = "requestData[" + i + "].show_can_cx"; | ||
| 1422 | + e.setData({ | ||
| 1423 | + [txt0]: {}, | ||
| 1424 | + }); | ||
| 1425 | + | ||
| 1835 | 1426 | ||
| 1836 | if (e.data.checkAllToggle) { | 1427 | if (e.data.checkAllToggle) { |
| 1837 | var txt = "requestData[" + i + "].selected"; | 1428 | var txt = "requestData[" + i + "].selected"; |
| @@ -1845,6 +1436,7 @@ Page({ | @@ -1845,6 +1436,7 @@ Page({ | ||
| 1845 | if (item[j].is_gift) continue; | 1436 | if (item[j].is_gift) continue; |
| 1846 | var obj = JSON.parse(JSON.stringify(item[j])); | 1437 | var obj = JSON.parse(JSON.stringify(item[j])); |
| 1847 | 1438 | ||
| 1439 | + | ||
| 1848 | //-- 判断起购数量 -- | 1440 | //-- 判断起购数量 -- |
| 1849 | if(!e.data.checkAllToggle){ | 1441 | if(!e.data.checkAllToggle){ |
| 1850 | //判断是不是有促销活动 | 1442 | //判断是不是有促销活动 |
| @@ -1858,6 +1450,13 @@ Page({ | @@ -1858,6 +1450,13 @@ Page({ | ||
| 1858 | //计算之前先移除阶梯购的计算 | 1450 | //计算之前先移除阶梯购的计算 |
| 1859 | if (obj.prom_type == 10) | 1451 | if (obj.prom_type == 10) |
| 1860 | ladder_calc.remove_ladder_prom(dda, i, obj); | 1452 | ladder_calc.remove_ladder_prom(dda, i, obj); |
| 1453 | + // //计算之前先移除组合购的计算 | ||
| 1454 | + // if (obj.prom_type == 7) | ||
| 1455 | + // zh_calc.remove_zhprom(dda, i, obj); | ||
| 1456 | + // //计算之前先移除阶梯购的计算 | ||
| 1457 | + // if (obj.prom_type == 10) | ||
| 1458 | + // ladder_calc.remove_ladder_prom(dda, i, obj); | ||
| 1459 | + | ||
| 1861 | 1460 | ||
| 1862 | 1461 | ||
| 1863 | if (fir == 0) { | 1462 | if (fir == 0) { |
| @@ -1873,10 +1472,11 @@ Page({ | @@ -1873,10 +1472,11 @@ Page({ | ||
| 1873 | 1472 | ||
| 1874 | if (e.data.checkAllToggle) obj.goods_num = 0; | 1473 | if (e.data.checkAllToggle) obj.goods_num = 0; |
| 1875 | 1474 | ||
| 1876 | - //加入组合购计算 | ||
| 1877 | - if (obj.prom_type == 7) zh_calc.add_zhprom(dda, i, obj); | ||
| 1878 | - //加入阶梯促销计算 | ||
| 1879 | - if (obj.prom_type == 10) ladder_calc.add_ladder_prom(dda, i, obj); | 1475 | + // //加入组合购计算 |
| 1476 | + // if (obj.prom_type == 7) zh_calc.add_zhprom(dda, i, obj); | ||
| 1477 | + // //加入阶梯促销计算 | ||
| 1478 | + // if (obj.prom_type == 10) ladder_calc.add_ladder_prom(dda, i, obj); | ||
| 1479 | + | ||
| 1880 | 1480 | ||
| 1881 | //多门店,多优惠次数控制 | 1481 | //多门店,多优惠次数控制 |
| 1882 | let pro_off1=false | 1482 | let pro_off1=false |
| @@ -1921,6 +1521,21 @@ Page({ | @@ -1921,6 +1521,21 @@ Page({ | ||
| 1921 | offline_num += item[j].goods_num; | 1521 | offline_num += item[j].goods_num; |
| 1922 | } | 1522 | } |
| 1923 | } | 1523 | } |
| 1524 | + e.setData({ | ||
| 1525 | + [txt]: !e.data.checkAllToggle, | ||
| 1526 | + }) | ||
| 1527 | + // if (!e.data.checkAllToggle) { | ||
| 1528 | + // //组合购的金额要另外算 | ||
| 1529 | + // if (item[j].prom_type != 7 && item[j].prom_type != 10) | ||
| 1530 | + // tfeel += item[j].goods_num * item[j].goods_price; | ||
| 1531 | + // t_num += item[j].goods_num; | ||
| 1532 | + // } | ||
| 1533 | + // | ||
| 1534 | + // //-- 如果这个商品是线下取价的时候 -- | ||
| 1535 | + // if (item[j].is_offline && item[j].prom_type != 7) { | ||
| 1536 | + // offline_price += (item[j].goods_price - item[j].offline_price) * item[j].goods_num; | ||
| 1537 | + // offline_num += item[j].goods_num; | ||
| 1538 | + // } | ||
| 1924 | 1539 | ||
| 1925 | 1540 | ||
| 1926 | } | 1541 | } |
| @@ -1953,35 +1568,35 @@ Page({ | @@ -1953,35 +1568,35 @@ Page({ | ||
| 1953 | // } | 1568 | // } |
| 1954 | 1569 | ||
| 1955 | //总的价格,把组合商品的价格拿出来 | 1570 | //总的价格,把组合商品的价格拿出来 |
| 1956 | - var zh_calc_res = zh_calc.calculate_zh(dda, i, this); | ||
| 1957 | - tfeel += zh_calc_res.tfeel; | ||
| 1958 | - offline_price += zh_calc_res.offline_price; | ||
| 1959 | - offline_num += zh_calc_res.offline_num; | ||
| 1960 | - | ||
| 1961 | - //总的价格,把阶梯促销的商品的价格拿出来 | ||
| 1962 | - var ladder_calc_res = ladder_calc.calculate_ladder(dda, i, this); | ||
| 1963 | - tfeel += ladder_calc_res.tfeel; | ||
| 1964 | - offline_price += ladder_calc_res.offline_price; | ||
| 1965 | - offline_num += ladder_calc_res.offline_num; | ||
| 1966 | - | ||
| 1967 | - //当有线下取价的时候 | ||
| 1968 | - if (offline_price) { | ||
| 1969 | - var txt1 = "requestData[" + i + "].offline_price"; | ||
| 1970 | - var txt2 = "requestData[" + i + "].offline_num"; | ||
| 1971 | - th.setData({ | ||
| 1972 | - [txt1]: offline_price.toFixed(2), | ||
| 1973 | - [txt2]: offline_num, | ||
| 1974 | - }); | ||
| 1975 | - } else { | ||
| 1976 | - if (dda[i].offline_price > 0) { | ||
| 1977 | - var txt1 = "requestData[" + i + "].offline_price"; | ||
| 1978 | - var txt2 = "requestData[" + i + "].offline_num"; | ||
| 1979 | - th.setData({ | ||
| 1980 | - [txt1]: 0, | ||
| 1981 | - [txt2]: 0 | ||
| 1982 | - }); | ||
| 1983 | - } | ||
| 1984 | - } | 1571 | + // var zh_calc_res = zh_calc.calculate_zh(dda, i, this); |
| 1572 | + // tfeel += zh_calc_res.tfeel; | ||
| 1573 | + // offline_price += zh_calc_res.offline_price; | ||
| 1574 | + // offline_num += zh_calc_res.offline_num; | ||
| 1575 | + // | ||
| 1576 | + // //总的价格,把阶梯促销的商品的价格拿出来 | ||
| 1577 | + // var ladder_calc_res = ladder_calc.calculate_ladder(dda, i, this); | ||
| 1578 | + // tfeel += ladder_calc_res.tfeel; | ||
| 1579 | + // offline_price += ladder_calc_res.offline_price; | ||
| 1580 | + // offline_num += ladder_calc_res.offline_num; | ||
| 1581 | + // | ||
| 1582 | + // //当有线下取价的时候 | ||
| 1583 | + // if (offline_price) { | ||
| 1584 | + // var txt1 = "requestData[" + i + "].offline_price"; | ||
| 1585 | + // var txt2 = "requestData[" + i + "].offline_num"; | ||
| 1586 | + // th.setData({ | ||
| 1587 | + // [txt1]: offline_price.toFixed(2), | ||
| 1588 | + // [txt2]: offline_num, | ||
| 1589 | + // }); | ||
| 1590 | + // } else { | ||
| 1591 | + // if (dda[i].offline_price > 0) { | ||
| 1592 | + // var txt1 = "requestData[" + i + "].offline_price"; | ||
| 1593 | + // var txt2 = "requestData[" + i + "].offline_num"; | ||
| 1594 | + // th.setData({ | ||
| 1595 | + // [txt1]: 0, | ||
| 1596 | + // [txt2]: 0 | ||
| 1597 | + // }); | ||
| 1598 | + // } | ||
| 1599 | + // } | ||
| 1985 | } | 1600 | } |
| 1986 | //多门店优惠次数控制 | 1601 | //多门店优惠次数控制 |
| 1987 | if (pro_off) { | 1602 | if (pro_off) { |
| @@ -1997,9 +1612,12 @@ Page({ | @@ -1997,9 +1612,12 @@ Page({ | ||
| 1997 | // checkAllToggle: !e.data.checkAllToggle, | 1612 | // checkAllToggle: !e.data.checkAllToggle, |
| 1998 | total_fee: tfeel.toFixed(2), | 1613 | total_fee: tfeel.toFixed(2), |
| 1999 | total_num: t_num, | 1614 | total_num: t_num, |
| 1615 | + | ||
| 2000 | }); | 1616 | }); |
| 2001 | 1617 | ||
| 2002 | - e.all_check_prom_activity(); | 1618 | + this.doCheckAll(function (){ |
| 1619 | + e.all_check_prom_activity(); | ||
| 1620 | + }); | ||
| 2003 | 1621 | ||
| 2004 | } | 1622 | } |
| 2005 | } | 1623 | } |
| @@ -2134,12 +1752,10 @@ Page({ | @@ -2134,12 +1752,10 @@ Page({ | ||
| 2134 | title: '购买数量超出商品库存', | 1752 | title: '购买数量超出商品库存', |
| 2135 | icon: 'none', | 1753 | icon: 'none', |
| 2136 | }); | 1754 | }); |
| 2137 | - | ||
| 2138 | return false; | 1755 | return false; |
| 2139 | } | 1756 | } |
| 2140 | } | 1757 | } |
| 2141 | } | 1758 | } |
| 2142 | - | ||
| 2143 | } | 1759 | } |
| 2144 | 1760 | ||
| 2145 | //判断多店优惠促销次数控制 | 1761 | //判断多店优惠促销次数控制 |
| @@ -2172,17 +1788,55 @@ Page({ | @@ -2172,17 +1788,55 @@ Page({ | ||
| 2172 | e.setData({ | 1788 | e.setData({ |
| 2173 | [txt]: Number(!sele), | 1789 | [txt]: Number(!sele), |
| 2174 | }); | 1790 | }); |
| 2175 | - } | ||
| 2176 | 1791 | ||
| 2177 | - e.data.duo_zp_num_arr = {}; | ||
| 2178 | - if (sele) { | ||
| 2179 | - await e.check_prom_activity(pitems); | ||
| 2180 | } | 1792 | } |
| 2181 | - for (var i in e.data.requestData) { | ||
| 2182 | - if (sele && i == pitems) continue; | ||
| 2183 | - await e.check_prom_activity(i); | 1793 | + |
| 1794 | + //-- 选择了什么商品,就用什么商品来判断 -- | ||
| 1795 | + var sele_arr={}; | ||
| 1796 | + for (var i = 0; i < item.length; i++) { | ||
| 1797 | + sele_arr[i] = !sele; | ||
| 2184 | } | 1798 | } |
| 2185 | - this.doCheckAll(); | 1799 | + |
| 1800 | + //-- 回调判断活动有没有冲突 -- | ||
| 1801 | + this.cx_check_ok(pitems,sele_arr,function (the_res) { | ||
| 1802 | + if(the_res.code==0) { | ||
| 1803 | + | ||
| 1804 | + | ||
| 1805 | + //-- 门店是所有的商品都要选择 -- | ||
| 1806 | + for (var i = 0; i < item.length; i++) { | ||
| 1807 | + var txt0 = "requestData[" + pitems + "].goods[" + i + "].selected"; | ||
| 1808 | + e.setData({ | ||
| 1809 | + [txt0]: Number(!sele), | ||
| 1810 | + }); | ||
| 1811 | + } | ||
| 1812 | + | ||
| 1813 | + //-- 门店按钮的选择 -- | ||
| 1814 | + var txt = "requestData[" + pitems + "].selected"; | ||
| 1815 | + e.setData({ | ||
| 1816 | + [txt]: Number(!sele), | ||
| 1817 | + }); | ||
| 1818 | + | ||
| 1819 | + th.doCheckAll(async function () { | ||
| 1820 | + | ||
| 1821 | + | ||
| 1822 | + | ||
| 1823 | + e.data.duo_zp_num_arr = {}; | ||
| 1824 | + if (sele) { | ||
| 1825 | + await e.check_prom_activity(pitems); | ||
| 1826 | + } | ||
| 1827 | + for (var i in e.data.requestData) { | ||
| 1828 | + if (sele && i == pitems) continue; | ||
| 1829 | + await e.check_prom_activity(i); | ||
| 1830 | + } | ||
| 1831 | + }); | ||
| 1832 | + }else{ | ||
| 1833 | + wx.showToast({ | ||
| 1834 | + title: the_res.msg, | ||
| 1835 | + icon: 'none', | ||
| 1836 | + }); | ||
| 1837 | + } | ||
| 1838 | + }) | ||
| 1839 | + | ||
| 2186 | }, | 1840 | }, |
| 2187 | 1841 | ||
| 2188 | //判断多门店,优惠促销次数的控制 | 1842 | //判断多门店,优惠促销次数的控制 |
| @@ -2332,10 +1986,8 @@ Page({ | @@ -2332,10 +1986,8 @@ Page({ | ||
| 2332 | } | 1986 | } |
| 2333 | 1987 | ||
| 2334 | } | 1988 | } |
| 2335 | - | ||
| 2336 | } | 1989 | } |
| 2337 | 1990 | ||
| 2338 | - | ||
| 2339 | let pro_off=false | 1991 | let pro_off=false |
| 2340 | //判断多店优惠促销次数控制 | 1992 | //判断多店优惠促销次数控制 |
| 2341 | if (th.data.requestData.length>1) { | 1993 | if (th.data.requestData.length>1) { |
| @@ -2352,23 +2004,44 @@ Page({ | @@ -2352,23 +2004,44 @@ Page({ | ||
| 2352 | return false; | 2004 | return false; |
| 2353 | } | 2005 | } |
| 2354 | 2006 | ||
| 2007 | + var txt0 = "requestData[" + pitems + "].show_can_cx"; | ||
| 2355 | 2008 | ||
| 2356 | e.setData({ | 2009 | e.setData({ |
| 2357 | - [txt]: Number(!a.selected), | 2010 | + [txt0]: {}, |
| 2358 | }); | 2011 | }); |
| 2359 | 2012 | ||
| 2360 | - if (a.prom_type == 3) { | ||
| 2361 | - e.data.duo_zp_num_arr = {}; | ||
| 2362 | - if (!a.selected) { | ||
| 2363 | - await e.check_prom_activity(pitems); | ||
| 2364 | - } | ||
| 2365 | - //判断商品是不是优惠活动 | ||
| 2366 | - for (var i in e.data.requestData) { | ||
| 2367 | - if (!a.selected && i == pitems) continue; | ||
| 2368 | - await e.check_prom_activity(i); | ||
| 2369 | - } | ||
| 2370 | - } | ||
| 2371 | - this.doCheckAll(); | 2013 | + //-- 选择了什么商品,就用什么商品来判断 -- |
| 2014 | + var sele_arr={}; | ||
| 2015 | + sele_arr[item]=!a.selected; | ||
| 2016 | + //回调判断活动有没有冲突 | ||
| 2017 | + this.cx_check_ok(pitems,sele_arr,function (the_res){ | ||
| 2018 | + if(the_res.code==0){ | ||
| 2019 | + th.setData({ | ||
| 2020 | + [txt]: Number(!a.selected), | ||
| 2021 | + }); | ||
| 2022 | + //要先处理了,再来判断要不要显示凑单 | ||
| 2023 | + th.doCheckAll(async function (){ | ||
| 2024 | + if (a.prom_type == 3) { | ||
| 2025 | + e.data.duo_zp_num_arr = {}; | ||
| 2026 | + if (!a.selected) { | ||
| 2027 | + await e.check_prom_activity(pitems); | ||
| 2028 | + } | ||
| 2029 | + //判断商品是不是优惠活动 | ||
| 2030 | + for (var i in e.data.requestData) { | ||
| 2031 | + if (!a.selected && i == pitems) continue; | ||
| 2032 | + await e.check_prom_activity(i); | ||
| 2033 | + } | ||
| 2034 | + } | ||
| 2035 | + | ||
| 2036 | + }); | ||
| 2037 | + }else{ | ||
| 2038 | + wx.showToast({ | ||
| 2039 | + title: the_res.msg, | ||
| 2040 | + icon: 'none', | ||
| 2041 | + }); | ||
| 2042 | + } | ||
| 2043 | + }) | ||
| 2044 | + | ||
| 2372 | } | 2045 | } |
| 2373 | }, | 2046 | }, |
| 2374 | 2047 | ||
| @@ -2459,7 +2132,7 @@ Page({ | @@ -2459,7 +2132,7 @@ Page({ | ||
| 2459 | }, | 2132 | }, |
| 2460 | 2133 | ||
| 2461 | //----------检查是否全选--------- | 2134 | //----------检查是否全选--------- |
| 2462 | - doCheckAll: function () { | 2135 | + doCheckAll:async function (func,n_ok) { |
| 2463 | var th = this, | 2136 | var th = this, |
| 2464 | tfeel = 0, | 2137 | tfeel = 0, |
| 2465 | t_num = 0, | 2138 | t_num = 0, |
| @@ -2468,100 +2141,181 @@ Page({ | @@ -2468,100 +2141,181 @@ Page({ | ||
| 2468 | car2 = this.data.service_data, | 2141 | car2 = this.data.service_data, |
| 2469 | all_num = 0; | 2142 | all_num = 0; |
| 2470 | 2143 | ||
| 2144 | + | ||
| 2145 | + //-- 如果是全部的时候,就要把它清理掉 -- | ||
| 2146 | + this.data.in_zhact_gdmap_new={}; | ||
| 2147 | + this.data.in_zhact_new={}; | ||
| 2148 | + this.data.in_yhact_new={}; | ||
| 2149 | + | ||
| 2471 | //-- 购物车 -- | 2150 | //-- 购物车 -- |
| 2472 | if (car && car.length > 0) { | 2151 | if (car && car.length > 0) { |
| 2473 | th.data.in_zhact_gdmap = {}; | 2152 | th.data.in_zhact_gdmap = {}; |
| 2153 | + | ||
| 2154 | + //-- 第一次过滤,show_can_cx的还要遍历一遍,确保数据的正确性 -- | ||
| 2155 | + var rd_arr=[]; | ||
| 2474 | for (var a = 0; a < car.length; a++) { | 2156 | for (var a = 0; a < car.length; a++) { |
| 2475 | - var item = car[a].goods, is_s_sele = 1; | ||
| 2476 | - var offline_price = 0; | ||
| 2477 | - var offline_num = 0; | ||
| 2478 | - for (var c = 0; c < item.length; c++) { | ||
| 2479 | - if (item[c].is_gift) continue; | ||
| 2480 | - all_num += item[c].goods_num; | 2157 | + var ite1=car[a].goods; |
| 2158 | + await m_cx.cart_cx_group(th,ite1,car[a],1,n_ok,(show_can_cx)=>{ | ||
| 2159 | + rd_arr.push(show_can_cx) | ||
| 2160 | + }) | ||
| 2161 | + } | ||
| 2481 | 2162 | ||
| 2482 | - //不管怎么样都要移出去 | ||
| 2483 | - var obj = JSON.parse(JSON.stringify(item[c])); | ||
| 2484 | - zh_calc.remove_zhprom(car, a, obj); | ||
| 2485 | - ladder_calc.remove_ladder_prom(car, a, obj); | 2163 | + //--- 第二次过滤 --- |
| 2164 | + for(var ui=0;ui<rd_arr.length;ui++){ | ||
| 2165 | + var is_has_no_ok=0; | ||
| 2166 | + var show_can_cx_item=rd_arr[ui]; | ||
| 2167 | + for (const per_sh_cx in show_can_cx_item) { | ||
| 2168 | + var cx_cur_act=show_can_cx_item[per_sh_cx].cur_act; //每一种活动切换的时候的当前活动 | ||
| 2169 | + var aid=cx_cur_act.prom_id; | ||
| 2170 | + //-- 就是那些活动未到达条件的时候,才需要重新过滤一遍 -- | ||
| 2171 | + if(cx_cur_act.is_no_ok) { | ||
| 2172 | + switch (cx_cur_act.prom_type){ | ||
| 2173 | + case 3: | ||
| 2174 | + if(th.data.in_yhact_new[aid]){ | ||
| 2175 | + is_has_no_ok=1; | ||
| 2176 | + } | ||
| 2177 | + break; | ||
| 2178 | + case 7: | ||
| 2179 | + if(th.data.in_zhact_new[aid]){ | ||
| 2180 | + is_has_no_ok=1; | ||
| 2181 | + } | ||
| 2182 | + break; | ||
| 2183 | + } | ||
| 2184 | + } | ||
| 2185 | + } | ||
| 2486 | 2186 | ||
| 2487 | - if (item[c].selected == 0) { | ||
| 2488 | - ischeck = 0; | ||
| 2489 | - is_s_sele = 0; | ||
| 2490 | - if (item[c].prom_type == 7) { | ||
| 2491 | - obj.goods_num = 0; | ||
| 2492 | - zh_calc.add_zhprom(car, a, obj); | 2187 | + //如果有重复就要重新计算一遍 |
| 2188 | + if(is_has_no_ok){ | ||
| 2189 | + await m_cx.cart_cx_group(th,car[ui].goods,car[ui],1,n_ok,(show_can_cx)=>{ | ||
| 2190 | + rd_arr[ui]=show_can_cx; | ||
| 2191 | + }) | ||
| 2192 | + } | ||
| 2193 | + } | ||
| 2194 | + | ||
| 2195 | + | ||
| 2196 | + | ||
| 2197 | + for (var a = 0; a < car.length; a++) { | ||
| 2198 | + //-- 把活动组装进去 --- | ||
| 2199 | + var show_can_cx=rd_arr[a]; | ||
| 2200 | + | ||
| 2201 | + car[a].zh_map=null; | ||
| 2202 | + car[a].ladder_map=null; | ||
| 2203 | + | ||
| 2204 | + | ||
| 2205 | + var item = car[a].goods, is_s_sele = 1; | ||
| 2206 | + //-- 先批量判断一下活动的类型,同时要同步跟新 -- | ||
| 2207 | + | ||
| 2208 | + var offline_price = 0; | ||
| 2209 | + var offline_num = 0; | ||
| 2210 | + for (var c = 0; c < item.length; c++) { | ||
| 2211 | + if (item[c].is_gift) continue; | ||
| 2212 | + all_num += item[c].goods_num; | ||
| 2213 | + | ||
| 2214 | + if(item[c].prom_type==7){ | ||
| 2215 | + item[c].act=th.data.zuhe_map[item[c].prom_id]; | ||
| 2493 | } | 2216 | } |
| 2494 | - if (item[c].prom_type == 10) { | ||
| 2495 | - obj.goods_num = 0; | ||
| 2496 | - ladder_calc.add_ladder_prom(car, a, obj); | 2217 | + if(item[c].prom_type==10){ |
| 2218 | + item[c].act=th.data.ladder_map[item[c].prom_id]; | ||
| 2497 | } | 2219 | } |
| 2498 | 2220 | ||
| 2221 | + //不管怎么样都要移出去 | ||
| 2222 | + var obj = JSON.parse(JSON.stringify(item[c])); | ||
| 2223 | + zh_calc.remove_zhprom(car, a, obj); | ||
| 2224 | + ladder_calc.remove_ladder_prom(car, a, obj); | ||
| 2225 | + | ||
| 2226 | + if (item[c].selected == 0) { | ||
| 2227 | + ischeck = 0; | ||
| 2228 | + is_s_sele = 0; | ||
| 2229 | + if (item[c].prom_type == 7) { | ||
| 2230 | + obj.goods_num = 0; | ||
| 2231 | + zh_calc.add_zhprom(car, a, obj); | ||
| 2232 | + } | ||
| 2233 | + | ||
| 2234 | + if (item[c].prom_type == 10) { | ||
| 2235 | + obj.goods_num = 0; | ||
| 2236 | + ladder_calc.add_ladder_prom(car, a, obj); | ||
| 2237 | + } | ||
| 2238 | + | ||
| 2499 | 2239 | ||
| 2500 | - } else { | ||
| 2501 | - if (item[c].prom_type == 7) { | ||
| 2502 | - //先把商品放入组合计算的专用的区域 | ||
| 2503 | - console.log('是组合商品---') | ||
| 2504 | - console.log(car); | ||
| 2505 | - console.log(a) | ||
| 2506 | - console.log(obj) | ||
| 2507 | - console.log('......................') | ||
| 2508 | - zh_calc.add_zhprom(car, a, obj); | ||
| 2509 | - } else if (item[c].prom_type == 10) { | ||
| 2510 | - ladder_calc.add_ladder_prom(car, a, obj); | 2240 | + } else { |
| 2241 | + | ||
| 2242 | + | ||
| 2243 | + if (item[c].prom_type == 7) { | ||
| 2244 | + //先把商品放入组合计算的专用的区域 | ||
| 2245 | + console.log('是组合商品---') | ||
| 2246 | + console.log(car); | ||
| 2247 | + console.log(a) | ||
| 2248 | + console.log(obj) | ||
| 2249 | + console.log('......................') | ||
| 2250 | + zh_calc.add_zhprom(car, a, obj); | ||
| 2251 | + } else if (item[c].prom_type == 10) { | ||
| 2252 | + ladder_calc.add_ladder_prom(car, a, obj); | ||
| 2253 | + } | ||
| 2254 | + else { | ||
| 2255 | + tfeel += item[c].goods_num * item[c].goods_price; | ||
| 2256 | + } | ||
| 2257 | + t_num += item[c].goods_num; | ||
| 2511 | } | 2258 | } |
| 2512 | - else { | ||
| 2513 | - tfeel += item[c].goods_num * item[c].goods_price; | 2259 | + |
| 2260 | + //-- 如果这个商品是线下取价的时候 -- | ||
| 2261 | + if (item[c].is_offline && item[c].prom_type != 7) { | ||
| 2262 | + offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num; | ||
| 2263 | + offline_num += item[c].goods_num; | ||
| 2514 | } | 2264 | } |
| 2515 | - t_num += item[c].goods_num; | ||
| 2516 | } | 2265 | } |
| 2517 | 2266 | ||
| 2518 | - //-- 如果这个商品是线下取价的时候 -- | ||
| 2519 | - if (item[c].is_offline && item[c].prom_type != 7) { | ||
| 2520 | - offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num; | ||
| 2521 | - offline_num += item[c].goods_num; | ||
| 2522 | - } | ||
| 2523 | - } | ||
| 2524 | - | ||
| 2525 | - //总的价格,把组合商品的价格拿出来 | ||
| 2526 | - var zh_calc_res = zh_calc.calculate_zh(car, a, th); | ||
| 2527 | - console.log('.组合价-----------') | ||
| 2528 | - console.log(zh_calc_res) | ||
| 2529 | - //总的价格,把阶梯促销商品的价格拿出来 | ||
| 2530 | - var ladder_calc_res = ladder_calc.calculate_ladder(car, a, th); | 2267 | + //总的价格,把组合商品的价格拿出来 |
| 2268 | + var zh_calc_res = zh_calc.calculate_zh(car, a, th); | ||
| 2269 | + console.log('.组合价-----------') | ||
| 2270 | + console.log(zh_calc_res) | ||
| 2271 | + //总的价格,把阶梯促销商品的价格拿出来 | ||
| 2272 | + var ladder_calc_res = ladder_calc.calculate_ladder(car, a, th); | ||
| 2531 | 2273 | ||
| 2532 | - tfeel += zh_calc_res.tfeel; | ||
| 2533 | - offline_price += zh_calc_res.offline_price; | ||
| 2534 | - offline_num += zh_calc_res.offline_num; | 2274 | + tfeel += zh_calc_res.tfeel; |
| 2275 | + offline_price += zh_calc_res.offline_price; | ||
| 2276 | + offline_num += zh_calc_res.offline_num; | ||
| 2535 | 2277 | ||
| 2536 | - tfeel += ladder_calc_res.tfeel; | ||
| 2537 | - offline_price += ladder_calc_res.offline_price; | ||
| 2538 | - offline_num += ladder_calc_res.offline_num; | 2278 | + tfeel += ladder_calc_res.tfeel; |
| 2279 | + offline_price += ladder_calc_res.offline_price; | ||
| 2280 | + offline_num += ladder_calc_res.offline_num; | ||
| 2539 | 2281 | ||
| 2540 | - var txt = "requestData[" + a + "].selected"; | ||
| 2541 | - th.setData({ | ||
| 2542 | - [txt]: Number(is_s_sele) | ||
| 2543 | - }); | 2282 | + var txt = "requestData[" + a + "].selected"; |
| 2283 | + th.setData({ | ||
| 2284 | + [txt]: Number(is_s_sele) | ||
| 2285 | + }); | ||
| 2544 | 2286 | ||
| 2545 | - //当有线下取价的时候 | ||
| 2546 | - if (offline_price) { | ||
| 2547 | - var txt1 = "requestData[" + a + "].offline_price"; | ||
| 2548 | - var txt2 = "requestData[" + a + "].offline_num"; | 2287 | + var txt1 = "requestData[" + a + "].show_can_cx"; |
| 2549 | th.setData({ | 2288 | th.setData({ |
| 2550 | - [txt1]: offline_price.toFixed(2), | ||
| 2551 | - [txt2]: offline_num, | 2289 | + [txt1]: show_can_cx |
| 2552 | }); | 2290 | }); |
| 2553 | - } else { | ||
| 2554 | - if (car[a].offline_price > 0) { | 2291 | + |
| 2292 | + //-- var et={show_can_cx:show_can_cx}; | ||
| 2293 | + //-- rd_arr.push(et); | ||
| 2294 | + | ||
| 2295 | + //当有线下取价的时候 | ||
| 2296 | + if (offline_price) { | ||
| 2555 | var txt1 = "requestData[" + a + "].offline_price"; | 2297 | var txt1 = "requestData[" + a + "].offline_price"; |
| 2556 | var txt2 = "requestData[" + a + "].offline_num"; | 2298 | var txt2 = "requestData[" + a + "].offline_num"; |
| 2557 | th.setData({ | 2299 | th.setData({ |
| 2558 | - [txt1]: 0, | ||
| 2559 | - [txt2]: 0 | 2300 | + [txt1]: offline_price.toFixed(2), |
| 2301 | + [txt2]: offline_num, | ||
| 2560 | }); | 2302 | }); |
| 2303 | + } else { | ||
| 2304 | + if (car[a].offline_price > 0) { | ||
| 2305 | + var txt1 = "requestData[" + a + "].offline_price"; | ||
| 2306 | + var txt2 = "requestData[" + a + "].offline_num"; | ||
| 2307 | + th.setData({ | ||
| 2308 | + [txt1]: 0, | ||
| 2309 | + [txt2]: 0 | ||
| 2310 | + }); | ||
| 2311 | + } | ||
| 2561 | } | 2312 | } |
| 2562 | - } | ||
| 2563 | - | ||
| 2564 | } | 2313 | } |
| 2314 | + | ||
| 2315 | + | ||
| 2316 | + //-- 切换活动的按钮要把他返回 -- | ||
| 2317 | + this.data.change_act=0; | ||
| 2318 | + if(func) func(); | ||
| 2565 | } | 2319 | } |
| 2566 | 2320 | ||
| 2567 | //-- 服务卡 -- | 2321 | //-- 服务卡 -- |
| @@ -2583,7 +2337,6 @@ Page({ | @@ -2583,7 +2337,6 @@ Page({ | ||
| 2583 | } | 2337 | } |
| 2584 | 2338 | ||
| 2585 | } | 2339 | } |
| 2586 | - | ||
| 2587 | var txt = "service_data[" + a + "].selected"; | 2340 | var txt = "service_data[" + a + "].selected"; |
| 2588 | th.setData({ | 2341 | th.setData({ |
| 2589 | [txt]: Number(is_s_sele) | 2342 | [txt]: Number(is_s_sele) |
| @@ -2598,53 +2351,6 @@ Page({ | @@ -2598,53 +2351,6 @@ Page({ | ||
| 2598 | total_num: t_num | 2351 | total_num: t_num |
| 2599 | }); | 2352 | }); |
| 2600 | }, | 2353 | }, |
| 2601 | - | ||
| 2602 | - //-- 循环汇总其他门店,其他活动有此商品的购买数量的汇总,不包含赠品 -- | ||
| 2603 | - get_goods_other(item, pitem,only){ | ||
| 2604 | - var goods_id = this.data.requestData[pitem].goods[item].goods_id; | ||
| 2605 | - var prom_type = this.data.requestData[pitem].goods[item].prom_type; | ||
| 2606 | - var prom_id = this.data.requestData[pitem].goods[item].prom_id; | ||
| 2607 | - | ||
| 2608 | - var num=0; | ||
| 2609 | - //-- 相同活动的商品汇总,秒杀,团购 -- | ||
| 2610 | - if(only==2){ | ||
| 2611 | - for (let j = 0; j < this.data.requestData.length;j++){ | ||
| 2612 | - if(j!=pitem){ | ||
| 2613 | - var goods=this.data.requestData[j].goods; | ||
| 2614 | - for (let k = 0; k <goods.length ; k++) { | ||
| 2615 | - var m_item=goods[k]; | ||
| 2616 | - if(m_item.goods_id==goods_id && m_item.is_gift==0 | ||
| 2617 | - && m_item.prom_id==prom_id && m_item.prom_type==prom_type ){ | ||
| 2618 | - num+=m_item.goods_num | ||
| 2619 | - } | ||
| 2620 | - } | ||
| 2621 | - } | ||
| 2622 | - } | ||
| 2623 | - return num; | ||
| 2624 | - } | ||
| 2625 | - | ||
| 2626 | - for (let i = 0; i < this.data.requestData[pitem].goods.length; i++) { | ||
| 2627 | - var t_item=this.data.requestData[pitem].goods[i] | ||
| 2628 | - if(i!=item && t_item.goods_id==goods_id && t_item.is_gift==0){ | ||
| 2629 | - num+=t_item.goods_num | ||
| 2630 | - } | ||
| 2631 | - } | ||
| 2632 | - if(only) return num; | ||
| 2633 | - for (let j = 0; j < this.data.requestData.length;j++){ | ||
| 2634 | - if(j!=pitem){ | ||
| 2635 | - var goods=this.data.requestData[j].goods; | ||
| 2636 | - for (let k = 0; k <goods.length ; k++) { | ||
| 2637 | - var m_item=goods[k]; | ||
| 2638 | - if(m_item.goods_id==goods_id && m_item.is_gift==0){ | ||
| 2639 | - num+=m_item.goods_num | ||
| 2640 | - } | ||
| 2641 | - } | ||
| 2642 | - } | ||
| 2643 | - } | ||
| 2644 | - | ||
| 2645 | - return num; | ||
| 2646 | - }, | ||
| 2647 | - | ||
| 2648 | //----------------------更新购物数量,加减,调用接口--------------------- | 2354 | //----------------------更新购物数量,加减,调用接口--------------------- |
| 2649 | postCardList: function (t, item, pitem) { | 2355 | postCardList: function (t, item, pitem) { |
| 2650 | var e = this,th = e,user_id = getApp().globalData.user_id; | 2356 | var e = this,th = e,user_id = getApp().globalData.user_id; |
| @@ -3192,8 +2898,6 @@ Page({ | @@ -3192,8 +2898,6 @@ Page({ | ||
| 3192 | } | 2898 | } |
| 3193 | }, | 2899 | }, |
| 3194 | 2900 | ||
| 3195 | - | ||
| 3196 | - | ||
| 3197 | //---检验线下库存的数量--- | 2901 | //---检验线下库存的数量--- |
| 3198 | async check_down_line(t, pitem, item, erpwareid) { | 2902 | async check_down_line(t, pitem, item, erpwareid) { |
| 3199 | var ob = {}, | 2903 | var ob = {}, |
| @@ -3446,6 +3150,30 @@ Page({ | @@ -3446,6 +3150,30 @@ Page({ | ||
| 3446 | if (i_arr[j].is_pd_normal || i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3) { | 3150 | if (i_arr[j].is_pd_normal || i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3) { |
| 3447 | normal_arr[i_arr[j].goods_id] = 1; | 3151 | normal_arr[i_arr[j].goods_id] = 1; |
| 3448 | } | 3152 | } |
| 3153 | + | ||
| 3154 | + //检查活动是不是满足了条件,或者要取满足条件的活动 | ||
| 3155 | + var fd1=null; | ||
| 3156 | + if(this.data.requestData[i].show_can_cx && (i_arr[j].prom_type == 3 || i_arr[j].prom_type == 7) ){ | ||
| 3157 | + for(var ik in this.data.requestData[i].show_can_cx){ | ||
| 3158 | + var ch_map=this.data.requestData[i].show_can_cx[ik].ch_map; | ||
| 3159 | + if(ch_map.indexOf(i_arr[j].goods_id)==-1) continue; | ||
| 3160 | + | ||
| 3161 | + var item_arr=this.data.requestData[i].show_can_cx[ik].act_arr; | ||
| 3162 | + fd1=item_arr.find(function (hb){ | ||
| 3163 | + return !hb.is_no_ok; | ||
| 3164 | + }) | ||
| 3165 | + if(fd1) break; | ||
| 3166 | + } | ||
| 3167 | + if(!fd1){ | ||
| 3168 | + i_arr[j].prom_id=0; | ||
| 3169 | + i_arr[j].prom_type=0; | ||
| 3170 | + }else{ | ||
| 3171 | + i_arr[j].prom_id=fd1.prom_id; | ||
| 3172 | + i_arr[j].prom_type=fd1.prom_type; | ||
| 3173 | + } | ||
| 3174 | + } | ||
| 3175 | + | ||
| 3176 | + | ||
| 3449 | if (i_arr[j].prom_type == 7 && (!this.data.requestData[i].need_list || (this.data.requestData[i].need_list && this.data.requestData[i].need_list.length == 0)) && i_arr[j].act && i_arr[j].act.buy_limit != 0) { | 3177 | if (i_arr[j].prom_type == 7 && (!this.data.requestData[i].need_list || (this.data.requestData[i].need_list && this.data.requestData[i].need_list.length == 0)) && i_arr[j].act && i_arr[j].act.buy_limit != 0) { |
| 3450 | let userbuynum = await this.getUserBuyPromNum(i_arr[j].goods_prom_id) | 3178 | let userbuynum = await this.getUserBuyPromNum(i_arr[j].goods_prom_id) |
| 3451 | console.log('活动次数:' + userbuynum); | 3179 | console.log('活动次数:' + userbuynum); |
| @@ -3467,6 +3195,8 @@ Page({ | @@ -3467,6 +3195,8 @@ Page({ | ||
| 3467 | goods_id: i_arr[j].goods_id, | 3195 | goods_id: i_arr[j].goods_id, |
| 3468 | id: i_arr[j].id, | 3196 | id: i_arr[j].id, |
| 3469 | goods_price: i_arr[j].goods_price, | 3197 | goods_price: i_arr[j].goods_price, |
| 3198 | + prom_id:i_arr[j].prom_id, | ||
| 3199 | + prom_type:i_arr[j].prom_type, | ||
| 3470 | }; | 3200 | }; |
| 3471 | //判断是不是线下取价 | 3201 | //判断是不是线下取价 |
| 3472 | if (i_arr[j].is_offline) { | 3202 | if (i_arr[j].is_offline) { |
| @@ -3789,7 +3519,9 @@ Page({ | @@ -3789,7 +3519,9 @@ Page({ | ||
| 3789 | var data = { | 3519 | var data = { |
| 3790 | id: g_arr[i].id, | 3520 | id: g_arr[i].id, |
| 3791 | selected: 1, | 3521 | selected: 1, |
| 3792 | - store_id: oo.stoid | 3522 | + store_id: oo.stoid, |
| 3523 | + prom_type:g_arr[i].prom_type, | ||
| 3524 | + prom_id:g_arr[i].prom_id, | ||
| 3793 | }; | 3525 | }; |
| 3794 | let gitem = checkArr7.find(item => item.goods_id == g_arr[i].goods_id) | 3526 | let gitem = checkArr7.find(item => item.goods_id == g_arr[i].goods_id) |
| 3795 | if (gitem) { | 3527 | if (gitem) { |
| @@ -3819,6 +3551,8 @@ Page({ | @@ -3819,6 +3551,8 @@ Page({ | ||
| 3819 | wx.hideLoading(); | 3551 | wx.hideLoading(); |
| 3820 | return false; | 3552 | return false; |
| 3821 | } | 3553 | } |
| 3554 | + | ||
| 3555 | + | ||
| 3822 | wx.hideLoading(); | 3556 | wx.hideLoading(); |
| 3823 | wx.navigateTo({ | 3557 | wx.navigateTo({ |
| 3824 | url: "/packageE/pages/cart/cart2/cart2" | 3558 | url: "/packageE/pages/cart/cart2/cart2" |
| @@ -3979,7 +3713,9 @@ Page({ | @@ -3979,7 +3713,9 @@ Page({ | ||
| 3979 | var data = { | 3713 | var data = { |
| 3980 | id: g_arr[i].id, | 3714 | id: g_arr[i].id, |
| 3981 | selected: 1, | 3715 | selected: 1, |
| 3982 | - store_id: oo.stoid | 3716 | + store_id: oo.stoid, |
| 3717 | + prom_type:g_arr[i].prom_type, | ||
| 3718 | + prom_id:g_arr[i].prom_id, | ||
| 3983 | }; | 3719 | }; |
| 3984 | 3720 | ||
| 3985 | //-- 如果有线下取价的时候 -- | 3721 | //-- 如果有线下取价的时候 -- |
| @@ -4904,6 +4640,224 @@ Page({ | @@ -4904,6 +4640,224 @@ Page({ | ||
| 4904 | icon: 'none', | 4640 | icon: 'none', |
| 4905 | duration: 2000 | 4641 | duration: 2000 |
| 4906 | }); | 4642 | }); |
| 4643 | + }, | ||
| 4644 | + | ||
| 4645 | + | ||
| 4646 | + | ||
| 4647 | + //-- 开始显示活动的弹出 -- | ||
| 4648 | + switch_cx_group:function (e){ | ||
| 4649 | + var idx=e.currentTarget.dataset.index; | ||
| 4650 | + var gd_key=e.currentTarget.dataset.gd_key; | ||
| 4651 | + this.data.sele_cx_group_cidx=idx; | ||
| 4652 | + this.data.cx_group_gd_key=gd_key; | ||
| 4653 | + //-- 获取到-- | ||
| 4654 | + var cx_prom_group=this.data.requestData[idx].show_can_cx[gd_key].act_arr; | ||
| 4655 | + | ||
| 4656 | + var cx_arr=[]; | ||
| 4657 | + var find_sele=0; | ||
| 4658 | + for (var h=0;h<cx_prom_group.length;h++){ | ||
| 4659 | + //-- 看有没有选中的活动 -- | ||
| 4660 | + if(cx_prom_group[h].sele){ | ||
| 4661 | + find_sele=1; | ||
| 4662 | + cx_prom_group[h].act.sele=1; | ||
| 4663 | + }else{ | ||
| 4664 | + cx_prom_group[h].act.sele=0; | ||
| 4665 | + } | ||
| 4666 | + cx_arr.push(cx_prom_group[h].act); | ||
| 4667 | + } | ||
| 4668 | + //-- 如果没有,就默认第一个为选中 -- | ||
| 4669 | + //-- if(!find_sele) cx_arr[0].sele=1; -- | ||
| 4670 | + var cp_arr=JSON.parse(JSON.stringify(cx_arr)); | ||
| 4671 | + var pro_pop = this.selectComponent("#pro_pop"); //组件的id | ||
| 4672 | + pro_pop.set_init(1,cp_arr,1); | ||
| 4673 | + }, | ||
| 4674 | + | ||
| 4675 | + //--- 选择回来时候的选择 --- | ||
| 4676 | + sure_cx_group:function(e){ | ||
| 4677 | + var th=this; | ||
| 4678 | + var sele_idx=e.detail.sele_idx; | ||
| 4679 | + var idx=this.data.sele_cx_group_cidx; | ||
| 4680 | + var gd_key= this.data.cx_group_gd_key; | ||
| 4681 | + //-- 获取到-- | ||
| 4682 | + var cx_prom_group=this.data.requestData[idx].show_can_cx[gd_key].act_arr; | ||
| 4683 | + | ||
| 4684 | + var fir_sele=0; | ||
| 4685 | + | ||
| 4686 | + for(var dx=0;dx<cx_prom_group.length;dx++){ | ||
| 4687 | + if(cx_prom_group[dx].sele) fir_sele=dx; | ||
| 4688 | + if(dx!=sele_idx) cx_prom_group[dx].sele=0; | ||
| 4689 | + else cx_prom_group[dx].sele=1; | ||
| 4690 | + } | ||
| 4691 | + | ||
| 4692 | + this.cx_check_ok2(async function (the_rs){ | ||
| 4693 | + if(the_rs.code==0){ | ||
| 4694 | + th.data.change_act=1; | ||
| 4695 | + | ||
| 4696 | + | ||
| 4697 | + th.doCheckAll(async function (){ | ||
| 4698 | + for (var i in th.data.requestData) { | ||
| 4699 | + await th.check_prom_activity(i) | ||
| 4700 | + } | ||
| 4701 | + }); | ||
| 4702 | + | ||
| 4703 | + }else{ | ||
| 4704 | + wx.showToast({ | ||
| 4705 | + title: the_rs.msg, | ||
| 4706 | + icon: 'none', | ||
| 4707 | + duration:2500 | ||
| 4708 | + }); | ||
| 4709 | + | ||
| 4710 | + for(var dx=0;dx<cx_prom_group.length;dx++){ | ||
| 4711 | + if(dx!=fir_sele) cx_prom_group[dx].sele=0; | ||
| 4712 | + else cx_prom_group[dx].sele=1; | ||
| 4713 | + } | ||
| 4714 | + | ||
| 4715 | + } | ||
| 4716 | + }) | ||
| 4717 | + | ||
| 4718 | + }, | ||
| 4719 | + | ||
| 4720 | + //--- 在点击商品和或者门店的时候调用,c_idx是购物车下标序号--- | ||
| 4721 | + async cx_check_ok(c_idx,sele_arr,func){ | ||
| 4722 | + | ||
| 4723 | + var th=this; | ||
| 4724 | + var car =JSON.parse(JSON.stringify(this.data.requestData)); | ||
| 4725 | + var item = car[c_idx].goods, is_s_sele = 1; | ||
| 4726 | + | ||
| 4727 | + var is_has_other=0; | ||
| 4728 | + for(var ii=0;ii<car.length;ii++){ | ||
| 4729 | + if(c_idx==ii) continue; | ||
| 4730 | + if(car[ii].show_can_cx && Object.keys(car[ii].show_can_cx).length){ | ||
| 4731 | + is_has_other=1; break; | ||
| 4732 | + } | ||
| 4733 | + } | ||
| 4734 | + | ||
| 4735 | + //其他门店并没有选择 | ||
| 4736 | + if(!is_has_other){ | ||
| 4737 | + func({'code': 0, 'msg': '成功'}); | ||
| 4738 | + return false; | ||
| 4739 | + } | ||
| 4740 | + //-- 让选择进入对应 -- | ||
| 4741 | + for(var i=0;i<item.length;i++){ | ||
| 4742 | + if(sele_arr.hasOwnProperty(i)){ | ||
| 4743 | + item[i].selected=sele_arr[i]; | ||
| 4744 | + } | ||
| 4745 | + } | ||
| 4746 | + //-- 先批量判断一下活动的类型,同时要同步跟新 -- | ||
| 4747 | + m_cx.cart_cx_group(this,item,car[c_idx],0,0,(show_can_cx)=>{ | ||
| 4748 | + car[c_idx].show_can_cx=show_can_cx; | ||
| 4749 | + th.cx_check_ok2(func,car); | ||
| 4750 | + }); | ||
| 4751 | + | ||
| 4752 | + }, | ||
| 4753 | + | ||
| 4754 | + //--- 在点击商品和或者门店的时候调用,这个可以在活动切换的时候调用,也可以被单个选择调用--- | ||
| 4755 | + async cx_check_ok2(func,car) { | ||
| 4756 | + | ||
| 4757 | + //如果购物车没有带入,要进行赋值 | ||
| 4758 | + if(!car) { | ||
| 4759 | + car = JSON.parse(JSON.stringify(this.data.requestData)); | ||
| 4760 | + } | ||
| 4761 | + | ||
| 4762 | + var nei_in_zhact_gdmap = {}; | ||
| 4763 | + var nei_in_zhact = {}; | ||
| 4764 | + var nei_in_yhact = {}; | ||
| 4765 | + for (var i = 0; i < car.length; i++) { | ||
| 4766 | + var show_can_cx = car[i].show_can_cx; | ||
| 4767 | + for (var j in show_can_cx) { | ||
| 4768 | + var sele_act = show_can_cx[j].act_arr.find(function (m) { | ||
| 4769 | + return m.sele == 1; | ||
| 4770 | + }) | ||
| 4771 | + | ||
| 4772 | + if (!sele_act) continue; | ||
| 4773 | + var pid = sele_act['prom_id']; | ||
| 4774 | + if (sele_act['prom_type'] == 3) { | ||
| 4775 | + if(!nei_in_yhact[pid]) nei_in_yhact[pid] = 0; | ||
| 4776 | + nei_in_yhact[pid]++; | ||
| 4777 | + } | ||
| 4778 | + if (sele_act['prom_type'] == 7) { | ||
| 4779 | + if(!nei_in_zhact[pid]) nei_in_zhact[pid] = 0; | ||
| 4780 | + nei_in_zhact[pid] += sele_act['act_num']; | ||
| 4781 | + } | ||
| 4782 | + var in_zhact_gdmap1 = sele_act['in_zhact_gdmap']; | ||
| 4783 | + for (var vg in in_zhact_gdmap1) { | ||
| 4784 | + if (!nei_in_zhact_gdmap[vg]) nei_in_zhact_gdmap[vg] = 0; | ||
| 4785 | + nei_in_zhact_gdmap[vg] += in_zhact_gdmap1[vg]; | ||
| 4786 | + } | ||
| 4787 | + } | ||
| 4788 | + } | ||
| 4789 | + | ||
| 4790 | + //-- 判断优惠促销是不是超出限购 -- | ||
| 4791 | + if (nei_in_yhact && Object.keys(nei_in_yhact).length) { | ||
| 4792 | + for (var ky0 in nei_in_yhact) { | ||
| 4793 | + var num = nei_in_yhact[ky0]; | ||
| 4794 | + | ||
| 4795 | + var fd=null; | ||
| 4796 | + var fd_res = await getApp().request.promiseGet('/api/weshop/promgoods/get/'+os.stoid+'/'+ky0,{}) | ||
| 4797 | + if(fd_res && fd_res.data.code==0 ){ | ||
| 4798 | + fd=fd_res.data.data; | ||
| 4799 | + } | ||
| 4800 | + if (fd && fd['limit_num'] > 0 && num > fd['limit_num']) { | ||
| 4801 | + func({'code': -1, 'msg': '超出优惠促销活动的限购'}); | ||
| 4802 | + return false; | ||
| 4803 | + } | ||
| 4804 | + } | ||
| 4805 | + } | ||
| 4806 | + | ||
| 4807 | + //-- 判断组合促销是不是超出活动总数量 -- | ||
| 4808 | + if (nei_in_zhact && Object.keys(nei_in_zhact).length) { | ||
| 4809 | + for (var ky in nei_in_zhact) { | ||
| 4810 | + | ||
| 4811 | + var num0 = nei_in_zhact[ky]; | ||
| 4812 | + var zh = this.data.zuhe_map[ky]; | ||
| 4813 | + var buyed=0; | ||
| 4814 | + | ||
| 4815 | + //获取已经购买了多少件 | ||
| 4816 | + var z_url = "/api/weshop/ordergoods/getUserBuyPromNum?store_id="+os.stoid+"user_id="+getApp().globalData.user_id+"prom_type=7&prom_id="+ky; | ||
| 4817 | + var zbuy=await getApp().request.promiseGet(z_url,{}); | ||
| 4818 | + if(zbuy && zbuy.data.code==0){ | ||
| 4819 | + buyed=zbuy.data.data.userbuynum; | ||
| 4820 | + } | ||
| 4821 | + if (zh['zh_num'] > 0 && zh['zh_buy_num'] + num0 > zh['zh_num']) { | ||
| 4822 | + func({'code': -1, 'msg': '超出组合购活动总数量'}); | ||
| 4823 | + return false; | ||
| 4824 | + } | ||
| 4825 | + } | ||
| 4826 | + } | ||
| 4827 | + | ||
| 4828 | + //-- 判断组合促销是不是超出活动总数量 -- | ||
| 4829 | + if (nei_in_zhact_gdmap && Object.keys(nei_in_zhact_gdmap).length) { | ||
| 4830 | + for (var key in nei_in_zhact_gdmap) { | ||
| 4831 | + | ||
| 4832 | + var num1 = nei_in_zhact_gdmap[key]; | ||
| 4833 | + var key_a = key.split('.'); | ||
| 4834 | + var gid = key_a[0]; | ||
| 4835 | + var pid = key_a[1]; | ||
| 4836 | + | ||
| 4837 | + //-- 商品的限购 -- | ||
| 4838 | + var promgoodsbuynum = 0; | ||
| 4839 | + var rq = { | ||
| 4840 | + 'store_id': os.stoid, 'user_id': getApp().globalData.user_id, 'goods_id': gid, | ||
| 4841 | + 'prom_type': 7, 'prom_id': pid | ||
| 4842 | + }; | ||
| 4843 | + | ||
| 4844 | + var res = await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {data: rq}); | ||
| 4845 | + if (res && res.data.code == 0) { | ||
| 4846 | + promgoodsbuynum = res.data.data.promgoodsbuynum; | ||
| 4847 | + } | ||
| 4848 | + | ||
| 4849 | + var gdlist_arr = this.data.zuhe_map_good[pid]; | ||
| 4850 | + var gdlist = gdlist_arr.find(function (e) { | ||
| 4851 | + return e.goods_id == gid; | ||
| 4852 | + }) | ||
| 4853 | + if (gdlist['buyqty'] > 0 && num1 + promgoodsbuynum > gdlist['buyqty']) { | ||
| 4854 | + func({'code': -1, 'msg': '超出组合购商品的限购'}); | ||
| 4855 | + return false; | ||
| 4856 | + } | ||
| 4857 | + } | ||
| 4858 | + } | ||
| 4859 | + func({'code': 0, 'msg': '成功'}) | ||
| 4907 | } | 4860 | } |
| 4908 | 4861 | ||
| 4862 | + | ||
| 4909 | }); | 4863 | }); |
| 4910 | \ No newline at end of file | 4864 | \ No newline at end of file |
pages/cart/cart/cart.json
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | "navigationBarTitleText": "购物车", | 2 | "navigationBarTitleText": "购物车", |
| 3 | "usingComponents": { | 3 | "usingComponents": { |
| 4 | "warn": "/components/long_warn/long_warn", | 4 | "warn": "/components/long_warn/long_warn", |
| 5 | - "goods_recommend":"/components/goods_list/goods_list" | 5 | + "goods_recommend":"/components/goods_list/goods_list", |
| 6 | + "pro_pop": "/components/promate_pop/promate_pop" | ||
| 6 | } | 7 | } |
| 7 | } | 8 | } |
| 8 | \ No newline at end of file | 9 | \ No newline at end of file |
pages/cart/cart/cart.wxml
| 1 | +<!-- 促销弹出框 --> | ||
| 2 | +<pro_pop id="pro_pop" bind:sure_cx_group="sure_cx_group"></pro_pop> | ||
| 3 | + | ||
| 1 | <wxs module="g_filter" src="g_filter.wxs"></wxs> | 4 | <wxs module="g_filter" src="g_filter.wxs"></wxs> |
| 2 | 5 | ||
| 3 | <block wx:if="{{ad_data}}"> | 6 | <block wx:if="{{ad_data}}"> |
| @@ -38,7 +41,7 @@ | @@ -38,7 +41,7 @@ | ||
| 38 | 41 | ||
| 39 | <!-- 商品的列表 --> | 42 | <!-- 商品的列表 --> |
| 40 | <block wx:if="{{requestData && requestData.length>0}}"> | 43 | <block wx:if="{{requestData && requestData.length>0}}"> |
| 41 | - <block wx:for="{{requestData}}" wx:key="{{index}}" wx:for-index="pidx"> | 44 | + <block wx:for="{{requestData}}" wx:key="{{pidx}}" wx:for-item="item" wx:for-index="pidx"> |
| 42 | <!-- 门店底下的商品 --> | 45 | <!-- 门店底下的商品 --> |
| 43 | <view class="store"> | 46 | <view class="store"> |
| 44 | <view class="shmd_m"> | 47 | <view class="shmd_m"> |
| @@ -54,80 +57,138 @@ | @@ -54,80 +57,138 @@ | ||
| 54 | </view> | 57 | </view> |
| 55 | 58 | ||
| 56 | </view> | 59 | </view> |
| 57 | - <view class="order-item" data-item="{{idx}}" wx:for="{{item.goods}}" wx:for-item="items" wx:for-index="idx" wx:key="{{index}}"> | ||
| 58 | - <block wx:if="{{!items.is_gift}}"> | ||
| 59 | - <view bindtap="check_th_item" class="order-raido flex-vertical " data-check="{{items.selected}}" data-item="{{idx}}" data-pitems="{{pidx}}"> | ||
| 60 | - <!--<radio color="red" checked="{{checkAllToggle||items.selected}}"></radio>--> | ||
| 61 | - <icon wx:if="{{checkAllToggle||items.selected}}" color="red" size="20" type="success"></icon> | ||
| 62 | - <text wx:else class="icon_no_sele"></text> | ||
| 63 | - </view> | ||
| 64 | - </block> | ||
| 65 | - <block wx:else><view class="order-raido flex-vertical " style="width: 45rpx"></view></block> | ||
| 66 | - | ||
| 67 | - <navigator class="goods-img rel" bindtap="go_gd" data-item="{{items}}" data-gd="{{items.goods_id}}"> | ||
| 68 | - <image class="wh100" src="{{items.original_img}}" binderror="bind_bnerr2" data-errorimg="requestData[{{pidx}}].goods[{{idx}}].original_img" data-url="{{items.original_img}}"></image> | ||
| 69 | - <block wx:if="{{items.is_gift}}"> | ||
| 70 | - <view style="background-color:red" class="abs flex-center fs26" wx:if="{{items.is_gift==1}}">赠品</view> | ||
| 71 | - </block> | ||
| 72 | - <block wx:else> | ||
| 73 | - <view class="abs flex-center fs26" wx:if="{{items.distr_type==0}}">自选</view> | ||
| 74 | - <view class="abs flex-center fs26" wx:if="{{items.distr_type==1}}">自提</view> | ||
| 75 | - <view class="abs flex-center fs26" wx:if="{{items.distr_type==2}}">物流</view> | ||
| 76 | - </block> | ||
| 77 | 60 | ||
| 78 | - <block wx:if="{{items.prom_type==7}}"> | ||
| 79 | - <block wx:if="{{items.selected}}"> | ||
| 80 | - <!-- 主要显示限购 --> | ||
| 81 | - <text wx:if="{{items.zhqty>items.goods_num}}" class="abs2">还需购买{{items.zhqty-items.goods_num}}件</text> | ||
| 82 | - </block> | ||
| 83 | - <block wx:else> | ||
| 84 | - <text wx:if="{{items.zhqty}}" class="abs2">需购买{{items.zhqty}}件</text> | 61 | + <block wx:for="{{item.goods}}" wx:for-item="items" wx:for-index="idx" wx:key="{{idx}}"> |
| 62 | + <view class="order-item" data-item="{{idx}}"> | ||
| 63 | + <block wx:if="{{!items.is_gift}}"> | ||
| 64 | + <view bindtap="check_th_item" class="order-raido flex-vertical " data-check="{{items.selected}}" data-item="{{idx}}" data-pitems="{{pidx}}"> | ||
| 65 | + <!--<radio color="red" checked="{{checkAllToggle||items.selected}}"></radio>--> | ||
| 66 | + <icon wx:if="{{checkAllToggle||items.selected}}" color="red" size="20" type="success"></icon> | ||
| 67 | + <text wx:else class="icon_no_sele"></text> | ||
| 68 | + </view> | ||
| 85 | </block> | 69 | </block> |
| 86 | - </block> | 70 | + <block wx:else><view class="order-raido flex-vertical " style="width: 45rpx"></view></block> |
| 71 | + | ||
| 72 | + <navigator class="goods-img rel" bindtap="go_gd" data-item="{{items}}" data-gd="{{items.goods_id}}"> | ||
| 73 | + <image class="wh100" src="{{items.original_img}}" binderror="bind_bnerr2" data-errorimg="requestData[{{pidx}}].goods[{{idx}}].original_img" data-url="{{items.original_img}}"></image> | ||
| 74 | + <block wx:if="{{items.is_gift}}"> | ||
| 75 | + <view style="background-color:red" class="abs flex-center fs26" wx:if="{{items.is_gift==1}}">赠品</view> | ||
| 76 | + </block> | ||
| 77 | + <block wx:else> | ||
| 78 | + <view class="abs flex-center fs26" wx:if="{{items.distr_type==0}}">自选</view> | ||
| 79 | + <view class="abs flex-center fs26" wx:if="{{items.distr_type==1}}">自提</view> | ||
| 80 | + <view class="abs flex-center fs26" wx:if="{{items.distr_type==2}}">物流</view> | ||
| 81 | + </block> | ||
| 82 | + | ||
| 83 | + <block wx:if="{{items.prom_type==7}}"> | ||
| 84 | + <block wx:if="{{items.selected}}"> | ||
| 85 | + <!-- 主要显示限购 --> | ||
| 86 | + <text wx:if="{{items.zhqty>items.goods_num}}" class="abs2">还需购买{{items.zhqty-items.goods_num}}件</text> | ||
| 87 | + </block> | ||
| 88 | + <block wx:else> | ||
| 89 | + <text wx:if="{{items.zhqty}}" class="abs2">需购买{{items.zhqty}}件</text> | ||
| 90 | + </block> | ||
| 91 | + </block> | ||
| 92 | + | ||
| 93 | + | ||
| 94 | + </navigator> | ||
| 95 | + <view class="goods-cont"> | ||
| 96 | + <view class="goods-name"> | ||
| 97 | + <navigator bindtap="go_gd" class="ellipsis-2 fs30" data-item="{{items}}" data-gd="{{items.goods_id}}">{{items.goods_name}}</navigator> | ||
| 98 | + | ||
| 99 | + <view class="specifications ellipsis-1"> | ||
| 100 | + <view wx:if="{{items.goods_color || items.goods_spec}}"> | ||
| 101 | + {{items.goods_color}}{{items.goods_color?"/":''}}{{items.goods_spec}}</view> | ||
| 102 | + <view wx:else>规格1</view> | ||
| 103 | + </view> | ||
| 104 | + <block wx:if="{{items.is_gift}}"> | ||
| 105 | + <view>{{items.goods_num}}件</view> | ||
| 106 | + </block> | ||
| 107 | + <view wx:if="{{items.buyqty>0}}" class="fs22 ml10 c-7b">组合限购{{items.buyqty}}件</view> | ||
| 108 | + </view> | ||
| 87 | 109 | ||
| 88 | 110 | ||
| 89 | - </navigator> | ||
| 90 | - <view class="goods-cont"> | ||
| 91 | - <view class="goods-name"> | ||
| 92 | - <navigator bindtap="go_gd" class="ellipsis-2 fs30" data-item="{{items}}" data-gd="{{items.goods_id}}">{{items.goods_name}}</navigator> | 111 | + <block wx:if="{{!items.is_gift}}"> |
| 112 | + <view class="flex alend jc_sb"> | ||
| 113 | + <view class="goods-price co-red baseline ellipsis-1"> | ||
| 114 | + <view class="fs20">¥</view> | ||
| 115 | + <view class="fs28">{{items.goods_price}}</view> | ||
| 93 | 116 | ||
| 94 | - <view class="specifications ellipsis-1"> | ||
| 95 | - <view wx:if="{{items.goods_color || items.goods_spec}}"> | ||
| 96 | - {{items.goods_color}}{{items.goods_color?"/":''}}{{items.goods_spec}}</view> | ||
| 97 | - <view wx:else>规格1</view> | ||
| 98 | - </view> | ||
| 99 | - <block wx:if="{{items.is_gift}}"> | ||
| 100 | - <view>{{items.goods_num}}件</view> | ||
| 101 | - </block> | ||
| 102 | - <view wx:if="{{items.buyqty>0}}" class="fs22 ml10 c-7b">组合限购{{items.buyqty}}件</view> | 117 | + <view wx:if="{{items.is_offline}}" class="quan_color flex ai-center"><text>券后 ¥{{g_filter.toFix(items.offline_price,2)}}</text></view> |
| 118 | + | ||
| 119 | + | ||
| 120 | + </view> | ||
| 121 | + <view class="count"> | ||
| 122 | + <view bindtap="{{items.goods_num <= 1 ? '':'subNum'}}" class="sub fs28 {{items.goods_num <= 1 ? 'active':''}}" data-pitems="{{pidx}}" data-item="{{idx}}">一</view> | ||
| 123 | + <input class="goodadd" bindblur="valueToNum" data-pitems="{{pidx}}" data-item="{{idx}}" | ||
| 124 | + bindinput="refresh_input" type="number" value="{{items.goods_num}}"></input> | ||
| 125 | + <view class="add" bindtap="addNum" data-pitems="{{pidx}}" data-item="{{idx}}">+</view> | ||
| 126 | + </view> | ||
| 127 | + </view> | ||
| 128 | + </block> | ||
| 129 | + </view> | ||
| 103 | </view> | 130 | </view> |
| 104 | 131 | ||
| 105 | 132 | ||
| 106 | - <block wx:if="{{!items.is_gift}}"> | ||
| 107 | - <view class="flex alend jc_sb"> | ||
| 108 | - <view class="goods-price co-red baseline ellipsis-1"> | ||
| 109 | - <view class="fs20">¥</view> | ||
| 110 | - <view class="fs28">{{items.goods_price}}</view> | 133 | + <!-- 验证活动是不是多个,要不要显示切换 --> |
| 134 | + <!-- 新增促销多活动的排版 --> | ||
| 135 | + <block wx:if="{{g_filter.is_more_act(items,item.show_can_cx) && item.show_can_cx[items.goods_id] && item.show_can_cx[items.goods_id].act_arr.length>1}}"> | ||
| 136 | + <view class="bdb16"> | ||
| 137 | + <view bindtap="switch_cx_group" | ||
| 138 | + data-index="{{pidx}}" | ||
| 139 | + data-gd_key="{{items.goods_id}}" | ||
| 140 | + class="cx-frame flex" style="position: relative"> | ||
| 141 | + <view class="cx-sizs fs30">可参促销</view> | ||
| 142 | + <view class="flex ai_c f1 pdh20"> | ||
| 143 | + <view class="xc-coupon-fram" wx:for="{{item.show_can_cx[items.goods_id].act_arr}}" > | ||
| 144 | + <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word">优惠促销</view> | ||
| 145 | + <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word">搭配促销</view> | ||
| 146 | + <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word">组合购</view> | ||
| 147 | + <view wx:if="{{item.prom_type==10}}" class="xc-coupon t-c four-level-word">阶梯促销</view> | ||
| 148 | + </view> | ||
| 149 | + </view> | ||
| 150 | + <view class="cx-obtain-coupon wsize"> | ||
| 151 | + <text class="bg_jj"></text> | ||
| 152 | + </view> | ||
| 153 | + </view> | ||
| 154 | + </view> | ||
| 155 | + </block> | ||
| 111 | 156 | ||
| 112 | - <view wx:if="{{items.is_offline}}" class="quan_color flex ai-center"><text>券后 ¥{{g_filter.toFix(items.offline_price,2)}}</text></view> | ||
| 113 | 157 | ||
| 158 | + </block > | ||
| 159 | + | ||
| 160 | + | ||
| 161 | + <!--此时是多个商品参与活动的切换 验证活动是不是多个,要不要显示切换 --> | ||
| 162 | + <!-- 新增促销多活动的排版 --> | ||
| 163 | + <block wx:if="{{item.show_can_cx}}"> | ||
| 164 | + <block wx:for="{{item.show_can_cx}}" wx:for-item="pitem"> | ||
| 165 | + <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1}}" > | ||
| 166 | + <view bindtap="switch_cx_group" | ||
| 167 | + data-index="{{pidx}}" | ||
| 168 | + data-gd_key="{{index}}" | ||
| 169 | + class="cx-frame flex" style="position: relative"> | ||
| 170 | + <view class="cx-sizs fs30">可参促销</view> | ||
| 171 | + <view class="flex ai_c f1 pdh20"> | ||
| 172 | + <view class="xc-coupon-fram" wx:for="{{pitem.act_arr}}" > | ||
| 173 | + <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word">优惠促销</view> | ||
| 174 | + <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word">搭配促销</view> | ||
| 175 | + <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word">组合购</view> | ||
| 176 | + <view wx:if="{{item.prom_type==10}}" class="xc-coupon t-c four-level-word">阶梯促销</view> | ||
| 177 | + </view> | ||
| 178 | + </view> | ||
| 179 | + <view class="cx-obtain-coupon wsize"> | ||
| 180 | + <text class="bg_jj"></text> | ||
| 181 | + </view> | ||
| 182 | + </view> | ||
| 183 | + </view> | ||
| 184 | + </block> | ||
| 185 | + </block> | ||
| 114 | 186 | ||
| 115 | - </view> | ||
| 116 | - <view class="count"> | ||
| 117 | - <view bindtap="{{items.goods_num <= 1 ? '':'subNum'}}" class="sub fs28 {{items.goods_num <= 1 ? 'active':''}}" data-pitems="{{pidx}}" data-item="{{idx}}">一</view> | ||
| 118 | - <input class="goodadd" bindblur="valueToNum" data-pitems="{{pidx}}" data-item="{{idx}}" | ||
| 119 | - bindinput="refresh_input" type="number" value="{{items.goods_num}}"></input> | ||
| 120 | - <view class="add" bindtap="addNum" data-pitems="{{pidx}}" data-item="{{idx}}">+</view> | ||
| 121 | - </view> | ||
| 122 | - </view> | ||
| 123 | - </block> | ||
| 124 | - </view> | ||
| 125 | - </view> | ||
| 126 | </view> | 187 | </view> |
| 127 | - <!--- 去凑单 --> | ||
| 128 | - <view style="margin-top: 20rpx; padding: 0 30rpx"> | 188 | + <!--- 去凑单 --> |
| 129 | <block wx:if="{{item.make_up_arr}}"> | 189 | <block wx:if="{{item.make_up_arr}}"> |
| 130 | - <view class="flex jc_sb fs28" wx:for="{{item.make_up_arr}}" style="margin-bottom: 20rpx" > | 190 | + <view style="margin-top: 20rpx; padding: 0 30rpx"> |
| 191 | + <view class="flex jc_sb fs28" wx:for="{{item.make_up_arr}}" style="margin-bottom: 20rpx" > | ||
| 131 | <view class="ellipsis-1" style="width: 80%">再买<text class="co-red">{{item.diff}}<text wx:if="{{item.diff_type==0}}">元</text> | 192 | <view class="ellipsis-1" style="width: 80%">再买<text class="co-red">{{item.diff}}<text wx:if="{{item.diff_type==0}}">元</text> |
| 132 | <text wx:if="{{item.diff_type==1}}">件</text> | 193 | <text wx:if="{{item.diff_type==1}}">件</text> |
| 133 | </text>, | 194 | </text>, |
| @@ -144,8 +205,8 @@ | @@ -144,8 +205,8 @@ | ||
| 144 | </view> | 205 | </view> |
| 145 | <view class="co-red" data-prom_id="{{item.prom_id}}" bindtap="go_cou_dang">去凑单></view> | 206 | <view class="co-red" data-prom_id="{{item.prom_id}}" bindtap="go_cou_dang">去凑单></view> |
| 146 | </view> | 207 | </view> |
| 208 | + </view> | ||
| 147 | </block> | 209 | </block> |
| 148 | - </view> | ||
| 149 | <!-- 还差多少件立即享受组合购 --> | 210 | <!-- 还差多少件立即享受组合购 --> |
| 150 | <block wx:if="{{item.need_list && item.need_list.length>0 && !is_edit}}"> | 211 | <block wx:if="{{item.need_list && item.need_list.length>0 && !is_edit}}"> |
| 151 | <view class="fs28 pdr20 pdl20 pdb20 c-red2 flex jc_sb" wx:for="{{item.need_list}}"> | 212 | <view class="fs28 pdr20 pdl20 pdb20 c-red2 flex jc_sb" wx:for="{{item.need_list}}"> |
pages/cart/cart/cart.wxss
| @@ -399,3 +399,81 @@ page { | @@ -399,3 +399,81 @@ page { | ||
| 399 | text-align: center; line-height: 30rpx; | 399 | text-align: center; line-height: 30rpx; |
| 400 | left: 0;bottom: 0;color: #fff; font-size: 20rpx; | 400 | left: 0;bottom: 0;color: #fff; font-size: 20rpx; |
| 401 | } | 401 | } |
| 402 | + | ||
| 403 | + | ||
| 404 | + | ||
| 405 | +.cx-frame { | ||
| 406 | + /* border-top:3rpx solid #eee; */ | ||
| 407 | + /* width:99%; | ||
| 408 | + height: 95rpx; | ||
| 409 | + line-height: 95rpx; | ||
| 410 | + padding-left:24rpx; */ | ||
| 411 | + padding: 20rpx; | ||
| 412 | +} | ||
| 413 | + | ||
| 414 | +.cx-frame .cx-sizs { | ||
| 415 | + /* width: 68rpx; */ | ||
| 416 | + /* height: 100%; */ | ||
| 417 | + /* line-height: 100rpx; */ | ||
| 418 | + /* overflow: hidden; */ | ||
| 419 | + /* margin-left: 10rpx; */ | ||
| 420 | +} | ||
| 421 | + | ||
| 422 | +.xc-coupon-fram { | ||
| 423 | + position: relative; | ||
| 424 | + margin-right: 16rpx; | ||
| 425 | + /* width:200rpx; */ | ||
| 426 | + /* padding-top:30rpx; */ | ||
| 427 | + | ||
| 428 | +} | ||
| 429 | + | ||
| 430 | +.xc-coupon-fram .xc-coupon { | ||
| 431 | + /* width:175rpx ; | ||
| 432 | + height: 40rpx; | ||
| 433 | + line-height: 40rpx; */ | ||
| 434 | + background-color: #d60021; | ||
| 435 | + /* margin:0 auto; */ | ||
| 436 | + color: #fff; | ||
| 437 | + padding: 6rpx 20rpx; | ||
| 438 | + | ||
| 439 | +} | ||
| 440 | + | ||
| 441 | +.xc-coupon-fram .xc-circular { | ||
| 442 | + width: 16rpx; | ||
| 443 | + height: 16rpx; | ||
| 444 | + background-color: white; | ||
| 445 | + position: absolute; | ||
| 446 | + top: 50%; | ||
| 447 | + /* left: -10rpx; */ | ||
| 448 | + transform: translateY(-50%); | ||
| 449 | +} | ||
| 450 | + | ||
| 451 | +.cx-obtain-coupon { | ||
| 452 | + /* width: 65rpx; | ||
| 453 | + height: 100%; | ||
| 454 | + padding-left:15rpx; */ | ||
| 455 | + color: #d70025; | ||
| 456 | + display: flex; | ||
| 457 | + align-items: center; | ||
| 458 | + /* position: absolute; | ||
| 459 | + right: 5rpx; */ | ||
| 460 | +} | ||
| 461 | + | ||
| 462 | +.bg_jj { | ||
| 463 | + width: 14rpx; | ||
| 464 | + height: 14rpx; | ||
| 465 | + border-top: 2rpx solid #d70026; | ||
| 466 | + border-right: 2rpx solid #d70026; | ||
| 467 | + transform: rotateZ(45deg); | ||
| 468 | + display: inline-block; | ||
| 469 | + margin-bottom: 3rpx; | ||
| 470 | +} | ||
| 471 | + | ||
| 472 | +.bg_jj.down { | ||
| 473 | + transform: rotateZ(135deg); | ||
| 474 | +} | ||
| 475 | + | ||
| 476 | +.bg_jj.up { | ||
| 477 | + transform: rotateZ(-45deg); | ||
| 478 | + margin-top: 6rpx; | ||
| 479 | +} |
pages/cart/cart/g_filter.wxs
| @@ -28,11 +28,21 @@ var g_filters = { | @@ -28,11 +28,21 @@ var g_filters = { | ||
| 28 | } | 28 | } |
| 29 | val = parseFloat(val); | 29 | val = parseFloat(val); |
| 30 | return val.toFixed(count) | 30 | return val.toFixed(count) |
| 31 | - } | 31 | + }, |
| 32 | + | ||
| 33 | + //判断商品是不是有活动切换 | ||
| 34 | + is_more_act:function (items,show_can_cx){ | ||
| 35 | + if([1,2,4,6,8,9].indexOf(items.prom_type)>-1) return false; | ||
| 36 | + if(!show_can_cx) return false; | ||
| 37 | + return true; | ||
| 38 | + } | ||
| 39 | + | ||
| 32 | } | 40 | } |
| 33 | module.exports = { | 41 | module.exports = { |
| 34 | has_char: g_filters.has_char, | 42 | has_char: g_filters.has_char, |
| 35 | beg_time: g_filters.beg_time, | 43 | beg_time: g_filters.beg_time, |
| 36 | end_time: g_filters.end_time, | 44 | end_time: g_filters.end_time, |
| 37 | toFix: g_filters.toFix, | 45 | toFix: g_filters.toFix, |
| 46 | + is_more_act: g_filters.is_more_act, | ||
| 47 | + check_show:g_filters.check_show | ||
| 38 | } | 48 | } |
| 39 | \ No newline at end of file | 49 | \ No newline at end of file |
pages/cart/cart/zh_calculate.js
| @@ -134,7 +134,7 @@ module.exports = { | @@ -134,7 +134,7 @@ module.exports = { | ||
| 134 | if (item.buyqty > 0) { | 134 | if (item.buyqty > 0) { |
| 135 | console.log(111, th.data.in_zhact_gdmap); | 135 | console.log(111, th.data.in_zhact_gdmap); |
| 136 | var cbuy = item.buyqty - zh_b_num; | 136 | var cbuy = item.buyqty - zh_b_num; |
| 137 | - var key = item.goods_id + "" + act.id; | 137 | + var key = item.goods_id + "." + act.id; |
| 138 | if (th.data.in_zhact_gdmap[key]) { | 138 | if (th.data.in_zhact_gdmap[key]) { |
| 139 | var cbuy = item.buyqty - zh_b_num - th.data.in_zhact_gdmap[key]; | 139 | var cbuy = item.buyqty - zh_b_num - th.data.in_zhact_gdmap[key]; |
| 140 | } | 140 | } |
| @@ -213,7 +213,7 @@ module.exports = { | @@ -213,7 +213,7 @@ module.exports = { | ||
| 213 | 213 | ||
| 214 | console.log(222, th.data.in_zhact_gdmap); | 214 | console.log(222, th.data.in_zhact_gdmap); |
| 215 | 215 | ||
| 216 | - var key = ite.goods_id + "" + act.id; | 216 | + var key = ite.goods_id + "." + act.id; |
| 217 | if (th.data.in_zhact_gdmap[key]) { | 217 | if (th.data.in_zhact_gdmap[key]) { |
| 218 | th.data.in_zhact_gdmap[key] += ite.num; | 218 | th.data.in_zhact_gdmap[key] += ite.num; |
| 219 | } else { | 219 | } else { |
| @@ -519,7 +519,279 @@ module.exports = { | @@ -519,7 +519,279 @@ module.exports = { | ||
| 519 | } | 519 | } |
| 520 | } | 520 | } |
| 521 | return zhqty_bz_flag; | 521 | return zhqty_bz_flag; |
| 522 | - } | 522 | + }, |
| 523 | + | ||
| 524 | + //-- 判断组合购有没有满足,只有在检查的时候,要用新的 --- | ||
| 525 | + ch_zh_ok(act,gdlist,c_goods,th,item_act_map,is_need_ck_num){ | ||
| 526 | + | ||
| 527 | + //-- 寻找一下 -- | ||
| 528 | + function get_num(ite) { | ||
| 529 | + for (let v1 in c_goods) { | ||
| 530 | + var vh = c_goods[v1]; | ||
| 531 | + if (vh.goods_id == ite.goods_id) { | ||
| 532 | + return vh; | ||
| 533 | + } | ||
| 534 | + } | ||
| 535 | + return 0; | ||
| 536 | + } | ||
| 537 | + var goods =gdlist; | ||
| 538 | + var all_num=0; | ||
| 539 | + var need_to_buy=0; | ||
| 540 | + var all_zhqty=0; | ||
| 541 | + //-- 是综合考虑到组合购的总数量和限购数量 -- | ||
| 542 | + var min_can_buy=-1; | ||
| 543 | + var aid=act.id; | ||
| 544 | + | ||
| 545 | + let no_in_arr = []; //剩余的未加入组合购 | ||
| 546 | + let out_arr = []; //超出活动限购的商品放入 | ||
| 547 | + | ||
| 548 | + //-- 判断组合购的总数量是不是到了 -- | ||
| 549 | + if(act.zh_num>0){ | ||
| 550 | + //如果是在全选的情况下,那么就需要in_zhact_new来控制数量 | ||
| 551 | + var need_ck=0; | ||
| 552 | + if(is_need_ck_num){ | ||
| 553 | + need_ck=th.data.in_zhact_new[aid]?th.data.in_zhact_new[aid]:0; | ||
| 554 | + } | ||
| 555 | + if(need_ck+act.zh_buy_num>=act.zh_num ){ | ||
| 556 | + return false; | ||
| 557 | + }else{ | ||
| 558 | + min_can_buy= act.zh_num-act.zh_buy_num-need_ck; | ||
| 559 | + } | ||
| 560 | + } | ||
| 561 | + | ||
| 562 | + //-- 判断组合购的限购是不是到了 -- | ||
| 563 | + if(act.buy_limit>0){ | ||
| 564 | + var need_ck0=0; | ||
| 565 | + if(is_need_ck_num){ | ||
| 566 | + need_ck0=th.data.in_zhact_new[aid]?th.data.in_zhact_new[aid]:0; | ||
| 567 | + } | ||
| 568 | + var min_can_buy0=0; | ||
| 569 | + if(need_ck+item_act_map.buyed>=act.buy_limit ){ | ||
| 570 | + return false; | ||
| 571 | + }else{ | ||
| 572 | + min_can_buy0=act.buy_limit-item_act_map.buyed-need_ck; | ||
| 573 | + } | ||
| 574 | + if(min_can_buy>0){ | ||
| 575 | + if(min_can_buy0<min_can_buy) min_can_buy=min_can_buy0; | ||
| 576 | + }else{ | ||
| 577 | + min_can_buy=min_can_buy0; | ||
| 578 | + } | ||
| 579 | + } | ||
| 580 | + | ||
| 581 | + for (var i in goods) { | ||
| 582 | + var item = goods[i]; | ||
| 583 | + var cart_num = get_num(item).goods_num; | ||
| 584 | + var zh_b_num = get_num(item).zh_b_num; | ||
| 585 | + if (!cart_num) { | ||
| 586 | + if (item.zhqty) { | ||
| 587 | + need_to_buy += item.zhqty; | ||
| 588 | + } | ||
| 589 | + continue; | ||
| 590 | + } | ||
| 591 | + | ||
| 592 | + item.cart_num = cart_num; | ||
| 593 | + //-- 当商品有购买的时候,以及有限购的时候 -- | ||
| 594 | + if (item.buyqty > 0) { | ||
| 595 | + var cbuy = item.buyqty - zh_b_num; | ||
| 596 | + var key = item.goods_id + "." + act.id; | ||
| 597 | + if (is_need_ck_num && th.data.in_zhact_gdmap_new[key]) { | ||
| 598 | + var cbuy = item.buyqty - zh_b_num - th.data.in_zhact_gdmap_new[key]; | ||
| 599 | + } | ||
| 600 | + //当可买的数量为0 | ||
| 601 | + if (cbuy <= 0) { | ||
| 602 | + item.num = 0; | ||
| 603 | + out_arr.push({ | ||
| 604 | + goods_id: item.goods_id, | ||
| 605 | + num: cart_num | ||
| 606 | + }) | ||
| 607 | + } else { | ||
| 608 | + if (cbuy >= cart_num) item.num = cart_num; | ||
| 609 | + else { | ||
| 610 | + item.num = cbuy; | ||
| 611 | + out_arr.push({ | ||
| 612 | + goods_id: item.goods_id, | ||
| 613 | + num: cart_num - cbuy | ||
| 614 | + }) | ||
| 615 | + } | ||
| 616 | + } | ||
| 617 | + } else { | ||
| 618 | + item.num = cart_num; | ||
| 619 | + } | ||
| 620 | + | ||
| 621 | + if (item.num) { | ||
| 622 | + all_num += item.num; | ||
| 623 | + //当有起购数的控制的时候 | ||
| 624 | + if (item.zhqty) { | ||
| 625 | + all_zhqty += item.zhqty; | ||
| 626 | + if (item.num < item.zhqty) { | ||
| 627 | + need_to_buy += item.zhqty - item.num; | ||
| 628 | + } | ||
| 629 | + if (item.num > item.zhqty) { | ||
| 630 | + for (let i = 0; i < item.num - item.zhqty; i++) { | ||
| 631 | + no_in_arr.push({ | ||
| 632 | + goods_id: item.goods_id, | ||
| 633 | + }) | ||
| 634 | + } | ||
| 635 | + } | ||
| 636 | + } | ||
| 637 | + else { | ||
| 638 | + for (let j = 0; j < item.num; j++) { | ||
| 639 | + no_in_arr.push({ | ||
| 640 | + goods_id: item.goods_id, | ||
| 641 | + }) | ||
| 642 | + } | ||
| 643 | + } | ||
| 644 | + } else { | ||
| 645 | + if (item.zhqty) { | ||
| 646 | + need_to_buy += item.zhqty; | ||
| 647 | + } | ||
| 648 | + } | ||
| 649 | + } | ||
| 650 | + | ||
| 651 | + //当满足组合的要求:总数要满足,起购数要满足 | ||
| 652 | + if (all_num >= act.zhbuyqty && !need_to_buy) { | ||
| 653 | + //默认数量是1 | ||
| 654 | + var act_num=1; | ||
| 655 | + function sortData(a, b) { | ||
| 656 | + return a.price - b.price | ||
| 657 | + } | ||
| 658 | + if (no_in_arr.length > 0) no_in_arr.sort(sortData); | ||
| 659 | + if (act.zhbuyqty > all_zhqty) { | ||
| 660 | + for (let n = 0; n < act.zhbuyqty - all_zhqty; n++) { | ||
| 661 | + no_in_arr.pop(); | ||
| 662 | + } | ||
| 663 | + } | ||
| 664 | + | ||
| 665 | + //看一下剩下的数量有没有满足组合购的要求,以及要不要倍增 | ||
| 666 | + if (act.is_bz && no_in_arr.length >= act.zhbuyqty) { | ||
| 667 | + | ||
| 668 | + var bz_num_ok = 0; //超量倍增是否满足 | ||
| 669 | + var zhqty_len = 0; //几个超量倍增 | ||
| 670 | + var delete_num = 0; | ||
| 671 | + //看一下是几倍 | ||
| 672 | + let be = parseInt(no_in_arr.length / act.zhbuyqty); | ||
| 673 | + //如果有总数控制的时候 | ||
| 674 | + if (min_can_buy>0) { | ||
| 675 | + var be1 = min_can_buy - 1; | ||
| 676 | + if (be1 < be) be = be1; | ||
| 677 | + } | ||
| 678 | + if(be) { | ||
| 679 | + if (act.is_bzyh && zhqty_bz.length > 0) { | ||
| 680 | + | ||
| 681 | + let zhqty_bz_arr = []; | ||
| 682 | + let zhqty_bz_flag = this.zhqty_bz_fun(zhqty_bz, be, zhqty_bz_arr); | ||
| 683 | + if (zhqty_bz_flag) { | ||
| 684 | + for (let i = 0; i < zhqty_bz.length; i++) { | ||
| 685 | + var vv = zhqty_bz[i]; | ||
| 686 | + for (let j = 0; j < be * vv['zhqty']; j++) { | ||
| 687 | + let index = no_in_arr.findIndex(i => { | ||
| 688 | + return vv.goods_id === i.goods_id | ||
| 689 | + }) | ||
| 690 | + if (index > -1) { | ||
| 691 | + delete_num++ | ||
| 692 | + no_in_arr.splice(index, 1) | ||
| 693 | + } | ||
| 694 | + } | ||
| 695 | + } | ||
| 696 | + } else { | ||
| 697 | + zhqty_len = 1; | ||
| 698 | + let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) { | ||
| 699 | + return o['be']; | ||
| 700 | + })); | ||
| 701 | + let new_arr = zhqty_bz_arr.filter(ii => { | ||
| 702 | + return ii['be'] == min_bz_num; | ||
| 703 | + }) | ||
| 704 | + //-- 要看一下倍数还有没有 --- | ||
| 705 | + be = new_arr[0].be; | ||
| 706 | + //如果有总数控制的时候 | ||
| 707 | + if (min_can_buy>0) { | ||
| 708 | + var be1 = min_can_buy - 1; | ||
| 709 | + if (be1 < be) be = be1; | ||
| 710 | + } | ||
| 711 | + if(be){ | ||
| 712 | + for (let i = 0; i < zhqty_bz.length; i++) { | ||
| 713 | + let item1 = zhqty_bz[i]; | ||
| 714 | + for (let j = 0; j < be * item1['zhqty']; j++) { | ||
| 715 | + let index = no_in_arr.findIndex(i => { | ||
| 716 | + return item1.goods_id === i.goods_id | ||
| 717 | + }) | ||
| 718 | + if (index > -1) { | ||
| 719 | + no_in_arr.splice(index, 1) | ||
| 720 | + } | ||
| 721 | + } | ||
| 722 | + } | ||
| 723 | + act_num+=be; | ||
| 724 | + } | ||
| 725 | + } | ||
| 726 | + } | ||
| 727 | + if (!zhqty_len) { | ||
| 728 | + let pop_num = be * act.zhbuyqty - delete_num; | ||
| 729 | + for (var m = 0; m < pop_num; m++) { | ||
| 730 | + no_in_arr.pop(); | ||
| 731 | + } | ||
| 732 | + act_num+=be; | ||
| 733 | + } | ||
| 734 | + } | ||
| 735 | + } | ||
| 736 | + | ||
| 737 | + //-- 参与活动的金额要返回回去 -- | ||
| 738 | + item_act_map.act_num=act_num; | ||
| 739 | + let goods_map = {}; | ||
| 740 | + //算一下剩余的商品 | ||
| 741 | + if (no_in_arr.length) { | ||
| 742 | + for (let ii in no_in_arr) { | ||
| 743 | + let item = no_in_arr[ii]; | ||
| 744 | + if (goods_map[item.goods_id]) { | ||
| 745 | + var num = goods_map[item.goods_id]; | ||
| 746 | + goods_map[item.goods_id] = ++num; | ||
| 747 | + } else { | ||
| 748 | + goods_map[item.goods_id] = 1; | ||
| 749 | + } | ||
| 750 | + } | ||
| 751 | + } | ||
| 752 | + //超量的部分也要计算一下 | ||
| 753 | + if (out_arr.length) { | ||
| 754 | + for (var m in out_arr) { | ||
| 755 | + if (goods_map[item.goods_id]) { | ||
| 756 | + var num = goods_map[item.goods_id]; | ||
| 757 | + num += item.num | ||
| 758 | + goods_map[item.goods_id] = num; | ||
| 759 | + } else { | ||
| 760 | + goods_map[item.goods_id] = item.num; | ||
| 761 | + } | ||
| 762 | + } | ||
| 763 | + } | ||
| 764 | + | ||
| 765 | + //-- 组合购的商品限购的数组控制 -- | ||
| 766 | + var in_zhact_gdmap={}; | ||
| 767 | + //商品的列表 | ||
| 768 | + for (var u in goods) { | ||
| 769 | + var ite = goods[u]; | ||
| 770 | + var cart_num = get_num(ite).goods_num; | ||
| 771 | + | ||
| 772 | + if (ite.buyqty > 0 && cart_num > 0) { | ||
| 773 | + var key = ite.goods_id + "." + act.id; | ||
| 774 | + if(goods_map[ite.goods_id]){ | ||
| 775 | + cart_num-=goods_map[ite.goods_id]; | ||
| 776 | + } | ||
| 777 | + if(cart_num>0){ | ||
| 778 | + if (in_zhact_gdmap[key]) { | ||
| 779 | + in_zhact_gdmap[key] += ite.num; | ||
| 780 | + } else { | ||
| 781 | + in_zhact_gdmap[key] = ite.num; | ||
| 782 | + } | ||
| 783 | + } | ||
| 784 | + | ||
| 785 | + } | ||
| 786 | + } | ||
| 787 | + item_act_map.in_zhact_gdmap=in_zhact_gdmap; | ||
| 788 | + return true; | ||
| 789 | + } | ||
| 790 | + | ||
| 791 | + item_act_map.act_num=0; | ||
| 792 | + return true; | ||
| 793 | + } | ||
| 794 | + | ||
| 523 | 795 | ||
| 524 | 796 | ||
| 525 | } | 797 | } |
| 526 | \ No newline at end of file | 798 | \ No newline at end of file |
pages/giftpack/giftpacklist/giftpacklist.js
| @@ -76,13 +76,9 @@ Page({ | @@ -76,13 +76,9 @@ Page({ | ||
| 76 | 76 | ||
| 77 | screenWidth: 0, | 77 | screenWidth: 0, |
| 78 | submit:0, | 78 | submit:0, |
| 79 | -<<<<<<< HEAD | ||
| 80 | - | ||
| 81 | - is_detail:1 //是详情页面的购买 | ||
| 82 | -======= | 79 | + is_detail:1, //是详情页面的购买 |
| 83 | keyword:'', //门店搜索 | 80 | keyword:'', //门店搜索 |
| 84 | sec_i:-1,//选中分类门店 下标 | 81 | sec_i:-1,//选中分类门店 下标 |
| 85 | ->>>>>>> dev_oa_lu7 | ||
| 86 | }, | 82 | }, |
| 87 | onLoad: function (options) { | 83 | onLoad: function (options) { |
| 88 | 84 |
pages/goods/goodsInfo/goodsInfo.js
| @@ -270,6 +270,7 @@ Page({ | @@ -270,6 +270,7 @@ Page({ | ||
| 270 | user_pre_buynum:0, //用户优惠促销参与次数 | 270 | user_pre_buynum:0, //用户优惠促销参与次数 |
| 271 | keyword:'', //门店搜索 | 271 | keyword:'', //门店搜索 |
| 272 | sec_i:-1,//选中分类门店 下标 | 272 | sec_i:-1,//选中分类门店 下标 |
| 273 | + cx_prom_group:[], //促销活动,用于显示和判断默认要用什么促销活动 | ||
| 273 | }, | 274 | }, |
| 274 | 275 | ||
| 275 | //------初始化加载---------- | 276 | //------初始化加载---------- |
| @@ -297,7 +298,6 @@ Page({ | @@ -297,7 +298,6 @@ Page({ | ||
| 297 | 298 | ||
| 298 | 299 | ||
| 299 | self = this; | 300 | self = this; |
| 300 | - | ||
| 301 | //检查测肤 | 301 | //检查测肤 |
| 302 | getApp().check_skin_face(t, 0, gid); | 302 | getApp().check_skin_face(t, 0, gid); |
| 303 | 303 | ||
| @@ -1209,6 +1209,7 @@ Page({ | @@ -1209,6 +1209,7 @@ Page({ | ||
| 1209 | this.data.enterAddressPage && (this.data.enterAddressPage = !1); | 1209 | this.data.enterAddressPage && (this.data.enterAddressPage = !1); |
| 1210 | 1210 | ||
| 1211 | 1211 | ||
| 1212 | + | ||
| 1212 | }, | 1213 | }, |
| 1213 | 1214 | ||
| 1214 | onReady() { | 1215 | onReady() { |
| @@ -1539,10 +1540,14 @@ Page({ | @@ -1539,10 +1540,14 @@ Page({ | ||
| 1539 | }) | 1540 | }) |
| 1540 | // return userbuynum | 1541 | // return userbuynum |
| 1541 | }, | 1542 | }, |
| 1543 | + | ||
| 1542 | //优惠促销用户参与次数 | 1544 | //优惠促销用户参与次数 |
| 1543 | async getUserBuyPromNum_pre(prom_id){ | 1545 | async getUserBuyPromNum_pre(prom_id){ |
| 1546 | + var user_id=0 | ||
| 1544 | var userInfo = getApp().globalData.userInfo; | 1547 | var userInfo = getApp().globalData.userInfo; |
| 1545 | - var url = `/api/weshop/ordergoods/getUserBuyPromNum?is_all=1&store_id=${os.stoid}&user_id=${userInfo.user_id}&prom_type=3&prom_id=${prom_id}`; | 1548 | + if(userInfo) user_id=userInfo.user_id; |
| 1549 | + | ||
| 1550 | + var url = `/api/weshop/ordergoods/getUserBuyPromNum?is_all=1&store_id=${os.stoid}&user_id=${user_id}&prom_type=3&prom_id=${prom_id}`; | ||
| 1546 | let res = await getApp().request.promiseGet(url, { | 1551 | let res = await getApp().request.promiseGet(url, { |
| 1547 | data:{} | 1552 | data:{} |
| 1548 | }); | 1553 | }); |
| @@ -1619,11 +1624,8 @@ Page({ | @@ -1619,11 +1624,8 @@ Page({ | ||
| 1619 | prom_type: th.data.sele_g.prom_type, | 1624 | prom_type: th.data.sele_g.prom_type, |
| 1620 | }; | 1625 | }; |
| 1621 | 1626 | ||
| 1622 | - | ||
| 1623 | - | ||
| 1624 | - | ||
| 1625 | //-- 代发商品不参加优惠 -- | 1627 | //-- 代发商品不参加优惠 -- |
| 1626 | - if (th.data.sele_g.whsle_id && newd.prom_type == 3) { | 1628 | + if (th.data.sele_g.whsle_id) { |
| 1627 | newd.prom_type = 0; | 1629 | newd.prom_type = 0; |
| 1628 | newd.prom_id = 0; | 1630 | newd.prom_id = 0; |
| 1629 | } | 1631 | } |
| @@ -1664,6 +1666,8 @@ Page({ | @@ -1664,6 +1666,8 @@ Page({ | ||
| 1664 | newd.pricing_type = o.pricing_type; | 1666 | newd.pricing_type = o.pricing_type; |
| 1665 | } | 1667 | } |
| 1666 | 1668 | ||
| 1669 | + | ||
| 1670 | + //获取到优惠测序类型 | ||
| 1667 | //-----如果是秒杀,团购,积分购,拼团----- | 1671 | //-----如果是秒杀,团购,积分购,拼团----- |
| 1668 | if (th.data.prom_type == 1 || th.data.prom_type == 2) { | 1672 | if (th.data.prom_type == 1 || th.data.prom_type == 2) { |
| 1669 | 1673 | ||
| @@ -1672,7 +1676,6 @@ Page({ | @@ -1672,7 +1676,6 @@ Page({ | ||
| 1672 | newd.prom_type = 0; | 1676 | newd.prom_type = 0; |
| 1673 | newd.prom_id = 0; | 1677 | newd.prom_id = 0; |
| 1674 | newd.is_pd_normal = 1; | 1678 | newd.is_pd_normal = 1; |
| 1675 | - | ||
| 1676 | //---如果是线下门店销售的时候--- | 1679 | //---如果是线下门店销售的时候--- |
| 1677 | if (th.data.sales_rules >= 2) { | 1680 | if (th.data.sales_rules >= 2) { |
| 1678 | var pick = th.get_pick_from_list(th.data.sto_sele_id) | 1681 | var pick = th.get_pick_from_list(th.data.sto_sele_id) |
| @@ -1720,10 +1723,9 @@ Page({ | @@ -1720,10 +1723,9 @@ Page({ | ||
| 1720 | return false; | 1723 | return false; |
| 1721 | } | 1724 | } |
| 1722 | 1725 | ||
| 1723 | - | ||
| 1724 | newd.goods_price = th.data.prom_price; | 1726 | newd.goods_price = th.data.prom_price; |
| 1725 | newd.member_goods_price = th.data.prom_price, | 1727 | newd.member_goods_price = th.data.prom_price, |
| 1726 | - newd.prom_type = th.data.prom_type; | 1728 | + newd.prom_type = th.data.prom_type; |
| 1727 | newd.prom_id = th.data.prom_id; | 1729 | newd.prom_id = th.data.prom_id; |
| 1728 | 1730 | ||
| 1729 | if (o.store_count <= 0 ) { | 1731 | if (o.store_count <= 0 ) { |
| @@ -1743,7 +1745,6 @@ Page({ | @@ -1743,7 +1745,6 @@ Page({ | ||
| 1743 | }; | 1745 | }; |
| 1744 | 1746 | ||
| 1745 | th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | 1747 | th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 |
| 1746 | - | ||
| 1747 | } else if (o.prom_type == 7) { | 1748 | } else if (o.prom_type == 7) { |
| 1748 | 1749 | ||
| 1749 | //判断进行中的活动,是不是要判断线下库存 | 1750 | //判断进行中的活动,是不是要判断线下库存 |
| @@ -1817,84 +1818,17 @@ Page({ | @@ -1817,84 +1818,17 @@ Page({ | ||
| 1817 | } | 1818 | } |
| 1818 | } | 1819 | } |
| 1819 | }) | 1820 | }) |
| 1820 | - | ||
| 1821 | } | 1821 | } |
| 1822 | 1822 | ||
| 1823 | - //要包含积分购的普通购买 | ||
| 1824 | - else if (th.data.prom_type == 0 || th.data.prom_type == 3 || newd.is_integral_normal || th.data.prom_type == 5 || th.data.prom_type == 10) { | 1823 | + //要包含积分购的普通购买0 3,5,7,10 |
| 1824 | + else if ( [0,3,5,7,10].indexOf(th.data.prom_type)>-1 || prom.prom_type == 7) { | ||
| 1825 | newd.prom_type = 0; | 1825 | newd.prom_type = 0; |
| 1826 | newd.prom_id = 0; | 1826 | newd.prom_id = 0; |
| 1827 | 1827 | ||
| 1828 | - if (th.data.prom_type == 10) { | ||
| 1829 | - newd.prom_type = th.data.prom_type; | ||
| 1830 | - newd.prom_id = th.data.prom_id; | ||
| 1831 | - } | ||
| 1832 | - | ||
| 1833 | //---如果是线下门店销售的时候--- | 1828 | //---如果是线下门店销售的时候--- |
| 1834 | if (th.data.sales_rules >= 2 && !th.data.sele_g.whsle_id) { | 1829 | if (th.data.sales_rules >= 2 && !th.data.sele_g.whsle_id) { |
| 1835 | var pick = th.get_pick_from_list(th.data.sto_sele_id) | 1830 | var pick = th.get_pick_from_list(th.data.sto_sele_id) |
| 1836 | //---通过接口获取门店的线下库存信息-- | 1831 | //---通过接口获取门店的线下库存信息-- |
| 1837 | - // getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1838 | - // data: { | ||
| 1839 | - // storageNos: pick.pickup_no, | ||
| 1840 | - // wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1841 | - // storeId: os.stoid | ||
| 1842 | - // }, | ||
| 1843 | - // success: function (res) { | ||
| 1844 | - // if (res.data.code == 0) { | ||
| 1845 | - // if (res.data.data.pageData.length > 0) { | ||
| 1846 | - // var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1847 | - // if (CanOutQty < e.data.goodsInputNum) { | ||
| 1848 | - // wx.showToast({ | ||
| 1849 | - // title: '库存不足!', | ||
| 1850 | - // icon: 'none', | ||
| 1851 | - // }); | ||
| 1852 | - // return false; | ||
| 1853 | - // //return s.my_warnning("库存不足!", 0, th); | ||
| 1854 | - // } | ||
| 1855 | - // //在调一次接口,读取商品的预出库的数量,lock | ||
| 1856 | - // getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1857 | - // data: { | ||
| 1858 | - // store_id: os.stoid, | ||
| 1859 | - // wareId: th.data.sele_g.goods_id, | ||
| 1860 | - // storageId: pick.pickup_id, | ||
| 1861 | - // pageSize: 1000 | ||
| 1862 | - // }, | ||
| 1863 | - // success: function (res_data) { | ||
| 1864 | - // if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1865 | - // | ||
| 1866 | - // var lock = 0; | ||
| 1867 | - // for (var i in res_data.data.data.pageData) { | ||
| 1868 | - // lock += res_data.data.data.pageData[i].outQty; | ||
| 1869 | - // } | ||
| 1870 | - // | ||
| 1871 | - // if (CanOutQty <= lock) { | ||
| 1872 | - // wx.showToast({ | ||
| 1873 | - // title: '库存不足!', | ||
| 1874 | - // icon: 'none', | ||
| 1875 | - // }); | ||
| 1876 | - // return false; | ||
| 1877 | - // //return s.my_warnning("库存不足!", 0, th); | ||
| 1878 | - // } | ||
| 1879 | - // th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1880 | - // } else { | ||
| 1881 | - // th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1882 | - // } | ||
| 1883 | - // } | ||
| 1884 | - // }) | ||
| 1885 | - // } else { | ||
| 1886 | - // wx.showToast({ | ||
| 1887 | - // title: '库存不足!', | ||
| 1888 | - // icon: 'none', | ||
| 1889 | - // }); | ||
| 1890 | - // return false; | ||
| 1891 | - // //return s.my_warnning("库存不足!", 0, th); | ||
| 1892 | - // } | ||
| 1893 | - // | ||
| 1894 | - // } | ||
| 1895 | - // } | ||
| 1896 | - // }) | ||
| 1897 | - | ||
| 1898 | th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) { | 1832 | th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) { |
| 1899 | if (CanOutQty) { | 1833 | if (CanOutQty) { |
| 1900 | 1834 | ||
| @@ -1977,7 +1911,6 @@ Page({ | @@ -1977,7 +1911,6 @@ Page({ | ||
| 1977 | //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d); | 1911 | //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d); |
| 1978 | if ("add" == t.currentTarget.dataset.action) { | 1912 | if ("add" == t.currentTarget.dataset.action) { |
| 1979 | 1913 | ||
| 1980 | - | ||
| 1981 | if( [3,5,10].indexOf(newd.prom_type)>-1){ | 1914 | if( [3,5,10].indexOf(newd.prom_type)>-1){ |
| 1982 | newd.prom_type=0; | 1915 | newd.prom_type=0; |
| 1983 | newd.prom_id=0; | 1916 | newd.prom_id=0; |
| @@ -1994,6 +1927,22 @@ Page({ | @@ -1994,6 +1927,22 @@ Page({ | ||
| 1994 | newd.prom_type = 7; | 1927 | newd.prom_type = 7; |
| 1995 | newd.prom_id = th.data.zh_act.id; | 1928 | newd.prom_id = th.data.zh_act.id; |
| 1996 | } | 1929 | } |
| 1930 | + // if( [3,5,10].indexOf(newd.prom_type)>-1){ | ||
| 1931 | + // newd.prom_type=0; | ||
| 1932 | + // newd.prom_id=0; | ||
| 1933 | + // } | ||
| 1934 | + // | ||
| 1935 | + // //如果有搭配购的时候的时候 | ||
| 1936 | + // if(th.data.collocationGoods && newd.prom_type==0){ | ||
| 1937 | + // newd.prom_type = 5; | ||
| 1938 | + // newd.prom_id = th.data.collocationGoods.id; | ||
| 1939 | + // } | ||
| 1940 | + // | ||
| 1941 | + // //如果有搭配购的时候的时候 | ||
| 1942 | + // if(th.data.zh_act && (!th.data.zh_act.zh_num || th.data.zh_act.zh_buy_num>th.data.zh_act.zh_num ) && newd.prom_type==0){ | ||
| 1943 | + // newd.prom_type = 7; | ||
| 1944 | + // newd.prom_id = th.data.zh_act.id; | ||
| 1945 | + // } | ||
| 1997 | 1946 | ||
| 1998 | //----先看会员在购物车中是否加入了该商品----- | 1947 | //----先看会员在购物车中是否加入了该商品----- |
| 1999 | i.get("/api/weshop/cart/page", { | 1948 | i.get("/api/weshop/cart/page", { |
| @@ -2028,7 +1977,6 @@ Page({ | @@ -2028,7 +1977,6 @@ Page({ | ||
| 2028 | 1977 | ||
| 2029 | if(item){ | 1978 | if(item){ |
| 2030 | item = re.data.data.pageData[0]; | 1979 | item = re.data.data.pageData[0]; |
| 2031 | - | ||
| 2032 | //判断数量,要看下购物车中有没有该商品 | 1980 | //判断数量,要看下购物车中有没有该商品 |
| 2033 | if (CanOutQty) { | 1981 | if (CanOutQty) { |
| 2034 | if (item.goods_num + th.data.goodsInputNum > CanOutQty) { | 1982 | if (item.goods_num + th.data.goodsInputNum > CanOutQty) { |
| @@ -2082,7 +2030,6 @@ Page({ | @@ -2082,7 +2030,6 @@ Page({ | ||
| 2082 | updata['groupchat_id'] = getApp().globalData.groupchat_id; | 2030 | updata['groupchat_id'] = getApp().globalData.groupchat_id; |
| 2083 | } | 2031 | } |
| 2084 | 2032 | ||
| 2085 | - | ||
| 2086 | getApp().request.put("/api/weshop/cart/update", { | 2033 | getApp().request.put("/api/weshop/cart/update", { |
| 2087 | data: updata, | 2034 | data: updata, |
| 2088 | success: function (t) { | 2035 | success: function (t) { |
| @@ -2110,6 +2057,7 @@ Page({ | @@ -2110,6 +2057,7 @@ Page({ | ||
| 2110 | } | 2057 | } |
| 2111 | }); | 2058 | }); |
| 2112 | 2059 | ||
| 2060 | + | ||
| 2113 | } else { | 2061 | } else { |
| 2114 | 2062 | ||
| 2115 | //-- 这一步主要是要让立即购买 走 购物车的逻辑 参与活动,如果有zh_act就强制组合购购买 -- | 2063 | //-- 这一步主要是要让立即购买 走 购物车的逻辑 参与活动,如果有zh_act就强制组合购购买 -- |
| @@ -2245,61 +2193,14 @@ Page({ | @@ -2245,61 +2193,14 @@ Page({ | ||
| 2245 | newd.prom_type = 10; | 2193 | newd.prom_type = 10; |
| 2246 | newd.prom_id = th.data.ladder_act_id; | 2194 | newd.prom_id = th.data.ladder_act_id; |
| 2247 | 2195 | ||
| 2196 | + }else{ | ||
| 2248 | 2197 | ||
| 2249 | - //----先看会员在购物车中是否加入了该商品,立即购买的----- | ||
| 2250 | - getApp().request.get("/api/weshop/cart/page", { | ||
| 2251 | - data: { | ||
| 2252 | - store_id: os.stoid, | ||
| 2253 | - user_id: oo.user_id, | ||
| 2254 | - state: 1 | ||
| 2255 | - }, | ||
| 2256 | - success: function (res) { | ||
| 2257 | - //-------如果购物车中有相关的数据,先清理掉--------- | ||
| 2258 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2259 | - for (let j in res.data.data.pageData) { | ||
| 2260 | - let item_j = res.data.data.pageData[j]; | ||
| 2261 | - var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; | ||
| 2262 | - getApp().request.delete(url, {}); | ||
| 2263 | - } | ||
| 2264 | - } | ||
| 2265 | - | ||
| 2266 | - newd.state = 1; | ||
| 2267 | - getApp().request.post("/api/weshop/cart/save", { | ||
| 2268 | - data: newd, | ||
| 2269 | - success: function (t) { | ||
| 2270 | - th.closeSpecModal(); | ||
| 2271 | - getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); | ||
| 2272 | - } | ||
| 2273 | - }); | ||
| 2274 | - | ||
| 2275 | - } | ||
| 2276 | - }) | ||
| 2277 | - return false; | ||
| 2278 | - | ||
| 2279 | - } | ||
| 2280 | - | ||
| 2281 | - | ||
| 2282 | - //如果有搭配购的时候的时候 | ||
| 2283 | - if(th.data.collocationGoods && newd.prom_type==0){ | ||
| 2284 | - newd.prom_type = 5; | ||
| 2285 | - newd.prom_id = th.data.collocationGoods.id; | ||
| 2286 | - newd.is_coupon= th.data.collocationGoods.is_coupon; | ||
| 2287 | - | ||
| 2288 | - } | ||
| 2289 | - | ||
| 2290 | - //如果有搭配购的时候的时候 | ||
| 2291 | - if(th.data.zh_act && (newd.prom_type==0 || newd.prom_type==3)){ | ||
| 2292 | - newd.prom_type = 7; | ||
| 2293 | - newd.prom_id = th.data.zh_act.id; | ||
| 2294 | - } | ||
| 2295 | - | ||
| 2296 | - //如果有搭配购的时候的时候 | ||
| 2297 | - if(th.data.jt && newd.prom_type==0){ | ||
| 2298 | - newd.prom_type = 7; | ||
| 2299 | - newd.prom_id = th.data.zh_act.id; | 2198 | + //-- 优惠促销的商品,立即购买就判断了,就直接购买 -- |
| 2199 | + if([1,2,4,6].indexOf(newd.prom_type)==-1){ | ||
| 2200 | + newd.prom_type=0; | ||
| 2201 | + newd.id=0; | ||
| 2300 | } | 2202 | } |
| 2301 | 2203 | ||
| 2302 | - | ||
| 2303 | newd['pick_name'] = th.data.sto_sele_name; | 2204 | newd['pick_name'] = th.data.sto_sele_name; |
| 2304 | newd['pick_dis'] = th.data.sto_sele_distr; | 2205 | newd['pick_dis'] = th.data.sto_sele_distr; |
| 2305 | th.buyNow(newd); | 2206 | th.buyNow(newd); |
| @@ -2309,7 +2210,6 @@ Page({ | @@ -2309,7 +2210,6 @@ Page({ | ||
| 2309 | //因为在购物车 普通商品和 优惠促销,搭配购,组合购 阶梯购是一样的 | 2210 | //因为在购物车 普通商品和 优惠促销,搭配购,组合购 阶梯购是一样的 |
| 2310 | check_is_like(e,newd,idx){ | 2211 | check_is_like(e,newd,idx){ |
| 2311 | if(e.prom_type ==newd.prom_type) return true; | 2212 | if(e.prom_type ==newd.prom_type) return true; |
| 2312 | - | ||
| 2313 | if(!idx) { | 2213 | if(!idx) { |
| 2314 | if (e.prom_type == 0) { | 2214 | if (e.prom_type == 0) { |
| 2315 | if ([3, 5, 7, 10].indexOf(newd.prom_type) > -1) return true; | 2215 | if ([3, 5, 7, 10].indexOf(newd.prom_type) > -1) return true; |
| @@ -2360,40 +2260,55 @@ Page({ | @@ -2360,40 +2260,55 @@ Page({ | ||
| 2360 | } else { | 2260 | } else { |
| 2361 | //要判断积分购的普通购买有没有参加优惠活动 | 2261 | //要判断积分购的普通购买有没有参加优惠活动 |
| 2362 | if (e.is_integral_normal == 1 || e.is_pd_normal == 1) { | 2262 | if (e.is_integral_normal == 1 || e.is_pd_normal == 1) { |
| 2363 | - this.check_nor_promgood(e.goods_id, function (res) { | ||
| 2364 | - if (res && res.cat_id) { | ||
| 2365 | - e.prom_type = 3; | ||
| 2366 | - e.prom_id = res.cat_id | ||
| 2367 | - } | ||
| 2368 | - s.set_b_now(e); | ||
| 2369 | - /*-- | ||
| 2370 | - wx.redirectTo({ | ||
| 2371 | - url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 2372 | - });--*/ | ||
| 2373 | - getApp().goto("/packageE/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | 2263 | + e.prom_type = 0; |
| 2264 | + e.prom_id = 0 | ||
| 2374 | 2265 | ||
| 2375 | - }) | ||
| 2376 | - } else { | ||
| 2377 | - //搭配购特殊处理 | ||
| 2378 | - if( [3,5,7,10].indexOf(th.data.data.prom_type)>-1){ | ||
| 2379 | - e.prom_type=th.data.data.prom_type | ||
| 2380 | - e.prom_id=th.data.data.prom_id | ||
| 2381 | - e.collocation_goods=[] | ||
| 2382 | - } | 2266 | + } |
| 2383 | 2267 | ||
| 2384 | - if(th.data.collocationGoods){ | ||
| 2385 | - e.prom_type=5 | ||
| 2386 | - e.prom_id=th.data.collocationGoods.id | ||
| 2387 | - } | ||
| 2388 | - | ||
| 2389 | - s.set_b_now(e); | ||
| 2390 | - /*-- | ||
| 2391 | - wx.redirectTo({ | ||
| 2392 | - url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 2393 | - });--*/ | ||
| 2394 | - getApp().goto("/packageE/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | 2268 | + //秒杀等活动的直接跳转到cart2中的立即购买 |
| 2269 | + if([1,2,4,6].indexOf(e.prom_type)>-1){ | ||
| 2270 | + s.set_b_now(e); | ||
| 2271 | + getApp().goto("/packageE/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | ||
| 2272 | + }else { | ||
| 2273 | + | ||
| 2274 | + //----其他就按照公众号的购物车立即购买形式来修改,先看会员在购物车中是否加入了该商品,立即购买的----- | ||
| 2275 | + getApp().request.get("/api/weshop/cart/page", { | ||
| 2276 | + data: { | ||
| 2277 | + store_id: os.stoid, | ||
| 2278 | + user_id: oo.user_id, | ||
| 2279 | + state: 1 | ||
| 2280 | + }, | ||
| 2281 | + success: function (res) { | ||
| 2282 | + //-------如果购物车中有相关的数据--------- | ||
| 2283 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2284 | + for (let j in res.data.data.pageData) { | ||
| 2285 | + let item_j = res.data.data.pageData[j]; | ||
| 2286 | + var url = '/api/weshop/cart/del/' + os.stoid + '/' + item_j.id; | ||
| 2287 | + getApp().request.delete(url, {}); | ||
| 2288 | + } | ||
| 2289 | + } | ||
| 2290 | + | ||
| 2291 | + //-- 推迟一下,因为删除没有那么快 -- | ||
| 2292 | + setTimeout( ()=>{ | ||
| 2293 | + e.state = 1; | ||
| 2294 | + e.prom_type = 0; | ||
| 2295 | + e.prom_id = 0 | ||
| 2296 | + getApp().request.post("/api/weshop/cart/save", { | ||
| 2297 | + data: e, | ||
| 2298 | + success: function (t) { | ||
| 2299 | + th.closeSpecModal(); | ||
| 2300 | + getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); | ||
| 2301 | + } | ||
| 2302 | + }); | ||
| 2303 | + },500) | ||
| 2304 | + | ||
| 2305 | + } | ||
| 2306 | + }) | ||
| 2395 | } | 2307 | } |
| 2396 | 2308 | ||
| 2309 | + | ||
| 2310 | + | ||
| 2311 | + | ||
| 2397 | } | 2312 | } |
| 2398 | }, | 2313 | }, |
| 2399 | 2314 | ||
| @@ -2860,26 +2775,11 @@ Page({ | @@ -2860,26 +2775,11 @@ Page({ | ||
| 2860 | 2775 | ||
| 2861 | var r_data = res.data.data; | 2776 | var r_data = res.data.data; |
| 2862 | 2777 | ||
| 2863 | - if(r_data.collocationList){ | ||
| 2864 | - th.data.ladderLists =null; | ||
| 2865 | - th.data.prom_goods =null; | ||
| 2866 | - r_data.promGoodsLists=null; | ||
| 2867 | - r_data.ladderLists=null; | ||
| 2868 | - } | ||
| 2869 | - | ||
| 2870 | if (r_data.ladderLists) { | 2778 | if (r_data.ladderLists) { |
| 2871 | var act_id = r_data.ladderLists[0].form_id; | 2779 | var act_id = r_data.ladderLists[0].form_id; |
| 2872 | //-- 判断会员能不能参与阶梯促销 -- | 2780 | //-- 判断会员能不能参与阶梯促销 -- |
| 2873 | await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + usr.user_id + "/" + act_id, {}).then(res => { | 2781 | await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + usr.user_id + "/" + act_id, {}).then(res => { |
| 2874 | if (res.data.code == 0 && res.data.data) { | 2782 | if (res.data.code == 0 && res.data.data) { |
| 2875 | - var prom_content = ""; | ||
| 2876 | - //暂定优惠促销还不能重叠 | ||
| 2877 | - if (res.data.data.good_object == 0 && (r_data.promGoodsLists || th.data.zh_act)) { | ||
| 2878 | - return false; | ||
| 2879 | - } | ||
| 2880 | - if (res.data.data.good_object == 1) { | ||
| 2881 | - r_data.promGoodsLists = null; | ||
| 2882 | - } | ||
| 2883 | th.data.ladderLists = r_data.ladderLists; | 2783 | th.data.ladderLists = r_data.ladderLists; |
| 2884 | } | 2784 | } |
| 2885 | }) | 2785 | }) |
| @@ -3387,9 +3287,11 @@ Page({ | @@ -3387,9 +3287,11 @@ Page({ | ||
| 3387 | 3287 | ||
| 3388 | 3288 | ||
| 3389 | //普通商品多规格的时候,商品切换 | 3289 | //普通商品多规格的时候,商品切换 |
| 3290 | + | ||
| 3390 | if(this.data.base_nor_prom_type) this.data.base_nor_prom_type=parseInt(this.data.base_nor_prom_type); | 3291 | if(this.data.base_nor_prom_type) this.data.base_nor_prom_type=parseInt(this.data.base_nor_prom_type); |
| 3391 | 3292 | ||
| 3392 | - if([1,2,4,8,9].indexOf(this.data.base_nor_prom_type)==-1){ | 3293 | + |
| 3294 | + if([1,2,4,6,8,9].indexOf(this.data.base_nor_prom_type)==-1){ | ||
| 3393 | this.setData({ | 3295 | this.setData({ |
| 3394 | prom_goods:null, | 3296 | prom_goods:null, |
| 3395 | jieti_prom:null, | 3297 | jieti_prom:null, |
| @@ -3448,6 +3350,7 @@ Page({ | @@ -3448,6 +3350,7 @@ Page({ | ||
| 3448 | if (!item.whsle_id && ([1,2,4,6].indexOf(item.prom_type)==-1 || this.data.is_normal==1)) | 3350 | if (!item.whsle_id && ([1,2,4,6].indexOf(item.prom_type)==-1 || this.data.is_normal==1)) |
| 3449 | that.check_is_youhui(gid, that.data.is_normal,1); | 3351 | that.check_is_youhui(gid, that.data.is_normal,1); |
| 3450 | 3352 | ||
| 3353 | + | ||
| 3451 | //默认门店要拿下门店库存 | 3354 | //默认门店要拿下门店库存 |
| 3452 | if (that.data.sales_rules >= 2 && that.data.def_pick_store && !that.data.sele_g.whsle_id && [1,2,4,6].indexOf(item.prom_type)==-1) { | 3355 | if (that.data.sales_rules >= 2 && that.data.def_pick_store && !that.data.sele_g.whsle_id && [1,2,4,6].indexOf(item.prom_type)==-1) { |
| 3453 | var lock = 0, | 3356 | var lock = 0, |
| @@ -3465,7 +3368,7 @@ Page({ | @@ -3465,7 +3368,7 @@ Page({ | ||
| 3465 | this.sele_spec_chech_activity(nor); | 3368 | this.sele_spec_chech_activity(nor); |
| 3466 | 3369 | ||
| 3467 | //如果是秒杀,拼团等互动,就不重新算界面 | 3370 | //如果是秒杀,拼团等互动,就不重新算界面 |
| 3468 | - if([1,2,4,8,9].indexOf(this.data.base_nor_prom_type)>0){ return false; } | 3371 | + if([1,2,4,6,8,9].indexOf(this.data.base_nor_prom_type)>-1){ return false; } |
| 3469 | 3372 | ||
| 3470 | this.check_has_flash(gid); | 3373 | this.check_has_flash(gid); |
| 3471 | var url = '/api/weshop/activitylist/listGoodActInfo2New'; | 3374 | var url = '/api/weshop/activitylist/listGoodActInfo2New'; |
| @@ -3485,6 +3388,8 @@ Page({ | @@ -3485,6 +3388,8 @@ Page({ | ||
| 3485 | var arr3 = arr.filter(function (e) { | 3388 | var arr3 = arr.filter(function (e) { |
| 3486 | return e.s_time < ut.gettimestamp() && e.prom_type==7; | 3389 | return e.s_time < ut.gettimestamp() && e.prom_type==7; |
| 3487 | }) | 3390 | }) |
| 3391 | + | ||
| 3392 | + //-- 组合购要在面前计算 --,计算完之后,再来计算check_is_youhui -- | ||
| 3488 | if(arr3 && arr3.length>0){ | 3393 | if(arr3 && arr3.length>0){ |
| 3489 | //获取活动信息 | 3394 | //获取活动信息 |
| 3490 | var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + | 3395 | var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + |
| @@ -3502,10 +3407,12 @@ Page({ | @@ -3502,10 +3407,12 @@ Page({ | ||
| 3502 | }); | 3407 | }); |
| 3503 | th.getUserBuyPromNum(e.data.data.id) | 3408 | th.getUserBuyPromNum(e.data.data.id) |
| 3504 | } | 3409 | } |
| 3505 | - | ||
| 3506 | } | 3410 | } |
| 3411 | + if (!item.whsle_id) that.check_is_youhui(gid, that.data.is_normal); | ||
| 3507 | } | 3412 | } |
| 3508 | }); | 3413 | }); |
| 3414 | + }else{ | ||
| 3415 | + if (!item.whsle_id) that.check_is_youhui(gid, that.data.is_normal); | ||
| 3509 | } | 3416 | } |
| 3510 | 3417 | ||
| 3511 | } | 3418 | } |
| @@ -7546,6 +7453,7 @@ Page({ | @@ -7546,6 +7453,7 @@ Page({ | ||
| 7546 | } | 7453 | } |
| 7547 | } | 7454 | } |
| 7548 | }, | 7455 | }, |
| 7456 | + | ||
| 7549 | //-----显示优惠券的时候情况----- | 7457 | //-----显示优惠券的时候情况----- |
| 7550 | show_more_cx: function () { | 7458 | show_more_cx: function () { |
| 7551 | if (this.data.is_more_cx) { | 7459 | if (this.data.is_more_cx) { |
| @@ -7627,21 +7535,29 @@ Page({ | @@ -7627,21 +7535,29 @@ Page({ | ||
| 7627 | }) | 7535 | }) |
| 7628 | } | 7536 | } |
| 7629 | } | 7537 | } |
| 7538 | + | ||
| 7630 | var r_data=null; | 7539 | var r_data=null; |
| 7631 | 7540 | ||
| 7541 | + //-- 如果有组合购的时候 -- | ||
| 7542 | + if(th.data.zh_act){ | ||
| 7543 | + var show_time=ut.formatTime(th.data.zh_act.start_time)+"至"+ ut.formatTime(th.data.zh_act.end_time); | ||
| 7544 | + //-- 开始组装数据 -- | ||
| 7545 | + th.add_cx_prom_group({ | ||
| 7546 | + id: th.data.zh_act.id, | ||
| 7547 | + title: th.data.zh_act.name, | ||
| 7548 | + show_time: show_time, | ||
| 7549 | + prom_type:7 | ||
| 7550 | + }); | ||
| 7551 | + } | ||
| 7552 | + | ||
| 7632 | //调用接口判断订单优惠, | 7553 | //调用接口判断订单优惠, |
| 7633 | await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + gid + "/0" + "/" + user_id, { | 7554 | await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + gid + "/0" + "/" + user_id, { |
| 7634 | }).then(async res=>{ | 7555 | }).then(async res=>{ |
| 7635 | if (res.data.code == 0 && res.data.data) { | 7556 | if (res.data.code == 0 && res.data.data) { |
| 7636 | r_data = res.data.data; | 7557 | r_data = res.data.data; |
| 7637 | var max = 0, min = 0; | 7558 | var max = 0, min = 0; |
| 7638 | - //暂时积分够 不和 优惠,阶梯重叠 | ||
| 7639 | - if(th.data.zh_act){ | ||
| 7640 | - r_data.collocationList=null; | ||
| 7641 | - r_data.ladderLists=null; | ||
| 7642 | - r_data.promGoodsLists=null; | ||
| 7643 | - } | ||
| 7644 | 7559 | ||
| 7560 | + //如果是搭配购的时候 | ||
| 7645 | if (r_data.collocationList) { | 7561 | if (r_data.collocationList) { |
| 7646 | for (var i in r_data.collocationList) { | 7562 | for (var i in r_data.collocationList) { |
| 7647 | if (max == 0) max = r_data.collocationList[i].price; | 7563 | if (max == 0) max = r_data.collocationList[i].price; |
| @@ -7652,10 +7568,96 @@ Page({ | @@ -7652,10 +7568,96 @@ Page({ | ||
| 7652 | } | 7568 | } |
| 7653 | r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); | 7569 | r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); |
| 7654 | r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); | 7570 | r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); |
| 7571 | + var show_price= '¥'+r_data.collocationPromList.max+'-'+ r_data.collocationPromList.min; | ||
| 7572 | + var show_time=ut.formatTime(r_data.collocationPromList.start_time)+"至"+ ut.formatTime(r_data.collocationPromList.end_time); | ||
| 7573 | + | ||
| 7574 | + //-- 开始组装数据 -- | ||
| 7575 | + th.add_cx_prom_group({ | ||
| 7576 | + id: r_data.collocationPromList.id, | ||
| 7577 | + title: r_data.collocationPromList.title, | ||
| 7578 | + show_price: show_price, | ||
| 7579 | + show_time: show_time, | ||
| 7580 | + prom_type:5, | ||
| 7581 | + main_gid:gid | ||
| 7582 | + }); | ||
| 7583 | + } | ||
| 7584 | + | ||
| 7585 | + | ||
| 7586 | + //-- 如果是阶梯促销的时候 -- | ||
| 7587 | + if (r_data.ladderLists) { | ||
| 7588 | + var act_id = r_data.ladderLists[0].form_id; | ||
| 7589 | + //-- 判断会员能不能参与阶梯促销 -- | ||
| 7590 | + await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => { | ||
| 7591 | + if (res.data.code == 0 && res.data.data) { | ||
| 7592 | + var prom_content = ""; | ||
| 7593 | + | ||
| 7594 | + for (let jj in r_data.ladderLists) { | ||
| 7595 | + if (r_data.ladderLists[jj].discount == 10) { | ||
| 7596 | + prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; | ||
| 7597 | + } else { | ||
| 7598 | + prom_content += "第" + (parseInt(jj) + 1) + "件" + r_data.ladderLists[jj].discount + "折,"; | ||
| 7599 | + } | ||
| 7600 | + } | ||
| 7601 | + prom_content = ut.sub_last(prom_content); | ||
| 7602 | + | ||
| 7603 | + // th.data.prom_type = 10; | ||
| 7604 | + // th.data.prom_id = act_id; | ||
| 7605 | + | ||
| 7606 | + th.setData({ | ||
| 7607 | + jieti_prom: prom_content, | ||
| 7608 | + ladder_act_id: act_id | ||
| 7609 | + }) | ||
| 7610 | + | ||
| 7611 | + var s_time=res.data.data.start_time; | ||
| 7612 | + var e_time=res.data.data.end_time; | ||
| 7613 | + th.add_cx_prom_group({ | ||
| 7614 | + id: act_id, | ||
| 7615 | + title: prom_content, | ||
| 7616 | + show_time: ut.formatTime(s_time) + "至" + ut.formatTime(e_time), | ||
| 7617 | + prom_type:10 | ||
| 7618 | + }); | ||
| 7619 | + | ||
| 7620 | + } | ||
| 7621 | + }) | ||
| 7622 | + } | ||
| 7623 | + | ||
| 7624 | + //优惠促销的时候 | ||
| 7625 | + if (r_data.promGoodsLists) { | ||
| 7626 | + | ||
| 7627 | + var fir_act = r_data.promGoodsLists[0]; | ||
| 7628 | + //-- 计算一下限购,满足限购数才显示 -- | ||
| 7629 | + await this.getUserBuyPromNum_pre(fir_act.prom_id); | ||
| 7630 | + | ||
| 7631 | + if(!fir_act.limit_num || th.data.user_pre_buynum<fir_act.limit_num){ | ||
| 7632 | + var more_arr = []; | ||
| 7633 | + //减价 | ||
| 7634 | + if (fir_act.money > 0) more_arr.push('减价'+fir_act.money+'元'); | ||
| 7635 | + if (fir_act.sale > 0) more_arr.push('打'+fir_act.sale+'折'); | ||
| 7636 | + if (fir_act.past ==1) more_arr.push('包邮'); | ||
| 7637 | + if (fir_act.intValue > 0) more_arr.push('送'+fir_act.intValue+'积分'); | ||
| 7638 | + if (fir_act.couponId > 0) more_arr.push('送'+fir_act.couponMoney+'元优惠券'); | ||
| 7639 | + if (fir_act.gift_id) { | ||
| 7640 | + var is_more_gf=fir_act.gift_id.split(',') | ||
| 7641 | + if(is_more_gf.length>1){ | ||
| 7642 | + more_arr.push('送赠品'); | ||
| 7643 | + }else{ | ||
| 7644 | + more_arr.push('送'+fir_act.goods_name+' x'+fir_act.zp_num); | ||
| 7645 | + } | ||
| 7646 | + } | ||
| 7647 | + if (fir_act.lb_id) more_arr.push('送'+fir_act.lbtitle); | ||
| 7648 | + if (fir_act.zxlb_id) more_arr.push('送'+fir_act.zxlbtitle); | ||
| 7649 | + | ||
| 7650 | + //-- 开始组装数据 -- | ||
| 7651 | + th.add_cx_prom_group( { | ||
| 7652 | + id: fir_act.prom_id, | ||
| 7653 | + condition: fir_act.condition + (fir_act.prom_type == 1 ? '件' : '元'), | ||
| 7654 | + limit: '每人' + (fir_act.limit_num ? '限参与' + fir_act.limit_num + '次' : '参与不限次'), | ||
| 7655 | + more: more_arr, | ||
| 7656 | + prom_type:3 | ||
| 7657 | + | ||
| 7658 | + }); | ||
| 7659 | + } | ||
| 7655 | 7660 | ||
| 7656 | - //如果有搭配促销先不和 阶梯促销和优惠测序重合,做到后台可以重合 | ||
| 7657 | - r_data.ladderLists=null; | ||
| 7658 | - r_data.promGoodsLists=null; | ||
| 7659 | } | 7661 | } |
| 7660 | 7662 | ||
| 7661 | //普通购买不在界面显示 | 7663 | //普通购买不在界面显示 |
| @@ -7670,9 +7672,11 @@ Page({ | @@ -7670,9 +7672,11 @@ Page({ | ||
| 7670 | }) | 7672 | }) |
| 7671 | } | 7673 | } |
| 7672 | th.is_show_more_buy(); | 7674 | th.is_show_more_buy(); |
| 7675 | + | ||
| 7673 | } | 7676 | } |
| 7674 | }) | 7677 | }) |
| 7675 | 7678 | ||
| 7679 | + | ||
| 7676 | //-- 如果有阶梯购的时候 -- | 7680 | //-- 如果有阶梯购的时候 -- |
| 7677 | if (r_data && r_data.ladderLists) { | 7681 | if (r_data && r_data.ladderLists) { |
| 7678 | var act_id = r_data.ladderLists[0].form_id; | 7682 | var act_id = r_data.ladderLists[0].form_id; |
| @@ -7721,7 +7725,68 @@ Page({ | @@ -7721,7 +7725,68 @@ Page({ | ||
| 7721 | var mo_num=getApp().get_limit_qty(th.data.sele_g,this.data.is_act); | 7725 | var mo_num=getApp().get_limit_qty(th.data.sele_g,this.data.is_act); |
| 7722 | this.setData({goodsInputNum:mo_num}) | 7726 | this.setData({goodsInputNum:mo_num}) |
| 7723 | this.setData({mo_num:mo_num}) | 7727 | this.setData({mo_num:mo_num}) |
| 7728 | + }, | ||
| 7729 | + | ||
| 7730 | + //获取促销活动的组合 | ||
| 7731 | + add_cx_prom_group(data){ | ||
| 7732 | + var th=this; | ||
| 7733 | + getApp().getConfig2(function (e) { | ||
| 7734 | + //需要读者系统顺序 | ||
| 7735 | + var json_d = JSON.parse(e.switch_list); | ||
| 7736 | + var auto_promote_sale=json_d.auto_promote_sale; | ||
| 7737 | + if(auto_promote_sale){ | ||
| 7738 | + var auto_promote_sale=auto_promote_sale.split(','); | ||
| 7739 | + var fd=auto_promote_sale.indexOf(data.prom_type+''); | ||
| 7740 | + data.sort=fd; | ||
| 7741 | + }else{ | ||
| 7742 | + data.sort=data.prom_type; | ||
| 7743 | + } | ||
| 7724 | 7744 | ||
| 7745 | + var fdix=th.data.cx_prom_group.findIndex(function (em){ | ||
| 7746 | + return em.prom_type==data.prom_type | ||
| 7747 | + }) | ||
| 7748 | + | ||
| 7749 | + if(fdix>-1){ | ||
| 7750 | + th.data.cx_prom_group.splice(fdix,1); | ||
| 7751 | + } | ||
| 7752 | + | ||
| 7753 | + th.data.cx_prom_group.push(data); | ||
| 7754 | + | ||
| 7755 | + //-- 排序一下 -- | ||
| 7756 | + function comp(a, b) { | ||
| 7757 | + return a.sort-b.sort; //升序 | ||
| 7758 | + } | ||
| 7759 | + var ppdata = th.data.cx_prom_group; | ||
| 7760 | + //使用sort排序 | ||
| 7761 | + ppdata.sort(comp); | ||
| 7762 | + | ||
| 7763 | + th.setData({ | ||
| 7764 | + cx_prom_group:ppdata | ||
| 7765 | + }) | ||
| 7766 | + | ||
| 7767 | + }) | ||
| 7768 | + }, | ||
| 7769 | + | ||
| 7770 | + //--- 获取默认的促销活动的默认活动 --- | ||
| 7771 | + check_prom_custom(ind) { | ||
| 7772 | + if(ind){ | ||
| 7773 | + if (!this.data.cx_prom_group.length) return 0; | ||
| 7774 | + }else{ | ||
| 7775 | + if (!this.data.cx_prom_group.length) return {prom_type:0,id:0}; | ||
| 7776 | + } | ||
| 7777 | + var prom=null; | ||
| 7778 | + //-- 看有没有选中的活动 -- | ||
| 7779 | + var fd=this.data.cx_prom_group.findIndex(function (a){ | ||
| 7780 | + return a.sele==1; | ||
| 7781 | + }) | ||
| 7782 | + | ||
| 7783 | + prom=this.data.cx_prom_group[0]; | ||
| 7784 | + if(fd>-1) prom=this.data.cx_prom_group[fd]; | ||
| 7785 | + | ||
| 7786 | + if(ind) { | ||
| 7787 | + return prom.prom_type; | ||
| 7788 | + } | ||
| 7789 | + return prom; | ||
| 7725 | }, | 7790 | }, |
| 7726 | 7791 | ||
| 7727 | closePoster() { | 7792 | closePoster() { |
| @@ -7743,6 +7808,11 @@ Page({ | @@ -7743,6 +7808,11 @@ Page({ | ||
| 7743 | 7808 | ||
| 7744 | is_show_more_buy: async function () { | 7809 | is_show_more_buy: async function () { |
| 7745 | var prom_goods = this.data.prom_goods; | 7810 | var prom_goods = this.data.prom_goods; |
| 7811 | + if(!prom_goods) return false; | ||
| 7812 | + //如果系统默认的顺序不是以优惠促销为默认第一位的时候 | ||
| 7813 | + if(this.check_prom_custom(1)!==3){ | ||
| 7814 | + return false; | ||
| 7815 | + } | ||
| 7746 | var per_price = this.data.sele_g.shop_price | 7816 | var per_price = this.data.sele_g.shop_price |
| 7747 | if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) { | 7817 | if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) { |
| 7748 | per_price = this.data.sele_g[this.data.card_field]; | 7818 | per_price = this.data.sele_g[this.data.card_field]; |
| @@ -7766,9 +7836,9 @@ Page({ | @@ -7766,9 +7836,9 @@ Page({ | ||
| 7766 | } | 7836 | } |
| 7767 | } | 7837 | } |
| 7768 | //获取用户参与优惠促销的次数 | 7838 | //获取用户参与优惠促销的次数 |
| 7769 | - if(con && con.prom_id){ | ||
| 7770 | - await this.getUserBuyPromNum_pre(con.prom_id); | ||
| 7771 | - } | 7839 | + //if(con && con.prom_id){ |
| 7840 | + //await this.getUserBuyPromNum_pre(con.prom_id); | ||
| 7841 | + //} | ||
| 7772 | this.setData({ | 7842 | this.setData({ |
| 7773 | hui_condition: con | 7843 | hui_condition: con |
| 7774 | }); | 7844 | }); |
| @@ -7892,7 +7962,7 @@ Page({ | @@ -7892,7 +7962,7 @@ Page({ | ||
| 7892 | }); | 7962 | }); |
| 7893 | }, | 7963 | }, |
| 7894 | 7964 | ||
| 7895 | - //积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动 | 7965 | + //-- 积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动,普通购买的时候一定要注意 -- |
| 7896 | check_nor_promgood(goods_id, back) { | 7966 | check_nor_promgood(goods_id, back) { |
| 7897 | var th=this; | 7967 | var th=this; |
| 7898 | var user_id=getApp().globalData.user_id; | 7968 | var user_id=getApp().globalData.user_id; |
| @@ -7985,9 +8055,10 @@ Page({ | @@ -7985,9 +8055,10 @@ Page({ | ||
| 7985 | item = this.data.sele_g; | 8055 | item = this.data.sele_g; |
| 7986 | } | 8056 | } |
| 7987 | 8057 | ||
| 8058 | + var prom_id=this.check_prom_custom().id; | ||
| 7988 | 8059 | ||
| 7989 | //如果有组合购 | 8060 | //如果有组合购 |
| 7990 | - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item.prom_id + "/" + getApp().globalData.user_id; | 8061 | + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + prom_id + "/" + getApp().globalData.user_id; |
| 7991 | getApp().request.promiseGet(url, {}).then(res => { | 8062 | getApp().request.promiseGet(url, {}).then(res => { |
| 7992 | if (res.data.code == 0 && res.data.data) { | 8063 | if (res.data.code == 0 && res.data.data) { |
| 7993 | if (res.data.data.is_show != 1) { | 8064 | if (res.data.data.is_show != 1) { |
| @@ -8417,6 +8488,12 @@ Page({ | @@ -8417,6 +8488,12 @@ Page({ | ||
| 8417 | current: url, // 当前显示图片的http链接 | 8488 | current: url, // 当前显示图片的http链接 |
| 8418 | urls: url_arr, // 需要预览的图片http链接列表 | 8489 | urls: url_arr, // 需要预览的图片http链接列表 |
| 8419 | }); | 8490 | }); |
| 8491 | + }, | ||
| 8492 | + | ||
| 8493 | + //开始显示活动的弹出 | ||
| 8494 | + switch_cx_group:function (){ | ||
| 8495 | + var pro_pop = this.selectComponent("#pro_pop"); //组件的id | ||
| 8496 | + pro_pop.set_init(0,this.data.cx_prom_group); | ||
| 8420 | } | 8497 | } |
| 8421 | 8498 | ||
| 8422 | 8499 |
pages/goods/goodsInfo/goodsInfo.json
| @@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
| 5 | "nav_box": "/components/nav_box/nav_box", | 5 | "nav_box": "/components/nav_box/nav_box", |
| 6 | "warn": "/components/long_warn/long_warn", | 6 | "warn": "/components/long_warn/long_warn", |
| 7 | "goods_recommend": "/components/goods_list/goods_list", | 7 | "goods_recommend": "/components/goods_list/goods_list", |
| 8 | - "share": "/components/share/share" | 8 | + "share": "/components/share/share", |
| 9 | + "pro_pop": "/components/promate_pop/promate_pop" | ||
| 9 | } | 10 | } |
| 10 | } | 11 | } |
| 11 | \ No newline at end of file | 12 | \ No newline at end of file |
pages/goods/goodsInfo/goodsInfo.wxml
| 1 | +<!-- 促销弹出框 --> | ||
| 2 | +<pro_pop id="pro_pop"></pro_pop> | ||
| 3 | + | ||
| 1 | <import src="../../../utils/wxParse/wxParse.wxml"></import> | 4 | <import src="../../../utils/wxParse/wxParse.wxml"></import> |
| 2 | <wxs module="filters" src="../../../utils/filter.wxs"></wxs> | 5 | <wxs module="filters" src="../../../utils/filter.wxs"></wxs> |
| 3 | <wxs module="g_filters" src="g_filter.wxs"></wxs> | 6 | <wxs module="g_filters" src="g_filter.wxs"></wxs> |
| @@ -501,66 +504,66 @@ | @@ -501,66 +504,66 @@ | ||
| 501 | 504 | ||
| 502 | 505 | ||
| 503 | <!-- 要判断是不是有促销活动 --> | 506 | <!-- 要判断是不是有促销活动 --> |
| 504 | - <block wx:if="{{prom_goods}}"> | ||
| 505 | - <view class="cx-frame flex" style="position: relative; height: auto" hidden="{{prom_type==4 || prom_type==6}}"> | ||
| 506 | - <!-- 中间显示层 --> | ||
| 507 | - <block> | ||
| 508 | - <view class="cx-sizs fs30 pdr20">促销</view> | ||
| 509 | - <view class="f1"> | ||
| 510 | - <view class="fs28 f1" wx:for="{{prom_goods}}"> | ||
| 511 | - <view> | ||
| 512 | - <text class="prom_condition"> | ||
| 513 | - <text class="fill-box">消费满{{item.condition}}{{item.prom_type==1 ? '件':'元'}}</text>享优惠(每人{{item.limit_num ? '限参与'+item.limit_num+'次' : '参与不限次' }}) | ||
| 514 | - </text> | ||
| 515 | - </view> | ||
| 516 | - | ||
| 517 | - <view class="word f1 fs26"> | ||
| 518 | - <text class="tick lh2 pdr20" wx:if="{{item.money>0}}">减价{{item.money}}元</text> | ||
| 519 | - <text class="tick lh2 pdr20" wx:if="{{item.sale>0}}">打{{item.sale}}折</text> | ||
| 520 | - <text class="tick lh2 pdr20" wx:if="{{item.past==1}}">包邮</text> | ||
| 521 | - <text class="tick lh2 pdr20" wx:if="{{item.intValue>0}}">送{{item.intValue}}积分</text> | ||
| 522 | - <view class="tick lh2 pdr20" wx:if="{{item.couponId>0}}">送{{item.couponMoney}}元优惠券</view> | ||
| 523 | - | ||
| 524 | - <block wx:if="{{item.gift_id}}"> | ||
| 525 | - <view class="tick ellipsis-1x lh2 details pdr40" bindtap="show_zp" data-index="{{index}}" data-prom="{{item.prom_id}}" wx:if="{{g_filters.is_more_gift(item.gift_id)>1}}">送赠品</view> | ||
| 526 | - <view class="tick ellipsis-1x lh2" style="display: flex;align-items: center;" wx:else> | ||
| 527 | - <block wx:if="{{item.zp_num>0}}"> | ||
| 528 | - <view class="ellipsis-1x">送{{item.goods_name}}</view> | ||
| 529 | - <view style="color: red;margin-left: 20rpx;">x{{item.zp_num}}</view> | ||
| 530 | - </block> | ||
| 531 | - </view> | ||
| 532 | - </block> | ||
| 533 | - | ||
| 534 | - | ||
| 535 | - | ||
| 536 | - <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.lb_id>0}}" data-id="{{item.lb_id}}" bindtap="viewLbDetails">送{{item.lbtitle}}</view> | ||
| 537 | - <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.zxlb_id>0}}" data-id="{{item.zxlb_id}}" data-flag="1" bindtap="viewLbDetails">送{{item.zxlbtitle}}</view> | ||
| 538 | - <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.monthgiftbag_id>0}}" data-id="{{item.monthgiftbag_id}}" data-flag="2" bindtap="viewLbDetails">送{{item.monthgiftbag_title}}</view> | ||
| 539 | - </view> | ||
| 540 | - </view> | ||
| 541 | - </view> | ||
| 542 | 507 | ||
| 543 | - </block> | ||
| 544 | - </view> | ||
| 545 | - </block> | 508 | +<!-- <block wx:if="{{prom_goods}}">--> |
| 509 | +<!-- <view class="cx-frame flex" style="position: relative; height: auto" hidden="{{prom_type==4 || prom_type==6}}">--> | ||
| 510 | +<!-- <!– 中间显示层 –>--> | ||
| 511 | +<!-- <block>--> | ||
| 512 | +<!-- <view class="cx-sizs fs30 pdr20">促销</view>--> | ||
| 513 | +<!-- <view class="f1">--> | ||
| 514 | +<!-- <view class="fs28 f1" wx:for="{{prom_goods}}">--> | ||
| 515 | +<!-- <view>--> | ||
| 516 | +<!-- <text class="prom_condition">--> | ||
| 517 | +<!-- <text class="fill-box">消费满{{item.condition}}{{item.prom_type==1 ? '件':'元'}}</text>享优惠(每人{{item.limit_num ? '限参与'+item.limit_num+'次' : '参与不限次' }})--> | ||
| 518 | +<!-- </text>--> | ||
| 519 | +<!-- </view>--> | ||
| 520 | + | ||
| 521 | +<!-- <view class="word f1 fs26">--> | ||
| 522 | +<!-- <text class="tick lh2 pdr20" wx:if="{{item.money>0}}">减价{{item.money}}元</text>--> | ||
| 523 | +<!-- <text class="tick lh2 pdr20" wx:if="{{item.sale>0}}">打{{item.sale}}折</text>--> | ||
| 524 | +<!-- <text class="tick lh2 pdr20" wx:if="{{item.past==1}}">包邮</text>--> | ||
| 525 | +<!-- <text class="tick lh2 pdr20" wx:if="{{item.intValue>0}}">送{{item.intValue}}积分</text>--> | ||
| 526 | +<!-- <view class="tick lh2 pdr20" wx:if="{{item.couponId>0}}">送{{item.couponMoney}}元优惠券</view>--> | ||
| 527 | + | ||
| 528 | +<!-- <block wx:if="{{item.gift_id}}">--> | ||
| 529 | +<!-- <view class="tick ellipsis-1x lh2 details pdr40" bindtap="show_zp" data-index="{{index}}" data-prom="{{item.prom_id}}" wx:if="{{g_filters.is_more_gift(item.gift_id)>1}}">送赠品</view>--> | ||
| 530 | +<!-- <view class="tick ellipsis-1x lh2" style="display: flex;align-items: center;" wx:else>--> | ||
| 531 | +<!-- <block wx:if="{{item.zp_num>0}}">--> | ||
| 532 | +<!-- <view class="ellipsis-1x">送{{item.goods_name}}</view>--> | ||
| 533 | +<!-- <view style="color: red;margin-left: 20rpx;">x{{item.zp_num}}</view>--> | ||
| 534 | +<!-- </block>--> | ||
| 535 | +<!-- </view>--> | ||
| 536 | +<!-- </block>--> | ||
| 537 | + | ||
| 538 | + | ||
| 539 | + | ||
| 540 | +<!-- <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.lb_id>0}}" data-id="{{item.lb_id}}" bindtap="viewLbDetails">送{{item.lbtitle}}</view>--> | ||
| 541 | +<!-- <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.zxlb_id>0}}" data-id="{{item.zxlb_id}}" data-flag="1" bindtap="viewLbDetails">送{{item.zxlbtitle}}</view>--> | ||
| 542 | +<!-- </view>--> | ||
| 543 | +<!-- </view>--> | ||
| 544 | +<!-- </view>--> | ||
| 545 | + | ||
| 546 | +<!-- </block>--> | ||
| 547 | +<!-- </view>--> | ||
| 548 | +<!-- </block>--> | ||
| 549 | + | ||
| 550 | +<!-- <block wx:if="{{jieti_prom}}">--> | ||
| 551 | +<!-- <view class="cx-frame flex jc_sb" bindtap="go_more_ladder" data-id="{{ladder_act_id}}" style="position: relative; height: auto">--> | ||
| 552 | +<!-- <view class="flex" style="width: 92%">--> | ||
| 553 | +<!-- <view class="cx-sizs fs30" style="width: 90rpx;flex-shrink: 0">阶梯促</view>--> | ||
| 554 | +<!-- <!– 中间显示层 –>--> | ||
| 555 | +<!-- <view class="ellipsis-1 fs24">--> | ||
| 556 | +<!-- <text class="jie_show fs22">阶</text>--> | ||
| 557 | +<!-- {{jieti_prom}}--> | ||
| 558 | +<!-- </view>--> | ||
| 559 | +<!-- </view>--> | ||
| 560 | +<!-- <view data-coupon="1" bindtap="show_more_cx" class="cx-obtain-coupon wsize">--> | ||
| 561 | +<!-- <text class="bg_jj" style="position: relative;right: 3rpx"></text>--> | ||
| 562 | +<!-- </view>--> | ||
| 563 | +<!-- </view>--> | ||
| 564 | +<!-- </block>--> | ||
| 546 | 565 | ||
| 547 | - <block wx:if="{{jieti_prom}}"> | ||
| 548 | - <view class="cx-frame flex jc_sb" bindtap="go_more_ladder" data-id="{{ladder_act_id}}" style="position: relative; height: auto"> | ||
| 549 | - <view class="flex" style="width: 92%"> | ||
| 550 | - <view class="cx-sizs fs30" style="width: 90rpx;flex-shrink: 0">阶梯促</view> | ||
| 551 | - <!-- 中间显示层 --> | ||
| 552 | - <view class="ellipsis-1 fs24"> | ||
| 553 | - <text class="jie_show fs22">阶</text> | ||
| 554 | - {{jieti_prom}} | ||
| 555 | - </view> | ||
| 556 | - </view> | ||
| 557 | - <view data-coupon="1" bindtap="show_more_cx" class="cx-obtain-coupon wsize"> | ||
| 558 | - <text class="bg_jj" style="position: relative;right: 3rpx"></text> | ||
| 559 | - </view> | ||
| 560 | - </view> | ||
| 561 | - </block> | ||
| 562 | 566 | ||
| 563 | - <!-- 要判断是不是有订单优惠 --> | ||
| 564 | <block wx:if="{{order_prom}}"> | 567 | <block wx:if="{{order_prom}}"> |
| 565 | <view class="cx-frame flex" style="position: relative; height: auto"> | 568 | <view class="cx-frame flex" style="position: relative; height: auto"> |
| 566 | <view class="cx-sizs fs30 pdr20">订单优惠</view> | 569 | <view class="cx-sizs fs30 pdr20">订单优惠</view> |
| @@ -576,27 +579,29 @@ | @@ -576,27 +579,29 @@ | ||
| 576 | </view> | 579 | </view> |
| 577 | </view> | 580 | </view> |
| 578 | </block> | 581 | </block> |
| 579 | - <!-- 要判断是不是有组合优惠 --> | ||
| 580 | - <block wx:if="{{zh_act}}"> | ||
| 581 | - <view class="cx-frame flex" style="position: relative; height: auto"> | ||
| 582 | - <view class="cx-sizs wsize" style="width: 144rpx">组合购</view> | ||
| 583 | - <!-- 中间显示层 --> | ||
| 584 | - <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_zh" data-id="{{zh_act.id}}"> | ||
| 585 | - <view class="flex"> | ||
| 586 | - <image class="hui_img" src="{{iurl}}/miniapp//images/hui.png"></image> | ||
| 587 | - <view class="order_hui"> | ||
| 588 | - <view class="fs28 ellipsis-1">{{zh_act.name}}</view> | ||
| 589 | - <view class="fs26"> | ||
| 590 | - (活动时间:{{tool.format_tt(zh_act.start_time)}} - {{tool.format_tt(zh_act.end_time)}}) | ||
| 591 | - </view> | ||
| 592 | - </view> | ||
| 593 | - </view> | ||
| 594 | - <view> | ||
| 595 | - <text class="bg_jj is_more_cx" style="position: relative;top:-10rpx"></text> | ||
| 596 | - </view> | ||
| 597 | - </view> | ||
| 598 | - </view> | ||
| 599 | - </block> | 582 | + |
| 583 | +<!-- <block wx:if="{{zh_act}}">--> | ||
| 584 | +<!-- <view class="cx-frame flex" style="position: relative; height: auto">--> | ||
| 585 | +<!-- <view class="cx-sizs wsize" style="width: 144rpx">组合购</view>--> | ||
| 586 | +<!-- <!– 中间显示层 –>--> | ||
| 587 | +<!-- <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_zh" data-id="{{zh_act.id}}">--> | ||
| 588 | +<!-- <view class="flex">--> | ||
| 589 | +<!-- <image class="hui_img" src="{{iurl}}/miniapp//images/hui.png"></image>--> | ||
| 590 | +<!-- <view class="order_hui">--> | ||
| 591 | +<!-- <view class="fs28 ellipsis-1">{{zh_act.name}}</view>--> | ||
| 592 | +<!-- <view class="fs26">--> | ||
| 593 | +<!-- (活动时间:{{tool.format_tt(zh_act.start_time)}} - {{tool.format_tt(zh_act.end_time)}})--> | ||
| 594 | +<!-- </view>--> | ||
| 595 | +<!-- </view>--> | ||
| 596 | +<!-- </view>--> | ||
| 597 | +<!-- <view>--> | ||
| 598 | +<!-- <text class="bg_jj is_more_cx" style="position: relative;top:-10rpx"></text>--> | ||
| 599 | +<!-- </view>--> | ||
| 600 | +<!-- </view>--> | ||
| 601 | +<!-- </view>--> | ||
| 602 | +<!-- </block>--> | ||
| 603 | + | ||
| 604 | + | ||
| 600 | <!-- 判断是不是有秒杀 --> | 605 | <!-- 判断是不是有秒杀 --> |
| 601 | <!-- 判断是不是有秒杀 --> | 606 | <!-- 判断是不是有秒杀 --> |
| 602 | <block wx:if="{{more_flash}}"> | 607 | <block wx:if="{{more_flash}}"> |
| @@ -623,6 +628,7 @@ | @@ -623,6 +628,7 @@ | ||
| 623 | <view wx:if="{{item.prom_type==9}}" class="miao_lab">幸</view> | 628 | <view wx:if="{{item.prom_type==9}}" class="miao_lab">幸</view> |
| 624 | 629 | ||
| 625 | 630 | ||
| 631 | + | ||
| 626 | <view class="order_hui"> | 632 | <view class="order_hui"> |
| 627 | <view class="fs28 ellipsis-1">{{item.act_name}}</view> | 633 | <view class="fs28 ellipsis-1">{{item.act_name}}</view> |
| 628 | <view class="fs26"> | 634 | <view class="fs26"> |
| @@ -638,35 +644,28 @@ | @@ -638,35 +644,28 @@ | ||
| 638 | </block> | 644 | </block> |
| 639 | </block> | 645 | </block> |
| 640 | 646 | ||
| 641 | - <!-- - 搭配促销 -- --> | ||
| 642 | - <view class="dp_cx_view" wx:if="{{collocationGoods}}"> | ||
| 643 | - <view class="bb_view"> | ||
| 644 | - <view>优惠热配</view> | ||
| 645 | - <view class="red_bb" bindtap="go_prom_list"> | ||
| 646 | - 查看全部 | ||
| 647 | - <text class="bg_jj"></text> | 647 | + <!-- 新增促销多活动的排版 --> |
| 648 | + <view class="bdt16" wx:if="{{ prom_type!=1 && prom_type!=2 && prom_type!=4 && prom_type!=6 && cx_prom_group.length>0}}"> | ||
| 649 | + <view data-coupon="1" bindtap="switch_cx_group" class="cx-frame flex" style="position: relative"> | ||
| 650 | + <view class="cx-sizs fs30">促销</view> | ||
| 651 | + <view class="flex ai_c f1 pdh20"> | ||
| 652 | + <view class="xc-coupon-fram" wx:for="{{cx_prom_group}}" > | ||
| 653 | + <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word">优惠促销</view> | ||
| 654 | + <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word">搭配促销</view> | ||
| 655 | + <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word">组合购</view> | ||
| 656 | + <view wx:if="{{item.prom_type==10}}" class="xc-coupon t-c four-level-word">阶梯促销</view> | ||
| 657 | + </view> | ||
| 648 | </view> | 658 | </view> |
| 649 | - </view> | ||
| 650 | - <!-- 搭配的显示 --> | ||
| 651 | - <view class="flex" bindtap="go_prom_list"> | ||
| 652 | - <image class="dp_img" src="{{iurl+collocationGoods.img_url}}"></image> | ||
| 653 | - <view class="act_content"> | ||
| 654 | - <view class="fs32">{{collocationGoods.title}}</view> | ||
| 655 | - <view class="fs30 color_b" wx:if="{{collocationGoods.max!=collocationGoods.min}}"> | ||
| 656 | - 搭配价¥{{collocationGoods.min}}-{{collocationGoods.max}} | ||
| 657 | - </view> | ||
| 658 | - <view class="fs30 color_b" wx:else>搭配价¥{{collocationGoods.min}}</view> | ||
| 659 | - <view class="fs30 color-gray"> | ||
| 660 | - 活动至{{filters.format_time(collocationGoods.end_time,1)}} | ||
| 661 | - </view> | 659 | + <view class="cx-obtain-coupon wsize"> |
| 660 | + <text class="bg_jj"></text> | ||
| 662 | </view> | 661 | </view> |
| 663 | </view> | 662 | </view> |
| 664 | </view> | 663 | </view> |
| 665 | 664 | ||
| 666 | 665 | ||
| 667 | <!-- 许程 7.24暂时注释 --> | 666 | <!-- 许程 7.24暂时注释 --> |
| 668 | - <view class="bdt16" wx:if="{{ prom_type!=1 && prom_act.kttype!=3&&prom_act.kttype!=2&&prom_act.kttype!=1 && is_closecoupon!=1 && sele_g.is_xz_yh !=1}}"> | ||
| 669 | - <view data-coupon="1" bindtap="switchCoupon" class="cx-frame flex" style="position: relative" wx:if="{{fir_quan.length>0}}"> | 667 | + <view class="bdt16" wx:if="{{ prom_type!=1 && prom_act.kttype!=3&&prom_act.kttype!=2&&prom_act.kttype!=1 && is_closecoupon!=1 && sele_g.is_xz_yh !=1 && fir_quan.length>0 }}"> |
| 668 | + <view data-coupon="1" bindtap="switchCoupon" class="cx-frame flex" style="position: relative"> | ||
| 670 | <view class="cx-sizs fs30">领券</view> | 669 | <view class="cx-sizs fs30">领券</view> |
| 671 | <view class="flex ai_c f1 pdh20"> | 670 | <view class="flex ai_c f1 pdh20"> |
| 672 | <view class="xc-coupon-fram" wx:for="{{fir_quan}}" wx:key="id"> | 671 | <view class="xc-coupon-fram" wx:for="{{fir_quan}}" wx:key="id"> |
| @@ -682,6 +681,7 @@ | @@ -682,6 +681,7 @@ | ||
| 682 | </view> | 681 | </view> |
| 683 | </view> | 682 | </view> |
| 684 | </view> | 683 | </view> |
| 684 | + | ||
| 685 | <!-- 门店收货地址 --> | 685 | <!-- 门店收货地址 --> |
| 686 | <view class="xc-address_frame bdt16 flex-vertical xc-ash {{def_pick_store!=null?'sn_height':'on_height'}}"> | 686 | <view class="xc-address_frame bdt16 flex-vertical xc-ash {{def_pick_store!=null?'sn_height':'on_height'}}"> |
| 687 | <view class="address_frame" bindtap="choice_store" data-ind="0"> | 687 | <view class="address_frame" bindtap="choice_store" data-ind="0"> |
| @@ -731,7 +731,31 @@ | @@ -731,7 +731,31 @@ | ||
| 731 | </view> | 731 | </view> |
| 732 | </view> | 732 | </view> |
| 733 | 733 | ||
| 734 | - | 734 | + <!-- - 搭配促销 -- --> |
| 735 | +<!-- <view class="dp_cx_view" wx:if="{{collocationGoods}}">--> | ||
| 736 | +<!-- <view class="bb_view">--> | ||
| 737 | +<!-- <view>优惠热配</view>--> | ||
| 738 | +<!-- <view class="red_bb" bindtap="go_prom_list">--> | ||
| 739 | +<!-- 查看全部--> | ||
| 740 | +<!-- <text class="bg_jj"></text>--> | ||
| 741 | +<!-- </view>--> | ||
| 742 | +<!-- </view>--> | ||
| 743 | +<!-- <!– 搭配的显示 –>--> | ||
| 744 | +<!-- <view class="flex" bindtap="go_prom_list">--> | ||
| 745 | +<!-- <image class="dp_img" src="{{iurl+collocationGoods.img_url}}"></image>--> | ||
| 746 | +<!-- <view class="act_content">--> | ||
| 747 | +<!-- <view class="fs32">{{collocationGoods.title}}</view>--> | ||
| 748 | +<!-- <view class="fs30 color_b" wx:if="{{collocationGoods.max!=collocationGoods.min}}">--> | ||
| 749 | +<!-- 搭配价¥{{collocationGoods.min}}-{{collocationGoods.max}}--> | ||
| 750 | +<!-- </view>--> | ||
| 751 | +<!-- <view class="fs30 color_b" wx:else>搭配价¥{{collocationGoods.min}}</view>--> | ||
| 752 | +<!-- <view class="fs30 color-gray">--> | ||
| 753 | +<!-- 活动至{{filters.format_time(collocationGoods.end_time,1)}}--> | ||
| 754 | +<!-- </view>--> | ||
| 755 | +<!-- </view>--> | ||
| 756 | +<!-- </view>--> | ||
| 757 | +<!-- </view>--> | ||
| 758 | + | ||
| 735 | <!-- - 宝贝评价 -- --> | 759 | <!-- - 宝贝评价 -- --> |
| 736 | <view class="bdt16"> | 760 | <view class="bdt16"> |
| 737 | <view class="bb_view"> | 761 | <view class="bb_view"> |
| @@ -1749,6 +1773,7 @@ | @@ -1749,6 +1773,7 @@ | ||
| 1749 | <warn id="warn"></warn> | 1773 | <warn id="warn"></warn> |
| 1750 | <!-- 分享控件,底部弹出 --> | 1774 | <!-- 分享控件,底部弹出 --> |
| 1751 | <share id="share_button" bind:send="send" bind:cancel="cancel" bind:share_img="saveImageToPhotosAlbum" wx:if="{{share_hidden}}"></share> | 1775 | <share id="share_button" bind:send="send" bind:cancel="cancel" bind:share_img="saveImageToPhotosAlbum" wx:if="{{share_hidden}}"></share> |
| 1776 | + | ||
| 1752 | <view wx:if="{{showPoster}}"> | 1777 | <view wx:if="{{showPoster}}"> |
| 1753 | <view class="mask" catchtap="closePoster"></view> | 1778 | <view class="mask" catchtap="closePoster"></view> |
| 1754 | <view class="poster-container"> | 1779 | <view class="poster-container"> |
| @@ -1819,4 +1844,6 @@ | @@ -1819,4 +1844,6 @@ | ||
| 1819 | <include src="buy_flash_normal.wxml" /> | 1844 | <include src="buy_flash_normal.wxml" /> |
| 1820 | </view> | 1845 | </view> |
| 1821 | 1846 | ||
| 1822 | -<include src="../../../components/com_servicer/com_servicer.wxml"></include> | ||
| 1823 | \ No newline at end of file | 1847 | \ No newline at end of file |
| 1848 | +<include src="../../../components/com_servicer/com_servicer.wxml"></include> | ||
| 1849 | + | ||
| 1850 | + |
pages/goods/goodsList/goodsList.wxml
| 1 | <wxs module="g_filter" src="../search/g_filter.wxs"></wxs> | 1 | <wxs module="g_filter" src="../search/g_filter.wxs"></wxs> |
| 2 | <view class="container" wx:if="{{show_all}}"> | 2 | <view class="container" wx:if="{{show_all}}"> |
| 3 | <view> | 3 | <view> |
| 4 | - | 4 | + |
| 5 | + <view wx:if="{{prom_goods_list}}" class="fs30"><text style="color: red;" wx:if="{{index==0 && limit_num>0}}">每人限参与{{limit_num}}次;</text></view> | ||
| 5 | <block wx:for="{{prom_goods_list}}"> | 6 | <block wx:for="{{prom_goods_list}}"> |
| 6 | <view class="fs30 ellipsis-1" style="padding: 20rpx 30rpx"> | 7 | <view class="fs30 ellipsis-1" style="padding: 20rpx 30rpx"> |
| 7 | - <text style="color: red;" wx:if="{{index==0 && limit_num>0}}">每人限参与{{limit_num}}次;</text> | ||
| 8 | 满{{item.condition}}<text space="{{true}}" wx:if="{{item.prom_type==0}}">元 </text> <text space="{{true}}" wx:else>件 </text> | 8 | 满{{item.condition}}<text space="{{true}}" wx:if="{{item.prom_type==0}}">元 </text> <text space="{{true}}" wx:else>件 </text> |
| 9 | <text space="{{true}}" wx:if="{{item.content.is_money && item.content.is_money!='0'}}">减{{item.content.money}}元 </text> | 9 | <text space="{{true}}" wx:if="{{item.content.is_money && item.content.is_money!='0'}}">减{{item.content.money}}元 </text> |
| 10 | + <text space="{{true}}" wx:if="{{item.content.past && item.content.past!='0'}}">包邮</text> | ||
| 10 | <text space="{{true}}" wx:if="{{item.content.is_sale && item.content.is_sale!='0'}}">打{{item.content.sale}}折 </text> | 11 | <text space="{{true}}" wx:if="{{item.content.is_sale && item.content.is_sale!='0'}}">打{{item.content.sale}}折 </text> |
| 11 | <text space="{{true}}" wx:if="{{item.content.is_int && item.content.is_int!='0'}}">送{{item.content.int}}积分 </text> | 12 | <text space="{{true}}" wx:if="{{item.content.is_int && item.content.is_int!='0'}}">送{{item.content.int}}积分 </text> |
| 12 | <text space="{{true}}" wx:if="{{item.content.is_coupon && item.content.is_coupon!='0'}}">送{{item.content.coupon}}元优惠券 </text> | 13 | <text space="{{true}}" wx:if="{{item.content.is_coupon && item.content.is_coupon!='0'}}">送{{item.content.coupon}}元优惠券 </text> |
utils/more_cx.js
0 → 100644
| 1 | +var regeneratorRuntime = require('runtime.js'); | ||
| 2 | +module.exports = { | ||
| 3 | + zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){ | ||
| 4 | + let zhqty_bz_flag =true; | ||
| 5 | + for(let i=0;i<zhqty_bz.length;i++){ | ||
| 6 | + let item=zhqty_bz[i]; | ||
| 7 | + let bz_num = be * item['zhqty']; //超量倍增 | ||
| 8 | + let num = item['num'] - item['zhqty']; //购买数量减去超量 | ||
| 9 | + if (bz_num > num) { | ||
| 10 | + zhqty_bz_flag=false; | ||
| 11 | + | ||
| 12 | + var be=0; | ||
| 13 | + if (num % vv.zhqty == 0) { | ||
| 14 | + be = num / vv.zhqty; | ||
| 15 | + } else { | ||
| 16 | + be = Math.floor(num / vv.zhqty) | ||
| 17 | + } | ||
| 18 | + item.be=item; | ||
| 19 | + | ||
| 20 | + zhqty_bz_arr.push(item); | ||
| 21 | + // zhqty_bz.splice(i,1) | ||
| 22 | + } | ||
| 23 | + } | ||
| 24 | + return zhqty_bz_flag; | ||
| 25 | + }, | ||
| 26 | + //-- 判断组合购有没有满足,只有在检查的时候,要用新的 --- | ||
| 27 | + ch_zh_ok(act,gdlist,c_goods,th,item_act_map,is_need_ck_num,need_ok){ | ||
| 28 | + | ||
| 29 | + //-- 寻找一下 -- | ||
| 30 | + function get_num(ite) { | ||
| 31 | + for (let v1 in c_goods) { | ||
| 32 | + var vh = c_goods[v1]; | ||
| 33 | + if (vh.goods_id == ite.goods_id) { | ||
| 34 | + return vh; | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + return 0; | ||
| 38 | + } | ||
| 39 | + var goods =gdlist; | ||
| 40 | + var all_num=0; | ||
| 41 | + var need_to_buy=0; | ||
| 42 | + var all_zhqty=0; | ||
| 43 | + //-- 是综合考虑到组合购的总数量和限购数量 -- | ||
| 44 | + var min_can_buy=-1; | ||
| 45 | + var aid=act.id; | ||
| 46 | + | ||
| 47 | + let no_in_arr = []; //剩余的未加入组合购 | ||
| 48 | + let out_arr = []; //超出活动限购的商品放入 | ||
| 49 | + | ||
| 50 | + //-- 判断组合购的总数量是不是到了 -- | ||
| 51 | + if(act.zh_num>0){ | ||
| 52 | + //如果是在全选的情况下,那么就需要in_zhact_new来控制数量 | ||
| 53 | + var need_ck=0; | ||
| 54 | + if(is_need_ck_num){ | ||
| 55 | + need_ck=th.data.in_zhact_new[aid]?th.data.in_zhact_new[aid]:0; | ||
| 56 | + } | ||
| 57 | + if(need_ck+act.zh_buy_num>=act.zh_num ){ | ||
| 58 | + return false; | ||
| 59 | + }else{ | ||
| 60 | + min_can_buy= act.zh_num-act.zh_buy_num-need_ck; | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + //-- 判断组合购的限购是不是到了 -- | ||
| 64 | + if(act.buy_limit>0){ | ||
| 65 | + var need_ck0=0; | ||
| 66 | + if(is_need_ck_num){ | ||
| 67 | + need_ck0=th.data.in_zhact_new[aid]?th.data.in_zhact_new[aid]:0; | ||
| 68 | + } | ||
| 69 | + var min_can_buy0=0; | ||
| 70 | + if(need_ck+item_act_map.buyed>=act.buy_limit ){ | ||
| 71 | + return false; | ||
| 72 | + }else{ | ||
| 73 | + min_can_buy0=act.buy_limit-item_act_map.buyed-need_ck; | ||
| 74 | + } | ||
| 75 | + if(min_can_buy>0){ | ||
| 76 | + if(min_can_buy0<min_can_buy) min_can_buy=min_can_buy0; | ||
| 77 | + }else{ | ||
| 78 | + min_can_buy=min_can_buy0; | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + for (var i in goods) { | ||
| 84 | + var item = goods[i]; | ||
| 85 | + var cart_num = get_num(item).goods_num; | ||
| 86 | + var zh_b_num = get_num(item).zh_b_num; | ||
| 87 | + if (!cart_num) { | ||
| 88 | + if (item.zhqty) { | ||
| 89 | + need_to_buy += item.zhqty; | ||
| 90 | + } | ||
| 91 | + continue; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + item.cart_num = cart_num; | ||
| 95 | + //-- 当商品有购买的时候,以及有限购的时候 -- | ||
| 96 | + if (item.buyqty > 0) { | ||
| 97 | + var cbuy = item.buyqty - zh_b_num; | ||
| 98 | + var key = item.goods_id + "." + act.id; | ||
| 99 | + if (is_need_ck_num && th.data.in_zhact_gdmap_new[key]) { | ||
| 100 | + var cbuy = item.buyqty - zh_b_num - th.data.in_zhact_gdmap_new[key]; | ||
| 101 | + } | ||
| 102 | + //当可买的数量为0 | ||
| 103 | + if (cbuy <= 0) { | ||
| 104 | + item.num = 0; | ||
| 105 | + out_arr.push({ | ||
| 106 | + goods_id: item.goods_id, | ||
| 107 | + num: cart_num | ||
| 108 | + }) | ||
| 109 | + } else { | ||
| 110 | + if (cbuy >= cart_num) item.num = cart_num; | ||
| 111 | + else { | ||
| 112 | + item.num = cbuy; | ||
| 113 | + out_arr.push({ | ||
| 114 | + goods_id: item.goods_id, | ||
| 115 | + num: cart_num - cbuy | ||
| 116 | + }) | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + } else { | ||
| 120 | + item.num = cart_num; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + if (item.num) { | ||
| 124 | + all_num += item.num; | ||
| 125 | + //当有起购数的控制的时候 | ||
| 126 | + if (item.zhqty) { | ||
| 127 | + all_zhqty += item.zhqty; | ||
| 128 | + if (item.num < item.zhqty) { | ||
| 129 | + need_to_buy += item.zhqty - item.num; | ||
| 130 | + } | ||
| 131 | + if (item.num > item.zhqty) { | ||
| 132 | + for (let i = 0; i < item.num - item.zhqty; i++) { | ||
| 133 | + no_in_arr.push({ | ||
| 134 | + goods_id: item.goods_id, | ||
| 135 | + }) | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | + else { | ||
| 140 | + for (let j = 0; j < item.num; j++) { | ||
| 141 | + no_in_arr.push({ | ||
| 142 | + goods_id: item.goods_id, | ||
| 143 | + }) | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + } else { | ||
| 147 | + if (item.zhqty) { | ||
| 148 | + need_to_buy += item.zhqty; | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + //当满足组合的要求:总数要满足,起购数要满足 | ||
| 153 | + if (all_num >= act.zhbuyqty && !need_to_buy) { | ||
| 154 | + //默认数量是1 | ||
| 155 | + var act_num=1; | ||
| 156 | + function sortData(a, b) { | ||
| 157 | + return a.price - b.price | ||
| 158 | + } | ||
| 159 | + if (no_in_arr.length > 0) no_in_arr.sort(sortData); | ||
| 160 | + if (act.zhbuyqty > all_zhqty) { | ||
| 161 | + for (let n = 0; n < act.zhbuyqty - all_zhqty; n++) { | ||
| 162 | + no_in_arr.pop(); | ||
| 163 | + } | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + //看一下剩下的数量有没有满足组合购的要求,以及要不要倍增 | ||
| 167 | + if (act.is_bz && no_in_arr.length >= act.zhbuyqty) { | ||
| 168 | + | ||
| 169 | + var bz_num_ok = 0; //超量倍增是否满足 | ||
| 170 | + var zhqty_len = 0; //几个超量倍增 | ||
| 171 | + var delete_num = 0; | ||
| 172 | + //看一下是几倍 | ||
| 173 | + let be = parseInt(no_in_arr.length / act.zhbuyqty); | ||
| 174 | + //如果有总数控制的时候 | ||
| 175 | + if (min_can_buy>0) { | ||
| 176 | + var be1 = min_can_buy - 1; | ||
| 177 | + if (be1 < be) be = be1; | ||
| 178 | + } | ||
| 179 | + if(be) { | ||
| 180 | + if (act.is_bzyh && zhqty_bz.length > 0) { | ||
| 181 | + | ||
| 182 | + let zhqty_bz_arr = []; | ||
| 183 | + let zhqty_bz_flag = this.zhqty_bz_fun(zhqty_bz, be, zhqty_bz_arr); | ||
| 184 | + if (zhqty_bz_flag) { | ||
| 185 | + for (let i = 0; i < zhqty_bz.length; i++) { | ||
| 186 | + var vv = zhqty_bz[i]; | ||
| 187 | + for (let j = 0; j < be * vv['zhqty']; j++) { | ||
| 188 | + let index = no_in_arr.findIndex(i => { | ||
| 189 | + return vv.goods_id === i.goods_id | ||
| 190 | + }) | ||
| 191 | + if (index > -1) { | ||
| 192 | + delete_num++ | ||
| 193 | + no_in_arr.splice(index, 1) | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + } | ||
| 197 | + } else { | ||
| 198 | + zhqty_len = 1; | ||
| 199 | + let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) { | ||
| 200 | + return o['be']; | ||
| 201 | + })); | ||
| 202 | + let new_arr = zhqty_bz_arr.filter(ii => { | ||
| 203 | + return ii['be'] == min_bz_num; | ||
| 204 | + }) | ||
| 205 | + //-- 要看一下倍数还有没有 --- | ||
| 206 | + be = new_arr[0].be; | ||
| 207 | + //如果有总数控制的时候 | ||
| 208 | + if (min_can_buy>0) { | ||
| 209 | + var be1 = min_can_buy - 1; | ||
| 210 | + if (be1 < be) be = be1; | ||
| 211 | + } | ||
| 212 | + if(be){ | ||
| 213 | + for (let i = 0; i < zhqty_bz.length; i++) { | ||
| 214 | + let item1 = zhqty_bz[i]; | ||
| 215 | + for (let j = 0; j < be * item1['zhqty']; j++) { | ||
| 216 | + let index = no_in_arr.findIndex(i => { | ||
| 217 | + return item1.goods_id === i.goods_id | ||
| 218 | + }) | ||
| 219 | + if (index > -1) { | ||
| 220 | + no_in_arr.splice(index, 1) | ||
| 221 | + } | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + act_num+=be; | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + if (!zhqty_len) { | ||
| 229 | + let pop_num = be * act.zhbuyqty - delete_num; | ||
| 230 | + for (var m = 0; m < pop_num; m++) { | ||
| 231 | + no_in_arr.pop(); | ||
| 232 | + } | ||
| 233 | + act_num+=be; | ||
| 234 | + } | ||
| 235 | + } | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + //-- 参与活动的金额要返回回去 -- | ||
| 239 | + item_act_map.act_num=act_num; | ||
| 240 | + let goods_map = {}; | ||
| 241 | + //算一下剩余的商品 | ||
| 242 | + if (no_in_arr.length) { | ||
| 243 | + for (let ii in no_in_arr) { | ||
| 244 | + let item = no_in_arr[ii]; | ||
| 245 | + if (goods_map[item.goods_id]) { | ||
| 246 | + var num = goods_map[item.goods_id]; | ||
| 247 | + goods_map[item.goods_id] = ++num; | ||
| 248 | + } else { | ||
| 249 | + goods_map[item.goods_id] = 1; | ||
| 250 | + } | ||
| 251 | + } | ||
| 252 | + } | ||
| 253 | + //超量的部分也要计算一下 | ||
| 254 | + if (out_arr.length) { | ||
| 255 | + for (var m in out_arr) { | ||
| 256 | + if (goods_map[item.goods_id]) { | ||
| 257 | + var num = goods_map[item.goods_id]; | ||
| 258 | + num += item.num | ||
| 259 | + goods_map[item.goods_id] = num; | ||
| 260 | + } else { | ||
| 261 | + goods_map[item.goods_id] = item.num; | ||
| 262 | + } | ||
| 263 | + } | ||
| 264 | + } | ||
| 265 | + | ||
| 266 | + //-- 组合购的商品限购的数组控制 -- | ||
| 267 | + var in_zhact_gdmap={}; | ||
| 268 | + //商品的列表 | ||
| 269 | + for (var u in goods) { | ||
| 270 | + var ite = goods[u]; | ||
| 271 | + var cart_num = get_num(ite).goods_num; | ||
| 272 | + | ||
| 273 | + if (ite.buyqty > 0 && cart_num > 0) { | ||
| 274 | + var key = ite.goods_id + "." + act.id; | ||
| 275 | + if(goods_map[ite.goods_id]){ | ||
| 276 | + cart_num-=goods_map[ite.goods_id]; | ||
| 277 | + } | ||
| 278 | + if(cart_num>0){ | ||
| 279 | + if (in_zhact_gdmap[key]) { | ||
| 280 | + in_zhact_gdmap[key] += ite.num; | ||
| 281 | + } else { | ||
| 282 | + in_zhact_gdmap[key] = ite.num; | ||
| 283 | + } | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + } | ||
| 287 | + } | ||
| 288 | + item_act_map.in_zhact_gdmap=in_zhact_gdmap; | ||
| 289 | + return true; | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + if(!need_ok) { | ||
| 293 | + item_act_map.is_no_ok=1; | ||
| 294 | + return true; | ||
| 295 | + } | ||
| 296 | + | ||
| 297 | + return false; | ||
| 298 | + }, | ||
| 299 | + //-- 判读一下促销分组的问题 -- | ||
| 300 | + //-- is_need_ck_num 是多门店计算的时候,数量是不是要累家计算,主要是拿来计算限购 -- | ||
| 301 | + //-- need_ok是判断要不要满足条件,这是在cart2的时候,才会赋值成1 -- | ||
| 302 | + async cart_cx_group(th,goods,car_item,is_need_ck_num,need_ok,func){ | ||
| 303 | + | ||
| 304 | + var os= getApp().globalData.setting; | ||
| 305 | + //更改活动的时候,就不能再重新计算活动,只有再加减数量和选择商品的时候,就要重新计算活动 | ||
| 306 | + if(th.data.change_act || (car_item.show_can_cx && Object.keys(car_item.show_can_cx).length>0)){ | ||
| 307 | + var show_can_cx=car_item.show_can_cx; | ||
| 308 | + for(var k in show_can_cx){ | ||
| 309 | + var k_item=show_can_cx[k]; | ||
| 310 | + var ck_prom_type=null; | ||
| 311 | + //-- 如果是多活动,先把活动按照后台的顺序排序一下, | ||
| 312 | + //-- 同时确定一下商品最终要用什么活动来购买计算。 --就是要进行切换 -- | ||
| 313 | + if(k_item.act_arr.length>1){ | ||
| 314 | + var json_d =th.data.json_d; | ||
| 315 | + var auto_promote_sale=json_d.auto_promote_sale; | ||
| 316 | + var sort_type=''; | ||
| 317 | + | ||
| 318 | + if(!auto_promote_sale){ | ||
| 319 | + sort_type='prom_type'; | ||
| 320 | + }else{ | ||
| 321 | + var auto_promote_sale=auto_promote_sale.split(','); | ||
| 322 | + //-- 循环处理 -- | ||
| 323 | + k_item.act_arr.map(function (e){ | ||
| 324 | + var fd=auto_promote_sale.indexOf(e.prom_type+''); | ||
| 325 | + e.sort=fd; | ||
| 326 | + }) | ||
| 327 | + sort_type='sort'; | ||
| 328 | + } | ||
| 329 | + //-- 排序一下,进行升序 -- | ||
| 330 | + function comp(a, b) { | ||
| 331 | + return a[sort_type]-b[sort_type]; //升序 | ||
| 332 | + } | ||
| 333 | + //活动要排序一下 | ||
| 334 | + k_item.act_arr.sort(comp); | ||
| 335 | + | ||
| 336 | + //确定一下活动,先看一下有没有选择的活动 | ||
| 337 | + ck_prom_type=k_item.act_arr.find(function (el){ | ||
| 338 | + return el.sele; | ||
| 339 | + }) | ||
| 340 | + | ||
| 341 | + } | ||
| 342 | + //-- 此时已经确定了商品的活动是什么类型的,可以确定购物车中商品的具体活动进行金额的计算 -- | ||
| 343 | + if(!ck_prom_type) ck_prom_type=k_item.act_arr[0]; | ||
| 344 | + | ||
| 345 | + //-- 此时要把购物车中的商品确定活动 -- | ||
| 346 | + for (var b=0; b<ck_prom_type.goods.length;b++){ | ||
| 347 | + //-- 开始查找 -- | ||
| 348 | + var fg=goods.findIndex(function (g_item){ | ||
| 349 | + return g_item.goods_id==ck_prom_type.goods[b].goods_id && [0,3,5,7,10].indexOf(g_item.prom_type)>-1; | ||
| 350 | + }) | ||
| 351 | + if(fg>-1){ | ||
| 352 | + goods[fg].prom_type=ck_prom_type.prom_type; | ||
| 353 | + goods[fg].prom_id=ck_prom_type.prom_id; | ||
| 354 | + } | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + } | ||
| 358 | + func(show_can_cx); | ||
| 359 | + return false; | ||
| 360 | + } | ||
| 361 | + | ||
| 362 | + //-- 促销活动对象表,最初的map表,包含活动类型,活动id,goods商品 --- | ||
| 363 | + var cx_act_map=[]; | ||
| 364 | + for(var i=0; i<goods.length;i++){ | ||
| 365 | + var c_item=goods[i]; | ||
| 366 | + //没有选中 | ||
| 367 | + if(!c_item.selected) continue; | ||
| 368 | + //如果是秒杀之类是商品 | ||
| 369 | + if([1,2,4,6,8,9].indexOf(c_item.prom_type)>-1) continue; | ||
| 370 | + | ||
| 371 | + //-- 把活动进行规整 -- | ||
| 372 | + var more_cx=c_item.more_cx; | ||
| 373 | + if(!more_cx) continue; | ||
| 374 | + for (var j=0;j<more_cx.length;j++){ | ||
| 375 | + var n_item=more_cx[j]; | ||
| 376 | + //--- 当是组合购的时候,这个地方要开始计算限购 is_need_ck_num=1-- | ||
| 377 | + if(n_item.prom_type==7 && is_need_ck_num){ | ||
| 378 | + //判断是不是限购 | ||
| 379 | + var zh_gd_fd=n_item.gdlist.find((e1)=>{ | ||
| 380 | + return e1.goods_id==c_item.goods_id && e1.buyqty>0 | ||
| 381 | + }) | ||
| 382 | + | ||
| 383 | + var in_zhact_gdmap_new=th.data.in_zhact_gdmap_new; | ||
| 384 | + var key = c_item.goods_id + "." + n_item.prom_id; | ||
| 385 | + | ||
| 386 | + //如果是组合购 | ||
| 387 | + if(zh_gd_fd && in_zhact_gdmap_new[key] && in_zhact_gdmap_new[key]>=zh_gd_fd.buyqty){ | ||
| 388 | + continue; | ||
| 389 | + } | ||
| 390 | + } | ||
| 391 | + | ||
| 392 | + | ||
| 393 | + var key=n_item.prom_type+'-'+n_item.prom_id; | ||
| 394 | + var fd=cx_act_map.find(function (e){ | ||
| 395 | + return e.key==key; | ||
| 396 | + }) | ||
| 397 | + if(fd){ | ||
| 398 | + fd.goods.push(c_item); | ||
| 399 | + }else{ | ||
| 400 | + var p_item={key:key,prom_type:n_item.prom_type,prom_id:n_item.prom_id,goods:[],act:n_item}; | ||
| 401 | + if(n_item.prom_type==7){ | ||
| 402 | + p_item.zh_pro=n_item.zh_pro; | ||
| 403 | + } | ||
| 404 | + p_item.goods.push(c_item); | ||
| 405 | + cx_act_map.push(p_item); | ||
| 406 | + } | ||
| 407 | + } | ||
| 408 | + goods[i].prom_type=0; | ||
| 409 | + goods[i].prom_id=0; | ||
| 410 | + } | ||
| 411 | + //-- 如果活动数量大于1个,那么活动就要排序一下,有商品种类数最多排再前面,降序进行排列 -- | ||
| 412 | + if(cx_act_map.length>1){ | ||
| 413 | + //门店分类要排序下 | ||
| 414 | + function compare(a, b) { | ||
| 415 | + var value1 = a.goods.length; | ||
| 416 | + var value2 = b.goods.length; | ||
| 417 | + return value2 - value1; | ||
| 418 | + } | ||
| 419 | + cx_act_map.sort(compare); | ||
| 420 | + } | ||
| 421 | + //-- 能够进行最后计算的活动(包含切换) -- | ||
| 422 | + var can_calc_cx=[]; | ||
| 423 | + //-- 此时对数组的活动进行判断,看能不能达到购买数量的条件 -- | ||
| 424 | + for(var ii=0;ii<cx_act_map.length;ii++){ | ||
| 425 | + | ||
| 426 | + var item_act_map=cx_act_map[ii]; | ||
| 427 | + //如果活动有交集的时候,商品数量一样多(不是完全相同时,就是参与的商品有交集),就按照后台确定的活动顺序 | ||
| 428 | + //如果活动商品数量少的和 活动数量多的 有交集,那么数量少的不显示,也不计算 | ||
| 429 | + //如果活动的商品一样(那就是多活动切换),优先计算的活动按照后台确定的活动顺序 | ||
| 430 | + if(!this.check_ok_cx_pro(item_act_map,can_calc_cx)){ | ||
| 431 | + continue; | ||
| 432 | + } | ||
| 433 | + switch(item_act_map.prom_type){ | ||
| 434 | + case 3: | ||
| 435 | + //活动ID | ||
| 436 | + var aid=item_act_map.prom_id; | ||
| 437 | + var need_num=0; | ||
| 438 | + //-- 这个时候要判断是不是要判断优惠促销多门店的时候的限购 -- | ||
| 439 | + if(is_need_ck_num){ | ||
| 440 | + need_num=th.data.in_yhact_new[aid]?th.data.in_yhact_new[aid]:0; | ||
| 441 | + } | ||
| 442 | + //-- 判断优惠促销要不要限购 -- | ||
| 443 | + var fd=th.data.in_yhact[aid]; | ||
| 444 | + if(!fd) { | ||
| 445 | + var fd_res = await getApp().request.promiseGet('/api/weshop/promgoods/get/' + os.stoid + '/' + aid, {}) | ||
| 446 | + if (fd_res && fd_res.data.code == 0) { | ||
| 447 | + fd = fd_res.data.data; | ||
| 448 | + th.data.in_yhact[aid]=fd; | ||
| 449 | + } | ||
| 450 | + } | ||
| 451 | + //如果有限购的时候,也要计算一下 | ||
| 452 | + if (fd && fd['limit_num'] > 0){ | ||
| 453 | + // 优惠的促销的限购要反写进去不和 | ||
| 454 | + item_act_map.limit_num=fd['limit_num']; | ||
| 455 | + if(fd.hasOwnProperty('buyed')){ | ||
| 456 | + item_act_map.buyed= fd.buyed; | ||
| 457 | + }else{ | ||
| 458 | + //-- 获取已经购买了多少件 -- | ||
| 459 | + var url = "/api/weshop/ordergoods/getUserBuyPromNum?store_id="+os.stoid+"&user_id=" | ||
| 460 | + +getApp().globalData.user_id+"&prom_type=3&prom_id="+aid; | ||
| 461 | + await getApp().request.promiseGet(url, {}).then(rh => { | ||
| 462 | + if(rh.data.code==0){ | ||
| 463 | + item_act_map.buyed=rh.data.data.userbuynum; | ||
| 464 | + fd.buyed=rh.data.data.userbuynum; | ||
| 465 | + th.data.in_yhact[aid].buyed=rh.data.data.userbuynum; | ||
| 466 | + } | ||
| 467 | + }) | ||
| 468 | + } | ||
| 469 | + | ||
| 470 | + if(item_act_map.buyed+need_num>=fd['limit_num']){ | ||
| 471 | + continue; //-- 进行下一个循环 -- | ||
| 472 | + } | ||
| 473 | + } | ||
| 474 | + | ||
| 475 | + | ||
| 476 | + | ||
| 477 | + var fir_act=item_act_map.act.fir_act; | ||
| 478 | + var t_goods=item_act_map.goods; | ||
| 479 | + var all_num=0; | ||
| 480 | + var all_pri=0; | ||
| 481 | + for(var f=0;f<t_goods.length;f++){ | ||
| 482 | + all_num+=t_goods[f].goods_num; | ||
| 483 | + all_pri+=t_goods[f].goods_num*t_goods[f].goods_price; | ||
| 484 | + } | ||
| 485 | + var yh_ok=1; | ||
| 486 | + switch (fir_act.prom_type){ | ||
| 487 | + case 0: | ||
| 488 | + if(all_pri<fir_act.condition) { | ||
| 489 | + yh_ok=0; | ||
| 490 | + } | ||
| 491 | + break; | ||
| 492 | + case 1: | ||
| 493 | + if(all_num<fir_act.condition) { | ||
| 494 | + yh_ok=0; | ||
| 495 | + } | ||
| 496 | + break; | ||
| 497 | + } | ||
| 498 | + //-- 如果有满足优惠条件的时候 -- | ||
| 499 | + if(yh_ok){ | ||
| 500 | + can_calc_cx.push(item_act_map) | ||
| 501 | + }else{ | ||
| 502 | + if(!need_ok){ | ||
| 503 | + item_act_map.is_no_ok=1; | ||
| 504 | + can_calc_cx.push(item_act_map); | ||
| 505 | + } | ||
| 506 | + } | ||
| 507 | + break | ||
| 508 | + | ||
| 509 | + case 7: | ||
| 510 | + //-- 活动列表 -- | ||
| 511 | + var zhact_gdlist=item_act_map.act.gdlist; | ||
| 512 | + var zh_goods=item_act_map.goods; | ||
| 513 | + //--- 要循环计算一下商品的已购数量 --- | ||
| 514 | + for(var h=0;h<zh_goods.length;h++){ | ||
| 515 | + if(zh_goods[h].zh_b_num) continue; | ||
| 516 | + var ky=item_act_map.prom_id+"."+zh_goods[h].goods_id; | ||
| 517 | + if(th.data.in_zh_gd_buy_map[ky]){ | ||
| 518 | + zh_goods[h].zh_b_num=th.data.in_zh_gd_buy_map[ky]; | ||
| 519 | + }else{ | ||
| 520 | + //-- 商品的限购 -- | ||
| 521 | + var promgoodsbuynum = 0; | ||
| 522 | + var res=await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 523 | + data: { | ||
| 524 | + store_id: os.stoid, | ||
| 525 | + user_id: getApp().globalData.user_id, | ||
| 526 | + goods_id: zh_goods[h].goods_id, | ||
| 527 | + prom_type: 7, | ||
| 528 | + prom_id: item_act_map.prom_id | ||
| 529 | + }, | ||
| 530 | + }) | ||
| 531 | + if(res.data.code==0 && res.data.data && res.data.data.promgoodsbuynum){ | ||
| 532 | + promgoodsbuynum = res.data.data.promgoodsbuynum; | ||
| 533 | + } | ||
| 534 | + zh_goods[h].zh_b_num=promgoodsbuynum; | ||
| 535 | + th.data.in_zh_gd_buy_map[ky]=promgoodsbuynum; | ||
| 536 | + } | ||
| 537 | + | ||
| 538 | + | ||
| 539 | + } | ||
| 540 | + //-- 放到参与组合优惠促销的map中 -- | ||
| 541 | + th.data.zuhe_map_good[item_act_map.prom_id] = zhact_gdlist; | ||
| 542 | + if(!car_item.zh_prom_goods) car_item.zh_prom_goods={}; | ||
| 543 | + car_item.zh_prom_goods[item_act_map.prom_id] = zhact_gdlist; | ||
| 544 | + | ||
| 545 | + //-- 兼容购物车和确认订单的页面 -- | ||
| 546 | + var ob=th.data.zuhe_map; | ||
| 547 | + if(!ob) ob=th.data.zhhe_act_map; | ||
| 548 | + | ||
| 549 | + var zh_pro0 = ob[item_act_map.prom_id]; | ||
| 550 | + if(zh_pro0.hasOwnProperty('buyed')){ | ||
| 551 | + item_act_map.buyed=zh_pro0.buyed; | ||
| 552 | + }else { | ||
| 553 | + //-- 获取活动信息 -- | ||
| 554 | + var url = "/api/weshop/ordergoods/getUserBuyPromNum?store_id="+os.stoid+"&user_id=" | ||
| 555 | + +getApp().globalData.user_id+"&prom_type=7&prom_id="+zh_pro0.id; | ||
| 556 | + await getApp().request.promiseGet(url, {}).then(rh => { | ||
| 557 | + if(rh.data.code==0){ | ||
| 558 | + item_act_map.buyed=rh.data.data.userbuynum; | ||
| 559 | + zh_pro0.buyed=rh.data.data.userbuynum; | ||
| 560 | + } | ||
| 561 | + }) | ||
| 562 | + } | ||
| 563 | + | ||
| 564 | + //当满足组合的要求:总数要满足,起购数要满足 | ||
| 565 | + if(this.ch_zh_ok(zh_pro0,zhact_gdlist,zh_goods,th,item_act_map,is_need_ck_num,need_ok)){ | ||
| 566 | + can_calc_cx.push(item_act_map) | ||
| 567 | + } | ||
| 568 | + break; | ||
| 569 | + default: | ||
| 570 | + can_calc_cx.push(item_act_map); | ||
| 571 | + } | ||
| 572 | + | ||
| 573 | + } | ||
| 574 | + | ||
| 575 | + //-- 此时来给满足条件的活动进行分组~~相同参与商品和数量的归纳再一起, -- | ||
| 576 | + //-- 同时相同商品数量的活动,还要看取那一个来进行计算金额。 默认的时候是按照后台的顺序。-- | ||
| 577 | + //-- 有选择的时候,就按照切换选择了什么就按照什么来计算 -- | ||
| 578 | + //-- can_calc_cx的元素(item_act_map)最后是放到act_arr里面去了 -- | ||
| 579 | + var show_can_cx={}; | ||
| 580 | + if(can_calc_cx.length){ | ||
| 581 | + for(var p=0;p<can_calc_cx.length;p++){ | ||
| 582 | + var ch_map=[]; | ||
| 583 | + can_calc_cx[p].goods.map(function (gd){ | ||
| 584 | + ch_map.push(gd.goods_id); | ||
| 585 | + }) | ||
| 586 | + ch_map.sort(); | ||
| 587 | + //-- 先找一下,有没有参与的商品一模一样的 -- | ||
| 588 | + var fd=show_can_cx[ch_map.join()]; | ||
| 589 | + if(fd){ | ||
| 590 | + //-- 把数组添加进去 --ch_map | ||
| 591 | + fd.act_arr.push(can_calc_cx[p]) | ||
| 592 | + }else{ | ||
| 593 | + var e={ch_map:ch_map,act_arr:[]}; | ||
| 594 | + if(ch_map.length>1){ | ||
| 595 | + e.is_duo_gd=1; | ||
| 596 | + } | ||
| 597 | + e.act_arr.push(can_calc_cx[p]); | ||
| 598 | + show_can_cx[ch_map.join()]=e; | ||
| 599 | + } | ||
| 600 | + } | ||
| 601 | + } | ||
| 602 | + | ||
| 603 | + for(var k in show_can_cx){ | ||
| 604 | + var k_item=show_can_cx[k]; | ||
| 605 | + var ck_prom_type=null; | ||
| 606 | + //-- 如果是多活动,先把活动按照后台的顺序排序一下, | ||
| 607 | + //-- 同时确定一下商品最终要用什么活动来购买计算。 --就是要进行切换 -- | ||
| 608 | + if(k_item.act_arr.length>1){ | ||
| 609 | + var json_d =th.data.json_d; | ||
| 610 | + var auto_promote_sale=json_d.auto_promote_sale; | ||
| 611 | + var sort_type=''; | ||
| 612 | + | ||
| 613 | + if(!auto_promote_sale){ | ||
| 614 | + sort_type='prom_type'; | ||
| 615 | + }else{ | ||
| 616 | + var auto_promote_sale=auto_promote_sale.split(','); | ||
| 617 | + //-- 循环处理 -- | ||
| 618 | + k_item.act_arr.map(function (e){ | ||
| 619 | + var fd=auto_promote_sale.indexOf(e.prom_type+''); | ||
| 620 | + e.sort=fd; | ||
| 621 | + }) | ||
| 622 | + sort_type='sort'; | ||
| 623 | + } | ||
| 624 | + //-- 排序一下,进行升序 -- | ||
| 625 | + function comp(a, b) { | ||
| 626 | + return a[sort_type]-b[sort_type]; //升序 | ||
| 627 | + } | ||
| 628 | + //活动要排序一下 | ||
| 629 | + k_item.act_arr.sort(comp); | ||
| 630 | + | ||
| 631 | + //确定一下活动,先看一下有没有选择的活动 | ||
| 632 | + ck_prom_type=k_item.act_arr.find(function (el){ | ||
| 633 | + return el.sele; | ||
| 634 | + }) | ||
| 635 | + | ||
| 636 | + //如果 | ||
| 637 | + | ||
| 638 | + } | ||
| 639 | + //-- 此时已经确定了商品的活动是什么类型的,可以确定购物车中商品的具体活动进行金额的计算 -- | ||
| 640 | + if(!ck_prom_type){ | ||
| 641 | + ck_prom_type=k_item.act_arr[0]; | ||
| 642 | + k_item.act_arr[0].sele=1; | ||
| 643 | + //-- 把当前活动进行赋值 -- | ||
| 644 | + k_item.cur_act=ck_prom_type; | ||
| 645 | + } | ||
| 646 | + | ||
| 647 | + //-- 如果是要控制数量的时候,也就是全选的时候,或者加减号的时候 -- | ||
| 648 | + if(is_need_ck_num && !ck_prom_type.is_no_ok){ | ||
| 649 | + var t_pid=ck_prom_type.prom_id; | ||
| 650 | + switch (ck_prom_type.prom_type){ | ||
| 651 | + case 3: | ||
| 652 | + if(!th.data.in_yhact_new[t_pid]) th.data.in_yhact_new[t_pid]=0; | ||
| 653 | + th.data.in_yhact_new[t_pid]++; | ||
| 654 | + break; | ||
| 655 | + case 7: | ||
| 656 | + if(!th.data.in_zhact_new[t_pid]) th.data.in_zhact_new[t_pid]=0; | ||
| 657 | + th.data.in_zhact_new[t_pid]+=ck_prom_type.act_num; | ||
| 658 | + //-- 数组的优化 -- | ||
| 659 | + var nei_gd_map=ck_prom_type.in_zhact_gdmap; | ||
| 660 | + if(nei_gd_map){ | ||
| 661 | + for (var vg in nei_gd_map) { | ||
| 662 | + if (!th.data.in_zhact_gdmap_new[vg]) th.data.in_zhact_gdmap_new[vg] = 0; | ||
| 663 | + th.data.in_zhact_gdmap_new[vg] += nei_gd_map[vg]; | ||
| 664 | + } | ||
| 665 | + } | ||
| 666 | + break; | ||
| 667 | + } | ||
| 668 | + } | ||
| 669 | + //-- 此时要把购物车中的商品确定活动 -- | ||
| 670 | + for (var b=0; b<ck_prom_type.goods.length;b++){ | ||
| 671 | + //-- 开始查找 -- | ||
| 672 | + var fg=goods.findIndex(function (g_item){ | ||
| 673 | + return g_item.goods_id==ck_prom_type.goods[b].goods_id && [0,3,5,7,10].indexOf(g_item.prom_type)>-1; | ||
| 674 | + }) | ||
| 675 | + if(fg>-1){ | ||
| 676 | + goods[fg].prom_type=ck_prom_type.prom_type; | ||
| 677 | + goods[fg].prom_id=ck_prom_type.prom_id; | ||
| 678 | + } | ||
| 679 | + } | ||
| 680 | + } | ||
| 681 | + //-- 显示到前端,并切换 -- | ||
| 682 | + //th.setData({show_can_cx}) | ||
| 683 | + //--- 调用回调函数 --- | ||
| 684 | + func(show_can_cx); | ||
| 685 | + | ||
| 686 | + }, | ||
| 687 | + //-- 查看活动参与的商品是不是有重复交集的地方,是不是一样的商品数量,can_calc_cx这个数组也是按照商品的数量降序排列的-- | ||
| 688 | + check_ok_cx_pro(item_act_map,can_calc_cx){ | ||
| 689 | + //-- 加入第一个,返回真 -- | ||
| 690 | + if(!can_calc_cx.length) return true; | ||
| 691 | + var th_goods=item_act_map.goods; | ||
| 692 | + for(var i=0;i<can_calc_cx.length;i++){ | ||
| 693 | + var can_goods=can_calc_cx[i].goods; | ||
| 694 | + //计算一下有交集的数量,没有交集,OK | ||
| 695 | + var num=this.hasJiao(can_goods,th_goods); | ||
| 696 | + if(!num) continue; | ||
| 697 | + //计算一下俩个shu | ||
| 698 | + if(can_goods.length==th_goods.length && can_goods.length==num){ | ||
| 699 | + return true; | ||
| 700 | + } | ||
| 701 | + if(can_goods.length>th_goods.length){ | ||
| 702 | + return false; | ||
| 703 | + } | ||
| 704 | + } | ||
| 705 | + return true; | ||
| 706 | + }, | ||
| 707 | + //-- 判断是不是有交集,返回交集的数量 -- | ||
| 708 | + hasJiao(arr1, arr2){ | ||
| 709 | + var num=0; | ||
| 710 | + arr1.map(function (e){ | ||
| 711 | + var idx=arr2.findIndex(function (g){ | ||
| 712 | + return g.goods_id==e.goods_id; | ||
| 713 | + }) | ||
| 714 | + if(idx>-1) num++; | ||
| 715 | + }) | ||
| 716 | + return num; | ||
| 717 | + }, | ||
| 718 | + | ||
| 719 | + | ||
| 720 | +} | ||
| 0 | \ No newline at end of file | 721 | \ No newline at end of file |