Commit e6412d6d5294cbc9d2fae3b50f4aad9d2f49ba28

Authored by abson
1 parent 8a1b1544

oa单处理

components/diy_goodsGroup/diy_goodsGroup.js
... ... @@ -45,6 +45,7 @@ Component({
45 45 nav_list:null,
46 46 title_index:0,
47 47 swiper_hei:0,
  48 + title_class:"",
48 49 },
49 50  
50 51 ready: function () {},
... ... @@ -96,7 +97,17 @@ Component({
96 97 if(this.data.object.goodsprice) hei+=80;
97 98 if(this.data.object.goodsnum) hei+=80;
98 99  
99   - this.setData({swiper_hei:hei});
  100 + if(this.data.object.title_color){
  101 + this.data.title_class=`color:${this.data.object.title_color};`
  102 + }
  103 +
  104 + if(this.data.object.title_font_size){
  105 + this.data.title_class=this.data.title_class.concat(`font-size:${this.data.object.title_font_size}px;`)
  106 + }
  107 + this.setData({
  108 + swiper_hei:hei,
  109 + title_class:this.data.title_class,
  110 + });
100 111  
101 112 if (nav_item && nav_item.goodsclass == 1) {
102 113 this.data.is_recommend = 1
... ...
components/diy_goodsGroup/diy_goodsGroup.wxml
... ... @@ -6,7 +6,7 @@
6 6 <block wx:if="{{is_nav}}">
7 7 <view class="flex gr_title_list" style="overflow-x: auto;">
8 8 <view class="gr_title_item" wx:for="{{nav_list}}" data-index="{{index}}" bindtap="gr_set_nav" data-idlist="{{item.idlist}}" data-wgroup="{{item.wgroup}}" data-classstyle="{{item.classstyle}}" >
9   - <text class="{{index==title_index?'t_red':''}}">{{item.title}}</text>
  9 + <text class="{{index==title_index?'t_red':''}}" style="{{title_class}}">{{item.title}}</text>
10 10 </view>
11 11 </view>
12 12 </block>
... ...
packageA/pages/quan_pro/quan_pro.js
... ... @@ -128,9 +128,16 @@ Page({
128 128 },
129 129  
130 130 go_quan:function(){
131   - //跳转到券列表
  131 + //跳转到券列表
  132 + this.setData({
  133 + show_success:0
  134 + })
132 135 getApp().goto("/pages/user/coupons/coupons");
133   - }
134   -
  136 + },
135 137  
  138 + close_show(){
  139 + this.setData({
  140 + show_success:0
  141 + })
  142 + },
136 143 });
... ...
packageA/pages/quan_pro/quan_pro.wxml
... ... @@ -7,42 +7,39 @@
7 7 <view class="img_part">
8 8 <image style="width: 100%; height: 450rpx" src="{{iurl}}/miniapp/images/coupon_img/q_detail_bg.png"></image>
9 9 <view class="q_content">
10   - <view class="upper flex jc_sb co-w">
11   - <view class="left fs30" style="width: 460rpx;">
12   - <view>
13   - <image style="width: 70rpx; height: 70rpx; vertical-align: middle; margin-right: 20rpx" src="{{iurl}}/miniapp/images/coupon_img/coupon_logo.png"></image>
14   - <text wx:if="{{q_data}}">{{q_data.name}}</text>
15   - <text wx:elif="{{is_get}}" class="fs28">不存在此微券或数量已领取完</text>
16   - </view>
17   -
18   - <block wx:if="{{q_data}}">
19   - <view class="flex ai-center" style="margin-top: 24rpx; margin-right: 20rpx; width: 440rpx">
20   - <view class="t_circle"></view>
21   - <view>
22   - <text wx:if="{{q_data.useobjecttype==0}}">全场通用</text>
23   - <text wx:else>仅限{{q_data.useobjectname}}使用</text>
24   - </view>
25   -
26   - </view>
27   - <view class="ellipsis-3" style="margin-top: 20rpx;">{{q_data.coupon_remark}}</view>
28   - </block>
  10 + <view class="upper quan_box jc_sb co-w" style="padding: 20rpx 20rpx 0;">
  11 + <view>
  12 + <image style="width: 70rpx; height: 70rpx; vertical-align: middle; margin-right: 20rpx" src="{{iurl}}/miniapp/images/coupon_img/coupon_logo.png"></image>
  13 + <text wx:if="{{q_data}}">{{q_data.name}}</text>
  14 + <text wx:elif="{{is_get}}" class="fs28">不存在此微券或数量已领取完</text>
29 15 </view>
30   - <view wx:if="{{q_data}}" class="right" style="margin-right: 80rpx;">
31   - <view class="f40 t-c" style="margin-top: 100rpx"><text class="fs26">¥</text>{{filters.toFix(q_data.money,2)}}</view>
32   - <view class="fs28">满{{filters.toFix(q_data.condition,2)}}可用</view>
  16 + <view class="fs30 flex" wx:if="{{q_data}}" style="height: 100rpx;justify-content: space-between;">
  17 + <view class="flex ai-center">
  18 + <view class="t_circle"></view>
  19 + <view>
  20 + <text wx:if="{{q_data.useobjecttype==0}}">全场通用</text>
  21 + <text wx:else>仅限{{q_data.useobjectname}}使用</text>
  22 + </view>
  23 + </view>
  24 + <view>
  25 + <view class="fs40 t-c"><text class="fs26">¥</text>{{filters.toFix(q_data.money,2)}}</view>
  26 + <view class="fs28">满{{filters.toFix(q_data.condition,2)}}可用</view>
  27 + </view>
33 28 </view>
  29 + <text class="ellipsis-3 fs30">{{q_data.coupon_remark}}</text>
34 30 </view>
35 31  
36   - <block wx:if="{{ q_data}}">
  32 + <block wx:if="{{ q_data}}">
37 33 <view wx:if="{{ q_data.endtype==0}}" class="lower fs30">有效期
38   - <text wx:if="{{q_data.starttype==1}}"> {{filters.format_time(getcurday+3600*24*q_data.startdays)}}</text>
  34 + <text wx:if="{{q_data.starttype==1}}"> {{filters.format_time(getcurday+3600*24*q_data.startdays)}}</text>
39 35 <text wx:if="{{q_data.use_start_time>0 && q_data.starttype==0}}"> {{filters.format_time(q_data.use_start_time)}}</text>至
40 36 <text wx:if="{{q_data.use_end_time>0}}"> {{filters.format_time(q_data.use_end_time)}}</text><text wx:else>不限</text>
41 37 </view>
42 38 <view wx:else class="lower fs30">有效期
43   - <text wx:if="{{ q_data.starttype==1}}"> {{filters.format_time(getcurday+3600*24*q_data.startdays)}}</text>
44   - <text wx:else>{{filters.format_time(getcurday)}}</text>至
45   - <text wx:if="{{q_data.days>0}}"> {{filters.format_time(getcurday+3600*24*q_data.days)}}</text><text wx:else>不限</text></view>
  39 + <text wx:if="{{ q_data.starttype==1}}"> {{filters.format_time(getcurday+3600*24*q_data.startdays)}}</text>
  40 + <text wx:else>{{filters.format_time(getcurday)}}</text>至
  41 + <text wx:if="{{q_data.days>0}}"> {{filters.format_time(getcurday+3600*24*q_data.days)}}</text><text wx:else>不限</text>
  42 + </view>
46 43 </block>
47 44  
48 45 <view wx:elif="{{is_get}}" class="fs28" style="text-align: center;color: #999;position: absolute;bottom: 20rpx;">
... ... @@ -58,7 +55,7 @@
58 55 </view>
59 56  
60 57 <view class="flex jc-center fs36" style="margin-top: 40rpx">
61   - <image style="margin-right: 20rpx" class="love" src="{{iurl}}/miniapp/images/coupon_img/love.png"></image>猜你喜欢
  58 + <image style="margin-right: 20rpx" class="love" src="{{iurl}}/miniapp/images/coupon_img/love.png"></image>猜你喜欢
62 59 </view>
63 60 </view>
64 61 <!-- 下部分 -->
... ... @@ -83,6 +80,4 @@
83 80  
84 81  
85 82 <warn id="warn"></warn>
86   -<nav_box id="nav"></nav_box>
87   -
88   -
  83 +<nav_box id="nav"></nav_box>
89 84 \ No newline at end of file
... ...
packageA/pages/quan_pro/quan_pro.wxss
... ... @@ -7,10 +7,10 @@ page{background-color: #f8f8f8;}
7 7 .img_part{ padding: 0 20rpx; position: relative}
8 8 .btn{ width: 90%; height: 72rpx; border-radius: 10rpx; background-color: #ff6c6c; color: #fff;}
9 9 .love{ width: 60rpx; height: 50rpx}
10   -.q_content{ position: absolute;top: 0; left: 0; width: 100%; height: 450rpx;padding: 0 20rpx; }
  10 +.q_content{ position: absolute;top: 0; left: 0; width: calc(100% - 40rpx); height: 450rpx;padding: 0 20rpx; }
11 11 .upper{ height:330rpx;}
12 12 .lower{ height: 120rpx; line-height: 170rpx;color:#7a668f}
13   -
  13 +.quan_box {display: flex;flex-direction: column;justify-content: flex-start; box-sizing: border-box;}
14 14 .upper .left{ margin-left:30rpx; margin-top: 30rpx }
15 15 .t_circle{ width: 10rpx; height: 10rpx; border-radius: 50%; background-color: #fff; margin-right: 8rpx}
16 16  
... ...
packageB/pages/zuhegou/index/index.js
... ... @@ -10,8 +10,7 @@ let imgDraw = {
10 10 "width": "650px",
11 11 "height": "843px",
12 12 "background": "https://mshopimg.yolipai.net/miniapp/images/zhg/bg-zuhegou.jpg",
13   - "views": [
14   - { // 头像
  13 + "views": [{ // 头像
15 14 "type": "image",
16 15 "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg",
17 16 "css": {
... ... @@ -64,7 +63,7 @@ let imgDraw = {
64 63 "textAlign": "center"
65 64 }
66 65 },
67   - { // 码
  66 + { // 码
68 67 "type": "image",
69 68 "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg",
70 69 "css": {
... ... @@ -102,64 +101,62 @@ Page({
102 101 showNum: false,
103 102 haveAdded: false,
104 103 //imgDraw: imgDraw, 分享内容
105   - id: 0, //获得活动id
106   - page: 1, //第一页
107   - no_more: 0, //没有更多
108   - loading: 0, //加载中
109   - list:null, //商品列表的显示
110   - act: null, //组合活动
  104 + id: 0, //获得活动id
  105 + page: 1, //第一页
  106 + no_more: 0, //没有更多
  107 + loading: 0, //加载中
  108 + list: null, //商品列表的显示
  109 + act: null, //组合活动
111 110 all_price: 0, //合计价格
112   - all_num: 0, //全部数量
  111 + all_num: 0, //全部数量
113 112 sele_pick_id: 0, //默认选择门店,当用户什么商品都没有选,sele_pick_id=0
114   - def_store: null, //用户默认的门店
115   - sele_store: 0, //是不是选择了门店
  113 + def_store: null, //用户默认的门店
  114 + sele_store: 0, //是不是选择了门店
116 115 more_store: 0, //选择门店
117 116 sort_store: 0, //门店分类
118 117 choice_sort_store: 0, //选择分类门店
119   - fir_pick_index: 0, //门店选择的下标
120   - sec_pick_index: 0 //门店选择的下标,地区选择之后的内页
  118 + fir_pick_index: 0, //门店选择的下标
  119 + sec_pick_index: 0 //门店选择的下标,地区选择之后的内页
121 120 },
122 121  
123 122 /**
124 123 * 生命周期函数--监听页面加载
125 124 */
126 125 onLoad: function (options) {
127   -
128   - console.log(options,111);
129   -
  126 + console.log(options, 111);
130 127 self = this;
131 128 var the_id = options.id;
132   - if(options.title) {
133   - wx.setNavigationBarTitle({
134   - title: options.title,
135   - });
136   - };
137   - var first_leader=options.first_leader;
  129 + if (options.title) {
  130 + wx.setNavigationBarTitle({
  131 + title: options.title,
  132 + });
  133 + };
  134 + var first_leader = options.first_leader;
138 135  
139 136 //--如果tg_id是空的话,分享回来--
140 137 if (the_id == undefined || the_id == null || the_id == "") {
141   - var gid_str = decodeURIComponent(options.scene);
142   - gid_str=gid_str.split("_");
143   - the_id=gid_str[0];
144   - if(gid_str.length>1){
145   - first_leader=gid_str[1];
  138 + var gid_str = decodeURIComponent(options.scene);
  139 + gid_str = gid_str.split("_");
  140 + the_id = gid_str[0];
  141 + if (gid_str.length > 1) {
  142 + first_leader = gid_str[1];
146 143 }
147 144 }
148 145  
149   - this.data.id=the_id;
150   - if(first_leader){
151   - getApp().globalData.first_leader=first_leader;
  146 + this.data.id = the_id;
  147 + if (first_leader) {
  148 + getApp().globalData.first_leader = first_leader;
152 149 //调用接口判断是不是会员
153   - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{
154   - if(res.data.code==0){
155   - getApp().globalData.guide_id=res.data.data.id;
  150 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  151 + if (res.data.code == 0) {
  152 + getApp().globalData.guide_id = res.data.data.id;
156 153 }
157 154 })
158 155 }
159 156  
160 157 //如果有会员的时候
161 158 var userInfo = getApp().globalData.userInfo;
162   - if(!userInfo){
  159 + if (!userInfo) {
163 160 getApp().goto("/pages/togoin/togoin");
164 161 return false;
165 162 }
... ... @@ -169,40 +166,51 @@ Page({
169 166 * 生命周期函数--监听页面显示
170 167 */
171 168 onShow: function () {
172   - var th = this, that = this, ee = this;
  169 + var th = this,
  170 + that = this,
  171 + ee = this;
173 172 this.data.is_timer = 1;
174 173 if (this.data.act) this.countDown();
175 174 //如果有会员的时候
176 175 var userInfo = getApp().globalData.userInfo;
177 176 if (userInfo) {
178   - if(!th.data.is_get_act){
  177 + if (!th.data.is_get_act) {
179 178 //获取活动信息
180   - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + th.data.id+"/"+userInfo.user_id;
  179 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + th.data.id + "/" + userInfo.user_id;
181 180 getApp().request.get(url, {
182 181 success: function (e) {
183   - th.data.is_get_act=1;
  182 + th.data.is_get_act = 1;
184 183 if (e.data.code == 0 && e.data.data) {
185   - self.setData({act: e.data.data});
186   - if(e.data.data.is_show!=1){
187   - th.setData({error:'活动未开启'});
  184 + self.setData({
  185 + act: e.data.data
  186 + });
  187 + if (e.data.data.is_show != 1) {
  188 + th.setData({
  189 + error: '活动未开启'
  190 + });
188 191 return false;
189 192 }
190   - if(ut.gettimestamp()<e.data.data.start_time){
191   - th.setData({error:'活动还未开始'});
  193 + if (ut.gettimestamp() < e.data.data.start_time) {
  194 + th.setData({
  195 + error: '活动还未开始'
  196 + });
192 197 return false;
193 198 }
194   - if (e.data.data.is_end == 0 && ut.gettimestamp()<e.data.data.end_time ) {
  199 + if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) {
195 200 //-- 获取商品列表 --
196 201 self.get_list();
197 202 self.countDown();
198   - }
199   - else{
200   - th.setData({error:'活动已经过期'});
  203 + } else {
  204 + th.setData({
  205 + error: '活动已经过期'
  206 + });
201 207 return false;
202 208 }
203 209 } else {
204   - th.data.is_get_act=0;
205   - th.setData({error:e.data.msg});
  210 + th.data.is_get_act = 0;
  211 + th.setData({
  212 + error: e.data.msg
  213 + });
206 214 return false;
207 215 }
208 216 }
... ... @@ -211,11 +219,11 @@ Page({
211 219  
212 220 //等待活动值
213 221 this.waitfor2(10, 'list', function () {
214   - if(!th.data.list) return false;
215   - if(ut.gettimestamp()<th.data.act.start_time){
  222 + if (!th.data.list) return false;
  223 + if (ut.gettimestamp() < th.data.act.start_time) {
216 224 return false;
217 225 }
218   - if (th.data.act.is_end == 10 || ut.gettimestamp()>=th.data.act.end_time ) {
  226 + if (th.data.act.is_end == 10 || ut.gettimestamp() >= th.data.act.end_time) {
219 227 return false;
220 228 }
221 229 //获取头像的分享
... ... @@ -241,7 +249,9 @@ Page({
241 249 success: function (res) {
242 250 var vpath = res.path;
243 251 imgDraw.views[4].url = vpath;
244   - th.setData({imgDraw: imgDraw})
  252 + th.setData({
  253 + imgDraw: imgDraw
  254 + })
245 255 }
246 256 })
247 257 })
... ... @@ -254,13 +264,13 @@ Page({
254 264 }
255 265  
256 266  
257   -
  267 +
258 268 var ee = JSON.parse(JSON.stringify(e));
259 269 var appd = getApp().globalData;
260 270 //-- 等待定位系统的开启 --
261 271 th.waitfor2(15, 'is_get_local_ok', function () {
262 272  
263   - if(!th.data.is_get_local_ok) return false;
  273 + if (!th.data.is_get_local_ok) return false;
264 274  
265 275 var e = JSON.parse(JSON.stringify(ee));
266 276 //如果有开启近距离的话,同时距离优不一样了
... ... @@ -325,10 +335,14 @@ Page({
325 335 var sw_arr = JSON.parse(swithc_list);
326 336 //---如果后台又开等级卡的开关---
327 337 if (sw_arr.rank_switch && sw_arr.rank_switch == "2") {
328   - th.setData({rank_switch: true});
  338 + th.setData({
  339 + rank_switch: true
  340 + });
329 341 //---回调卡的列表---
330 342 th.getPlusCardType(function (ob) {
331   - th.setData({card_list: ob.card_list});
  343 + th.setData({
  344 + card_list: ob.card_list
  345 + });
332 346 var user = getApp().globalData.userInfo;
333 347 if (!user) return false;
334 348 if (user.card_field && user['card_expiredate']) {
... ... @@ -350,7 +364,7 @@ Page({
350 364 th.get_cart_val(e);
351 365  
352 366 })
353   - }else{
  367 + } else {
354 368 //获取购物车的内容
355 369 th.get_cart_val(e);
356 370 }
... ... @@ -359,9 +373,6 @@ Page({
359 373 })
360 374  
361 375 }
362   -
363   -
364   -
365 376 },
366 377  
367 378 onHide: function () {
... ... @@ -386,33 +397,43 @@ Page({
386 397 data: req_data,
387 398 success: function (res) {
388 399 th.data.loading = 0;
389   - th.setData({is_get: 1})
  400 + th.setData({
  401 + is_get: 1
  402 + })
390 403 if (ut.ajax_ok(res)) {
391 404 th.data.page++;
392 405 var list = th.data.list;
393   - if(!list) list=[];
  406 + if (!list) list = [];
394 407  
395 408 //当是下拉刷新的时候
396   - if(th.data.page>1 && th.data.cart_list){
  409 + if (th.data.page > 1 && th.data.cart_list) {
397 410 //下拉之后也要重新计算一下金额
398   - th.calc_more(res.data.data.pageData,function (list1) {
  411 + th.calc_more(res.data.data.pageData, function (list1) {
399 412 for (var i in list1) {
400 413 list.push(list1[i]);
401 414 }
402   - th.setData({list: list});
  415 + th.setData({
  416 + list: list
  417 + });
403 418 th.re_sum_price();
404 419 })
405   - }else{
  420 + } else {
406 421 for (var i in res.data.data.pageData) {
407 422 list.push(res.data.data.pageData[i]);
408 423 }
409   - th.setData({list: list});
  424 + th.setData({
  425 + list: list
  426 + });
410 427 if (res.data.data.total <= 10) {
411   - th.setData({no_more: 1});
  428 + th.setData({
  429 + no_more: 1
  430 + });
412 431 }
413 432 }
414 433 } else {
415   - th.setData({no_more: 1});
  434 + th.setData({
  435 + no_more: 1
  436 + });
416 437 }
417 438 }
418 439 })
... ... @@ -428,34 +449,34 @@ Page({
428 449 */
429 450 onShareAppMessage: function () {
430 451 var title = this.data.act.name;
431   - var url= "/packageB/pages/zuhegou/index/index?id="+this.data.act.id;
  452 + var url = "/packageB/pages/zuhegou/index/index?id=" + this.data.act.id;
432 453 if (getApp().globalData.user_id) {
433 454 url += "&first_leader=" + getApp().globalData.user_id;
434 455 }
435 456 var ob = {
436   - title:title,
  457 + title: title,
437 458 path: url,
438 459 };
439   - if(this.data.act.img_url)
440   - ob.imageUrl=this.data.iurl+this.data.act.img_url;
  460 + if (this.data.act.img_url)
  461 + ob.imageUrl = this.data.iurl + this.data.act.img_url;
441 462 return ob;
442 463 },
443 464  
444 465 /**
445 466 * 用户分享朋友圈
446 467 */
447   - onShareTimeline(){
  468 + onShareTimeline() {
448 469 var title = this.data.act.name;
449   - var url= "/packageB/pages/zuhegou/index/index?id="+this.data.act.id;
  470 + var url = "/packageB/pages/zuhegou/index/index?id=" + this.data.act.id;
450 471 if (getApp().globalData.user_id) {
451 472 url += "&first_leader=" + getApp().globalData.user_id;
452 473 }
453 474 var ob = {
454   - title:title,
  475 + title: title,
455 476 path: url,
456 477 };
457   - if(this.data.act.img_url)
458   - ob.imageUrl=this.data.iurl+this.data.act.img_url;
  478 + if (this.data.act.img_url)
  479 + ob.imageUrl = this.data.iurl + this.data.act.img_url;
459 480 return ob;
460 481 },
461 482 /**
... ... @@ -505,7 +526,7 @@ Page({
505 526 this.data.sele_index = index;
506 527 let title = '';
507 528 self = this;
508   - th.data.s_cart_num=0;
  529 + th.data.s_cart_num = 0;
509 530  
510 531 //说明是加入购物车是时候
511 532 this.data.is_zuhe_addcart = 1;
... ... @@ -527,7 +548,7 @@ Page({
527 548 wx.showModal({
528 549 title: '温馨提示',
529 550 content: '该商品的物流配送方式和默认门店不匹配,是否要切换门店?',
530   - success (res) {
  551 + success(res) {
531 552 if (res.confirm) {
532 553 //物流的配送方式不一样
533 554 th.get_sto();
... ... @@ -544,7 +565,9 @@ Page({
544 565 }
545 566 return false;
546 567 } else {
547   - th.setData({is_no_pipei: 0});
  568 + th.setData({
  569 + is_no_pipei: 0
  570 + });
548 571 th.check_is_in_cart(function () {
549 572 th.add_cart_func();
550 573 })
... ... @@ -559,10 +582,10 @@ Page({
559 582 wx.showModal({
560 583 title: '温馨提示',
561 584 content: "确定取消该商品参与活动?",
562   - success (res) {
  585 + success(res) {
563 586 if (res.confirm) {
564 587 console.log('用户点击确定');
565   - if(th.data.sele_g.cart_num && th.data.sele_g.cart_num - th.data.sele_g.num>0){
  588 + if (th.data.sele_g.cart_num && th.data.sele_g.cart_num - th.data.sele_g.num > 0) {
566 589  
567 590 var updata = {
568 591 id: th.data.sele_g.cart_id,
... ... @@ -571,8 +594,8 @@ Page({
571 594 }
572 595 getApp().request.put("/api/weshop/cart/update", {
573 596 data: updata,
574   - success:function (rs) {
575   - if(rs.data.code==0) {
  597 + success: function (rs) {
  598 + if (rs.data.code == 0) {
576 599 title = '取消成功';
577 600 th.setData({
578 601 [txt1]: 0,
... ... @@ -588,12 +611,12 @@ Page({
588 611 }
589 612 })
590 613  
591   - }else{
592   - var url = '/api/weshop/cart/del/' + os.stoid + '/' + th.data.sele_g.cart_id;
593   - getApp().request.delete(url, {
594   - success:function (res) {
  614 + } else {
  615 + var url = '/api/weshop/cart/del/' + os.stoid + '/' + th.data.sele_g.cart_id;
  616 + getApp().request.delete(url, {
  617 + success: function (res) {
595 618  
596   - if(res.data.code==0) {
  619 + if (res.data.code == 0) {
597 620 title = '取消成功';
598 621 th.setData({
599 622 [txt1]: 0,
... ... @@ -635,14 +658,14 @@ Page({
635 658 return false;
636 659 }
637 660  
638   - if(this.data.changing) return false;
639   - this.data.changing=1;
  661 + if (this.data.changing) return false;
  662 + this.data.changing = 1;
640 663  
641 664 var index = e.currentTarget.dataset.index;
642 665 this.data.sele_g = this.data.list[index];
643   - this.data.sele_index=index;
  666 + this.data.sele_index = index;
644 667 th.data.goodsInputNum = this.data.sele_g.num + 1;
645   - if(this.data.sele_g.cart_num){
  668 + if (this.data.sele_g.cart_num) {
646 669 th.data.s_cart_num = this.data.sele_g.cart_num + 1;
647 670 }
648 671 th.add_cart_func();
... ... @@ -661,7 +684,7 @@ Page({
661 684 var th = this;
662 685 var index = e.currentTarget.dataset.index;
663 686 var item = this.data.list[index];
664   - this.data.sele_g=item;
  687 + this.data.sele_g = item;
665 688 let num = item.num;
666 689 th.data.s_cart_num = item.cart_num - 1;
667 690  
... ... @@ -677,8 +700,8 @@ Page({
677 700 return false;
678 701 }
679 702  
680   - if(th.data.changing) return false;
681   - th.data.changing=1;
  703 + if (th.data.changing) return false;
  704 + th.data.changing = 1;
682 705 th.data.sele_g = item;
683 706 th.data.sele_index = index;
684 707 th.data.goodsInputNum = check_num;
... ... @@ -694,19 +717,19 @@ Page({
694 717 wx.showModal({
695 718 title: '温馨提示',
696 719 content: '确定取消该商品参与活动?',
697   - success (res) {
  720 + success(res) {
698 721 if (res.confirm) {
699 722  
700   - if(th.data.s_cart_num){
  723 + if (th.data.s_cart_num) {
701 724 var updata = {
702 725 id: th.data.sele_g.cart_id,
703   - goods_num:th.data.s_cart_num ,
  726 + goods_num: th.data.s_cart_num,
704 727 store_id: os.stoid
705 728 }
706 729 getApp().request.put("/api/weshop/cart/update", {
707 730 data: updata,
708   - success:function (rs) {
709   - if(rs.data.code==0) {
  731 + success: function (rs) {
  732 + if (rs.data.code == 0) {
710 733 var title = '取消成功';
711 734 th.setData({
712 735 [txt1]: 0,
... ... @@ -721,7 +744,7 @@ Page({
721 744 }
722 745 }
723 746 })
724   - }else {
  747 + } else {
725 748 var url = '/api/weshop/cart/del/' + os.stoid + '/' + item.cart_id;
726 749 getApp().request.delete(url, {
727 750 success: function (res) {
... ... @@ -736,7 +759,7 @@ Page({
736 759 title: title,
737 760 icon: 'success',
738 761 });
739   - th.re_sum_price();//重新统计数量和总金额
  762 + th.re_sum_price(); //重新统计数量和总金额
740 763 }
741 764 }
742 765 });
... ... @@ -911,11 +934,11 @@ Page({
911 934 //-- 加入购物的函数 --
912 935 add_cart_func: function () {
913 936 if (oo.user_id == null) {
914   - this.data.changing=0;
  937 + this.data.changing = 0;
915 938 return getApp().my_warnning("还未登录!", 0, this);
916 939 }
917 940 if (!getApp().globalData.userInfo) {
918   - this.data.changing=0;
  941 + this.data.changing = 0;
919 942 return getApp().my_warnning("还未登录!", 0, this);
920 943 }
921 944  
... ... @@ -933,16 +956,16 @@ Page({
933 956 title: '提示',
934 957 content: '超出商品限购'
935 958 });
936   - th.data.changing=0;
  959 + th.data.changing = 0;
937 960 return false;
938 961 }
939   - if(th.data.s_cart_num){
  962 + if (th.data.s_cart_num) {
940 963 if (th.data.s_cart_num + th.data.g_buy_num.get(th.data.sele_g.goods_id).gd_buynum > th.data.sele_g.viplimited) {
941 964 wx.showModal({
942 965 title: '提示',
943 966 content: '超出商品限购'
944 967 });
945   - th.data.changing=0;
  968 + th.data.changing = 0;
946 969 return false;
947 970 }
948 971 }
... ... @@ -950,25 +973,27 @@ Page({
950 973 }
951 974 //---判断商品是否超出活动限购---
952 975 if (th.data.sele_g.buyqty > 0) {
953   - if (th.data.goodsInputNum+ th.data.g_buy_num.get(th.data.sele_g.goods_id).prom_buybum > th.data.sele_g.buyqty) {
  976 + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id).prom_buybum > th.data.sele_g.buyqty) {
954 977 wx.showModal({
955 978 title: '提示',
956 979 content: '超出商品活动限购'
957 980 });
958   - th.data.changing=0;
  981 + th.data.changing = 0;
959 982 return false;
960 983 }
961 984 }
962 985  
963   - if (th.data.goodsInputNum <= 0){
964   - this.data.changing=0;return s.my_warnning("商品数量不能为0", 0, th);
  986 + if (th.data.goodsInputNum <= 0) {
  987 + this.data.changing = 0;
  988 + return s.my_warnning("商品数量不能为0", 0, th);
965 989 }
966 990 if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined)
967 991 this.setData({
968 992 sto_sele_name: ""
969 993 });
970 994 if (th.data.sto_sele_name == "") {
971   - th.data.changing=0;return s.my_warnning("请选择门店", 0, th);
  995 + th.data.changing = 0;
  996 + return s.my_warnning("请选择门店", 0, th);
972 997 }
973 998  
974 999 //--------------此时操作的数据------------
... ... @@ -984,8 +1009,8 @@ Page({
984 1009 goods_sn: o.goods_sn,
985 1010 };
986 1011  
987   - if(th.data.s_cart_num){
988   - newd.goods_num=th.data.s_cart_num;
  1012 + if (th.data.s_cart_num) {
  1013 + newd.goods_num = th.data.s_cart_num;
989 1014 }
990 1015  
991 1016 //---是不是从收藏夹出来的---
... ... @@ -1010,19 +1035,21 @@ Page({
1010 1035 if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id;
1011 1036 }
1012 1037  
1013   - if (o.store_count <= 0){
1014   - th.data.changing=0;return getApp().my_warnning("库存已为空!", 0, th);
  1038 + if (o.store_count <= 0) {
  1039 + th.data.changing = 0;
  1040 + return getApp().my_warnning("库存已为空!", 0, th);
1015 1041 }
1016   - if (o.store_count < e.data.goodsInputNum){
1017   - th.data.changing=0;return getApp().my_warnning("库存不足!", 0, th);
  1042 + if (o.store_count < e.data.goodsInputNum) {
  1043 + th.data.changing = 0;
  1044 + return getApp().my_warnning("库存不足!", 0, th);
1018 1045 }
1019   - th.add_cart_next(o, newd); //加入购物车下一步
  1046 + th.add_cart_next(o, newd); //加入购物车下一步
1020 1047  
1021 1048 })
1022 1049 },
1023 1050  
1024 1051 //---加入购物车的最后一步---
1025   - add_cart_next(o, newd){
  1052 + add_cart_next(o, newd) {
1026 1053 var th = this;
1027 1054 //如果会员有等级价
1028 1055 if (th.data.card_field) {
... ... @@ -1052,12 +1079,12 @@ Page({
1052 1079 th.data.adding = 0;
1053 1080 return getApp().my_warnning("库存不足!", 0, th);
1054 1081 }
1055   - if (th.data.goodsInputNum+ th.data.g_buy_num.get(th.data.sele_g.goods_id).prom_buybum > o.buyqty && o.buyqty>0) {
  1082 + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id).prom_buybum > o.buyqty && o.buyqty > 0) {
1056 1083 th.data.adding = 0;
1057 1084 return getApp().my_warnning("超出商品活动限购!", 0, th);
1058 1085 }
1059   - if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id).prom_buybum > th.data.sele_g.viplimited
1060   - && th.data.sele_g.viplimited > 0
  1086 + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id).prom_buybum > th.data.sele_g.viplimited &&
  1087 + th.data.sele_g.viplimited > 0
1061 1088 ) {
1062 1089 th.data.adding = 0;
1063 1090 return getApp().my_warnning("超出商品限购!", 0, th);
... ... @@ -1071,13 +1098,13 @@ Page({
1071 1098 member_goods_price: newd.goods_price,
1072 1099 store_id: os.stoid,
1073 1100 };
1074   - if(th.data.s_cart_num){
1075   - updata.goods_num=th.data.s_cart_num;
  1101 + if (th.data.s_cart_num) {
  1102 + updata.goods_num = th.data.s_cart_num;
1076 1103 }
1077 1104 //---是不是从收藏夹出来的---
1078 1105 if (th.data.c_guide_id) {
1079 1106 updata['guide_id'] = th.data.c_guide_id;
1080   - updata['guide_type'] = 3; //加入购物车之后就变成了3
  1107 + updata['guide_type'] = 3; //加入购物车之后就变成了3
1081 1108 } else {
1082 1109 if (getApp().globalData.guide_id) {
1083 1110 updata['guide_id'] = getApp().globalData.guide_id;
... ... @@ -1096,12 +1123,14 @@ Page({
1096 1123 th.data.adding = 0;
1097 1124 th.data.sele_store = 1;
1098 1125  
1099   - if(th.data.s_cart_num){
  1126 + if (th.data.s_cart_num) {
1100 1127 var txt_temp = "list[" + index + "].cart_num";
1101   - th.setData({[txt_temp]:th.data.s_cart_num})
  1128 + th.setData({
  1129 + [txt_temp]: th.data.s_cart_num
  1130 + })
1102 1131 }
1103 1132  
1104   - th.re_sum_price();//重新统计数量和总金额
  1133 + th.re_sum_price(); //重新统计数量和总金额
1105 1134 }
1106 1135 });
1107 1136 } else {
... ... @@ -1121,7 +1150,7 @@ Page({
1121 1150  
1122 1151 th.data.adding = 0;
1123 1152 th.data.sele_store = 1;
1124   - th.re_sum_price();//重新统计数量和总金额
  1153 + th.re_sum_price(); //重新统计数量和总金额
1125 1154 }
1126 1155 }
1127 1156 });
... ... @@ -1182,14 +1211,17 @@ Page({
1182 1211 list.push(plusCard[i]);
1183 1212 }
1184 1213  
1185   - var ob = {"card_list": list, "name_map": card_name_map};
  1214 + var ob = {
  1215 + "card_list": list,
  1216 + "name_map": card_name_map
  1217 + };
1186 1218 func(ob);
1187 1219 })
1188 1220 },
1189 1221  
1190 1222  
1191 1223 //--- 设置一下默认库存的数量 ----
1192   - set_def_storage(ee){
  1224 + set_def_storage(ee) {
1193 1225 var that = this;
1194 1226 that.data.fir_def_store = ee;
1195 1227 that.setData({
... ... @@ -1206,8 +1238,8 @@ Page({
1206 1238 this.waitfor2(15, 'is_get_local_ok', function () {
1207 1239 //if (!th.data.sele_g) return false;
1208 1240 var dd = null;
1209   - var g_distr_type =0;
1210   - if(th.data.sele_g) g_distr_type=th.data.sele_g.distr_type;
  1241 + var g_distr_type = 0;
  1242 + if (th.data.sele_g) g_distr_type = th.data.sele_g.distr_type;
1211 1243 if (g_distr_type != 0) {
1212 1244 dd = {
1213 1245 store_id: os.stoid,
... ... @@ -1233,7 +1265,9 @@ Page({
1233 1265  
1234 1266 //如果会员是有默认的门店话
1235 1267 if (!th.data.def_pick_store && th.data.fir_def_store) {
1236   - th.setData({def_pick_store: th.data.fir_def_store});
  1268 + th.setData({
  1269 + def_pick_store: th.data.fir_def_store
  1270 + });
1237 1271 }
1238 1272  
1239 1273 wx.showLoading({
... ... @@ -1246,14 +1280,15 @@ Page({
1246 1280 var e = res;
1247 1281 if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) {
1248 1282  
1249   - var his_cate_num=0;
1250   - for(let i in e.data.data.pageData){
1251   - let item=e.data.data.pageData[i];
1252   - if(item.category_id>0){
1253   - his_cate_num=1;break;
  1283 + var his_cate_num = 0;
  1284 + for (let i in e.data.data.pageData) {
  1285 + let item = e.data.data.pageData[i];
  1286 + if (item.category_id > 0) {
  1287 + his_cate_num = 1;
  1288 + break;
1254 1289 }
1255 1290 }
1256   - e.his_cate_num=his_cate_num;
  1291 + e.his_cate_num = his_cate_num;
1257 1292  
1258 1293 //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店
1259 1294 if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) {
... ... @@ -1277,14 +1312,16 @@ Page({
1277 1312 e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加
1278 1313 }
1279 1314  
1280   - th.setData({all_pick_list: e.data.data.pageData});
  1315 + th.setData({
  1316 + all_pick_list: e.data.data.pageData
  1317 + });
1281 1318 th.deal_pickup(e);
1282 1319 }
1283 1320 })
1284 1321 })
1285 1322 },
1286 1323 //------------处理门店---------------
1287   - deal_pickup(e){
  1324 + deal_pickup(e) {
1288 1325 var th = this;
1289 1326 wx.hideLoading();
1290 1327 //单总量超出5个的时候
... ... @@ -1299,12 +1336,13 @@ Page({
1299 1336 success: function (ee) {
1300 1337 if (ee.data.code == 0) {
1301 1338  
1302   - var check_all_cate=0;
1303   - if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0){
1304   - for(let i in ee.data.data.pageData){
1305   - let item=ee.data.data.pageData[i];
1306   - if(item.is_show==1){
1307   - check_all_cate=1;break
  1339 + var check_all_cate = 0;
  1340 + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) {
  1341 + for (let i in ee.data.data.pageData) {
  1342 + let item = ee.data.data.pageData[i];
  1343 + if (item.is_show == 1) {
  1344 + check_all_cate = 1;
  1345 + break
1308 1346 }
1309 1347 }
1310 1348 }
... ... @@ -1316,12 +1354,14 @@ Page({
1316 1354 var newarr = new Array();
1317 1355 var qita = new Array();
1318 1356  
1319   - var is_del_pk=0;
  1357 + var is_del_pk = 0;
1320 1358 //----要进行门店分组--------
1321 1359 for (var i = 0; i < sto_arr.length; i++) {
1322 1360 //找一下这个门店有没有在分类数组内
1323   - var find2 = 0, find2name = "", sort = 0;
1324   - is_del_pk=0;
  1361 + var find2 = 0,
  1362 + find2name = "",
  1363 + sort = 0;
  1364 + is_del_pk = 0;
1325 1365 for (var m = 0; m < sto_cate.length; m++) {
1326 1366 if (sto_arr[i].category_id == sto_cate[m].cat_id) {
1327 1367 if (sto_cate[m].is_show != 1) {
... ... @@ -1337,7 +1377,7 @@ Page({
1337 1377 break;
1338 1378 }
1339 1379 }
1340   - if(is_del_pk) continue;
  1380 + if (is_del_pk) continue;
1341 1381  
1342 1382 if (newarr.length > 0) {
1343 1383 var find = 0;
... ... @@ -1416,13 +1456,13 @@ Page({
1416 1456 }
1417 1457  
1418 1458  
1419   - var sd={
  1459 + var sd = {
1420 1460 all_sto: newarr,
1421   - is_show_sto_cat:1
  1461 + is_show_sto_cat: 1
1422 1462 }
1423   - if(!sto_arr || sto_arr.length<=10){
1424   - sd.is_show_sto_cat=-1;
1425   - sd.only_pk=sto_arr;
  1463 + if (!sto_arr || sto_arr.length <= 10) {
  1464 + sd.is_show_sto_cat = -1;
  1465 + sd.only_pk = sto_arr;
1426 1466 }
1427 1467 th.setData(sd);
1428 1468  
... ... @@ -1433,7 +1473,9 @@ Page({
1433 1473 });
1434 1474 //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
1435 1475 if (!th.data.def_pick_store) {
1436   - th.setData({def_pick_store: e.data.data.pageData[0]})
  1476 + th.setData({
  1477 + def_pick_store: e.data.data.pageData[0]
  1478 + })
1437 1479 }
1438 1480 }
1439 1481 } else {
... ... @@ -1443,7 +1485,9 @@ Page({
1443 1485 });
1444 1486 //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
1445 1487 if (!th.data.def_pick_store) {
1446   - th.setData({def_pick_store: e.data.data.pageData[0]})
  1488 + th.setData({
  1489 + def_pick_store: e.data.data.pageData[0]
  1490 + })
1447 1491 }
1448 1492 }
1449 1493 }
... ... @@ -1508,7 +1552,7 @@ Page({
1508 1552 }
1509 1553  
1510 1554 //判断门店的配送方式是不是匹配
1511   - var g_distr_type=0;
  1555 + var g_distr_type = 0;
1512 1556 if (th.data.sele_g)
1513 1557 g_distr_type = th.data.sele_g.distr_type;
1514 1558 if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) {
... ... @@ -1609,7 +1653,7 @@ Page({
1609 1653 sto_sele_distr: item.distr_type,
1610 1654 store: 0,
1611 1655 choice_sort_store: 0,
1612   - sort_store: 0, //关闭门店2级
  1656 + sort_store: 0, //关闭门店2级
1613 1657 });
1614 1658  
1615 1659 th.add_cart_func();
... ... @@ -1643,7 +1687,8 @@ Page({
1643 1687 //-------------获取购买数量的总函数----------------
1644 1688 get_buy_num: function (gd, func) {
1645 1689 var map = this.data.g_buy_num,
1646   - th = this, user_id = getApp().globalData.user_id;
  1690 + th = this,
  1691 + user_id = getApp().globalData.user_id;
1647 1692  
1648 1693 if (user_id == null) {
1649 1694 getApp().goto("/pages/togoin/togoin");
... ... @@ -1652,7 +1697,7 @@ Page({
1652 1697 if (map && map.has(gd.goods_id)) {
1653 1698 "function" == typeof func && func();
1654 1699 } else {
1655   - var res1=null;
  1700 + var res1 = null;
1656 1701 //----获取商品购买数----
1657 1702 getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
1658 1703 data: {
... ... @@ -1662,9 +1707,9 @@ Page({
1662 1707 prom_type: 7,
1663 1708 prom_id: th.data.act.id
1664 1709 },
1665   - }).then(res2=>{
1666   - var g_buy_num=0;
1667   - var promgoodsbuynum=0;
  1710 + }).then(res2 => {
  1711 + var g_buy_num = 0;
  1712 + var promgoodsbuynum = 0;
1668 1713 if (res2.data.code == 0) {
1669 1714 var buy_num_data = res2.data.data;
1670 1715 if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
... ... @@ -1672,9 +1717,9 @@ Page({
1672 1717 }
1673 1718  
1674 1719 if (!map) map = new Map();
1675   - var ob={
1676   - gd_buynum:g_buy_num,
1677   - prom_buybum:promgoodsbuynum,
  1720 + var ob = {
  1721 + gd_buynum: g_buy_num,
  1722 + prom_buybum: promgoodsbuynum,
1678 1723 }
1679 1724 map.set(gd.goods_id, ob);
1680 1725 th.setData({
... ... @@ -1686,7 +1731,7 @@ Page({
1686 1731 },
1687 1732  
1688 1733 //-- 当是减数量的调用 --
1689   - sub_updata_cart(){
  1734 + sub_updata_cart() {
1690 1735 var th = this;
1691 1736 var index = this.data.sele_index;
1692 1737 var txt = "list[" + index + "].haveAdded";
... ... @@ -1704,14 +1749,14 @@ Page({
1704 1749 store_id: os.stoid,
1705 1750 };
1706 1751  
1707   - if(th.data.s_cart_num){
1708   - updata.goods_num=th.data.s_cart_num;
  1752 + if (th.data.s_cart_num) {
  1753 + updata.goods_num = th.data.s_cart_num;
1709 1754 }
1710 1755  
1711 1756 //---是不是从收藏夹出来的---
1712 1757 if (th.data.c_guide_id) {
1713 1758 updata['guide_id'] = th.data.c_guide_id;
1714   - updata['guide_type'] = 3; //加入购物车之后就变成了3
  1759 + updata['guide_type'] = 3; //加入购物车之后就变成了3
1715 1760 } else {
1716 1761 if (getApp().globalData.guide_id) {
1717 1762 updata['guide_id'] = getApp().globalData.guide_id;
... ... @@ -1729,12 +1774,14 @@ Page({
1729 1774 });
1730 1775 th.data.adding = 0;
1731 1776 th.data.sele_store = 1;
1732   - if(th.data.s_cart_num){
  1777 + if (th.data.s_cart_num) {
1733 1778 var txt_temp = "list[" + index + "].cart_num";
1734   - th.setData({[txt_temp]:th.data.s_cart_num})
  1779 + th.setData({
  1780 + [txt_temp]: th.data.s_cart_num
  1781 + })
1735 1782 }
1736 1783  
1737   - th.re_sum_price();//重新统计数量和总金额
  1784 + th.re_sum_price(); //重新统计数量和总金额
1738 1785 }
1739 1786 });
1740 1787 },
... ... @@ -1776,24 +1823,24 @@ Page({
1776 1823 success: function (re) {
1777 1824 if (re.data.data.total > 0) {
1778 1825 var item = re.data.data.pageData[0];
1779   - th.get_buy_num(th.data.sele_g,function () {
  1826 + th.get_buy_num(th.data.sele_g, function () {
1780 1827 //当前的价格要更新进去
1781 1828 var cur_price = th.data.sele_g.shop_price;
1782 1829 if (th.data.card_field && th.data.sele_g[th.data.card_field]) {
1783 1830 cur_price = th.data.sele_g[th.data.card_field];
1784 1831 }
1785 1832  
1786   - var prom_buybum=0;
1787   - var gd_buynum=0;
  1833 + var prom_buybum = 0;
  1834 + var gd_buynum = 0;
1788 1835 //加入也要控制一下限购
1789   - var check_obj=th.data.g_buy_num.get(th.data.sele_g.goods_id);
1790   - if(check_obj.gd_buynum && check_obj.gd_buynum>0) gd_buynum=check_obj.gd_buynum;
1791   - if(check_obj.prom_buybum && check_obj.prom_buybum>0) prom_buybum=check_obj.prom_buybum;
1792   -
1793   - if(check_obj){
1794   - if(check_obj.prom_buybum && check_obj.prom_buybum>=th.data.sele_g.buyqty &&
1795   - th.data.sele_g.buyqty>0
1796   - ){
  1836 + var check_obj = th.data.g_buy_num.get(th.data.sele_g.goods_id);
  1837 + if (check_obj.gd_buynum && check_obj.gd_buynum > 0) gd_buynum = check_obj.gd_buynum;
  1838 + if (check_obj.prom_buybum && check_obj.prom_buybum > 0) prom_buybum = check_obj.prom_buybum;
  1839 +
  1840 + if (check_obj) {
  1841 + if (check_obj.prom_buybum && check_obj.prom_buybum >= th.data.sele_g.buyqty &&
  1842 + th.data.sele_g.buyqty > 0
  1843 + ) {
1797 1844 wx.showToast({
1798 1845 title: "您的已购数量超出活动的限购",
1799 1846 icon: 'none',
... ... @@ -1801,9 +1848,9 @@ Page({
1801 1848 });
1802 1849 return false;
1803 1850 }
1804   - if(check_obj.gd_buynum && check_obj.gd_buynum>=th.data.sele_g.viplimited &&
1805   - th.data.sele_g.viplimited>0
1806   - ){
  1851 + if (check_obj.gd_buynum && check_obj.gd_buynum >= th.data.sele_g.viplimited &&
  1852 + th.data.sele_g.viplimited > 0
  1853 + ) {
1807 1854 wx.showToast({
1808 1855 title: "您的已购数量超出商品的限购",
1809 1856 icon: 'none',
... ... @@ -1813,17 +1860,17 @@ Page({
1813 1860 }
1814 1861 }
1815 1862  
1816   - item.cbuy='no';
1817   - var cbuy=th.data.sele_g.viplimited>0?th.data.sele_g.viplimited-gd_buynum:'no';
1818   - if(cbuy!='no') item.cbuy=cbuy;
1819   - var cbuy2=th.data.sele_g.buyqty>0?th.data.sele_g.buyqty-prom_buybum:'no';
1820   - if(cbuy2!='no'){
1821   - if(item.cbuy=='no' || item.cbuy>cbuy2) item.cbuy=cbuy2;
  1863 + item.cbuy = 'no';
  1864 + var cbuy = th.data.sele_g.viplimited > 0 ? th.data.sele_g.viplimited - gd_buynum : 'no';
  1865 + if (cbuy != 'no') item.cbuy = cbuy;
  1866 + var cbuy2 = th.data.sele_g.buyqty > 0 ? th.data.sele_g.buyqty - prom_buybum : 'no';
  1867 + if (cbuy2 != 'no') {
  1868 + if (item.cbuy == 'no' || item.cbuy > cbuy2) item.cbuy = cbuy2;
1822 1869 }
1823 1870  
1824   - var num=item.goods_num;
1825   - if(item.cbuy>-1 && item.cbuy<item.goods_num){
1826   - num=item.cbuy;
  1871 + var num = item.goods_num;
  1872 + if (item.cbuy > -1 && item.cbuy < item.goods_num) {
  1873 + num = item.cbuy;
1827 1874 }
1828 1875 th.setData({
1829 1876 [txt1]: num,
... ... @@ -1848,11 +1895,10 @@ Page({
1848 1895  
1849 1896 getApp().request.put("/api/weshop/cart/update", {
1850 1897 data: updata,
1851   - success: function (t) {
1852   - }
  1898 + success: function (t) {}
1853 1899 });
1854 1900 th.re_sum_price();
1855   - })
  1901 + })
1856 1902  
1857 1903 } else {
1858 1904 func();
... ... @@ -1863,12 +1909,12 @@ Page({
1863 1909  
1864 1910 //-- 计算统计之后的金额 --
1865 1911 re_sum_price: function () {
1866   - var all_num = 0; //商品数量之和
  1912 + var all_num = 0; //商品数量之和
1867 1913 var all_price = 0;
1868 1914 var need_to_buy = 0;
1869 1915 var data = this.data.list;
1870   - var all_zhqty = 0; //所有商品要求起购数之后
1871   -
  1916 + var all_zhqty = 0; //所有商品要求起购数之后
  1917 + var zhqty_bz=[]; //超量
1872 1918 var no_in_arr = [];
1873 1919 for (var i in data) {
1874 1920 var item = data[i];
... ... @@ -1877,18 +1923,25 @@ Page({
1877 1923 all_price += item.num * item.current_price;
1878 1924 //当有起购数的控制的时候
1879 1925 if (item.zhqty) {
  1926 + zhqty_bz.push(item);
1880 1927 all_zhqty += item.zhqty;
1881 1928 if (item.num < item.zhqty) {
1882 1929 need_to_buy += item.zhqty - item.num;
1883 1930 }
1884 1931 if (item.num > item.zhqty) {
1885 1932 for (var i = 0; i < item.num - item.zhqty; i++) {
1886   - no_in_arr.push({price: item.current_price,goods_id:item.goods_id});
  1933 + no_in_arr.push({
  1934 + price: item.current_price,
  1935 + goods_id: item.goods_id
  1936 + });
1887 1937 }
1888 1938 }
1889 1939 } else {
1890 1940 for (var j = 0; j < item.num; j++) {
1891   - no_in_arr.push({price: item.current_price,goods_id:item.goods_id});
  1941 + no_in_arr.push({
  1942 + price: item.current_price,
  1943 + goods_id: item.goods_id
  1944 + });
1892 1945 }
1893 1946 }
1894 1947 } else {
... ... @@ -1901,23 +1954,49 @@ Page({
1901 1954 function sortData(a, b) {
1902 1955 return a.price - b.price
1903 1956 }
1904   - if(no_in_arr.length) no_in_arr.sort(sortData);
  1957 + if (no_in_arr.length) no_in_arr.sort(sortData);
1905 1958  
1906 1959 var aprice = this.data.act.zhprice;
1907 1960 if (this.data.act.zhbuyqty > all_zhqty) {
1908   - for (var n = 0; n < this.data.act.zhbuyqty-all_zhqty; n++) {
  1961 + for (var n = 0; n < this.data.act.zhbuyqty - all_zhqty; n++) {
1909 1962 no_in_arr.pop();
1910 1963 }
1911 1964 }
1912 1965  
1913 1966 //看一下剩下的数量有没有满足组合购的要求,以及要不要倍增
1914 1967 if (this.data.act.is_bz && no_in_arr.length >= this.data.act.zhbuyqty) {
1915   - //看一下是几倍
  1968 + let zhqty_map=new map();
  1969 + //看一下是几倍
1916 1970 var be = parseInt(no_in_arr.length / this.data.act.zhbuyqty);
1917   - aprice += be * aprice;
1918   - for (var m = 0; m < be * this.data.act.zhbuyqty; m++) {
1919   - no_in_arr.pop();
  1971 + if(this.data.act.is_bzyh && zhqty_bz.length > 0 ){
  1972 + for(let i=0;i<zhqty_bz.length;i++){
  1973 + let vv=zhqty_bz[i];
  1974 + let num=0;
  1975 + let bz_num=be*vv.zhqty;
  1976 + for(let j=0;j<no_in_arr.length;j++){
  1977 + let ii=no_in_arr[j];
  1978 + if(vv.goods_id===ii.goods_id){
  1979 + num++;
  1980 + zhqty_map.set('num',num);
  1981 + zhqty_map.set('price',ii.price);
  1982 + }
  1983 +
  1984 + }
  1985 + }
1920 1986 }
  1987 + if(bz_num <= num){
  1988 + aprice += be * aprice;
  1989 + let pop_num=(be * this.data.act.zhbuyqty)-bz_num;
  1990 + console.log(pop_num);
  1991 + for (var m = 0; m < pop_num; m++) {
  1992 + no_in_arr.pop();
  1993 + }
  1994 + }
  1995 + // var be = parseInt(no_in_arr.length / this.data.act.zhbuyqty);
  1996 + // aprice += be * aprice;
  1997 + // for (var m = 0; m < be * this.data.act.zhbuyqty; m++) {
  1998 + // no_in_arr.pop();
  1999 + // }
1921 2000 }
1922 2001  
1923 2002 //算一下剩余的钱
... ... @@ -1929,146 +2008,148 @@ Page({
1929 2008 }
1930 2009 all_price = aprice;
1931 2010 }
1932   - this.data.changing=0;
  2011 + this.data.changing = 0;
1933 2012 this.setData({
1934 2013 all_price: all_price,
1935 2014 need_to_buy: need_to_buy,
1936 2015 all_num: all_num
1937 2016 })
1938 2017  
1939   - if(all_num<=0){
1940   - this.data.sele_store = 0; //什么都没有选,就没有选择了门店
  2018 + if (all_num <= 0) {
  2019 + this.data.sele_store = 0; //什么都没有选,就没有选择了门店
1941 2020 }
1942 2021  
1943 2022 },
1944 2023  
1945   - go_cart:function () {
  2024 + go_cart: function () {
1946 2025 getApp().goto("/pages/cart/cart/cart");
1947 2026 },
1948 2027  
1949 2028 //获取购物车中,相应的门店已购买的商品
1950   - get_cart_val:function (e) {
1951   - var th=this;
1952   - var user_id=getApp().globalData.user_id;
1953   - var req={
1954   - user_id: user_id,
1955   - store_id: os.stoid,
1956   - pageSize: 600,
1957   - state:0,
1958   - prom_type:7,
1959   - prom_id:this.data.act.id
  2029 + get_cart_val: function (e) {
  2030 + var th = this;
  2031 + var user_id = getApp().globalData.user_id;
  2032 + var req = {
  2033 + user_id: user_id,
  2034 + store_id: os.stoid,
  2035 + pageSize: 600,
  2036 + state: 0,
  2037 + prom_type: 7,
  2038 + prom_id: this.data.act.id
1960 2039 };
1961 2040 //获取购物车列表
1962   - getApp().request.get("/api/weshop/cart/list",{
1963   - data:req,
1964   - success: async function(e) {
  2041 + getApp().request.get("/api/weshop/cart/list", {
  2042 + data: req,
  2043 + success: async function (e) {
1965 2044 if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length) {
1966   - var map={};
1967   - var mlist=e.data.data.pageData;
1968   - th.data.cart_list=mlist;
1969   -
1970   - for(let i in mlist){
1971   - let item=mlist[i];
1972   - if(item.prom_type!=7) continue;
1973   - if(item.prom_id!=th.data.act.id) continue;
1974   - map[item.goods_id]=item;
  2045 + var map = {};
  2046 + var mlist = e.data.data.pageData;
  2047 + th.data.cart_list = mlist;
  2048 +
  2049 + for (let i in mlist) {
  2050 + let item = mlist[i];
  2051 + if (item.prom_type != 7) continue;
  2052 + if (item.prom_id != th.data.act.id) continue;
  2053 + map[item.goods_id] = item;
1975 2054 }
1976   - for(let j in th.data.list){
1977   - let item_j=th.data.list[j];
1978   - item_j.current_price=item_j.shop_price;
  2055 + for (let j in th.data.list) {
  2056 + let item_j = th.data.list[j];
  2057 + item_j.current_price = item_j.shop_price;
1979 2058  
1980   - var card_price=0;
  2059 + var card_price = 0;
1981 2060 //如果会员有等级价
1982 2061 if (th.data.card_field) {
1983 2062 card_price = item_j[th.data.card_field];
1984 2063 if (card_price > 0) {
1985   - item_j.current_price=card_price;
  2064 + item_j.current_price = card_price;
1986 2065 }
1987 2066 }
1988 2067  
1989 2068  
1990   - if(map[item_j.goods_id]){
1991   - var cart_num=map[item_j.goods_id].goods_num;
1992   - item_j.num=cart_num;
1993   - item_j.cart_num=cart_num;
1994   - item_j.cart_id=map[item_j.goods_id].id;
1995   - if(item_j.buyqty>0){
1996   - var g_buy_num=0;
1997   - var promgoodsbuynum=0;
1998   - //----获取商品购买数----
1999   - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
2000   - data: {
2001   - store_id: os.stoid,
2002   - user_id: user_id,
2003   - goods_id: item_j.goods_id,
2004   - prom_type: 7,
2005   - prom_id: th.data.act.id
2006   - },
2007   - }).then(res2=>{
2008   - if (res2.data.code == 0) {
2009   - var buy_num_data = res2.data.data;
2010   - if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
2011   - g_buy_num = buy_num_data.goodsbuynum;
2012   - }
2013   - })
2014   -
2015   - if(item_j.viplimited>0){
2016   - var cby=item_j.viplimited-g_buy_num;
2017   - if(cby<=0) continue;//不能买就continue下一个
2018   - item_j.num=cby>item_j.num?item_j.num:cby;
2019   - }
2020   - if(item_j.buyqty>0){
2021   - var cby=item_j.buyqty-promgoodsbuynum;
2022   - if(cby<=0) continue;//不能买就continue下一个
2023   - item_j.num=cby>item_j.num?item_j.num:cby;
2024   - }
2025   - }
2026   -
2027   - item_j.haveAdded=1;
2028   - item_j.showNum=true;
  2069 + if (map[item_j.goods_id]) {
  2070 + var cart_num = map[item_j.goods_id].goods_num;
  2071 + item_j.num = cart_num;
  2072 + item_j.cart_num = cart_num;
  2073 + item_j.cart_id = map[item_j.goods_id].id;
  2074 + if (item_j.buyqty > 0) {
  2075 + var g_buy_num = 0;
  2076 + var promgoodsbuynum = 0;
  2077 + //----获取商品购买数----
  2078 + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  2079 + data: {
  2080 + store_id: os.stoid,
  2081 + user_id: user_id,
  2082 + goods_id: item_j.goods_id,
  2083 + prom_type: 7,
  2084 + prom_id: th.data.act.id
  2085 + },
  2086 + }).then(res2 => {
  2087 + if (res2.data.code == 0) {
  2088 + var buy_num_data = res2.data.data;
  2089 + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
  2090 + g_buy_num = buy_num_data.goodsbuynum;
  2091 + }
  2092 + })
  2093 +
  2094 + if (item_j.viplimited > 0) {
  2095 + var cby = item_j.viplimited - g_buy_num;
  2096 + if (cby <= 0) continue; //不能买就continue下一个
  2097 + item_j.num = cby > item_j.num ? item_j.num : cby;
  2098 + }
  2099 + if (item_j.buyqty > 0) {
  2100 + var cby = item_j.buyqty - promgoodsbuynum;
  2101 + if (cby <= 0) continue; //不能买就continue下一个
  2102 + item_j.num = cby > item_j.num ? item_j.num : cby;
  2103 + }
  2104 + }
  2105 +
  2106 + item_j.haveAdded = 1;
  2107 + item_j.showNum = true;
2029 2108 }
2030 2109 }
2031   - th.setData({list:th.data.list});
  2110 + th.setData({
  2111 + list: th.data.list
  2112 + });
2032 2113 th.re_sum_price();
2033 2114 }
2034   - }
2035   - });
  2115 + }
  2116 + });
2036 2117 },
2037 2118  
2038 2119 //滚动加载跟多的时候的计算
2039   - async calc_more(list,func){
2040   - var th=this;
2041   - var map={};
2042   - var mlist=this.data.cart_list;
2043   - for(let i in mlist){
2044   - let item=mlist[i];
2045   - if(item.prom_type!=7) continue;
2046   - if(item.prom_id!=th.data.act.id) continue;
2047   - map[item.goods_id]=item;
  2120 + async calc_more(list, func) {
  2121 + var th = this;
  2122 + var map = {};
  2123 + var mlist = this.data.cart_list;
  2124 + for (let i in mlist) {
  2125 + let item = mlist[i];
  2126 + if (item.prom_type != 7) continue;
  2127 + if (item.prom_id != th.data.act.id) continue;
  2128 + map[item.goods_id] = item;
2048 2129 }
2049 2130  
2050   - for(let j in list){
2051   - let item_j=list[j];
2052   - item_j.current_price=item_j.shop_price;
  2131 + for (let j in list) {
  2132 + let item_j = list[j];
  2133 + item_j.current_price = item_j.shop_price;
2053 2134  
2054   - var card_price=0;
  2135 + var card_price = 0;
2055 2136 //如果会员有等级价
2056 2137 if (th.data.card_field) {
2057 2138 card_price = item_j[th.data.card_field];
2058 2139 if (card_price > 0) {
2059   - item_j.current_price=card_price;
  2140 + item_j.current_price = card_price;
2060 2141 }
2061 2142 }
2062 2143  
2063 2144  
2064   - if(map[item_j.goods_id]){
2065   - var cart_num=map[item_j.goods_id].goods_num;
2066   - item_j.num=cart_num;
2067   - item_j.cart_num=cart_num;
2068   - item_j.cart_id=map[item_j.goods_id].id;
2069   - if(item_j.buyqty>0){
2070   - var g_buy_num=0;
2071   - var promgoodsbuynum=0;
  2145 + if (map[item_j.goods_id]) {
  2146 + var cart_num = map[item_j.goods_id].goods_num;
  2147 + item_j.num = cart_num;
  2148 + item_j.cart_num = cart_num;
  2149 + item_j.cart_id = map[item_j.goods_id].id;
  2150 + if (item_j.buyqty > 0) {
  2151 + var g_buy_num = 0;
  2152 + var promgoodsbuynum = 0;
2072 2153 //----获取商品购买数----
2073 2154 await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
2074 2155 data: {
... ... @@ -2078,7 +2159,7 @@ Page({
2078 2159 prom_type: 7,
2079 2160 prom_id: th.data.act.id
2080 2161 },
2081   - }).then(res2=>{
  2162 + }).then(res2 => {
2082 2163 if (res2.data.code == 0) {
2083 2164 var buy_num_data = res2.data.data;
2084 2165 if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
... ... @@ -2086,23 +2167,23 @@ Page({
2086 2167 }
2087 2168 })
2088 2169  
2089   - if(item_j.viplimited>0){
2090   - var cby=item_j.viplimited-g_buy_num;
2091   - if(cby<=0) continue;//不能买就continue下一个
2092   - item_j.num=cby>item_j.num?item_j.num:cby;
  2170 + if (item_j.viplimited > 0) {
  2171 + var cby = item_j.viplimited - g_buy_num;
  2172 + if (cby <= 0) continue; //不能买就continue下一个
  2173 + item_j.num = cby > item_j.num ? item_j.num : cby;
2093 2174 }
2094   - if(item_j.buyqty>0){
2095   - var cby=item_j.buyqty-promgoodsbuynum;
2096   - if(cby<=0) continue;//不能买就continue下一个
2097   - item_j.num=cby>item_j.num?item_j.num:cby;
  2175 + if (item_j.buyqty > 0) {
  2176 + var cby = item_j.buyqty - promgoodsbuynum;
  2177 + if (cby <= 0) continue; //不能买就continue下一个
  2178 + item_j.num = cby > item_j.num ? item_j.num : cby;
2098 2179 }
2099 2180 }
2100 2181  
2101   - item_j.haveAdded=1;
2102   - item_j.showNum=true;
  2182 + item_j.haveAdded = 1;
  2183 + item_j.showNum = true;
2103 2184 }
2104 2185 }
2105   - if(func) func(list)
  2186 + if (func) func(list)
2106 2187  
2107 2188 }
2108 2189  
... ...
packageB/pages/zuhegou/list/list.wxml
... ... @@ -23,19 +23,15 @@
23 23  
24 24 </block>
25 25 </swiper>
26   -
27 26  
28 27 </block>
29 28 <block wx:else>
30 29 <image class="xc-top-img" src="{{url}}/miniapp/images/seckill_top_img.jpg"></image>
31 30 </block>
32 31  
33   -
34   -
35 32 <view class="kill-list">
36 33 <view class="kill-item" wx:for="{{goodlist}}">
37 34 <navigator class="kill-pic rel" url="/packageB/pages/zuhegou/index/index?id={{item.id}}&title={{item.name}}" hover-class="none">
38   - <!-- <image class="abs xc-miaosha" src="{{url}}/miniapp/images/zms.png"></image> -->
39 35 <image class="wh100" src="{{url+item.img_url}}" data-val="{{item.img_url}}"
40 36 data-errorimg="goodlist[{{index}}].img_url" binderror="bind_bnerr2" lazy-load="true"></image>
41 37 </navigator>
... ... @@ -47,78 +43,16 @@
47 43 <view>
48 44 <view>组合数量: {{item.zhbuyqty}}</view>
49 45 <view>活动时间: {{filters.format_time(item.start_time) + '至' + filters.format_time(item.end_time)}}</view>
50   - <!-- <view class="{{type==1?'xc-wc':'blue_c'}}">
51   - <text>剩余:</text>
52   - <text class='tui-conutdown-box'> {{item.djs.day}}</text>天
53   - <text class='tui-conutdown-box'>{{item.djs.hou}}</text>时
54   - <text class='tui-conutdown-box'>{{item.djs.min}}</text>分
55   - <text class='tui-conutdown-box tui-countdown-bg'>{{item.djs.sec}}</text>秒
56   - </view> -->
57 46 <view class="fs40 flex xc-buttom-money {{type==1?'xc-wc':'blue_c'}}" >
58 47 <view class="fs28" style="line-height: 16px;">¥</view>
59 48 <text>{{item.zhprice}}</text>
60   - <!-- <span class="underline fs20">零售价¥{{item.market_price}}</span> -->
61 49 </view>
62   -
63 50 </view>
64   - <!-- <view class="kill-btn "> -->
65   - <!-- <navigator style="background-color: #059de5;" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}" wx:if="{{type==0}}" >即将开始</navigator> -->
66   - <!-- <navigator url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}" wx:if="{{item.status==1 && type==1}}">马上抢</navigator>
67   - <navigator class="huise"url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}" wx:if="{{item.status==3 && type==1}}">已抢光</navigator> -->
68   - <!-- </view> -->
69 51 </view>
70   -
71   -
72 52 </navigator>
73   -
74   - <!-- <view class="flex-vertical xc-strip-frame">
75   - <view class="xc-strip-blank rel">
76   -
77   - <view class="flex-vertical rel total">
78   - <view class="t-c abs xc-fill"style="width:{{type==1?(100-(item.buy_num+item.virtual) /(item.goods_num+item.virtual)*100)>3?(100-(item.buy_num+item.virtual) /(item.goods_num+item.virtual)*100):'3':'100'}}%;background:{{type==1?'#e4374d':'#059de5'}};">
79   - </view>
80   - <text class="fs20 white abs xc-fill-text" style="">剩余{{type==1?filters.toFix(100-(item.buy_num+item.virtual)/(item.goods_num+item.virtual)*100,0):'100'}}%</text>
81   - </view>
82   -
83   - </view>
84   - <view class=" ml10 fs20 " wx:if="{{type==1}}"> 已抢{{item.buy_num+item.virtual}}件</view>
85   - <view class=" ml10 fs20 " wx:else> 已抢0件</view>
86   -
87   - </view> -->
88   -
89   -
90   - <!-- <view class="goods-num">
91   - <view>
92   - <view>组合数量: {{item.zhbuyqty}}</view>
93   - <view>活动时间: {{filters.format_time(item.start_time) + '至' + filters.format_time(item.end_time)}}</view>
94   -
95   - <view class="fs40 flex xc-buttom-money {{type==1?'xc-wc':'blue_c'}}" >
96   - <view class="fs28" style="line-height: 16px;">¥</view>
97   - <text>{{item.zhprice}}</text>
98   -
99   - </view>
100   -
101   - </view>
102   - </view> -->
103 53 </view>
104 54 </view>
105   - <!-- <view style="height:120rpx"></view> -->
106 55 </view>
107   -
108   -<!-- <view class="kill-time xc-seckill-bottom">
109   - <view class="theader" >
110   - <view bindtap='tip' data-ty="1" class="xc-border-right flex-center timeac left {{type==1?'active':''}}">
111   - <image class="xc-bottom"
112   - src="{{url}}{{type==1?'/miniapp/images/fire-red.png':'/miniapp/images/fire-black.png'}}"></image>
113   - 火热进行中</view>
114   - <view bindtap='tip' data-ty="0" class=" flex-center timeac right {{type==0?'active':''}}">
115   - <image class="xc-bottom"
116   - src="{{url}}{{type==0?'/miniapp/images/clock-rad.png':'/miniapp/images/clock-black.png'}}"></image>
117   - 即将开始</view>
118   - </view>
119   -</view> -->
120   -
121   -
122 56 <view class="no-more" wx:if="{{goodlist.length==0}}">没有相关内容</view>
123 57 </view>
124 58  
... ...
packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js
... ... @@ -1272,9 +1272,10 @@ Page({
1272 1272 var all_cutprice = 0; //所有的优惠减
1273 1273 var all_zh_cutprice = 0; //所有的组合优惠减
1274 1274 var all_order_prom = 0; //所有的订单优惠
1275   -
  1275 + var out_of_weight=0; //超出多少重量
1276 1276 var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0);
1277 1277 var freight_free = ee.freight_free; //全场满多少包邮
  1278 + var weight_free = ee.weight_free; //多少kg内包邮
1278 1279 var no_ex_id = ee.no_ex_id;
1279 1280 var no_ex_good = null;
1280 1281 var by_qc = {};
... ... @@ -1371,6 +1372,16 @@ Page({
1371 1372 o_price_no_zh += item[j].goods_price * item[j].goods_num;
1372 1373 }
1373 1374 o_price += item[j].goods_price * item[j].goods_num;
  1375 +
  1376 + //判断是否有设置限制重量包邮
  1377 + if(weight_free){
  1378 + if( item[j]['exp_sum_type']==2 ){
  1379 + if (goods_weight < 0) goods_weight = 0;
  1380 + //累积商品重量 每种商品的重量 * 数量
  1381 + goods_weight += item[j]['weight'] * item[j]['goods_num'];
  1382 + out_of_weight = (weight_free*1000) - goods_weight;
  1383 + }
  1384 + }
1374 1385 }
1375 1386 //判断是不是有组合购的金额
1376 1387 var f_o_price = o_price;
... ... @@ -1410,7 +1421,7 @@ Page({
1410 1421  
1411 1422  
1412 1423 //--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额--
1413   - if (no_ex_id && freight_free > 0 && (o_price - quan_price) >= freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list)) {
  1424 + if (no_ex_id && freight_free > 0 && (o_price - quan_price) >= freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list) && out_of_weight > 0) {
1414 1425 //如果有设置不包邮区域的时候
1415 1426 if (by_qc.region_list != "" && by_qc.region_list != null && by_qc.region_list != undefined) {
1416 1427 if (th.check_by_area(by_qc.region_list)) {
... ... @@ -1533,13 +1544,13 @@ Page({
1533 1544 //统一运费
1534 1545 o_shipping_price += item[j]['uniform_exp_sum'];
1535 1546 break;
1536   - case 2:
1537   - +''
1538   - if (goods_weight < 0) goods_weight = 0;
1539   - //累积商品重量 每种商品的重量 * 数量
1540   - goods_weight += item[j]['weight'] * item[j]['goods_num'];
1541   -
1542   - break;
  1547 + // case 2: //1464行已计算 不必重复计算 注释为:判断是否有设置限制重量包邮
  1548 + // +''
  1549 + // if (goods_weight < 0) goods_weight = 0;
  1550 + // //累积商品重量 每种商品的重量 * 数量
  1551 + // goods_weight += item[j]['weight'] * item[j]['goods_num'];
  1552 + // out_of_weight = (weight_free*1000) - goods_weight;
  1553 + // break;
1543 1554 case 3:
1544 1555 if (goods_piece < 0) goods_piece = 0;
1545 1556 //累积商品数量
... ... @@ -1548,6 +1559,11 @@ Page({
1548 1559 }
1549 1560 }
1550 1561  
  1562 + }else{
  1563 + if(goods_weight && out_of_weight !== 0){
  1564 + goods_weight=-1;
  1565 + out_of_weight=0;
  1566 + }
1551 1567 }
1552 1568 }
1553 1569  
... ... @@ -1558,7 +1574,7 @@ Page({
1558 1574 if (th.data.wu_arr && th.data.wu_arr[cart_item.wind])
1559 1575 code = th.data.wu_arr[cart_item.wind].code;
1560 1576 cart_item.shipping_price =
1561   - th.calculatewuliu(code, o_shipping_price, goods_weight,
  1577 + th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight,
1562 1578 goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs);
1563 1579  
1564 1580 if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) {
... ... @@ -1777,7 +1793,10 @@ Page({
1777 1793 to.getwuliuprice(async function (rs) {
1778 1794  
1779 1795 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
1780   -
  1796 + var out_of_weight=null; //超出多少重量
  1797 + var freight_free = ee.freight_free; //全场满多少包邮
  1798 + var weight_free = ee.weight_free; //多少kg内包邮
  1799 + var no_ex_id = ee.no_ex_id;
1781 1800 //---如果有选择优惠券的情况下---
1782 1801 var quan_price = 0, bn_pick = th.data.bn_pick;
1783 1802 var quan_no = null;
... ... @@ -1844,6 +1863,7 @@ Page({
1844 1863 if (goods_weight < 0) goods_weight = 0;
1845 1864 //累积商品重量 每种商品的重量 * 数量
1846 1865 goods_weight += good['weight'] * good['buynum'];
  1866 + out_of_weight = (weight_free * 1000 ) - goods_weight;
1847 1867 break;
1848 1868 case 3:
1849 1869 if (goods_piece < 0) goods_piece = 0;
... ... @@ -1854,8 +1874,7 @@ Page({
1854 1874  
1855 1875 var code = "";
1856 1876 if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
1857   - var freight_free = ee.freight_free; //全场满多少包邮
1858   - var no_ex_id = ee.no_ex_id;
  1877 +
1859 1878 th.data.is_no_by[th.data.bn_pick] = 0;
1860 1879  
1861 1880 var no_by_data = null;
... ... @@ -1891,12 +1910,12 @@ Page({
1891 1910 th.data.is_by[th.data.bn_pick] = 0;
1892 1911 //--------------开始计算物流------------------
1893 1912 var shipping_price =
1894   - th.calculatewuliu(code, o_shipping_price, goods_weight,
  1913 + th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight,
1895 1914 goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs);
1896 1915  
1897 1916 //如果有赠品的时候,也要计算赠品的物流费用
1898 1917 if (th.data.buy_now_gift_goods) {
1899   - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,
  1918 + shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,out_of_weight,
1900 1919 parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece);
1901 1920 }
1902 1921  
... ... @@ -2832,12 +2851,12 @@ Page({
2832 2851 th.calculatePrice();
2833 2852 },
2834 2853 //-------------------计算物流---------------
2835   - calculatewuliu: function (code, o_shipping_price, goods_weight,
  2854 + calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight,
2836 2855 goods_piece, user_addr, freight_free, o_price, rs) {
2837 2856 var price = 0, th = this;
2838 2857 price += parseFloat(o_shipping_price);
2839 2858 //如果是包邮
2840   - if (freight_free > 0 && o_price >= freight_free) {
  2859 + if (freight_free > 0 && o_price >= freight_free && out_of_weight > 0) {
2841 2860 return 0;
2842 2861 }
2843 2862 if (user_addr == null) {
... ... @@ -2855,7 +2874,7 @@ Page({
2855 2874 item = item.config;
2856 2875 if (item == null) return o_shipping_price;
2857 2876 //------按重量----------
2858   - if (goods_weight >= 0 && item['money']) {
  2877 + if (goods_weight >= 0 && item['money'] && out_of_weight > 0) {
2859 2878 fw_price = parseFloat(item['money']);
2860 2879 if (goods_weight > item['first_weight']) {
2861 2880 var fw = goods_weight - item['first_weight'];
... ... @@ -2863,6 +2882,13 @@ Page({
2863 2882 fw_price = fw_price + n * parseFloat(item['add_money']);
2864 2883 }
2865 2884 }
  2885 + //------超出重量----------
  2886 + if(out_of_weight < 0){
  2887 + fw_price = parseFloat(item['money']);
  2888 + var out_of_weight = Math.abs(out_of_weight);
  2889 + var n = Math.ceil(out_of_weight / item['second_weight'])
  2890 + fw_price = fw_price + n * parseFloat(item['add_money']);
  2891 + }
2866 2892 //------按件数----------
2867 2893 if (goods_piece > 0 && item['piecemoney']) {
2868 2894 fp_price = parseFloat(item['piecemoney']);
... ... @@ -3718,7 +3744,7 @@ Page({
3718 3744 },
3719 3745  
3720 3746 //计算立即购买赠品的物流费用
3721   - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
  3747 + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
3722 3748 var good = this.data.buy_now_gift_goods;
3723 3749 var goods_weight = -1, goods_piece = -1;
3724 3750 var gift_shipping_price = 0;
... ... @@ -3735,6 +3761,7 @@ Page({
3735 3761 goods_weight += good['weight'] * good['buynum'];
3736 3762 if (goods_weight1 > 0) {
3737 3763 goods_weight += goods_weight1;
  3764 + out_of_weight = (gift_weight_free*1000) - goods_weight;
3738 3765 }
3739 3766 break;
3740 3767 case 3:
... ...
packageC/pages/presell/cart/cart2.js
... ... @@ -612,7 +612,10 @@ Page({
612 612 to.getwuliuprice(async function (rs) {
613 613  
614 614 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
615   -
  615 + var out_of_weight=null; //超出多少重量
  616 + var freight_free = ee.freight_free; //全场满多少包邮
  617 + var weight_free = ee.weight_free; //多少kg内包邮
  618 + var no_ex_id = ee.no_ex_id;
616 619 //---如果有选择优惠券的情况下---
617 620 var quan_price = 0, bn_pick = th.data.bn_pick;
618 621 var quan_no = null;
... ... @@ -679,6 +682,7 @@ Page({
679 682 if (goods_weight < 0) goods_weight = 0;
680 683 //累积商品重量 每种商品的重量 * 数量
681 684 goods_weight += good['weight'] * good['buynum'];
  685 + out_of_weight = (weight_free * 1000 ) - goods_weight;
682 686 break;
683 687 case 3:
684 688 if (goods_piece < 0) goods_piece = 0;
... ... @@ -689,8 +693,7 @@ Page({
689 693  
690 694 var code = "";
691 695 if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
692   - var freight_free = ee.freight_free; //全场满多少包邮
693   - var no_ex_id = ee.no_ex_id;
  696 +
694 697 th.data.is_no_by[th.data.bn_pick] = 0;
695 698  
696 699 var no_by_data = null;
... ... @@ -726,12 +729,12 @@ Page({
726 729 th.data.is_by[th.data.bn_pick] = 0;
727 730 //--------------开始计算物流------------------
728 731 var shipping_price =
729   - th.calculatewuliu(code, o_shipping_price, goods_weight,
  732 + th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight,
730 733 goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs);
731 734  
732 735 //如果有赠品的时候,也要计算赠品的物流费用
733 736 if (th.data.buy_now_gift_goods) {
734   - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,
  737 + shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,gift_weight_free,
735 738 parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece);
736 739 }
737 740  
... ... @@ -1665,12 +1668,12 @@ Page({
1665 1668 th.calculatePrice();
1666 1669 },
1667 1670 //-------------------计算物流---------------
1668   - calculatewuliu: function (code, o_shipping_price, goods_weight,
  1671 + calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight,
1669 1672 goods_piece, user_addr, freight_free, o_price, rs) {
1670 1673 var price = 0, th = this;
1671 1674 price += parseFloat(o_shipping_price);
1672 1675 //如果是包邮
1673   - if (freight_free > 0 && o_price >= freight_free) {
  1676 + if (freight_free > 0 && o_price >= freight_free && out_of_weight > 0) {
1674 1677 return 0;
1675 1678 }
1676 1679 if (user_addr == null) {
... ... @@ -1688,7 +1691,7 @@ Page({
1688 1691 item = item.config;
1689 1692 if (item == null) return o_shipping_price;
1690 1693 //------按重量----------
1691   - if (goods_weight >= 0 && item['money']) {
  1694 + if (goods_weight >= 0 && item['money'] && out_of_weight > 0) {
1692 1695 fw_price = parseFloat(item['money']);
1693 1696 if (goods_weight > item['first_weight']) {
1694 1697 var fw = goods_weight - item['first_weight'];
... ... @@ -1696,6 +1699,14 @@ Page({
1696 1699 fw_price = fw_price + n * parseFloat(item['add_money']);
1697 1700 }
1698 1701 }
  1702 +
  1703 + //------超出重量----------
  1704 + if(out_of_weight < 0){
  1705 + fw_price = parseFloat(item['money']);
  1706 + var out_of_weight = Math.abs(out_of_weight);
  1707 + var n = Math.ceil(out_of_weight / item['second_weight'])
  1708 + fw_price = fw_price + n * parseFloat(item['add_money']);
  1709 + }
1699 1710 //------按件数----------
1700 1711 if (goods_piece > 0 && item['piecemoney']) {
1701 1712 fp_price = parseFloat(item['piecemoney']);
... ... @@ -2527,7 +2538,7 @@ Page({
2527 2538 },
2528 2539  
2529 2540 //计算立即购买赠品的物流费用
2530   - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
  2541 + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
2531 2542 var good = this.data.buy_now_gift_goods;
2532 2543 var goods_weight = -1, goods_piece = -1;
2533 2544 var gift_shipping_price = 0;
... ... @@ -2544,6 +2555,7 @@ Page({
2544 2555 goods_weight += good['weight'] * good['buynum'];
2545 2556 if (goods_weight1 > 0) {
2546 2557 goods_weight += goods_weight1;
  2558 + out_of_weight = (gift_weight_free*1000) - goods_weight;
2547 2559 }
2548 2560 break;
2549 2561 case 3:
... ...
packageC/pages/presell/goodsInfo/goodsInfo.wxml
... ... @@ -16,6 +16,22 @@
16 16 </view>
17 17 <view class="goods-detail">
18 18 <view class="goods-info" hidden="{{activeCategoryId==0?false:true}}">
  19 +
  20 + <!-- 历史购买记录 -->
  21 + <view class="swiper-container">
  22 + <swiper class="swiper" autoplay="true" circular="true" vertical="true" interval="3000">
  23 + <swiper-item class="swiper-item" wx:for="">
  24 + <view class="item">
  25 + <view class="avatar-container">
  26 + <image src=""></image>
  27 + </view>
  28 + <view class="flex ai_c pd10">
  29 + <view class="nickname ellipsis-1x">abson下单成功</view>
  30 + </view>
  31 + </view>
  32 + </swiper-item>
  33 + </swiper>
  34 + </view>
19 35 <!-- 视频 -->
20 36 <!-- <swiper bindchange="swiperChange"class="xc-pictures swiperContainer rel" current="{{swiperCurrent}}"
21 37 indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> -->
... ...
pages/activity/pind_list/pind_list.js
1   -var e = getApp(),
2   -i = e.request,
3   - a = e.globalData.setting,
4   - os=a,ut = require("../../../utils/util.js");
  1 +var e = getApp(),
  2 + i = e.request,
  3 + a = e.globalData.setting,
  4 + os = a,
  5 + ut = require("../../../utils/util.js");
5 6 var regeneratorRuntime = require('../../../utils/runtime.js');
6 7  
7   -Page({
8   - data: {
9   - url: a.imghost,
10   - killtime: null,
11   - currentPage: 1,
12   - goodlist: null,
13   - type:1,
14   - timer:null,
15   - ismore:1,
16   - isshow:0,
17   - iurl: os.imghost,
18   - ad_data:null,
19   - max_sw_height:200,
20   - },
21   -
22   - //------初始化加载----------
23   - onLoad: function(t) {
24   - wx.setNavigationBarTitle({ title: "天天拼单",})
25   - var first_leader = t.first_leader;
26   - var th=this;
27   -
28   - console.log("------------");
29   - console.log(first_leader);
30   - getApp().getConfig();
31   -
32   - if (first_leader) {
33   - getApp().globalData.first_leader = first_leader;
34   - //调用接口判断是不是会员
35   - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
36   - if (res.data.code == 0) {
37   - getApp().globalData.guide_id = res.data.data.id;
38   - }
39   - })
  8 +Page({
  9 + data: {
  10 + url: a.imghost,
  11 + killtime: null,
  12 + currentPage: 1,
  13 + goodlist: [],
  14 + type: 1,
  15 + timer: null,
  16 + ismore: 1,
  17 + isshow: 0,
  18 + iurl: os.imghost,
  19 + ad_data: null,
  20 + max_sw_height: 200,
  21 + },
  22 +
  23 + //------初始化加载----------
  24 + onLoad: function (t) {
  25 + wx.setNavigationBarTitle({
  26 + title: "天天拼单",
  27 + })
  28 + var first_leader = t.first_leader;
  29 + var th = this;
  30 +
  31 + console.log("------------");
  32 + console.log(first_leader);
  33 + getApp().getConfig();
  34 +
  35 + if (first_leader) {
  36 + getApp().globalData.first_leader = first_leader;
  37 + //调用接口判断是不是会员
  38 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  39 + if (res.data.code == 0) {
  40 + getApp().globalData.guide_id = res.data.data.id;
40 41 }
41   -
42   - getApp().request.promiseGet("/api/weshop/ad/page?pid=801&store_id=" + os.stoid, {
43   - data: {
44   - enabled: 1
45   - }
46   - }).then(res => {
47   - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){
48   - var a = res.data.data.pageData;
49   - var narr=[];
50   - for(var i in a){
51   - var tt = {
52   - 'ad_code': os.imghost + a[i].ad_code,
53   - 'media_link': '',
54   - 'ad_weapplink':a[i].ad_weapplink
55   - };
56   - narr.push(tt);
57   - }
58   -
59   - th.setData({ad_data:narr});
60   - }
61   - })
62   - },
63   -
64   - onShow: function(t) {
65   -
66   - this.data.is_timer=1;
67   - this.data.currentPage=1;
68   - this.data.ismore=1;
69   - this.setData({goodlist:null});
70   - var th=this;
71   - this.requestSalelist();
72   - //设置全局定时器
73   - th.data.timer=setInterval(function () {
74   - th.countDown();
75   - },1000);
76   - },
77   -
78   - onHide:function(){
79   - //--清理定时器--
80   - clearInterval(this.timer);
81   - this.setData({isshow:0});
82   - },
83   -
84   - //---小于10的格式化函数----
85   - timeFormat(param) {
86   - return param < 10 ? '0' + param : param;
87   - },
  42 + })
  43 + }
  44 +
  45 + getApp().request.promiseGet("/api/weshop/ad/page?pid=801&store_id=" + os.stoid, {
  46 + data: {
  47 + enabled: 1
  48 + }
  49 + }).then(res => {
  50 + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) {
  51 + var a = res.data.data.pageData;
  52 + var narr = [];
  53 + for (var i in a) {
  54 + var tt = {
  55 + 'ad_code': os.imghost + a[i].ad_code,
  56 + 'media_link': '',
  57 + 'ad_weapplink': a[i].ad_weapplink
  58 + };
  59 + narr.push(tt);
  60 + }
  61 +
  62 + th.setData({
  63 + ad_data: narr
  64 + });
  65 + }
  66 + })
  67 +
  68 + },
  69 +
  70 + onShow: function (t) {
  71 +
  72 + this.data.is_timer = 1;
  73 + this.data.currentPage = 1;
  74 + this.data.ismore = 1;
  75 + var th = this;
  76 + var userInfo = wx.getStorageSync('userinfo');
  77 + console.log(userInfo,30000);
  78 + if (userInfo && th.data.goodlist.length==0) {
  79 + //调用列表
  80 + this.requestSalelist(userInfo.user_id);
  81 + } else {
  82 + getApp().goto("/pages/togoin/togoin");
  83 + }
  84 + //设置全局定时器
  85 + th.data.timer = setInterval(function () {
  86 + th.countDown();
  87 + }, 1000);
  88 + },
  89 +
  90 + onHide: function () {
  91 + //--清理定时器--
  92 + clearInterval(this.timer);
  93 + this.setData({
  94 + isshow: 0
  95 + });
  96 + },
  97 +
  98 + //---小于10的格式化函数----
  99 + timeFormat(param) {
  100 + return param < 10 ? '0' + param : param;
  101 + },
88 102  
89 103 //----倒计时函数-----
90   - countDown() {
91   - if(!this.data.goodlist) return false;
92   - var th=this;
  104 + countDown() {
  105 + if (!this.data.goodlist) return false;
  106 + var th = this;
93 107 // 获取当前时间,同时得到活动结束时间数组
94 108 var newTime = ut.gettimestamp();
95 109 var endTimeList = this.data.goodlist;
... ... @@ -119,119 +133,138 @@ Page({
119 133 }
120 134 },
121 135  
122   - //读取数据
123   - async requestSalelist(){
124   - if(!this.data.ismore) return false;
125   - var e = this,th=e,i = "/api/weshop/teamlist/pageteam/"+th.data.type+"?page=" + e.data.currentPage;
126   - var plist=null,alllist=th.data.goodlist;
127   - if(!alllist) alllist=[];
128   -
129   - await getApp().request.promiseGet(i,
130   - {isShowLoading:1,data:{store_id:os.stoid,is_end:0,is_show:1}}
131   - ).then(res=>{
132   - if(ut.ajax_ok(res)) plist=res.data.data.pageData;
133   - });
  136 + //读取数据
  137 + async requestSalelist(user_id) {
  138 + if (!this.data.ismore) return false;
  139 + var e = this,
  140 + th = e,
  141 + i = "/api/weshop/teamlist/pageteam/" + th.data.type + "?page=" + e.data.currentPage;
  142 + var plist = null,
  143 + alllist = th.data.goodlist;
  144 + if (!alllist) alllist = [];
  145 + await getApp().request.promiseGet(i, {
  146 + isShowLoading: 1,
  147 + data: {
  148 + store_id: os.stoid,
  149 + is_end: 0,
  150 + is_show: 1,
  151 + user_id,
  152 + }
  153 + }).then(res => {
  154 + plist = res.data.data.pageData;
  155 + });
134 156  
135   - if(!plist || plist.length<=0){
136   - getApp().showWarning("没有更多数据");
137   - th.data.ismore=0;
138   - return false;
139   - }
140   - //--循环读取接口---
141   - for(var i=0;i<plist.length;i++){
142   - var prom_id=plist[i].id;
143   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/"+
144   - os.stoid+"/6/"+prom_id,{}).then(res=>{
145   - if(res.data.code==0){
146   - plist[i].status=1;
147   - if(res.data.data<=0) plist[i].status=3;
148   - }
149   - });
150   - alllist.push(plist[i]);
151   - }
152   - e.data.currentPage++;
153   -
154   - th.setData({goodlist:alllist,isshow:1});
155   - },
156   -
157   - onPullDownRefresh: function() {
158   - this.reloadGoodList();
159   - },
160   - reloadGoodList: function() {
161   - this.data.goodlist = null, this.data.currentPage = 1, this.requestSalelist();
162   - },
163   - onReachBottom: function() {
164   - this.requestSalelist();
165   - },
166   -
167   - //点击tab事件
168   - tip:function(e){
169   - var a=e.currentTarget.dataset.ty,th=this; th.data.ismore=1;th.data.currentPage=1;
170   - this.setData({type:a,goodlist:null});
171   - this.reloadGoodList();
172   - },
173   -
174   -
175   -
176   - //---------分享配置--------
177   - onShareAppMessage: function (e) {
178   - var curPage=this;
179   - var pagePath = curPage.route; //当前页面url
180   - if (pagePath.indexOf('/') != 0) {
181   - pagePath = '/' + pagePath;
  157 + if (plist.length <= 0) {
  158 + getApp().showWarning("没有更多数据");
  159 + th.data.ismore = 0;
  160 + }
  161 + //--循环读取接口---
  162 + for (var i = 0; i < plist.length; i++) {
  163 + var prom_id = plist[i].id;
  164 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  165 + os.stoid + "/6/" + prom_id, {}).then(res => {
  166 + if (res.data.code == 0) {
  167 + plist[i].status = 1;
  168 + if (res.data.data <= 0) plist[i].status = 3;
182 169 }
183   - if(getApp().globalData.user_id){
  170 + });
  171 + alllist.push(plist[i]);
  172 + }
  173 + e.data.currentPage++;
184 174  
185   - if(pagePath.indexOf("?")>0){
186   - pagePath+="&first_leader="+getApp().globalData.user_id;
187   - }else{
188   - pagePath+="?first_leader="+getApp().globalData.user_id;
189   - }
190   - }
  175 + th.setData({
  176 + goodlist: alllist,
  177 + isshow: 1,
  178 + ismore:0,
  179 + });
  180 + },
191 181  
192   - console.log("11"+pagePath);
  182 + onPullDownRefresh: function () {
  183 + this.reloadGoodList();
  184 + },
  185 + reloadGoodList: function () {
  186 + this.data.goodlist = null, this.data.currentPage = 1, this.requestSalelist();
  187 + },
  188 + onReachBottom: function () {
  189 + this.requestSalelist();
  190 + },
193 191  
194   - return {
195   - title: "限时团购",
196   - path:pagePath,
197   - }
198   - },
199   -
200   -
201   -
202   -
203   - //图片失败,默认图片
204   - bind_bnerr2: function (e) {
205   - var _errImg = e.target.dataset.errorimg;
206   - var val = e.target.dataset.val;
207   - if(val!="/public/images/default_goods_image_240.gif"){
208   - var _errObj = {};
209   - _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
210   - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
211   - }
212   - },
213   -
214   - imageLoad:function(e){
215   - var imgwidth = e.detail.width;
216   - var imgheight = e.detail.height;
217   - //宽高比
218   - var ratio = imgwidth / imgheight;
219   - //计算的高度值
220   - var viewHeight = 750 / ratio;
221   - var hei=this.data.max_sw_height;
222   -
223   - if (hei< viewHeight) {
224   - this.setData({ max_sw_height: viewHeight });
225   - }
226   - },
227   -
228   - onShareTimeline() {
229   - var store_name=getApp().globalData.config?getApp().globalData.config.store_name:'';
230   - if(!store_name)
231   - store_name=getApp().globalData.setting.appName;
232   - return {
233   - title: '秒杀活动-' + store_name,
234   - }
235   - },
236   -
237   -});
  192 + //点击tab事件
  193 + tip: function (e) {
  194 + var a = e.currentTarget.dataset.ty,
  195 + th = this;
  196 + th.data.ismore = 1;
  197 + th.data.currentPage = 1;
  198 + this.setData({
  199 + type: a,
  200 + goodlist: []
  201 + });
  202 + this.reloadGoodList();
  203 + },
  204 +
  205 +
  206 +
  207 + //---------分享配置--------
  208 + onShareAppMessage: function (e) {
  209 + var curPage = this;
  210 + var pagePath = curPage.route; //当前页面url
  211 + if (pagePath.indexOf('/') != 0) {
  212 + pagePath = '/' + pagePath;
  213 + }
  214 + if (getApp().globalData.user_id) {
  215 +
  216 + if (pagePath.indexOf("?") > 0) {
  217 + pagePath += "&first_leader=" + getApp().globalData.user_id;
  218 + } else {
  219 + pagePath += "?first_leader=" + getApp().globalData.user_id;
  220 + }
  221 + }
  222 +
  223 + console.log("11" + pagePath);
  224 +
  225 + return {
  226 + title: "限时团购",
  227 + path: pagePath,
  228 + }
  229 + },
  230 +
  231 +
  232 +
  233 +
  234 + //图片失败,默认图片
  235 + bind_bnerr2: function (e) {
  236 + var _errImg = e.target.dataset.errorimg;
  237 + var val = e.target.dataset.val;
  238 + if (val != "/public/images/default_goods_image_240.gif") {
  239 + var _errObj = {};
  240 + _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
  241 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  242 + }
  243 + },
  244 +
  245 + imageLoad: function (e) {
  246 + var imgwidth = e.detail.width;
  247 + var imgheight = e.detail.height;
  248 + //宽高比
  249 + var ratio = imgwidth / imgheight;
  250 + //计算的高度值
  251 + var viewHeight = 750 / ratio;
  252 + var hei = this.data.max_sw_height;
  253 +
  254 + if (hei < viewHeight) {
  255 + this.setData({
  256 + max_sw_height: viewHeight
  257 + });
  258 + }
  259 + },
  260 +
  261 + onShareTimeline() {
  262 + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';
  263 + if (!store_name)
  264 + store_name = getApp().globalData.setting.appName;
  265 + return {
  266 + title: '秒杀活动-' + store_name,
  267 + }
  268 + },
  269 +
  270 +});
238 271 \ No newline at end of file
... ...
pages/activity/pind_list/pind_list.wxml
... ... @@ -104,7 +104,7 @@
104 104  
105 105 </view>
106 106  
107   -<view class="no-more" wx:if="{{goodlist.length==0}}">没有相关内容</view>
  107 +<view class="no-more" wx:if="{{goodlist.length==0 && !ismore}}">没有相关内容</view>
108 108 </view>
109 109  
110 110  
... ...
pages/cart/cart/cart.js
1 1 var t = getApp(),
2 2 a = t.request,
3 3 oo = t.globalData.setting,
4   - os=oo,
  4 + os = oo,
5 5 app = getApp(),
6 6 rq = t.request,
7 7 ut = require("../../../utils/util.js"),
... ... @@ -9,6 +9,7 @@ var t = getApp(),
9 9 ladder_calc = require("ladder_calculate.js");
10 10 var regeneratorRuntime = require('../../../utils/runtime.js');
11 11  
  12 +
12 13 Page({
13 14 data: {
14 15 url: t.globalData.setting.url,
... ... @@ -41,33 +42,35 @@ Page({
41 42 in_zhact_gdmap:{}, //不同门店参与同一活动的限购
42 43  
43 44 ladder_map:{}, //阶梯促销需要的map
  45 +
44 46 },
45   - onLoad: function() {
46   - var a = this,ee=a;
  47 + onLoad: function () {
  48 + var a = this,
  49 + ee = a;
47 50 //----获取系统参数-----
48   - getApp().getConfig2(function(e) {
49   - ee.setData({
50   - bconfig: e,
51   - sales_rules:e.sales_rules
52   - });
53   - })
  51 + // getApp().getConfig2(function (e) {
  52 + // ee.setData({
  53 + // bconfig: e,
  54 + // sales_rules: e.sales_rules
  55 + // });
  56 + // })
54 57  
55 58 wx.setNavigationBarTitle({
56 59 title: "购物车",
57 60 })
58 61  
59 62 //判断是否有登录
60   - t.auth.hadAuth() && t.getUserInfo(function() {
  63 + t.auth.hadAuth() && t.getUserInfo(function () {
61 64 //a.getCardList();
62 65 });
63 66  
64 67 },
65   - onShow: function() {
  68 + onShow: function () {
66 69 //每次显示都清空
67   - this.data.in_zhact_gdmap={};
  70 + this.data.in_zhact_gdmap = {};
68 71  
69 72 if (typeof this.getTabBar === 'function' && this.getTabBar()) {
70   - var index=getApp().getPageIndex(this);
  73 + var index = getApp().getPageIndex(this);
71 74 this.getTabBar().setData({
72 75 active: index //数字是当前页面在tabbar的索引
73 76 })
... ... @@ -76,7 +79,10 @@ Page({
76 79 }
77 80  
78 81 var th = this;
79   - this.setData({requestData:null,is_load:0});
  82 + this.setData({
  83 + requestData: null,
  84 + is_load: 0
  85 + });
80 86 //调用底部导航
81 87 //t.editTabBar(th,getApp().globalData.setting.stoid,getApp().globalData.url);
82 88 //----获取系统参数-----
... ... @@ -84,7 +90,10 @@ Page({
84 90 var json_d = JSON.parse(e.switch_list);
85 91 var is_open_offline=json_d.is_pricing_open;
86 92 th.setData({
87   - bconfig: e,sales_rules:e.sales_rules
  93 + bconfig: e,
  94 + freight_free:e.freight_free,
  95 + weight_free:e.weight_free,
  96 + sales_rules:e.sales_rules,
88 97 });
89 98 getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{
90 99 //未购买
... ... @@ -131,58 +140,60 @@ Page({
131 140 is_end: 0,
132 141 is_show: 1,
133 142 pageSize: 1,
134   - user_id:user_id
  143 + user_id: user_id
135 144 }
136   - //--获取是否又秒杀活动--
137   - getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {
138   - data:req_d,
139   - }).then(res => {
140   - if (res.data.code == 0 && res.data.data && res.data.data.pageData.length > 0) {
141   - th.setData({
142   - is_has_flash: 1
143   - })
144   - }
145   - });
146   - }
147   - })
148   -
149   -
  145 + //--获取是否又秒杀活动--
  146 + getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {
  147 + data: req_d,
  148 + }).then(res => {
  149 + if (res.data.code == 0 && res.data.data && res.data.data.pageData.length > 0) {
  150 + th.setData({
  151 + is_has_flash: 1
  152 + })
  153 + }
  154 + });
  155 + }
  156 + })
  157 +
  158 +
150 159 },
151 160  
152   - onHide(){
153   - this.data.zuhe_map={};
  161 + onHide() {
  162 + this.data.zuhe_map = {};
154 163 },
155   - onUnLoad(){
156   - getApp().globalData.cart_zh_act=null;
  164 + onUnLoad() {
  165 + getApp().globalData.cart_zh_act = null;
157 166 },
158 167 //-------------获取购物车列表,要安装门店进行分类订单-----------
159   - getCardList: function() {
160   -
  168 + getCardList: function () {
  169 +
161 170 var th = this;
162 171  
163 172 //要获取会员是不是等级会员
164   - getApp().getConfig2(function(conf){
  173 + getApp().getConfig2(function (conf) {
165 174 //--- 看后台是不是有开通等级卡 ---
166   - if(conf.switch_list){
167   - var s_list=JSON.parse(conf.switch_list);
168   - var user=getApp().globalData.userInfo;
  175 + if (conf.switch_list) {
  176 + var s_list = JSON.parse(conf.switch_list);
  177 + var user = getApp().globalData.userInfo;
169 178 //如果后台有开启等级价的功能
170   - if(user && parseInt(s_list.rank_switch)==2 && user['card_expiredate']){
  179 + if (user && parseInt(s_list.rank_switch) == 2 && user['card_expiredate']) {
171 180  
172 181 var str = user['card_expiredate'].replace(/-/g, '/');
173 182 var end = new Date(str);
174 183 end = Date.parse(end) / 1000;
175 184 var now = ut.gettimestamp();
176 185 //--- 判断是等级会员,且在有效期范围内 ---
177   - if(user.card_field && now<end){
178   - th.setData({card_field:user.card_field})
  186 + if (user.card_field && now < end) {
  187 + th.setData({
  188 + card_field: user.card_field
  189 + })
179 190 }
180 191 }
181 192  
182 193 //如果门店还未读出来的时候
183 194 if (th.data.allsto == null) {
184 195 //读取门店
185   - app.get_allsto(function(e) {
  196 + app.get_allsto(function (e) {
186 197 th.setData({
187 198 allsto: e
188 199 });
... ... @@ -193,57 +204,56 @@ Page({
193 204 th.get_cart();
194 205 th.get_ser_cart();
195 206 }
196   -
  207 +
197 208  
198 209 }
199 210 })
200   - if( (!this.data.requestData || this.data.requestData.length==0) && (!this.data.service_data || this.data.service_data.length==0)) {
  211 + if ((!this.data.requestData || this.data.requestData.length == 0) && (!this.data.service_data || this.data.service_data.length == 0)) {
201 212 setTimeout(function () {
202 213 var goods_list = th.selectComponent("#goods_list"); //组件的id
203   - if(goods_list){
  214 + if (goods_list) {
204 215 goods_list.init();
205 216 goods_list.get_list();
206 217 }
207 218 }, 800)
208 219 }
209 220 },
210   -
211   - //-----真的获取购物车--------
212   - get_cart: function() {
  221 +
  222 + //-----真的获取购物车--------
  223 + get_cart: function () {
213 224 var th = this;
214 225 th.data.in_zhact_gdmap={};
215 226 th.data.ladder_map={};
216   -
217 227 var rd = Math.random().toString(36).substr(2, 15);
218   - var user_id=getApp().globalData.userInfo.user_id;
  228 + var user_id = getApp().globalData.userInfo.user_id;
219 229 getApp().request.get("/api/weshop/cart/list", {
220 230 data: {
221 231 user_id: app.globalData.user_id,
222 232 rd: rd,
223 233 store_id: oo.stoid,
224 234 pageSize: 600,
225   - state:0
  235 + state: 0
226 236 },
227   - success:async function(su) {
228   - console.log(su,10000);
  237 + success: async function (su) {
  238 + console.log(su, 10000);
229 239 //按门店分类的数组
230 240 var arr = new Array(), carr = su.data.data.pageData;
231 241 var all_num = 0;
232 242  
233   - if(carr && carr.length>0) {
234   - var g_arr=[];
  243 + if (carr && carr.length > 0) {
  244 + var g_arr = [];
235 245 for (var i = 0; i < carr.length; i++) {
236   - if(g_arr.length==0) g_arr.push(carr[i].goods_id);
237   - else{
238   - var ind=g_arr.findIndex(function (ele) {
239   - return ele.goods_id==carr[i].goods_id
240   - })
241   - if(ind>-1) continue;
242   - g_arr.push(carr[i].goods_id)
243   - }
  246 + if (g_arr.length == 0) g_arr.push(carr[i].goods_id);
  247 + else {
  248 + var ind = g_arr.findIndex(function (ele) {
  249 + return ele.goods_id == carr[i].goods_id
  250 + })
  251 + if (ind > -1) continue;
  252 + g_arr.push(carr[i].goods_id)
  253 + }
244 254 }
245 255  
246   - var by_map=null;
  256 + var by_map = null;
247 257 //--要获得商品,该用户买了多少件,同步应用--
248 258 await getApp().request.promiseGet("/api/weshop/ordergoods/listUserBuyGoodsNum", {
249 259 data: {
... ... @@ -253,11 +263,11 @@ Page({
253 263  
254 264 },
255 265 }).then(res => {
256   - if(res.data.code==0 && res.data.data && res.data.data.length>0){
257   - by_map={};
258   - for(let i in res.data.data){
259   - let item=res.data.data[i];
260   - by_map[item.goods_id]=item;
  266 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  267 + by_map = {};
  268 + for (let i in res.data.data) {
  269 + let item = res.data.data[i];
  270 + by_map[item.goods_id] = item;
261 271 }
262 272 }
263 273 })
... ... @@ -265,11 +275,10 @@ Page({
265 275 for (var i = 0; i < carr.length; i++) {
266 276 var item = carr[i];
267 277 var good = item;
268   - if(item.is_gift){
  278 + if (item.is_gift) {
269 279 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
270 280 getApp().request.delete(url, {
271   - success: function (t) {
272   - }
  281 + success: function (t) {}
273 282 });
274 283 //商品已经下架
275 284 continue;
... ... @@ -280,77 +289,92 @@ Page({
280 289 if ((good.down_time > 0 && good.down_time < tt) || good.is_on_sale == 0) {
281 290 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
282 291 getApp().request.delete(url, {
283   - success: function (t) {
284   - }
  292 + success: function (t) {}
285 293 });
286 294 //商品已经下架
287 295 continue;
288 296 }
289   - var goodsbuynum=0,promgoodsbuynum=0,limit=0;
290   - if(by_map && by_map[good.goods_id]){
291   - goodsbuynum=by_map[good.goods_id].goodsbuynum;
292   - promgoodsbuynum=by_map[good.goods_id].promgoodsbuynum;
  297 + var goodsbuynum = 0,
  298 + promgoodsbuynum = 0,
  299 + limit = 0;
  300 + if (by_map && by_map[good.goods_id]) {
  301 + goodsbuynum = by_map[good.goods_id].goodsbuynum;
  302 + promgoodsbuynum = by_map[good.goods_id].promgoodsbuynum;
293 303 }
294 304  
295   - limit=good.viplimited;
  305 + limit = good.viplimited;
296 306 //判断商品的限购
297   - if(item.goods_num+goodsbuynum>limit && limit>0){
298   - var cbuy=limit-goodsbuynum;
299   - if(cbuy<=0){
  307 + if (item.goods_num + goodsbuynum > limit && limit > 0) {
  308 + var cbuy = limit - goodsbuynum;
  309 + if (cbuy <= 0) {
300 310 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
301 311 a.delete(url, {});
302 312 continue;
303 313 }
304 314 //-- 购物车更新 --
305   - var updata1={id: item.id,goods_num:cbuy,store_id:os.stoid,user_id:getApp().globalData.userInfo.user_id };
  315 + var updata1 = {
  316 + id: item.id,
  317 + goods_num: cbuy,
  318 + store_id: os.stoid,
  319 + user_id: getApp().globalData.userInfo.user_id
  320 + };
306 321 getApp().request.put("/api/weshop/cart/update", {
307 322 data: updata1,
308 323 })
309   - item.goods_num=cbuy;
  324 + item.goods_num = cbuy;
310 325 }
311 326  
312 327 //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着
313 328 if (item.prom_type == 1) {
314 329 var prom = null;
315 330 var now = ut.gettimestamp();
316   - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid +'/'+user_id+ "/" + item.prom_id, {}).then(res => {
317   - if (res.data.code == 0){
  331 + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + '/' + user_id + "/" + item.prom_id, {}).then(res => {
  332 + if (res.data.code == 0) {
318 333 prom = res.data.data;
319   - prom.price=prom.user_price;
  334 + prom.price = prom.user_price;
320 335 }
321 336 })
322 337 //---如果互动都已经过期,或者还未开始,或者无活动
323 338 if (!prom || prom.is_end == 1 || prom.end_time < now || prom.start_time > now) {
324 339 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
325 340 a.delete(url, {
326   - success: function (t) {
327   - }
  341 + success: function (t) {}
328 342 });
329 343 //商品已经下架
330 344 continue;
331 345 }
332 346  
333 347 //判断秒杀的限购
334   - if(item.goods_num+promgoodsbuynum>prom.buy_limit && prom.buy_limit>0){
335   - var cbuy=prom.buy_limit-promgoodsbuynum;
336   - if(cbuy<=0){
  348 + if (item.goods_num + promgoodsbuynum > prom.buy_limit && prom.buy_limit > 0) {
  349 + var cbuy = prom.buy_limit - promgoodsbuynum;
  350 + if (cbuy <= 0) {
337 351 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
338 352 a.delete(url, {});
339 353 continue;
340 354 }
341 355 //-- 购物车更新 --
342   - var updata1={id: item.id,goods_num:cbuy,store_id:os.stoid,user_id:getApp().globalData.userInfo.user_id };
  356 + var updata1 = {
  357 + id: item.id,
  358 + goods_num: cbuy,
  359 + store_id: os.stoid,
  360 + user_id: getApp().globalData.userInfo.user_id
  361 + };
343 362 getApp().request.put("/api/weshop/cart/update", {
344 363 data: updata1,
345 364 })
346   - item.goods_num=cbuy;
  365 + item.goods_num = cbuy;
347 366 }
348 367  
349 368 //价格不对,就要更新一下
350   - if(good.goods_price!=prom.price){
351   - good.goods_price=prom.price;
  369 + if (good.goods_price != prom.price) {
  370 + good.goods_price = prom.price;
352 371 //-- 购物车更新秒杀价格 --
353   - var updata1={id: item.id,goods_price:prom.price,store_id:os.stoid,user_id:getApp().globalData.userInfo.user_id };
  372 + var updata1 = {
  373 + id: item.id,
  374 + goods_price: prom.price,
  375 + store_id: os.stoid,
  376 + user_id: getApp().globalData.userInfo.user_id
  377 + };
354 378 getApp().request.put("/api/weshop/cart/update", {
355 379 data: updata1,
356 380 })
... ... @@ -371,13 +395,12 @@ Page({
371 395 let item=res.data.data[i];
372 396 if(item.prom_type==3) {
373 397 is_g_prom=1; break;
374   -
375 398 }
376 399 }
377 400 }
378 401 })
379 402  
380   - if(is_g_prom){
  403 + if (is_g_prom) {
381 404 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => {
382 405 if (res.data.code == 0) {
383 406 var r_data = res.data.data;
... ... @@ -386,9 +409,9 @@ Page({
386 409 getApp().request.delete(url, {});
387 410 //商品已经无活动
388 411 isok = 0;
389   - }else{
  412 + } else {
390 413 //如果活动的ID不一样,说明原先的活动已经没有参与了或者过期了
391   - if(item.prom_id!=r_data.promGoodsLists[0].prom_id ){
  414 + if (item.prom_id != r_data.promGoodsLists[0].prom_id) {
392 415 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
393 416 getApp().request.delete(url, {});
394 417 //商品已经下架
... ... @@ -404,7 +427,7 @@ Page({
404 427 }
405 428 })
406 429  
407   - }else{
  430 + } else {
408 431 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + item.goods_id, {}).then(res => {
409 432 if (res.data.code == 0) {
410 433 var r_data = res.data.data;
... ... @@ -413,9 +436,9 @@ Page({
413 436 getApp().request.delete(url, {});
414 437 //商品已经无活动
415 438 isok = 0;
416   - }else{
  439 + } else {
417 440 //如果活动的ID不一样,说明原先的活动已经没有参与了或者过期了
418   - if(item.prom_id!=r_data.promGoodsLists[0].prom_id ){
  441 + if (item.prom_id != r_data.promGoodsLists[0].prom_id) {
419 442 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
420 443 getApp().request.delete(url, {});
421 444 //商品已经下架
... ... @@ -434,47 +457,47 @@ Page({
434 457 }
435 458  
436 459 if (!isok) continue;
437   -
438 460 }
439 461 else if (item.prom_type == 7) {
440 462 if(!th.data.zuhe_map[item.prom_id]){
  463 +
441 464 //如果有组合购
442 465 var isok = 1;
443   - var is_flag=1;
444   - var act=null;
445   - var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+item.prom_id+"/"+getApp().globalData.userInfo.user_id;
  466 + var is_flag = 1;
  467 + var act = null;
  468 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item.prom_id + "/" + getApp().globalData.userInfo.user_id;
446 469 await getApp().request.promiseGet(url, {}).then(res => {
447   - console.log(res,1000);
448   - if(res.data.code==0 && res.data.data){
449   - if(res.data.data.is_show!=1){
450   - isok=0;
451   - }
452   - //如果活动已经结束
453   - if(res.data.data.is_end==1){
454   - isok=0;
455   - }
456   - //已经结束
457   - if(ut.gettimestamp()>res.data.data.end_time){
458   - isok=0;
459   - }
460   - //还未开始
461   - if(ut.gettimestamp()<res.data.data.start_time){
462   - isok=0;
463   - }
464   - act=res.data.data;
465   -
466   - }else{
467   - //未找到商品的活动
468   - is_flag = 0;
469   - }
  470 + console.log(res, 1000);
  471 + if (res.data.code == 0 && res.data.data) {
  472 + if (res.data.data.is_show != 1) {
  473 + isok = 0;
  474 + }
  475 + //如果活动已经结束
  476 + if (res.data.data.is_end == 1) {
  477 + isok = 0;
  478 + }
  479 + //已经结束
  480 + if (ut.gettimestamp() > res.data.data.end_time) {
  481 + isok = 0;
  482 + }
  483 + //还未开始
  484 + if (ut.gettimestamp() < res.data.data.start_time) {
  485 + isok = 0;
  486 + }
  487 + act = res.data.data;
  488 +
  489 + } else {
  490 + //未找到商品的活动
  491 + is_flag = 0;
  492 + }
470 493 })
471   - if (!isok){
  494 + if (!isok) {
472 495 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
473 496 getApp().request.delete(url, {});
474   - th.data.zuhe_map[item.prom_id]=-1;
  497 + th.data.zuhe_map[item.prom_id] = -1;
475 498 continue;
476 499 }
477   - th.data.zuhe_map[item.prom_id]=act;
  500 + th.data.zuhe_map[item.prom_id] = act;
478 501 var url1 = "/api/weshop/prom/zhbuyGoods/page";
479 502 var req_data = {
480 503 page: 1,
... ... @@ -485,37 +508,37 @@ Page({
485 508 await getApp().request.promiseGet(url1, {
486 509 data: req_data
487 510 }).then(res => {
488   - console.log(res,2000);
  511 + console.log(res, 2000);
489 512 if (ut.ajax_ok(res)) {
490 513 var gdlist = res.data.data.pageData;
491   - gdlist.forEach(i=>{
492   - if(item.goods_id==i.goods_id&&!is_flag){
493   - item.prom_type=0;
494   - item.prom_type1=0;
495   - item.prom_id=0;
496   - item.prom_id1=0
  514 + gdlist.forEach(i => {
  515 + if (item.goods_id == i.goods_id && !is_flag) {
  516 + item.prom_type = 0;
  517 + item.prom_type1 = 0;
  518 + item.prom_id = 0;
  519 + item.prom_id1 = 0
497 520 }
498 521 })
499   - th.data.zuhe_map_good[item.prom_id]=gdlist;
  522 + th.data.zuhe_map_good[item.prom_id] = gdlist;
500 523 }
501 524 })
502 525 }
503 526  
504   - if(th.data.zuhe_map[item.prom_id] && th.data.zuhe_map[item.prom_id]!=-1 ){
505   - var gdlist=th.data.zuhe_map_good[item.prom_id];
506   - var t_item=gdlist.find(function (ele) {
507   - return ele.goods_id==item.goods_id
  527 + if (th.data.zuhe_map[item.prom_id] && th.data.zuhe_map[item.prom_id] != -1) {
  528 + var gdlist = th.data.zuhe_map_good[item.prom_id];
  529 + var t_item = gdlist.find(function (ele) {
  530 + return ele.goods_id == item.goods_id
508 531 })
509   - if(!t_item){
  532 + if (!t_item) {
510 533 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
511 534 getApp().request.delete(url, {});
512   - th.data.zuhe_map[item.prom_id]=-1;
  535 + th.data.zuhe_map[item.prom_id] = -1;
513 536 continue;
514 537 }
515   - item.buyqty=t_item.buyqty;
516   - item.zh_b_num=promgoodsbuynum;
517   - item.act=th.data.zuhe_map[item.prom_id];
518   - }//else{
  538 + item.buyqty = t_item.buyqty;
  539 + item.zh_b_num = promgoodsbuynum;
  540 + item.act = th.data.zuhe_map[item.prom_id];
  541 + } //else{
519 542 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
520 543 // getApp().request.delete(url, {});
521 544 // th.data.zuhe_map[item.prom_id]=-1;
... ... @@ -524,7 +547,7 @@ Page({
524 547 }
525 548 else if (item.prom_type == 10) {
526 549 if(!th.data.ladder_map[item.prom_id]){
527   - //如果有组合
  550 + //如果有阶梯
528 551 var isok = 1;
529 552 var is_flag=1;
530 553 var act=null;
... ... @@ -585,6 +608,7 @@ Page({
585 608 }
586 609  
587 610 else if(item.prom_type == 0) {
  611 +
588 612 //如果有优惠活动,要更新活动
589 613 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => {
590 614 if (res.data.code == 0) {
... ... @@ -592,7 +616,12 @@ Page({
592 616 if (r_data.promGoodsLists) {
593 617 var url = '/api/weshop/cart/update';
594 618 getApp().request.put(url, {
595   - data:{id:item.id,store_id:oo.stoid,prom_type:3,prom_id:r_data.promGoodsLists[0].prom_id}
  619 + data: {
  620 + id: item.id,
  621 + store_id: oo.stoid,
  622 + prom_type: 3,
  623 + prom_id: r_data.promGoodsLists[0].prom_id
  624 + }
596 625 });
597 626 item.prom_type=3;
598 627 item.prom_id=r_data.promGoodsLists[0].prom_id;
... ... @@ -681,19 +710,27 @@ Page({
681 710 all_num += item.goods_num;
682 711 item.original_img = oo.imghost + item.original_img;
683 712 item.selected = 0;
684   - item.erpwareid=good.erpwareid; //要同步下线商品的id
685   - item.shop_price=good.shop_price; //要同步下线商品的id
  713 + item.erpwareid = good.erpwareid; //要同步下线商品的id
  714 + item.shop_price = good.shop_price; //要同步下线商品的id
686 715  
687 716 //当商品要计算等级价的售
688   - if(item.prom_type == 0 || item.prom_type == 3 || item.prom_type == 5 || item.prom_type == 7){
689   - if(th.data.card_field && good[th.data.card_field]){
690   - item.goods_price=good[th.data.card_field]; //要同步下线商品的id
691   - }else{
692   - item.goods_price=good.shop_price;
  717 + if (item.prom_type == 0 || item.prom_type == 3 || item.prom_type == 5 || item.prom_type == 7) {
  718 + if (th.data.card_field && good[th.data.card_field]) {
  719 + item.goods_price = good[th.data.card_field]; //要同步下线商品的id
  720 + } else {
  721 + item.goods_price = good.shop_price;
693 722 }
694 723  
695   - var t={id:item.id,store_id:os.stoid,user_id:getApp().globalData.userInfo.user_id,goods_price:item.goods_price}
696   - getApp().request.put("/api/weshop/cart/update", {isShowLoading:0,data: t,})
  724 + var t = {
  725 + id: item.id,
  726 + store_id: os.stoid,
  727 + user_id: getApp().globalData.userInfo.user_id,
  728 + goods_price: item.goods_price
  729 + }
  730 + getApp().request.put("/api/weshop/cart/update", {
  731 + isShowLoading: 0,
  732 + data: t,
  733 + })
697 734  
698 735 }
699 736  
... ... @@ -733,20 +770,20 @@ Page({
733 770 }
734 771 }
735 772  
736   - if(th.data.is_open_offline && th.data.is_open_offline>0 && th.data.sales_rules==2){
737   - //-- 此时要实时更新线下取价价格 --
738   - for(var i=0;i<arr.length;i++){
739   - //每个门店都去看下线下取价
740   - var list=arr[i];
741   - await th.set_offline(list);
742   - }
743   - }else{
  773 + if (th.data.is_open_offline && th.data.is_open_offline > 0 && th.data.sales_rules == 2) {
  774 + //-- 此时要实时更新线下取价价格 --
  775 + for (var i = 0; i < arr.length; i++) {
  776 + //每个门店都去看下线下取价
  777 + var list = arr[i];
  778 + await th.set_offline(list);
  779 + }
  780 + } else {
744 781 //-- 此时要实时更新线下取价价格 --
745   - for(var ij in arr){
  782 + for (var ij in arr) {
746 783 //每个门店都去看下线下取价
747   - var list=arr[ij];
748   - for(var i in list.goods){
749   - list.goods[i].offline_price=0
  784 + var list = arr[ij];
  785 + for (var i in list.goods) {
  786 + list.goods[i].offline_price = 0
750 787 }
751 788 }
752 789 }
... ... @@ -779,7 +816,7 @@ Page({
779 816 },
780 817  
781 818 //-----真的获取购物车--------
782   - get_ser_cart: function() {
  819 + get_ser_cart: function () {
783 820 var th = this;
784 821 var rd = Math.random().toString(36).substr(2, 15);
785 822 getApp().request.get("/api/weshop/cartService/page", {
... ... @@ -787,27 +824,26 @@ Page({
787 824 user_id: app.globalData.user_id,
788 825 rd: rd,
789 826 store_id: oo.stoid,
790   - pageSize: 600,
  827 + pageSize: 600,
791 828 },
792   - success:async function(su) {
  829 + success: async function (su) {
793 830 //按门店分类的数组
794 831 var arr = new Array(),
795 832 carr = su.data.data.pageData;
796 833 var all_num = 0;
797   -
798   - if(carr && carr.length>0) {
  834 +
  835 + if (carr && carr.length > 0) {
799 836 for (var i = 0; i < carr.length; i++) {
800 837 var item = carr[i];
801 838 var good = null;
802   -
  839 +
803 840 await getApp().request.promiseGet("/api/weshop/serviceCard/get/" + oo.stoid + "/" + item.service_id, {}).then(res => {
804 841 good = res.data.data;
805 842 })
806   - if(!good){
  843 + if (!good) {
807 844 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
808 845 getApp().request.delete(url, {
809   - success: function (t) {
810   - }
  846 + success: function (t) {}
811 847 });
812 848 continue;
813 849 }
... ... @@ -816,8 +852,7 @@ Page({
816 852 if (good.is_show == 0) {
817 853 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
818 854 getApp().request.delete(url, {
819   - success: function (t) {
820   - }
  855 + success: function (t) {}
821 856 });
822 857 //商品已经下架
823 858 continue;
... ... @@ -826,7 +861,7 @@ Page({
826 861 all_num += item.goods_num;
827 862 item.img_url = oo.imghost + good.imgUrl;
828 863 item.selected = 0;
829   -
  864 +
830 865  
831 866 var pcid = item.pick_id;
832 867 var find = 0;
... ... @@ -840,7 +875,7 @@ Page({
840 875 }
841 876 }
842 877 }
843   -
  878 +
844 879 //------如果没有找到-----
845 880 if (find == 0) {
846 881 var pikname = '';
... ... @@ -863,75 +898,74 @@ Page({
863 898 }
864 899 }
865 900 }
866   -
867   - // console.log('BBBBBB', all_num);
  901 +
  902 + // console.log('BBBBBB', all_num);
868 903 th.setData({
869   - service_data: arr,
870   - all_num2: all_num,
871   - is_edit: 0
872   - }),
873   - th.doCheckAll(), wx.stopPullDownRefresh();
874   -
  904 + service_data: arr,
  905 + all_num2: all_num,
  906 + is_edit: 0
  907 + }),
  908 + th.doCheckAll(), wx.stopPullDownRefresh();
  909 +
875 910 }
876 911 });
877 912 },
878   -
879   -
  913 +
  914 +
880 915 //设置莫个门店的所有线下价格
881   - async set_offline(list){
882   - var th=this;
883   - var userInfo=getApp().globalData.userInfo;
  916 + async set_offline(list) {
  917 + var th = this;
  918 + var userInfo = getApp().globalData.userInfo;
884 919 //组织一下商品,然后进行线下价格的赋值
885   - var wlist="";
886   - for(var i in list.goods){
  920 + var wlist = "";
  921 + for (var i in list.goods) {
887 922 //如果商品有促销活动
888   - if(list.goods[i].prom_type>0 && list.goods[i].prom_type!=7) continue;
889   - wlist+= encodeURIComponent(list.goods[i].erpwareid)+",";
  923 + if (list.goods[i].prom_type > 0 && list.goods[i].prom_type != 7) continue;
  924 + wlist += encodeURIComponent(list.goods[i].erpwareid) + ",";
890 925 }
891   - wlist=ut.sub_last(wlist);
  926 + wlist = ut.sub_last(wlist);
892 927 //调用接口进行赋值
893   - await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
894   - data:{
895   - store_id:os.stoid,
896   - PickupId:list.pid,
897   - WareIds:wlist,
898   - VIPId:encodeURIComponent(userInfo.erpvipid)
  928 + await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
  929 + data: {
  930 + store_id: os.stoid,
  931 + PickupId: list.pid,
  932 + WareIds: wlist,
  933 + VIPId: encodeURIComponent(userInfo.erpvipid)
899 934 }
900 935 }).then(res => {
901   - if(res.data.code==0 && res.data.data && res.data.data.length>0){
902   - for(var e in res.data.data){
903   - th.set_cart_offline_price(res.data.data[e],list.goods);
  936 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  937 + for (var e in res.data.data) {
  938 + th.set_cart_offline_price(res.data.data[e], list.goods);
904 939 }
905 940 }
906 941 })
907 942 },
908 943  
909 944 //-- 设置购物车线下 --
910   - set_cart_offline_price:function(data,glist)
911   - {
912   - for(var i in glist) {
913   - if(glist[i].erpwareid==data.WareId && (glist[i].prom_type==0 || glist[i].prom_type==7)){
914   - if(glist[i].goods_price>=data.WarePrice){
915   - glist[i].is_offline=1;
916   - glist[i].offline_price=data.WarePrice;
917   - glist[i].pricing_type=data.PriceType;
  945 + set_cart_offline_price: function (data, glist) {
  946 + for (var i in glist) {
  947 + if (glist[i].erpwareid == data.WareId && (glist[i].prom_type == 0 || glist[i].prom_type == 7)) {
  948 + if (glist[i].goods_price >= data.WarePrice) {
  949 + glist[i].is_offline = 1;
  950 + glist[i].offline_price = data.WarePrice;
  951 + glist[i].pricing_type = data.PriceType;
918 952 }
919 953 }
920 954 }
921 955 },
922 956 //删除商品
923   - delete_th_item: function(t) {
  957 + delete_th_item: function (t) {
924 958 var e = this;
925 959 var a = rq;
926 960 console.log(a);
927 961 wx.showModal({
928 962 title: "确定删除?",
929   - success: function(s) {
  963 + success: function (s) {
930 964 if (s.confirm) {
931 965 var r = t.currentTarget.dataset.cartid;
932 966 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + r;
933 967 a.delete(url, {
934   - success: function(t) {
  968 + success: function (t) {
935 969 e.getCardList();
936 970 }
937 971 });
... ... @@ -941,19 +975,19 @@ Page({
941 975 },
942 976  
943 977 //-----------------点击输入修改商品数量---------------
944   - valueToNum: function(t) {
945   - if(!this.data.is_load) return false;
  978 + valueToNum: function (t) {
  979 + if (!this.data.is_load) return false;
946 980 //控制住,避免事件响应冲突,只有input有输入的时候,才刷新
947   - if(this.data.btn_click){
  981 + if (this.data.btn_click) {
948 982 return false;
949 983 }
950   - this.data.btn_click=1;
  984 + this.data.btn_click = 1;
951 985  
952 986 var a = t.currentTarget.dataset.item;
953 987 var b = t.currentTarget.dataset.pitems;
954 988 a = this.data.requestData[b].goods[a];
955 989 var e = a;
956   - var th=this;
  990 + var th = this;
957 991  
958 992 if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) {
959 993 var s = {
... ... @@ -967,24 +1001,24 @@ Page({
967 1001 },
968 1002  
969 1003 //-------------加数量---------------------
970   - addNum: function(t) {
971   - if(!this.data.is_load) return false;
  1004 + addNum: function (t) {
  1005 + if (!this.data.is_load) return false;
972 1006 if (this.data.up_dating == 1) return false;
973 1007 this.data.up_dating = 1;
974 1008  
975 1009 var a = t.currentTarget.dataset.item;
976 1010 var b = t.currentTarget.dataset.pitems;
977 1011 a = this.data.requestData[b].goods[a];
978   -
979   - console.log('add+');
980   - if (a.goods_num<a.store_count) {
  1012 +
  1013 + console.log('add+');
  1014 + if (a.goods_num < a.store_count) {
981 1015 var e = {
982 1016 goods_num: a.goods_num + 1,
983 1017 id: a.id,
984 1018 goods_id: a.goods_id,
985 1019 store_id: oo.stoid
986 1020 };
987   - // console.log('goods_num', e.goods_num);
  1021 + // console.log('goods_num', e.goods_num);
988 1022 this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
989 1023 } else {
990 1024 wx.showModal({
... ... @@ -995,17 +1029,17 @@ Page({
995 1029 }
996 1030 },
997 1031 //-------------减数量---------------------
998   - subNum: function(t) {
999   - if(!this.data.is_load) return false;
  1032 + subNum: function (t) {
  1033 + if (!this.data.is_load) return false;
1000 1034 if (this.data.up_dating == 1) return false;
1001 1035 this.data.up_dating = 1;
1002 1036  
1003 1037 var a = t.currentTarget.dataset.item;
1004 1038 var b = t.currentTarget.dataset.pitems;
1005 1039 a = this.data.requestData[b].goods[a];
1006   - this.data.btn_click=1;
  1040 + this.data.btn_click = 1;
1007 1041  
1008   - if (a.goods_num - 1 < 0){
  1042 + if (a.goods_num - 1 < 0) {
1009 1043 this.data.up_dating = 0;
1010 1044 return false;
1011 1045 }
... ... @@ -1020,91 +1054,92 @@ Page({
1020 1054 this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
1021 1055 }
1022 1056 },
1023   -
1024   -
1025   - //-----------------点击输入修改商品数量---------------
1026   - valueToNum_ser: function(t) {
1027   - if(!this.data.is_load) return false;
1028   - //控制住,避免事件响应冲突,只有input有输入的时候,才刷新
1029   - if(this.data.btn_click){
1030   - return false;
1031   - }
1032   - this.data.btn_click=1;
1033   -
1034   - var a = t.currentTarget.dataset.item;
1035   - var b = t.currentTarget.dataset.pitems;
1036   - a = this.data.service_data[b].goods[a];
1037   - var e = a;
1038   - var th=this;
1039   -
1040   - if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) {
1041   - var s = {
1042   - goods_num: a,
1043   - goods_id: e.goods_id,
1044   - id: e.id,
1045   - store_id: oo.stoid
1046   - };
1047   - th.postCardList_ser(s, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
1048   - }
1049   - },
1050   - //-------------加数量---------------------
1051   - addNum_ser: function(t) {
1052   - if(!this.data.is_load) return false;
1053   - if (this.data.up_dating == 1) return false;
1054   - this.data.up_dating = 1;
1055   -
1056   - var a = t.currentTarget.dataset.item;
1057   - var b = t.currentTarget.dataset.pitems;
1058   - a = this.data.service_data[b].goods[a];
1059   -
1060   - var e = {
1061   - goods_num: a.goods_num + 1,
1062   - id: a.id,
1063   - goods_id: a.goods_id,
1064   - store_id: oo.stoid
1065   - };
1066   - // this.postCardList_ser(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
1067   -
1068   - },
1069   - //-------------减数量---------------------
1070   - subNum_ser: function(t) {
1071   - if(!this.data.is_load) return false;
1072   - if (this.data.up_dating == 1) return false;
1073   - this.data.up_dating = 1;
1074   -
1075   - var a = t.currentTarget.dataset.item;
1076   - var b = t.currentTarget.dataset.pitems;
1077   - a = this.data.service_data[b].goods[a];
1078   - this.data.btn_click=1;
1079   -
1080   - if (a.goods_num - 1 < 0){
1081   - this.data.up_dating = 0;
1082   - return false;
1083   - }
1084   -
1085   - if (1 != a.goods_num) {
1086   - var e = {
1087   - goods_num: a.goods_num - 1,
1088   - id: a.id,
1089   - goods_id: a.goods_id,
1090   - store_id: oo.stoid
1091   - };
1092   - this.postCardList_ser(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
1093   - }
1094   - },
1095   -
1096   -
1097   - //---------------全选,全选的时候要判断是否门店的匹配方式一致--------------
1098   - checkAll: function() {
1099   - var e = this,th=this,
  1057 +
  1058 +
  1059 + //-----------------点击输入修改商品数量---------------
  1060 + valueToNum_ser: function (t) {
  1061 + if (!this.data.is_load) return false;
  1062 + //控制住,避免事件响应冲突,只有input有输入的时候,才刷新
  1063 + if (this.data.btn_click) {
  1064 + return false;
  1065 + }
  1066 + this.data.btn_click = 1;
  1067 +
  1068 + var a = t.currentTarget.dataset.item;
  1069 + var b = t.currentTarget.dataset.pitems;
  1070 + a = this.data.service_data[b].goods[a];
  1071 + var e = a;
  1072 + var th = this;
  1073 +
  1074 + if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) {
  1075 + var s = {
  1076 + goods_num: a,
  1077 + goods_id: e.goods_id,
  1078 + id: e.id,
  1079 + store_id: oo.stoid
  1080 + };
  1081 + th.postCardList_ser(s, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
  1082 + }
  1083 + },
  1084 + //-------------加数量---------------------
  1085 + addNum_ser: function (t) {
  1086 + if (!this.data.is_load) return false;
  1087 + if (this.data.up_dating == 1) return false;
  1088 + this.data.up_dating = 1;
  1089 +
  1090 + var a = t.currentTarget.dataset.item;
  1091 + var b = t.currentTarget.dataset.pitems;
  1092 + a = this.data.service_data[b].goods[a];
  1093 +
  1094 + var e = {
  1095 + goods_num: a.goods_num + 1,
  1096 + id: a.id,
  1097 + goods_id: a.goods_id,
  1098 + store_id: oo.stoid
  1099 + };
  1100 + // this.postCardList_ser(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
  1101 +
  1102 + },
  1103 + //-------------减数量---------------------
  1104 + subNum_ser: function (t) {
  1105 + if (!this.data.is_load) return false;
  1106 + if (this.data.up_dating == 1) return false;
  1107 + this.data.up_dating = 1;
  1108 +
  1109 + var a = t.currentTarget.dataset.item;
  1110 + var b = t.currentTarget.dataset.pitems;
  1111 + a = this.data.service_data[b].goods[a];
  1112 + this.data.btn_click = 1;
  1113 +
  1114 + if (a.goods_num - 1 < 0) {
  1115 + this.data.up_dating = 0;
  1116 + return false;
  1117 + }
  1118 +
  1119 + if (1 != a.goods_num) {
  1120 + var e = {
  1121 + goods_num: a.goods_num - 1,
  1122 + id: a.id,
  1123 + goods_id: a.goods_id,
  1124 + store_id: oo.stoid
  1125 + };
  1126 + this.postCardList_ser(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
  1127 + }
  1128 + },
  1129 +
  1130 +
  1131 + //---------------全选,全选的时候要判断是否门店的匹配方式一致--------------
  1132 + checkAll: function () {
  1133 + var e = this,
  1134 + th = this,
1100 1135 dda = e.data.requestData,
1101 1136 sdda = e.data.service_data,
1102 1137 tfeel = 0,
1103 1138 t_num = 0,
1104 1139 text_arr = "";
1105 1140  
1106   - if(e.data.requestData && e.data.requestData.length>0
1107   - && e.data.service_data && e.data.service_data.length>0){
  1141 + if (e.data.requestData && e.data.requestData.length > 0 &&
  1142 + e.data.service_data && e.data.service_data.length > 0) {
1108 1143 wx.showModal({
1109 1144 title: '提示',
1110 1145 content: '服务卡项目不能和商品一起选择'
... ... @@ -1112,19 +1147,19 @@ Page({
1112 1147 return false;
1113 1148 }
1114 1149  
1115   - this.data.btn_click=1;
  1150 + this.data.btn_click = 1;
1116 1151  
1117 1152  
1118 1153  
1119   - var offline_price=0;
1120   - var offline_num=0;
1121   - th.data.in_zhact_gdmap={};
  1154 + var offline_price = 0;
  1155 + var offline_num = 0;
  1156 + th.data.in_zhact_gdmap = {};
1122 1157  
1123 1158  
1124   - if(dda && dda.length>0){
  1159 + if (dda && dda.length > 0) {
1125 1160 for (var i = 0; i < dda.length; i++) {
1126 1161 var item = dda[i].goods;
1127   -
  1162 +
1128 1163 if (e.data.checkAllToggle) {
1129 1164 var txt = "requestData[" + i + "].selected";
1130 1165 e.setData({
... ... @@ -1143,6 +1178,7 @@ Page({
1143 1178 if(obj.prom_type==10)
1144 1179 ladder_calc.remove_ladder_prom(dda,i,obj);
1145 1180  
  1181 +
1146 1182 if (fir == 0) {
1147 1183 fir = item[j].distr_type;
1148 1184 } else {
... ... @@ -1160,27 +1196,27 @@ Page({
1160 1196 if(obj.prom_type==7) zh_calc.add_zhprom(dda,i,obj);
1161 1197 //加入阶梯促销计算
1162 1198 if(obj.prom_type==10) ladder_calc.add_ladder_prom(dda,i,obj);
1163   -
1164 1199  
1165 1200 e.setData({
  1201 +
1166 1202 [txt]: !e.data.checkAllToggle,
1167 1203 })
1168   -
  1204 +
1169 1205 if (!e.data.checkAllToggle) {
1170 1206 //组合购的金额要另外算
1171 1207 if(item[j].prom_type!=7 && item[j].prom_type!=10)
1172 1208 tfeel += item[j].goods_num * item[j].goods_price;
1173   - t_num += item[j].goods_num;
  1209 + t_num += item[j].goods_num;
1174 1210 }
1175 1211  
1176 1212 //-- 如果这个商品是线下取价的时候 --
1177   - if(item[j].is_offline && item[j].prom_type!=7){
1178   - offline_price+= (item[j].goods_price-item[j].offline_price)*item[j].goods_num;
1179   - offline_num+=item[j].goods_num;
  1213 + if (item[j].is_offline && item[j].prom_type != 7) {
  1214 + offline_price += (item[j].goods_price - item[j].offline_price) * item[j].goods_num;
  1215 + offline_num += item[j].goods_num;
1180 1216 }
1181 1217  
1182   - }
1183   - }
  1218 + }
  1219 + }
1184 1220  
1185 1221  
1186 1222 if (text_arr != "") {
... ... @@ -1191,7 +1227,7 @@ Page({
1191 1227 return false;
1192 1228 } else {
1193 1229  
1194   - for (var i = 0; i < dda.length; i++) {
  1230 + for (var i = 0; i < dda.length; i++) {
1195 1231  
1196 1232 if (!e.data.checkAllToggle) {
1197 1233 var txt = "requestData[" + i + "].selected";
... ... @@ -1200,11 +1236,11 @@ Page({
1200 1236 });
1201 1237 }
1202 1238  
1203   - //总的价格,把组合商品的价格拿出来
1204   - var zh_calc_res=zh_calc.calculate_zh(dda,i,this);
1205   - tfeel+=zh_calc_res.tfeel;
1206   - offline_price+=zh_calc_res.offline_price;
1207   - offline_num+=zh_calc_res.offline_num;
  1239 + //总的价格,把组合商品的价格拿出来
  1240 + var zh_calc_res = zh_calc.calculate_zh(dda, i, this);
  1241 + tfeel += zh_calc_res.tfeel;
  1242 + offline_price += zh_calc_res.offline_price;
  1243 + offline_num += zh_calc_res.offline_num;
1208 1244  
1209 1245 //总的价格,把阶梯促销的商品的价格拿出来
1210 1246 var ladder_calc_res=ladder_calc.calculate_ladder(dda,i,this);
... ... @@ -1213,24 +1249,24 @@ Page({
1213 1249 offline_num+=ladder_calc_res.offline_num;
1214 1250  
1215 1251 //当有线下取价的时候
1216   - if(offline_price){
1217   - var txt1= "requestData[" + i + "].offline_price";
1218   - var txt2= "requestData[" + i+ "].offline_num";
  1252 + if (offline_price) {
  1253 + var txt1 = "requestData[" + i + "].offline_price";
  1254 + var txt2 = "requestData[" + i + "].offline_num";
1219 1255 th.setData({
1220 1256 [txt1]: offline_price.toFixed(2),
1221 1257 [txt2]: offline_num,
1222 1258 });
1223   - }else{
1224   - if(dda[i].offline_price>0){
1225   - var txt1= "requestData[" + i + "].offline_price";
1226   - var txt2= "requestData[" + i + "].offline_num";
  1259 + } else {
  1260 + if (dda[i].offline_price > 0) {
  1261 + var txt1 = "requestData[" + i + "].offline_price";
  1262 + var txt2 = "requestData[" + i + "].offline_num";
1227 1263 th.setData({
1228 1264 [txt1]: 0,
1229 1265 [txt2]: 0
1230 1266 });
1231 1267 }
1232 1268 }
1233   - }
  1269 + }
1234 1270  
1235 1271 e.setData({
1236 1272 checkAllToggle: !e.data.checkAllToggle,
... ... @@ -1238,13 +1274,13 @@ Page({
1238 1274 total_num: t_num,
1239 1275 });
1240 1276  
1241   - for(var i in e.data.requestData){
  1277 + for (var i in e.data.requestData) {
1242 1278 e.check_prom_activity(i)
1243 1279 }
1244 1280 }
1245 1281 }
1246 1282  
1247   - if(sdda && sdda.length>0){
  1283 + if (sdda && sdda.length > 0) {
1248 1284 for (var i = 0; i < sdda.length; i++) {
1249 1285 var item = sdda[i].goods;
1250 1286 if (e.data.checkAllToggle) {
... ... @@ -1274,30 +1310,30 @@ Page({
1274 1310  
1275 1311 },
1276 1312 //------门店全选按钮,要判断是否门店的匹配方式一致---------
1277   - check_th_all_item:async function(ele) {
  1313 + check_th_all_item: async function (ele) {
1278 1314 var e = this,
1279 1315 pitems = ele.currentTarget.dataset.pitems,
1280 1316 item = this.data.requestData[pitems].goods,
1281 1317 sele = this.data.requestData[pitems].selected;
1282   - this.data.btn_click=1;
1283   - var garr=e.data.service_data;
  1318 + this.data.btn_click = 1;
  1319 + var garr = e.data.service_data;
1284 1320  
1285 1321 var isok = 1,
1286 1322 fir = 0,
1287 1323 iarr = item;
1288 1324  
1289   - if(!sele){
1290   - var check_is_service_selected=0;
1291   - for (var ii in garr){
1292   - for (var ij in garr[ii].goods){
1293   - if( garr[ii].goods[ij].selected){
1294   - check_is_service_selected=1;
  1325 + if (!sele) {
  1326 + var check_is_service_selected = 0;
  1327 + for (var ii in garr) {
  1328 + for (var ij in garr[ii].goods) {
  1329 + if (garr[ii].goods[ij].selected) {
  1330 + check_is_service_selected = 1;
1295 1331 break;
1296 1332 }
1297 1333 }
1298 1334 }
1299 1335  
1300   - if(check_is_service_selected){
  1336 + if (check_is_service_selected) {
1301 1337 wx.showModal({
1302 1338 title: '提示',
1303 1339 content: '服务卡项目不能和商品一起选择'
... ... @@ -1308,7 +1344,7 @@ Page({
1308 1344  
1309 1345 if (!sele && item.length > 0) {
1310 1346 for (var i = 0; i < iarr.length; i++) {
1311   - if(iarr[i].is_gift==1) continue;
  1347 + if (iarr[i].is_gift == 1) continue;
1312 1348 if (iarr[i].distr_type != 0) {
1313 1349 if (fir == 0) {
1314 1350 fir = iarr[i].distr_type;
... ... @@ -1340,23 +1376,24 @@ Page({
1340 1376 e.setData({
1341 1377 [txt]: Number(!sele),
1342 1378 });
1343   -
1344   - await e.check_prom_activity(pitems);
1345   - for(var i in e.data.requestData){
1346   - if(i!=pitems) await e.check_prom_activity(i);
1347   - }
  1379 +
  1380 + await e.check_prom_activity(pitems);
  1381 + for (var i in e.data.requestData) {
  1382 + if (i != pitems) await e.check_prom_activity(i);
  1383 + }
1348 1384 this.doCheckAll();
1349 1385 },
1350 1386 //---------------单选,也要判断门店的配送方式是否一致--------------
1351   - check_th_item: async function(t) {
  1387 + check_th_item: async function (t) {
1352 1388 var e = this,
1353 1389 item = t.currentTarget.dataset.item,
1354 1390 pitems = t.currentTarget.dataset.pitems;
1355 1391 a = this.data.requestData[pitems].goods[item];
1356   - var isok = 1,fir = 0;
  1392 + var isok = 1,
  1393 + fir = 0;
1357 1394 var iarr = e.data.requestData[pitems].goods;
1358   - this.data.btn_click=1;
1359   - var garr= e.data.service_data;
  1395 + this.data.btn_click = 1;
  1396 + var garr = e.data.service_data;
1360 1397  
1361 1398 if (!a.selected) {
1362 1399 var check_is_service_selected = 0;
... ... @@ -1381,7 +1418,7 @@ Page({
1381 1418 if (iarr.length > 1 && !a.selected) {
1382 1419  
1383 1420 for (var i = 0; i < iarr.length; i++) {
1384   - if(iarr[i].is_gift==1) continue;
  1421 + if (iarr[i].is_gift == 1) continue;
1385 1422 //---当不是本身选择项目----
1386 1423 var sel = iarr[i].selected;
1387 1424 if (iarr[i].distr_type != 0 && (sel || iarr[i].id == a.id)) {
... ... @@ -1407,42 +1444,42 @@ Page({
1407 1444 [txt]: Number(!a.selected),
1408 1445 });
1409 1446  
1410   - if(a.prom_type==3){
1411   -
1412   - await e.check_prom_activity(pitems);
  1447 + if (a.prom_type == 3) {
  1448 +
  1449 + await e.check_prom_activity(pitems);
1413 1450 //判断商品是不是优惠活动
1414   - for(var i in e.data.requestData){
1415   - if(i!=pitems) await e.check_prom_activity(i);
1416   - }
  1451 + for (var i in e.data.requestData) {
  1452 + if (i != pitems) await e.check_prom_activity(i);
  1453 + }
1417 1454 }
1418 1455 this.doCheckAll();
1419 1456 }
1420 1457 },
1421 1458  
1422 1459 //------门店全选按钮,要判断是否门店的匹配方式一致---------
1423   - check_th_all_item_ser:async function(ele) {
  1460 + check_th_all_item_ser: async function (ele) {
1424 1461 var e = this,
1425 1462 pitems = ele.currentTarget.dataset.pitems,
1426 1463 item = this.data.service_data[pitems].goods,
1427 1464 sele = this.data.service_data[pitems].selected;
1428   - this.data.btn_click=1;
1429   - var garr= e.data.requestData;
  1465 + this.data.btn_click = 1;
  1466 + var garr = e.data.requestData;
1430 1467  
1431 1468 var isok = 1,
1432 1469 fir = 0,
1433 1470 iarr = item;
1434 1471  
1435   - if(!sele){
1436   - var check_is_goods_selected=0;
1437   - for (var ii in garr){
1438   - for (var ij in garr[ii].goods){
1439   - if( garr[ii].goods[ij].selected){
1440   - check_is_goods_selected=1;
  1472 + if (!sele) {
  1473 + var check_is_goods_selected = 0;
  1474 + for (var ii in garr) {
  1475 + for (var ij in garr[ii].goods) {
  1476 + if (garr[ii].goods[ij].selected) {
  1477 + check_is_goods_selected = 1;
1441 1478 break;
1442 1479 }
1443 1480 }
1444 1481 }
1445   - if(check_is_goods_selected){
  1482 + if (check_is_goods_selected) {
1446 1483 wx.showModal({
1447 1484 title: '提示',
1448 1485 content: '服务卡项目不能和商品一起选择'
... ... @@ -1464,29 +1501,30 @@ Page({
1464 1501 this.doCheckAll();
1465 1502 },
1466 1503 //---------------单选,也要判断门店的配送方式是否一致--------------
1467   - check_th_item_ser: async function(t) {
  1504 + check_th_item_ser: async function (t) {
1468 1505 var e = this,
1469 1506 item = t.currentTarget.dataset.item,
1470 1507 pitems = t.currentTarget.dataset.pitems;
1471 1508 a = this.data.service_data[pitems].goods[item];
1472   - var isok = 1,fir = 0;
  1509 + var isok = 1,
  1510 + fir = 0;
1473 1511 var iarr = e.data.service_data[pitems].goods;
1474   - this.data.btn_click=1;
  1512 + this.data.btn_click = 1;
1475 1513  
1476   - var garr= e.data.requestData;
  1514 + var garr = e.data.requestData;
1477 1515  
1478   - if(!a.selected){
1479   - var check_is_goods_selected=0;
1480   - for (var ii in garr){
1481   - for (var ij in garr[ii].goods){
1482   - if( garr[ii].goods[ij].selected){
1483   - check_is_goods_selected=1;
  1516 + if (!a.selected) {
  1517 + var check_is_goods_selected = 0;
  1518 + for (var ii in garr) {
  1519 + for (var ij in garr[ii].goods) {
  1520 + if (garr[ii].goods[ij].selected) {
  1521 + check_is_goods_selected = 1;
1484 1522 break;
1485 1523 }
1486 1524 }
1487 1525 }
1488 1526  
1489   - if(check_is_goods_selected){
  1527 + if (check_is_goods_selected) {
1490 1528 wx.showModal({
1491 1529 title: '提示',
1492 1530 content: '服务卡项目不能和商品一起选择'
... ... @@ -1503,7 +1541,7 @@ Page({
1503 1541 },
1504 1542  
1505 1543 //----------检查是否全选---------
1506   - doCheckAll: function() {
  1544 + doCheckAll: function () {
1507 1545 var th = this,
1508 1546 tfeel = 0,
1509 1547 t_num = 0,
... ... @@ -1513,28 +1551,27 @@ Page({
1513 1551 all_num = 0;
1514 1552  
1515 1553 //-- 购物车 --
1516   - if(car && car.length>0){
1517   - th.data.in_zhact_gdmap={};
  1554 + if (car && car.length > 0) {
  1555 + th.data.in_zhact_gdmap = {};
1518 1556 for (var a = 0; a < car.length; a++) {
1519 1557 var item = car[a].goods,is_s_sele = 1;
1520 1558 var offline_price=0;
1521 1559 var offline_num=0;
1522 1560 for (var c = 0; c < item.length; c++) {
1523   - if(item[c].is_gift) continue;
  1561 + if (item[c].is_gift) continue;
1524 1562 all_num += item[c].goods_num;
1525 1563  
1526 1564 //不管怎么样都要移出去
1527 1565 var obj=JSON.parse(JSON.stringify(item[c]));
1528   -
1529 1566 zh_calc.remove_zhprom(car,a,obj);
1530 1567 ladder_calc.remove_ladder_prom(car,a,obj);
1531 1568  
1532 1569 if (item[c].selected == 0) {
1533 1570 ischeck = 0;
1534 1571 is_s_sele = 0;
1535   - if(item[c].prom_type==7) {
1536   - obj.goods_num=0;
1537   - zh_calc.add_zhprom(car,a,obj);
  1572 + if (item[c].prom_type == 7) {
  1573 + obj.goods_num = 0;
  1574 + zh_calc.add_zhprom(car, a, obj);
1538 1575 }
1539 1576 if(item[c].prom_type==10) {
1540 1577 obj.goods_num=0;
... ... @@ -1556,9 +1593,9 @@ Page({
1556 1593 }
1557 1594  
1558 1595 //-- 如果这个商品是线下取价的时候 --
1559   - if(item[c].is_offline && item[c].prom_type!=7){
1560   - offline_price+= (item[c].goods_price-item[c].offline_price)*item[c].goods_num;
1561   - offline_num+=item[c].goods_num;
  1596 + if (item[c].is_offline && item[c].prom_type != 7) {
  1597 + offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num;
  1598 + offline_num += item[c].goods_num;
1562 1599 }
1563 1600 }
1564 1601  
... ... @@ -1581,35 +1618,36 @@ Page({
1581 1618 });
1582 1619  
1583 1620 //当有线下取价的时候
1584   - if(offline_price){
1585   - var txt1= "requestData[" + a + "].offline_price";
1586   - var txt2= "requestData[" + a + "].offline_num";
  1621 + if (offline_price) {
  1622 + var txt1 = "requestData[" + a + "].offline_price";
  1623 + var txt2 = "requestData[" + a + "].offline_num";
1587 1624 th.setData({
1588 1625 [txt1]: offline_price.toFixed(2),
1589 1626 [txt2]: offline_num,
1590 1627 });
1591   - }else{
1592   - if(car[a].offline_price>0){
1593   - var txt1= "requestData[" + a + "].offline_price";
1594   - var txt2= "requestData[" + a + "].offline_num";
1595   - th.setData({
1596   - [txt1]: 0,
1597   - [txt2]: 0
1598   - });
1599   - }
  1628 + } else {
  1629 + if (car[a].offline_price > 0) {
  1630 + var txt1 = "requestData[" + a + "].offline_price";
  1631 + var txt2 = "requestData[" + a + "].offline_num";
  1632 + th.setData({
  1633 + [txt1]: 0,
  1634 + [txt2]: 0
  1635 + });
  1636 + }
1600 1637 }
1601 1638  
1602 1639 }
1603 1640 }
1604 1641  
1605 1642 //-- 服务卡 --
1606   - if(car2 && car2.length>0){
  1643 + if (car2 && car2.length > 0) {
1607 1644 for (var a = 0; a < car2.length; a++) {
1608   - var c_item=car2[a];
1609   - var item = car2[a].goods, is_s_sele = 1;
  1645 + var c_item = car2[a];
  1646 + var item = car2[a].goods,
  1647 + is_s_sele = 1;
1610 1648  
1611 1649 for (var c = 0; c < item.length; c++) {
1612   - if(item[c].is_gift) continue;
  1650 + if (item[c].is_gift) continue;
1613 1651 all_num += item[c].goods_num;
1614 1652 if (item[c].selected == 0) {
1615 1653 ischeck = 0;
... ... @@ -1637,28 +1675,31 @@ Page({
1637 1675 },
1638 1676  
1639 1677 //----------------------更新购物数量,加减,调用接口---------------------
1640   - postCardList: function(t, item, pitem) {
1641   - var e = this,th=e,user_id = getApp().globalData.user_id;
1642   - function normal_check(store_count,goodsinfo,wareIds) {
1643   - //--- 看一下是不是线下库存 ---
1644   - if(th.data.sales_rules==2 && goodsinfo.prom_type!=7){
1645   - th.check_down_line(t, pitem, item,wareIds);
1646   - }else{
1647   - if (t.goods_num > store_count) {
1648   - wx.showModal({
1649   - title: '提示',
1650   - content: '购买数量超出商品库存'
1651   - });
1652   - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
1653   - e.setData({
1654   - [txt]: store_count
1655   - });
1656   - e.doCheckAll();
1657   - t.goods_num=store_count;
1658   - }
1659   - e.update_cart(t, pitem, item);
1660   - }
1661   - }
  1678 + postCardList: function (t, item, pitem) {
  1679 + var e = this,
  1680 + th = e,
  1681 + user_id = getApp().globalData.user_id;
  1682 +
  1683 + function normal_check(store_count, goodsinfo, wareIds) {
  1684 + //--- 看一下是不是线下库存 ---
  1685 + if (th.data.sales_rules == 2 && goodsinfo.prom_type != 7) {
  1686 + th.check_down_line(t, pitem, item, wareIds);
  1687 + } else {
  1688 + if (t.goods_num > store_count) {
  1689 + wx.showModal({
  1690 + title: '提示',
  1691 + content: '购买数量超出商品库存'
  1692 + });
  1693 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  1694 + e.setData({
  1695 + [txt]: store_count
  1696 + });
  1697 + e.doCheckAll();
  1698 + t.goods_num = store_count;
  1699 + }
  1700 + e.update_cart(t, pitem, item);
  1701 + }
  1702 + }
1662 1703  
1663 1704 // console.log('update');
1664 1705 // console.log('9995959595959',t);
... ... @@ -1688,8 +1729,10 @@ Page({
1688 1729 var buy_num_data = res.data.data;
1689 1730 if (buy_num_data.promgoodsbuynum) {
1690 1731 promgoodsbuynum = buy_num_data.promgoodsbuynum;
1691   - var txt="requestData[" + pitem + "].goods[" + item + "].zh_b_num";
1692   - th.setData({[txt]:promgoodsbuynum});
  1732 + var txt = "requestData[" + pitem + "].goods[" + item + "].zh_b_num";
  1733 + th.setData({
  1734 + [txt]: promgoodsbuynum
  1735 + });
1693 1736 }
1694 1737 goodsbuynum = buy_num_data.goodsbuynum;
1695 1738  
... ... @@ -1710,19 +1753,19 @@ Page({
1710 1753 });
1711 1754 e.doCheckAll();
1712 1755  
1713   - t.goods_num=cbuy > 0 ? cbuy : 0,
  1756 + t.goods_num = cbuy > 0 ? cbuy : 0,
1714 1757 e.update_cart(t, pitem, item);
1715 1758 return false;
1716 1759 }
1717 1760  
1718 1761  
1719   - switch (goodsinfo.prom_type){
1720   - case 1:
  1762 + switch (goodsinfo.prom_type) {
  1763 + case 1:
1721 1764 //读取秒杀
1722 1765 rq.get("/api/ms/flash_sale/getFlashSaleOne/" + oo.stoid + "/" + goodsinfo.prom_id, {
1723 1766 isShowLoading: 0,
1724   - success: function(res_d) {
1725   - if(res_d.data.code==0 && res_d.data.data){
  1767 + success: function (res_d) {
  1768 + if (res_d.data.code == 0 && res_d.data.data) {
1726 1769 if (t.goods_num > store_count) {
1727 1770 wx.showModal({
1728 1771 title: '提示',
... ... @@ -1734,7 +1777,7 @@ Page({
1734 1777 });
1735 1778 e.doCheckAll();
1736 1779  
1737   - t.goods_num=store_count;
  1780 + t.goods_num = store_count;
1738 1781 e.update_cart(t, pitem, item);
1739 1782  
1740 1783 return false;
... ... @@ -1753,7 +1796,7 @@ Page({
1753 1796 });
1754 1797 e.doCheckAll();
1755 1798  
1756   - t.goods_num=false_data.goods_num - false_data.buy_num;
  1799 + t.goods_num = false_data.goods_num - false_data.buy_num;
1757 1800 e.update_cart(t, pitem, item);
1758 1801  
1759 1802 return false;
... ... @@ -1771,7 +1814,7 @@ Page({
1771 1814 });
1772 1815 e.doCheckAll();
1773 1816  
1774   - t.goods_num=false_data.redisnum;
  1817 + t.goods_num = false_data.redisnum;
1775 1818 e.update_cart(t, pitem, item);
1776 1819 return false;
1777 1820 }
... ... @@ -1787,110 +1830,110 @@ Page({
1787 1830 [txt]: false_data.buy_limit
1788 1831 });
1789 1832 e.doCheckAll();
1790   - t.goods_num=(false_data.buy_limit-promgoodsbuynum)?false_data.buy_limit-promgoodsbuynum:0;
  1833 + t.goods_num = (false_data.buy_limit - promgoodsbuynum) ? false_data.buy_limit - promgoodsbuynum : 0;
1791 1834 e.update_cart(t, pitem, item);
1792 1835 return false;
1793 1836 }
1794 1837 e.update_cart(t, pitem, item);
1795 1838  
1796   - }else{
1797   - normal_check(store_count,goodsinfo,wareIds);
  1839 + } else {
  1840 + normal_check(store_count, goodsinfo, wareIds);
1798 1841 }
1799 1842 }
1800 1843 })
1801   - break;
1802   - case 2:
1803   - getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {
1804   - }).then(res => {
1805   - if(res.data.code==0 && res.data.data){
1806   - if (t.goods_num > store_count) {
1807   - wx.showModal({
1808   - title: '提示',
1809   - content: '购买数量超出商品库存'
1810   - });
1811   - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
1812   - e.setData({
1813   - [txt]: store_count
1814   - });
1815   - e.doCheckAll();
1816   -
1817   - t.goods_num=store_count;
1818   - e.update_cart(t, pitem, item);
1819   -
1820   - return false;
1821   - }
1822   -
1823   - var gr_data = res.data.data;
1824   - //--判断库存--
1825   - if (t.goods_num > gr_data.goods_num - gr_data.buy_num) {
1826   - wx.showModal({
1827   - title: '提示',
1828   - content: '购买数量超出活动库存'
1829   - });
1830   - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
1831   - e.setData({
1832   - [txt]: gr_data.goods_num - gr_data.buy_num
1833   - });
1834   - e.doCheckAll();
1835   -
1836   - t.goods_num=gr_data.goods_num - gr_data.buy_num;
1837   - e.update_cart(t, pitem, item);
1838   -
1839   - return false;
1840   - }
1841   -
1842   - //--判断redis数量是否已经超出--
1843   - if (t.goods_num > gr_data.redisnum) {
1844   - wx.showModal({
1845   - title: '提示',
1846   - content: '购买数量超出商品库存'
1847   - });
1848   - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
1849   - e.setData({
1850   - [txt]: gr_data.redisnum
1851   - });
1852   - e.doCheckAll();
1853   -
1854   - t.goods_num=gr_data.redisnum;
1855   - e.update_cart(t, pitem, item);
1856   - return false;
1857   - }
1858   -
1859   - //--活动的限购是不是要判断--
1860   - if (t.goods_num + promgoodsbuynum > gr_data.buy_limit && gr_data.buy_limit > 0) {
1861   - wx.showModal({
1862   - title: '提示',
1863   - content: '购买数量超出团购限购'
1864   - });
1865   - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
1866   - e.setData({
1867   - [txt]: gr_data.buy_limit
1868   - });
1869   - e.doCheckAll();
1870   -
1871   - t.goods_num=(gr_data.buy_limit-promgoodsbuynum)?gr_data.buy_limit-promgoodsbuynum:0;
1872   - e.update_cart(t, pitem, item);
1873   - return false;
1874   - }
1875   - e.update_cart(t, pitem, item);
1876   -
1877   - }else{
1878   - normal_check(store_count,goodsinfo,wareIds);
1879   - }
  1844 + break;
  1845 + case 2:
  1846 + getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => {
  1847 + if (res.data.code == 0 && res.data.data) {
  1848 + if (t.goods_num > store_count) {
  1849 + wx.showModal({
  1850 + title: '提示',
  1851 + content: '购买数量超出商品库存'
  1852 + });
  1853 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  1854 + e.setData({
  1855 + [txt]: store_count
  1856 + });
  1857 + e.doCheckAll();
  1858 +
  1859 + t.goods_num = store_count;
  1860 + e.update_cart(t, pitem, item);
  1861 +
  1862 + return false;
  1863 + }
  1864 +
  1865 + var gr_data = res.data.data;
  1866 + //--判断库存--
  1867 + if (t.goods_num > gr_data.goods_num - gr_data.buy_num) {
  1868 + wx.showModal({
  1869 + title: '提示',
  1870 + content: '购买数量超出活动库存'
  1871 + });
  1872 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  1873 + e.setData({
  1874 + [txt]: gr_data.goods_num - gr_data.buy_num
  1875 + });
  1876 + e.doCheckAll();
  1877 +
  1878 + t.goods_num = gr_data.goods_num - gr_data.buy_num;
  1879 + e.update_cart(t, pitem, item);
  1880 +
  1881 + return false;
  1882 + }
  1883 +
  1884 + //--判断redis数量是否已经超出--
  1885 + if (t.goods_num > gr_data.redisnum) {
  1886 + wx.showModal({
  1887 + title: '提示',
  1888 + content: '购买数量超出商品库存'
  1889 + });
  1890 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  1891 + e.setData({
  1892 + [txt]: gr_data.redisnum
  1893 + });
  1894 + e.doCheckAll();
  1895 +
  1896 + t.goods_num = gr_data.redisnum;
  1897 + e.update_cart(t, pitem, item);
  1898 + return false;
  1899 + }
  1900 +
  1901 + //--活动的限购是不是要判断--
  1902 + if (t.goods_num + promgoodsbuynum > gr_data.buy_limit && gr_data.buy_limit > 0) {
  1903 + wx.showModal({
  1904 + title: '提示',
  1905 + content: '购买数量超出团购限购'
  1906 + });
  1907 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  1908 + e.setData({
  1909 + [txt]: gr_data.buy_limit
  1910 + });
  1911 + e.doCheckAll();
  1912 +
  1913 + t.goods_num = (gr_data.buy_limit - promgoodsbuynum) ? gr_data.buy_limit - promgoodsbuynum : 0;
  1914 + e.update_cart(t, pitem, item);
  1915 + return false;
  1916 + }
  1917 + e.update_cart(t, pitem, item);
  1918 +
  1919 + } else {
  1920 + normal_check(store_count, goodsinfo, wareIds);
  1921 + }
1880 1922 })
1881 1923  
1882   - break;
1883   - default:
1884   - normal_check(store_count,goodsinfo,wareIds);
1885   - break
1886   - }
  1924 + break;
  1925 + default:
  1926 + normal_check(store_count, goodsinfo, wareIds);
  1927 + break
  1928 + }
1887 1929 }
1888 1930 });
1889 1931 },
1890 1932  
1891 1933 //----------------------更新购物数量,加减,调用接口---------------------
1892   - postCardList_ser: function(t, item, pitem) {
1893   - var e = this,th=e;
  1934 + postCardList_ser: function (t, item, pitem) {
  1935 + var e = this,
  1936 + th = e;
1894 1937 var user_id = getApp().globalData.user_id;
1895 1938 var txt = "service_data[" + pitem + "].goods[" + item + "].goods_num";
1896 1939 e.setData({
... ... @@ -1899,17 +1942,18 @@ Page({
1899 1942 e.doCheckAll();
1900 1943 e.update_cart_ser(t, pitem, item);
1901 1944 },
1902   -
  1945 +
1903 1946  
1904 1947  
1905 1948 //---检验线下库存的数量---
1906   - async check_down_line(t, pitem, item,erpwareid){
1907   - var ob={},th=this;
1908   - await this.check_down_line_next(t, pitem, item,erpwareid,function(res){
1909   - ob=res;
  1949 + async check_down_line(t, pitem, item, erpwareid) {
  1950 + var ob = {},
  1951 + th = this;
  1952 + await this.check_down_line_next(t, pitem, item, erpwareid, function (res) {
  1953 + ob = res;
1910 1954 });
1911   - var log=0;
1912   - if(ob.code==-1){
  1955 + var log = 0;
  1956 + if (ob.code == -1) {
1913 1957 wx.showModal({
1914 1958 title: '提示',
1915 1959 content: '购买数量超出商品库存'
... ... @@ -1919,31 +1963,41 @@ Page({
1919 1963 [txt]: ob.CanOutQty
1920 1964 });
1921 1965 th.doCheckAll();
1922   - t.goods_num=ob.CanOutQty;
  1966 + t.goods_num = ob.CanOutQty;
1923 1967 }
1924 1968 this.update_cart(t, pitem, item);
1925 1969 },
1926 1970  
1927 1971 //---检验线下库存的数量的子函数---
1928   - async check_down_line_next(t, pitem, item,erpwareid,func){
  1972 + async check_down_line_next(t, pitem, item, erpwareid, func) {
1929 1973  
1930 1974 var goodsinfo = this.data.requestData[pitem].goods[item];
1931   - var lock=0,pick_no,plist;
  1975 + var lock = 0,
  1976 + pick_no, plist;
1932 1977 //先读取门店的lock
1933   - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
1934   - data:{store_id:os.stoid,wareId:t.goods_id,storageId:goodsinfo.pick_id,pageSize:1000}
1935   - }).then(res=>{
1936   - if(res.data.code==0 && res.data.data.total>0){
1937   - for(var i in res.data.data.pageData)
1938   - lock+=res.data.data.pageData[i].outQty;
  1978 + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
  1979 + data: {
  1980 + store_id: os.stoid,
  1981 + wareId: t.goods_id,
  1982 + storageId: goodsinfo.pick_id,
  1983 + pageSize: 1000
  1984 + }
  1985 + }).then(res => {
  1986 + if (res.data.code == 0 && res.data.data.total > 0) {
  1987 + for (var i in res.data.data.pageData)
  1988 + lock += res.data.data.pageData[i].outQty;
1939 1989 }
1940 1990 })
1941 1991 //先获取门店的编号
1942   - await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+goodsinfo.pick_id,{
1943   - data:{storeId:os.stoid,goodsId:t.goods_id,pickupId:goodsinfo.pick_id}
1944   - }).then(res=>{
1945   - if(res.data.code==0){
1946   - pick_no=res.data.data.pickup_no;
  1992 + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + goodsinfo.pick_id, {
  1993 + data: {
  1994 + storeId: os.stoid,
  1995 + goodsId: t.goods_id,
  1996 + pickupId: goodsinfo.pick_id
  1997 + }
  1998 + }).then(res => {
  1999 + if (res.data.code == 0) {
  2000 + pick_no = res.data.data.pickup_no;
1947 2001 }
1948 2002 })
1949 2003 //读取线下的门店库存
... ... @@ -1954,40 +2008,44 @@ Page({
1954 2008 plist=res.data.data.pageData[0];
1955 2009 }
1956 2010 })
1957   - var ob={}; ob.code=1;
  2011 + var ob = {};
  2012 + ob.code = 1;
1958 2013  
1959   - if(!plist){
1960   - ob.code=-1;ob.CanOutQty=0;func(ob); return false;
  2014 + if (!plist) {
  2015 + ob.code = -1;
  2016 + ob.CanOutQty = 0;
  2017 + func(ob);
  2018 + return false;
1961 2019 }
1962 2020  
1963   - var c_num=t.goods_num;
1964   - if(t.need_downlow_num) c_num=t.need_downlow_num;
  2021 + var c_num = t.goods_num;
  2022 + if (t.need_downlow_num) c_num = t.need_downlow_num;
1965 2023  
1966   - if( c_num>plist.CanOutQty-lock){
1967   - ob.code=-1;
1968   - ob.CanOutQty=plist.CanOutQty-lock
1969   - if(ob.CanOutQty<0) ob.CanOutQty=0;
  2024 + if (c_num > plist.CanOutQty - lock) {
  2025 + ob.code = -1;
  2026 + ob.CanOutQty = plist.CanOutQty - lock
  2027 + if (ob.CanOutQty < 0) ob.CanOutQty = 0;
1970 2028 }
1971 2029 func(ob)
1972 2030 },
1973 2031  
1974 2032  
1975 2033 //--更新购物车---
1976   - update_cart: function(t, pitem, item) {
  2034 + update_cart: function (t, pitem, item) {
1977 2035 var e = this;
1978 2036  
1979 2037 getApp().request.put("/api/weshop/cart/update", {
1980 2038 data: t,
1981   - success:async function(ee) {
  2039 + success: async function (ee) {
1982 2040 var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
1983 2041  
1984 2042 e.setData({
1985 2043 [txt]: t.goods_num,
1986 2044 });
1987   -
1988   - await e.check_prom_activity(pitem)
1989   - for(var i in e.data.requestData){
1990   - if(i!=pitem) await e.check_prom_activity(i)
  2045 +
  2046 + await e.check_prom_activity(pitem)
  2047 + for (var i in e.data.requestData) {
  2048 + if (i != pitem) await e.check_prom_activity(i)
1991 2049 }
1992 2050 e.doCheckAll();
1993 2051 getApp().requestCardNum(e);
... ... @@ -1996,11 +2054,11 @@ Page({
1996 2054 },
1997 2055  
1998 2056 //--更新购物车---
1999   - update_cart_ser: function(t, pitem, item) {
  2057 + update_cart_ser: function (t, pitem, item) {
2000 2058 var e = this;
2001 2059 getApp().request.put("/api/weshop/cartService/update", {
2002 2060 data: t,
2003   - success:async function(ee) {
  2061 + success: async function (ee) {
2004 2062 var txt = "service_data[" + pitem + "].goods[" + item + "].goods_num";
2005 2063 e.setData({
2006 2064 [txt]: t.goods_num,
... ... @@ -2013,22 +2071,22 @@ Page({
2013 2071  
2014 2072  
2015 2073 //-------下拉刷新---------
2016   - onPullDownRefresh: function(t) {
  2074 + onPullDownRefresh: function (t) {
2017 2075 this.getCardList();
2018 2076 },
2019 2077  
2020 2078 //--------------去结算------------
2021 2079 async checkout() {
2022   - if(!this.data.total_num || this.data.total_num<=0) return false;
2023   - if(!this.data.is_load) return false;
2024   - if(this.data.up_dating) {
  2080 + if (!this.data.total_num || this.data.total_num <= 0) return false;
  2081 + if (!this.data.is_load) return false;
  2082 + if (this.data.up_dating) {
2025 2083 wx.showLoading({
2026   - title:"计算中"
  2084 + title: "计算中"
2027 2085 })
2028 2086 }
2029   - var garr=this.data.requestData;
2030   - var check_is_goods_selected=0;
2031   - if(garr) {
  2087 + var garr = this.data.requestData;
  2088 + var check_is_goods_selected = 0;
  2089 + if (garr) {
2032 2090 for (var ii in garr) {
2033 2091 for (var ij in garr[ii].goods) {
2034 2092 if (garr[ii].goods[ij].selected) {
... ... @@ -2039,7 +2097,7 @@ Page({
2039 2097 }
2040 2098 }
2041 2099 //-- 如果是商品的结算 --
2042   - if(check_is_goods_selected) {
  2100 + if (check_is_goods_selected) {
2043 2101 var glist = ""; //用逗号隔开的
2044 2102 var map = new Map(); //使用map值键进行运算
2045 2103 var map_limit = new Map(); //使用map值键进行存储限购
... ... @@ -2055,7 +2113,7 @@ Page({
2055 2113 for (var j = 0; j < i_arr.length; j++) {
2056 2114 if (i_arr[j].selected && i_arr[j].is_gift != 1) {
2057 2115  
2058   - if (i_arr[j].is_pd_normal || i_arr[j].prom_type==0 || i_arr[j].prom_type==3) {
  2116 + if (i_arr[j].is_pd_normal || i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3) {
2059 2117 normal_arr[i_arr[j].goods_id] = 1;
2060 2118 }
2061 2119  
... ... @@ -2083,8 +2141,8 @@ Page({
2083 2141 glist += i_arr[j].goods_id + ",";
2084 2142 ab = 1;
2085 2143 //--普通商品,如果有开启线下库存的功能,要调用线下库存进行计算,赠品不要进行调用线下库存---
2086   - if ((i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3 || i_arr[j].prom_type == 5
2087   - || i_arr[j].need_downlow_num ) && th.data.sales_rules == 2 && i_arr[j].is_gift != 1) {
  2144 + if ((i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3 || i_arr[j].prom_type == 5 ||
  2145 + i_arr[j].need_downlow_num) && th.data.sales_rules == 2 && i_arr[j].is_gift != 1) {
2088 2146 //--获取商品的线下商品ID--
2089 2147 var gd = null;
2090 2148 await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + i_arr[j].goods_id, {}).then(res => {
... ... @@ -2254,7 +2312,7 @@ Page({
2254 2312 throw "商品价格已经变化";
2255 2313 }
2256 2314 } else {
2257   - if (g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price != val.prom_price && val.prom_price>0) {
  2315 + if (g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price != val.prom_price && val.prom_price > 0) {
2258 2316 isok = 0;
2259 2317 gname = val.goods_name;
2260 2318 throw "商品价格已经变化";
... ... @@ -2297,7 +2355,7 @@ Page({
2297 2355 }
2298 2356 }
2299 2357 });
2300   - }else{
  2358 + } else {
2301 2359 //-- 开始服务卡的购物车购买 --
2302 2360 for (var i = 0; i < this.data.service_data.length; i++) {
2303 2361 var i_arr = this.data.service_data[i].goods;
... ... @@ -2319,7 +2377,7 @@ Page({
2319 2377 },
2320 2378  
2321 2379 //结算到最后一个商品
2322   - set_last: function(ab, isok, gname) {
  2380 + set_last: function (ab, isok, gname) {
2323 2381 if (isok == 0) {
2324 2382 t.my_warnning(gname + "商品超出库存", 0, this);
2325 2383 } else {
... ... @@ -2331,7 +2389,7 @@ Page({
2331 2389  
2332 2390  
2333 2391 //图片失败,默认图片
2334   - bind_bnerr2: function(e) {
  2392 + bind_bnerr2: function (e) {
2335 2393 var _errImg = e.target.dataset.errorimg;
2336 2394 var _errurl = e.target.dataset.url;
2337 2395 var ii = _errurl.indexOf(oo.imghost);
... ... @@ -2342,13 +2400,13 @@ Page({
2342 2400 }
2343 2401 },
2344 2402 //设置点击按钮为true或者false
2345   - radio_chick: function(checked, num) {
  2403 + radio_chick: function (checked, num) {
2346 2404 var th = this;
2347 2405 var requestData = th.data.requestData;
2348 2406 },
2349 2407  
2350 2408 //点击编辑后的效果
2351   - edit_cart: function(e) {
  2409 + edit_cart: function (e) {
2352 2410 var type = parseFloat(e.currentTarget.dataset.type);
2353 2411 this.setData({
2354 2412 is_edit: type
... ... @@ -2356,13 +2414,14 @@ Page({
2356 2414 },
2357 2415  
2358 2416 //--多个删除购物车商品---
2359   - check_del: function() {
2360   - var glist = "",slist=''; //用逗号隔开的
  2417 + check_del: function () {
  2418 + var glist = "",
  2419 + slist = ''; //用逗号隔开的
2361 2420 var user_id = getApp().globalData.user_id;
2362 2421 var th = this;
2363 2422  
2364 2423 var ab = 0; //选中
2365   - var abc=0; //
  2424 + var abc = 0; //
2366 2425 for (var i = 0; i < this.data.requestData.length; i++) {
2367 2426 var i_arr = this.data.requestData[i].goods;
2368 2427 for (var j = 0; j < i_arr.length; j++) {
... ... @@ -2383,104 +2442,112 @@ Page({
2383 2442 }
2384 2443 }
2385 2444  
2386   - if (ab == 0 && abc==0) {
  2445 + if (ab == 0 && abc == 0) {
2387 2446 t.my_warnning("未选择商品或者服务卡", 0, th);
2388 2447 return false;
2389 2448 }
2390 2449  
2391   - if(ab){
  2450 + if (ab) {
2392 2451 glist = glist.substring(0, glist.length - 1);
2393 2452 //要删除购物车中的商品
2394 2453 var url = '/api/weshop/cart/delIds/' + oo.stoid + '/' + user_id + "/" + glist;
2395 2454 getApp().request.delete(url, {
2396   - success: function(t) {
2397   - // console.log('del done1111111111');
  2455 + success: function (t) {
  2456 + // console.log('del done1111111111');
2398 2457 th.getCardList();
2399   - getApp().requestCardNum(th);
2400   - // console.log('all================', th.data.all_num);
2401   - // getApp().globalData.cartGoodsNum =
  2458 + getApp().requestCardNum(th);
  2459 + // console.log('all================', th.data.all_num);
  2460 + // getApp().globalData.cartGoodsNum =
2402 2461 }
2403 2462 });
2404 2463 }
2405   - if(abc){
  2464 + if (abc) {
2406 2465 slist = slist.substring(0, slist.length - 1);
2407 2466 //要删除购物车中的商品
2408 2467 var url = '/api/weshop/cartService/delIds/' + oo.stoid + '/' + user_id + "/" + slist;
2409 2468 getApp().request.delete(url, {
2410   - success: function(t) {
  2469 + success: function (t) {
2411 2470 th.getCardList();
2412   - getApp().requestCardNum(th);
2413   - console.log('all2================', th.data.all_num);
  2471 + getApp().requestCardNum(th);
  2472 + console.log('all2================', th.data.all_num);
2414 2473 }
2415 2474 });
2416 2475 }
2417   -
  2476 +
2418 2477 },
2419 2478 //跳到首页
2420   - goto: function(e) {
2421   - var url='/pages/index/index/index';
2422   - getApp().goto(url);
  2479 + goto: function (e) {
  2480 + var url = '/pages/index/index/index';
  2481 + getApp().goto(url);
2423 2482 },
2424 2483  
2425 2484 //---加载更多是靠这个函数----
2426   - onReachBottom: function() {
2427   - if(this.data.requestData && this.data.requestData.length==0) {
  2485 + onReachBottom: function () {
  2486 + if (this.data.requestData && this.data.requestData.length == 0) {
2428 2487 var goods_list = this.selectComponent("#goods_list"); //组件的id
2429 2488 if (goods_list) goods_list.get_list();
2430 2489 }
2431 2490 },
2432 2491  
2433 2492 //检查莫个门店下的商品是不是优惠活动,有的话,看要不要送礼品,同时有没有倍增
2434   - check_prom_activity:async function (cindex) {
2435   - var make_up_arr=new Array();
2436   - var th=this;
2437   - var map=new Map();
2438   - var list= JSON.parse(JSON.stringify(this.data.requestData[cindex]));
  2493 + check_prom_activity: async function (cindex) {
  2494 + var make_up_arr = new Array();
  2495 + var th = this;
  2496 + var map = new Map();
  2497 + var list = JSON.parse(JSON.stringify(this.data.requestData[cindex]));
2439 2498 //循环处理活动,看活动商品的数量,用map来出来存储,key为活动id,值是数量
2440   -
2441   - //-- 所有的购物车的数据,要用拷贝的赖进行计算 --
2442   - var alllist= JSON.parse(JSON.stringify(this.data.requestData));
2443   - var list2=alllist[cindex];
2444   - var no_gift_arr=[];
2445   -
2446   - //主要判断有没有促销活动
2447   - var is_sele_prom=0;
2448   - var is_gift_del=0;
2449   - for(var i=0;i<list.goods.length;i++){
2450   - var item=list.goods[i];
2451   - if(item.prom_type==3 && item.selected && !item.is_gift){
2452   - is_sele_prom=1;
2453   - if(map.has(item.prom_id+"")){
2454   - var ob=map.get(item.prom_id+"");
2455   - ob.num+=item.goods_num;
2456   - ob.price+=item.goods_num*item.goods_price;
2457   - delete map[item.prom_id+""];
2458   - map.set(item.prom_id+"",ob);
2459   - }else{
2460   - var ob={};
2461   - ob.num=item.goods_num;
2462   - ob.price=item.goods_num*item.goods_price;
2463   - map.set(item.prom_id+"",ob);
  2499 +
  2500 + //-- 所有的购物车的数据,要用拷贝的赖进行计算 --
  2501 + var alllist = JSON.parse(JSON.stringify(this.data.requestData));
  2502 + var list2 = alllist[cindex];
  2503 + var no_gift_arr = [];
  2504 +
  2505 + //主要判断有没有促销活动
  2506 + var is_sele_prom = 0;
  2507 + var is_gift_del = 0;
  2508 + for (var i = 0; i < list.goods.length; i++) {
  2509 + var item = list.goods[i];
  2510 + if (item.prom_type == 3 && item.selected && !item.is_gift) {
  2511 + is_sele_prom = 1;
  2512 + if (map.has(item.prom_id + "")) {
  2513 + var ob = map.get(item.prom_id + "");
  2514 + ob.num += item.goods_num;
  2515 + ob.price += item.goods_num * item.goods_price;
  2516 + delete map[item.prom_id + ""];
  2517 + map.set(item.prom_id + "", ob);
  2518 + } else {
  2519 + var ob = {};
  2520 + ob.num = item.goods_num;
  2521 + ob.price = item.goods_num * item.goods_price;
  2522 + if (item.guide_id) {
  2523 + ob.guide_id = item.guide_id;
  2524 + }
  2525 + if (item.guide_type) {
  2526 + ob.guide_type = item.guide_type;
  2527 + }
  2528 + map.set(item.prom_id + "", ob);
2464 2529 }
2465 2530 }
2466   - if(item.is_gift==1){
  2531 + if (item.is_gift == 1) {
2467 2532 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
2468 2533 //getApp().request.delete(url, {});
2469   - await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除
2470   - list2.goods.splice(i,1);
2471   - list.goods.splice(i--,1);
2472   - is_gift_del=1;
  2534 + await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除
  2535 + list2.goods.splice(i, 1);
  2536 + list.goods.splice(i--, 1);
  2537 + is_gift_del = 1;
  2538 + }
  2539 + }
  2540 + //--如果没有选中的促销活动的,直接退出 --
  2541 + if (!is_sele_prom) {
  2542 + //如果有赠品,要重新更新购物车的前台渲染--
  2543 + if (is_gift_del) {
  2544 + var rq_text = "requestData[" + cindex + "]";
  2545 + this.setData({
  2546 + [rq_text]: list
  2547 + });
2473 2548 }
  2549 + return false;
2474 2550 }
2475   - //--如果没有选中的促销活动的,直接退出 --
2476   - if(!is_sele_prom){
2477   - //如果有赠品,要重新更新购物车的前台渲染--
2478   - if(is_gift_del){
2479   - var rq_text="requestData["+cindex+"]";
2480   - this.setData({[rq_text]:list});
2481   - }
2482   - return false;
2483   - }
2484 2551 /*--
2485 2552 var map2=new Map();
2486 2553 //请那些是赠品,但是优惠活动并没有被选中的商品要删除,同时满足条件的要放到map2,
... ... @@ -2499,20 +2566,20 @@ Page({
2499 2566 }
2500 2567 }--*/
2501 2568  
2502   - var t_prom_list=new Array();
2503   - for(let p_item of map.entries()){
2504   - var prom=null;
2505   - await getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+p_item[0],{}).then(res=> {
2506   - if(res.data.code==0){
2507   - prom=res.data.data;
  2569 + var t_prom_list = new Array();
  2570 + for (let p_item of map.entries()) {
  2571 + var prom = null;
  2572 + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + p_item[0], {}).then(res => {
  2573 + if (res.data.code == 0) {
  2574 + prom = res.data.data;
2508 2575 }
2509 2576 })
2510 2577 //如果活动已经结束
2511   - if(!prom || prom.is_end || prom.end_time<ut.gettimestamp() ){
2512   - for(var ii in list.goods){
2513   - var item=list.goods[ii];
2514   - list.goods.splice(ii,1);
2515   - if(item.prom_id==p_item[0] && item.prom_type==3){
  2578 + if (!prom || prom.is_end || prom.end_time < ut.gettimestamp()) {
  2579 + for (var ii in list.goods) {
  2580 + var item = list.goods[ii];
  2581 + list.goods.splice(ii, 1);
  2582 + if (item.prom_id == p_item[0] && item.prom_type == 3) {
2516 2583 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
2517 2584 getApp().request.delete(url, {});
2518 2585 }
... ... @@ -2522,8 +2589,9 @@ Page({
2522 2589  
2523 2590 t_prom_list.push(prom);
2524 2591 //---读取打折的详情---
2525   - var ob=p_item[1];var discount=null;
2526   - await getApp().request.promiseGet("/api/weshop/goods/getDiscount",{
  2592 + var ob = p_item[1];
  2593 + var discount = null;
  2594 + await getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
2527 2595 data: {
2528 2596 price: ob.price,
2529 2597 prom_id: p_item[0],
... ... @@ -2531,15 +2599,15 @@ Page({
2531 2599 user_id: getApp().globalData.user_id,
2532 2600 is_bz: prom.is_bz
2533 2601 }
2534   - }).then(res=>{
2535   - if(res.data.code==0) discount=res.data.data;
  2602 + }).then(res => {
  2603 + if (res.data.code == 0) discount = res.data.data;
2536 2604 })
2537 2605  
2538 2606 //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量---
2539   - if(discount && discount['goods_id'] && discount.limit_num>=discount.bs && discount.gift_storecount>=discount.bs){
2540   - //如果这礼品超了情况下
2541   - if(no_gift_arr.indexOf(discount.gift_id)!=-1) continue;
2542   - var o=discount.goodsinfo;
  2607 + if (discount && discount['goods_id'] && discount.limit_num >= discount.bs && discount.gift_storecount >= discount.bs) {
  2608 + //如果这礼品超了情况下
  2609 + if (no_gift_arr.indexOf(discount.gift_id) != -1) continue;
  2610 + var o = discount.goodsinfo;
2543 2611 var newd = {
2544 2612 goods_id: o.goods_id,
2545 2613 goods_num: discount.bs,
... ... @@ -2547,88 +2615,107 @@ Page({
2547 2615 user_id: app.globalData.user_id,
2548 2616 store_id: os.stoid,
2549 2617 goods_price: 0,
  2618 + guide_id:ob.guide_id?ob.guide_id:0,
  2619 + guide_type:ob.guide_type?ob.guide_type:0,
2550 2620 member_goods_price: 0,
2551 2621 goods_name: o.goods_name,
2552 2622 goods_sn: o.goods_sn,
2553 2623 sku: o.sku,
2554 2624 is_gift: 1,
2555   - prom_id:p_item[0],
2556   - prom_type:3,
2557   - selected:1,
2558   - gift_id:discount.gift_id,
2559   - original_img:th.data.imgUrl+o.original_img
  2625 + prom_id: p_item[0],
  2626 + prom_type: 3,
  2627 + selected: 1,
  2628 + gift_id: discount.gift_id,
  2629 + original_img: th.data.imgUrl + o.original_img
2560 2630 };
2561 2631  
2562   -
2563   - list2.goods.push(newd);
2564   - var all_num=0;
2565   - var all_limit_num=0;
2566   -
2567   - for(var i in alllist){
2568   - var list_item=alllist[i];
2569   - for(var j in list_item.goods){
2570   - //如果赠品的ID一样,要进行统计数量
2571   - if(list_item.goods[j].is_gift==1 && list_item.goods[j].gift_id==newd.gift_id){
2572   - all_num+= list_item.goods[j].goods_num;
2573   - }
2574   - if(list_item.goods[j].is_gift==1 && list_item.goods[j].gift_id==newd.gift_id && list_item.goods[j].prom_id==p_item[0]){
2575   - all_limit_num+= list_item.goods[j].goods_num;
2576   - }
2577   -
2578   - }
2579   - }
2580   -
2581   - //-- 赠品的数量超出库存数量和会员的限制,这里是保证所有的赠品部会超出 --
2582   - if(discount.gift_storecount<all_num || discount.limit_num<all_limit_num ){
2583   - no_gift_arr.push(discount.gift_id);
2584   - //--进入下一个循环 --
2585   - continue;
2586   - }
2587   -
2588   -
2589   - var url="/api/weshop/cart/delGift?store_id="+newd.store_id+"&user_id="
2590   - +newd.user_id+"&goods_id="+newd.goods_id+"&is_gift=1&pick_id="+newd.pick_id+"&prom_id="+newd.prom_id
  2632 + list2.goods.push(newd);
  2633 + var all_num = 0;
  2634 + var all_limit_num = 0;
  2635 +
  2636 + for (var i in alllist) {
  2637 + var list_item = alllist[i];
  2638 + for (var j in list_item.goods) {
  2639 + //如果赠品的ID一样,要进行统计数量
  2640 + if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id == newd.gift_id) {
  2641 + all_num += list_item.goods[j].goods_num;
  2642 + }
  2643 + if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id == newd.gift_id && list_item.goods[j].prom_id == p_item[0]) {
  2644 + all_limit_num += list_item.goods[j].goods_num;
  2645 + }
  2646 +
  2647 + }
  2648 + }
  2649 +
  2650 + //-- 赠品的数量超出库存数量和会员的限制,这里是保证所有的赠品部会超出 --
  2651 + if (discount.gift_storecount < all_num || discount.limit_num < all_limit_num) {
  2652 + no_gift_arr.push(discount.gift_id);
  2653 + //--进入下一个循环 --
  2654 + continue;
  2655 + }
  2656 +
  2657 +
  2658 + var url = "/api/weshop/cart/delGift?store_id=" + newd.store_id + "&user_id=" +
  2659 + newd.user_id + "&goods_id=" + newd.goods_id + "&is_gift=1&pick_id=" + newd.pick_id + "&prom_id=" + newd.prom_id
2591 2660 await getApp().request.promiseDelete(url, {})
2592 2661  
2593   - var add_data=null;
2594   - await getApp().request.promisePost("/api/weshop/cart/save", { data: newd }).then(res=>{
2595   - if(res.data.code==0){
2596   - add_data=res.data.data;
  2662 + var add_data = null;
  2663 + await getApp().request.promisePost("/api/weshop/cart/save", {
  2664 + data: newd
  2665 + }).then(res => {
  2666 + if (res.data.code == 0) {
  2667 + add_data = res.data.data;
2597 2668 }
2598 2669 })
2599   - if(add_data){
2600   - newd.id=add_data.id;
  2670 + if (add_data) {
  2671 + newd.id = add_data.id;
2601 2672 list.goods.push(newd);
2602   - }
  2673 + }
2603 2674 }
2604 2675  
2605 2676 }
2606 2677 //--更新购物车的前台渲染--
2607   - var rq_text="requestData["+cindex+"]";
2608   - this.setData({[rq_text]:list});
  2678 + var rq_text = "requestData[" + cindex + "]";
  2679 + this.setData({
  2680 + [rq_text]: list
  2681 + });
2609 2682  
2610   - if(!t_prom_list || t_prom_list.length==0 ) return false;
  2683 + if (!t_prom_list || t_prom_list.length == 0) return false;
2611 2684  
2612 2685 //-- 提示凑单的,放在最后显示 --
2613   - for(let prid in t_prom_list){
2614   - var prom=t_prom_list[prid];
  2686 + for (let prid in t_prom_list) {
  2687 + var prom = t_prom_list[prid];
2615 2688 //-- 获取凑单提示 --
2616   - await getApp().request.promiseGet("/api/weshop/promgoodslist/list",{
2617   - data:{prom_id:prom.id}
2618   - }).then(res=>{
2619   - if(res.data.code==0){
2620   - var list=res.data.data;
2621   - for(var i in list){
2622   - var item=list[i];
2623   - if(item.prom_type==0){
2624   - if(ob.price<item.condition){
2625   - var elem={prom_id:prom.id,diff_type:item.prom_type,diff:(item.condition-ob.price).toFixed(2), content:JSON.parse(item.preferential_type)}
2626   - make_up_arr.push(elem); break;
  2689 + await getApp().request.promiseGet("/api/weshop/promgoodslist/list", {
  2690 + data: {
  2691 + prom_id: prom.id
  2692 + }
  2693 + }).then(res => {
  2694 + if (res.data.code == 0) {
  2695 + var list = res.data.data;
  2696 + for (var i in list) {
  2697 + var item = list[i];
  2698 + if (item.prom_type == 0) {
  2699 + if (ob.price < item.condition) {
  2700 + var elem = {
  2701 + prom_id: prom.id,
  2702 + diff_type: item.prom_type,
  2703 + diff: (item.condition - ob.price).toFixed(2),
  2704 + content: JSON.parse(item.preferential_type)
  2705 + }
  2706 + make_up_arr.push(elem);
  2707 + break;
2627 2708 }
2628   - }else{
2629   - if(ob.num<item.condition){
2630   - var elem={prom_id:prom.id,diff_type:item.prom_type,diff:(item.condition-ob.num).toFixed(2), content:JSON.parse(item.preferential_type)}
2631   - make_up_arr.push(elem);break;
  2709 + } else {
  2710 + if (ob.num < item.condition) {
  2711 + var elem = {
  2712 + prom_id: prom.id,
  2713 + diff_type: item.prom_type,
  2714 + diff: (item.condition - ob.num).toFixed(2),
  2715 + content: JSON.parse(item.preferential_type)
  2716 + }
  2717 + make_up_arr.push(elem);
  2718 + break;
2632 2719 }
2633 2720 }
2634 2721 }
... ... @@ -2637,50 +2724,56 @@ Page({
2637 2724 }
2638 2725  
2639 2726  
2640   - var diff_text="requestData["+cindex+"].make_up_arr";
  2727 + var diff_text = "requestData[" + cindex + "].make_up_arr";
2641 2728 //-- 如果有凑单的话 --
2642   - if(make_up_arr.length>0){
2643   - this.setData({[diff_text]:make_up_arr});
2644   - }else{
2645   - this.setData({[diff_text]:null});
  2729 + if (make_up_arr.length > 0) {
  2730 + this.setData({
  2731 + [diff_text]: make_up_arr
  2732 + });
  2733 + } else {
  2734 + this.setData({
  2735 + [diff_text]: null
  2736 + });
2646 2737 }
2647 2738 },
2648 2739  
2649 2740 //去凑单
2650   - go_cou_dang:function (e) {
2651   - var prom_id=e.currentTarget.dataset.prom_id;
2652   - var url="/pages/goods/goodsList/goodsList?prom_type=3&prom_id="+prom_id;
  2741 + go_cou_dang: function (e) {
  2742 + var prom_id = e.currentTarget.dataset.prom_id;
  2743 + var url = "/pages/goods/goodsList/goodsList?prom_type=3&prom_id=" + prom_id;
2653 2744 getApp().goto(url);
2654 2745 },
2655 2746  
2656 2747 //导航跳转
2657   - nav_goto:function(e){
2658   - var url=e.currentTarget.dataset.url;
2659   - if(!url || url=='') return;
2660   - if(url[0]!='/') url='/'+url;
  2748 + nav_goto: function (e) {
  2749 + var url = e.currentTarget.dataset.url;
  2750 + if (!url || url == '') return;
  2751 + if (url[0] != '/') url = '/' + url;
2661 2752 getApp().goto(url);
2662 2753 },
2663 2754  
2664   - refresh_input:function(){
2665   - this.data.btn_click=0;
  2755 + refresh_input: function () {
  2756 + this.data.btn_click = 0;
  2757 + },
  2758 +
  2759 + imageLoad: function (e) {
  2760 + var imgwidth = e.detail.width;
  2761 + var imgheight = e.detail.height;
  2762 + //宽高比
  2763 + var ratio = imgwidth / imgheight;
  2764 + //计算的高度值
  2765 + var viewHeight = 715 / ratio;
  2766 + var hei = this.data.max_sw_height;
  2767 +
  2768 + if (hei < viewHeight) {
  2769 + this.setData({
  2770 + max_sw_height: viewHeight
  2771 + });
  2772 + }
2666 2773 },
2667   -
2668   - imageLoad:function(e){
2669   - var imgwidth = e.detail.width;
2670   - var imgheight = e.detail.height;
2671   - //宽高比
2672   - var ratio = imgwidth / imgheight;
2673   - //计算的高度值
2674   - var viewHeight = 715 / ratio;
2675   - var hei=this.data.max_sw_height;
2676   -
2677   - if (hei< viewHeight) {
2678   - this.setData({ max_sw_height: viewHeight });
2679   - }
2680   - },
2681   -
2682   - go_url(e){
2683   - var url=e.currentTarget.dataset.url;
  2774 +
  2775 + go_url(e) {
  2776 + var url = e.currentTarget.dataset.url;
2684 2777 getApp().goto(url);
2685 2778 },
2686 2779  
... ... @@ -2713,10 +2806,10 @@ Page({
2713 2806 }
2714 2807 getApp().goto(good_url);
2715 2808  
2716   - }else{
2717   - getApp().goto(good_url);
  2809 + } else {
  2810 + getApp().goto(good_url);
2718 2811 }
2719 2812 })
2720 2813 }
2721   -
  2814 +
2722 2815 });
2723 2816 \ No newline at end of file
... ...
pages/cart/cart/cart.wxml
... ... @@ -43,6 +43,7 @@
43 43 <view class="flex">
44 44 <view>总数量:</view>
45 45 <view class="goods_num">{{all_num}}</view>
  46 + <view wx:if="{{total_fee > 0 && freight_free - total_fee > 0}}" class="co-red weight_free">再买{{freight_free - total_fee}}元可享包邮({{weight_free}}kg内);</view>
46 47 </view>
47 48 <view wx:if="{{is_edit==0}}" bindtap="edit_cart" data-type="1">编辑</view>
48 49 <view wx:else bindtap="edit_cart" data-type="0">完成</view>
... ...
pages/cart/cart/cart.wxss
... ... @@ -234,6 +234,12 @@ radio {
234 234 margin-left: 13rpx;
235 235 }
236 236  
  237 +.login-in .weight_free {
  238 + font-size: 26rpx;
  239 + line-height: 48rpx;
  240 + margin-left: 30rpx;
  241 +}
  242 +
237 243 .allradio {
238 244 width: 600rpx;
239 245 height: 100%;
... ...
pages/cart/cart/zh_calculate.js
1 1 module.exports = {
2 2 //辅助数组添加元素功能
3   - find_in_add: function(list, ele) {
  3 + find_in_add: function (list, ele) {
4 4 for (var i in list) {
5 5 var item = list[i];
6 6 if (item.goods_id == ele.goods_id) {
... ... @@ -10,7 +10,7 @@ module.exports = {
10 10 list.push(ele);
11 11 },
12 12 //辅助数组添加元素功能
13   - find_in_remove: function(list, ele) {
  13 + find_in_remove: function (list, ele) {
14 14 for (var i in list) {
15 15 var item = list[i];
16 16 if (item.goods_id == ele.goods_id) {
... ... @@ -20,7 +20,7 @@ module.exports = {
20 20 },
21 21  
22 22 //主要是把组合购的商品分离出来
23   - add_zhprom: function(car, a, ele) {
  23 + add_zhprom: function (car, a, ele) {
24 24 var point = car[a];
25 25 if (point.zh_map) {
26 26 if (point.zh_map[ele.prom_id]) {
... ... @@ -42,7 +42,7 @@ module.exports = {
42 42 }
43 43 },
44 44 //未选中的商品,要从中剔除
45   - remove_zhprom: function(car, a, ele) {
  45 + remove_zhprom: function (car, a, ele) {
46 46 var point = car[a];
47 47 if (point.zh_map) {
48 48 if (point.zh_map[ele.prom_id]) {
... ... @@ -52,14 +52,14 @@ module.exports = {
52 52 },
53 53  
54 54 //把组合购的商品价格计算出来,同时每个会员都有购买组合商品的上限!zh_b_num是已经购买了多少件
55   - calculate_zh: function(car, a, th) {
  55 + calculate_zh: function (car, a, th) {
56 56 var car_item = car[a];
57 57 var tfeel = 0,
58 58 offline_price = 0,
59 59 offline_num = 0;
60 60 var txt = "requestData[" + a + "].need_list";
61   - //活动的列表都存储在这里面,可以快速查询
62   - var zh_prom_goods=car_item.zh_prom_goods;
  61 + //活动的列表都存储在这里面,可以快速查询
  62 + var zh_prom_goods = car_item.zh_prom_goods;
63 63 if (!car_item.zh_map || !zh_prom_goods) {
64 64 var res = {
65 65 tfeel: tfeel,
... ... @@ -71,7 +71,7 @@ module.exports = {
71 71 });
72 72 return res;
73 73 }
74   -
  74 +
75 75 //因为可能有多个组合购的活动
76 76 for (var i in car_item.zh_map) {
77 77 var bitem = car_item.zh_map[i];
... ... @@ -81,14 +81,13 @@ module.exports = {
81 81 var need_to_buy = 0;
82 82 var all_zhqty = 0; //所有商品要求起购数之和
83 83 var no_in_arr = []; //剩余的未加入组合购
84   - var out_arr=[]; //超出活动限购的商品放入
85   -
86   - var title =""; //提示语;
  84 + var out_arr = []; //超出活动限购的商品放入
  85 + var zhqty_bz = []; //超量
  86 + var title = ""; //提示语;
87 87 //var goods = bitem.goods;
88 88 var goods = zh_prom_goods[act.id];
89   -
90   - for (let v3 in car_item.goods) {
91   - car_item.goods[v3].need_downlow_num=0;
  89 + for (let v3 in car_item.goods) {
  90 + car_item.goods[v3].need_downlow_num = 0;
92 91 }
93 92  
94 93 //寻找一下
... ... @@ -102,71 +101,76 @@ module.exports = {
102 101 return 0;
103 102 }
104 103  
105   - //寻找一下
106   - function get_num2(ite) {
107   - for (let v2 in car_item.goods) {
108   - var vh = car_item.goods[v2];
109   - if (vh.goods_id == ite.goods_id) {
110   - return vh;
111   - }
112   - }
113   - return 0;
114   - }
  104 + //寻找一下
  105 + function get_num2(ite) {
  106 + for (let v2 in car_item.goods) {
  107 + var vh = car_item.goods[v2];
  108 + if (vh.goods_id == ite.goods_id) {
  109 + return vh;
  110 + }
  111 + }
  112 + return 0;
  113 + }
115 114  
116 115 for (var i in goods) {
117 116 var item = goods[i];
118   - item.goods_price=get_num(item).goods_price;
119   - item.offline_price=get_num(item).offline_price;
120   - var cart_num=get_num(item).goods_num;
121   - var zh_b_num=get_num2(item).zh_b_num;
122   - if(!cart_num) {
123   - if (item.zhqty) {
124   - title="必买商品未加购,下单立享【"+act.zhprice+"元任选"+act.zhbuyqty+"件】";
125   - need_to_buy += item.zhqty;
126   - }
127   - continue;
  117 + item.goods_price = get_num(item).goods_price;
  118 + item.offline_price = get_num(item).offline_price;
  119 + var cart_num = get_num(item).goods_num;
  120 + var zh_b_num = get_num2(item).zh_b_num;
  121 + if (!cart_num) {
  122 + if (item.zhqty) {
  123 + title = "必买商品未加购,下单立享【" + act.zhprice + "元任选" + act.zhbuyqty + "件】";
  124 + need_to_buy += item.zhqty;
  125 + }
  126 + continue;
128 127 }
129 128  
130   - item.cart_num =cart_num;
131   - //-- 当商品有购买的时候,以及有限购的时候 --
132   - if(item.buyqty>0){
133   -
134   - console.log(111,th.data.in_zhact_gdmap);
135   -
136   - var cbuy=item.buyqty-zh_b_num;
137   - var key=item.goods_id+""+act.id;
138   - if(th.data.in_zhact_gdmap[key]){
139   - var cbuy=item.buyqty-zh_b_num-th.data.in_zhact_gdmap[key];
140   - }
141   - //当可买的数量为0
142   - if(cbuy<=0){
143   - item.num=0;
144   - out_arr.push({
145   - price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num
146   - })
147   - }else{
148   - if(cbuy>=cart_num) item.num =cart_num;
149   - else{
150   - item.num =cbuy;
151   - out_arr.push({
152   - price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num-cbuy
153   - })
154   - }
155   - }
156   -
157   - }else{
158   - item.num =cart_num;
  129 + item.cart_num = cart_num;
  130 + //-- 当商品有购买的时候,以及有限购的时候 --
  131 + if (item.buyqty > 0) {
  132 + console.log(111, th.data.in_zhact_gdmap);
  133 + var cbuy = item.buyqty - zh_b_num;
  134 + var key = item.goods_id + "" + act.id;
  135 + if (th.data.in_zhact_gdmap[key]) {
  136 + var cbuy = item.buyqty - zh_b_num - th.data.in_zhact_gdmap[key];
  137 + }
  138 + //当可买的数量为0
  139 + if (cbuy <= 0) {
  140 + item.num = 0;
  141 + out_arr.push({
  142 + price: item.goods_price,
  143 + offline_price: item.offline_price,
  144 + goods_id: item.goods_id,
  145 + num: cart_num
  146 + })
  147 + } else {
  148 + if (cbuy >= cart_num) item.num = cart_num;
  149 + else {
  150 + item.num = cbuy;
  151 + out_arr.push({
  152 + price: item.goods_price,
  153 + offline_price: item.offline_price,
  154 + goods_id: item.goods_id,
  155 + num: cart_num - cbuy
  156 + })
  157 + }
  158 + }
  159 +
  160 + } else {
  161 + item.num = cart_num;
159 162 }
160 163  
161   - item.goods_price=get_num(item).goods_price;
162   - item.offline_price=get_num(item).offline_price;
163   - if(item.cart_num){
164   - all_price += item.cart_num * item.goods_price;
  164 + item.goods_price = get_num(item).goods_price;
  165 + item.offline_price = get_num(item).offline_price;
  166 + if (item.cart_num) {
  167 + all_price += item.cart_num * item.goods_price;
165 168 }
166 169 if (item.num) {
167 170 all_num += item.num;
168 171 //当有起购数的控制的时候
169 172 if (item.zhqty) {
  173 + zhqty_bz.push(item);
170 174 all_zhqty += item.zhqty;
171 175 if (item.num < item.zhqty) {
172 176 need_to_buy += item.zhqty - item.num;
... ... @@ -174,20 +178,24 @@ module.exports = {
174 178 if (item.num > item.zhqty) {
175 179 for (var i = 0; i < item.num - item.zhqty; i++) {
176 180 no_in_arr.push({
177   - price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id
  181 + price: item.goods_price,
  182 + offline_price: item.offline_price,
  183 + goods_id: item.goods_id
178 184 })
179 185 }
180 186 }
181 187 } else {
182 188 for (var j = 0; j < item.num; j++) {
183 189 no_in_arr.push({
184   - price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id
  190 + price: item.goods_price,
  191 + offline_price: item.offline_price,
  192 + goods_id: item.goods_id
185 193 })
186 194 }
187 195 }
188 196 } else {
189   - if (item.zhqty) {
190   - title="必买商品未加购,下单立享【"+act.zhprice+"元任选"+act.zhbuyqty+"件】";
  197 + if (item.zhqty) {
  198 + title = "必买商品未加购,下单立享【" + act.zhprice + "元任选" + act.zhbuyqty + "件】";
191 199 need_to_buy += item.zhqty;
192 200 }
193 201 }
... ... @@ -195,83 +203,97 @@ module.exports = {
195 203  
196 204 //当满足组合的要求:总数要满足,起购数要满足
197 205 if (all_num >= act.zhbuyqty && !need_to_buy) {
198   - //商品的列表
199   - for (var u in goods) {
200   - var ite=goods[u];
201   - if(ite.buyqty>0 && ite.num>0){
202   -
203   - console.log(222,th.data.in_zhact_gdmap);
204   -
205   - var key=ite.goods_id+""+act.id;
206   - if(th.data.in_zhact_gdmap[key]){
207   - th.data.in_zhact_gdmap[key]+=ite.num;
208   - }else{
209   - th.data.in_zhact_gdmap[key]=ite.num;
210   - }
211   - }
  206 + //商品的列表
  207 + for (var u in goods) {
  208 + var ite = goods[u];
  209 + if (ite.buyqty > 0 && ite.num > 0) {
  210 +
  211 + console.log(222, th.data.in_zhact_gdmap);
  212 +
  213 + var key = ite.goods_id + "" + act.id;
  214 + if (th.data.in_zhact_gdmap[key]) {
  215 + th.data.in_zhact_gdmap[key] += ite.num;
  216 + } else {
  217 + th.data.in_zhact_gdmap[key] = ite.num;
  218 + }
  219 + }
212 220 }
213 221  
214   - function sortData(a, b) {
215   - return a.price - b.price
216   - }
217   - if(no_in_arr.length>0) no_in_arr.sort(sortData);
  222 + function sortData(a, b) {
  223 + return a.price - b.price
  224 + }
  225 + if (no_in_arr.length > 0) no_in_arr.sort(sortData);
218 226  
219 227 var aprice = act.zhprice;
220 228 if (act.zhbuyqty > all_zhqty) {
221   - for (var n = 0; n < act.zhbuyqty-all_zhqty; n++) {
  229 + for (var n = 0; n < act.zhbuyqty - all_zhqty; n++) {
222 230 no_in_arr.pop();
223 231 }
224 232 }
225 233 //看一下剩下的数量有没有满足组合购的要求,以及要不要倍增
226 234 if (act.is_bz && no_in_arr.length >= act.zhbuyqty) {
227 235 //看一下是几倍
  236 + let num = 0;
  237 + let bz_num = 0;
228 238 var be = parseInt(no_in_arr.length / act.zhbuyqty);
229   - aprice += be * act.zhprice;
230   - for (var m = 0; m < be * act.zhbuyqty; m++) {
231   - no_in_arr.pop();
  239 + if (act.is_bzyh && zhqty_bz.length > 0) {
  240 + for (let i = 0; i < zhqty_bz.length; i++) {
  241 + let item = zhqty_bz[i];
  242 + bz_num = be * item.zhqty;
  243 + for (let j = 0; j < no_in_arr.length; j++) {
  244 + let i = no_in_arr[j];
  245 + if (item.goods_id === i.goods_id) {
  246 + num++
  247 + }
  248 + }
  249 + }
  250 + }
  251 + if (bz_num <= num) {
  252 + aprice += be * act.zhprice;
  253 + for (var m = 0; m < be * act.zhbuyqty; m++) {
  254 + no_in_arr.pop();
  255 + }
232 256 }
233 257 }
234 258 //算一下剩余的钱
235 259 if (no_in_arr.length) {
236 260 for (var ii in no_in_arr) {
237 261 var item = no_in_arr[ii];
238   - var gitem=get_num2(item);
239   - if(gitem) {
240   - if (!gitem.need_downlow_num) {
241   - gitem.need_downlow_num = 1;
242   - }
243   - else {
244   - gitem.need_downlow_num++;
245   - }
246   - aprice += item.price;
247   - if (item.offline_price) {
248   - offline_price += gitem.goods_price - gitem.offline_price;
249   - offline_num += 1;
250   - }
251   - }
  262 + var gitem = get_num2(item);
  263 + if (gitem) {
  264 + if (!gitem.need_downlow_num) {
  265 + gitem.need_downlow_num = 1;
  266 + } else {
  267 + gitem.need_downlow_num++;
  268 + }
  269 + aprice += item.price;
  270 + if (item.offline_price) {
  271 + offline_price += gitem.goods_price - gitem.offline_price;
  272 + offline_num += 1;
  273 + }
  274 + }
252 275 }
253 276 }
254 277  
255 278 //超量的部分也要计算一下
256   - if(out_arr.length){
257   - for (var m in out_arr) {
258   - var item = out_arr[m];
259   - var gitem=get_num2(item);
260   - if(gitem) {
261   - if (!gitem.need_downlow_num) {
262   - gitem.need_downlow_num = item.num;
263   - }
264   - else {
265   - gitem.need_downlow_num+=item.num;
266   - }
267   - aprice += item.price*item.num;
268   - if (item.offline_price && th.data.sales_rules==2) {
269   - offline_price += (gitem.goods_price - gitem.offline_price)*item.num;
270   - offline_num += item.num;
271   - }
  279 + if (out_arr.length) {
  280 + for (var m in out_arr) {
  281 + var item = out_arr[m];
  282 + var gitem = get_num2(item);
  283 + if (gitem) {
  284 + if (!gitem.need_downlow_num) {
  285 + gitem.need_downlow_num = item.num;
  286 + } else {
  287 + gitem.need_downlow_num += item.num;
  288 + }
  289 + aprice += item.price * item.num;
  290 + if (item.offline_price && th.data.sales_rules == 2) {
  291 + offline_price += (gitem.goods_price - gitem.offline_price) * item.num;
  292 + offline_num += item.num;
  293 + }
272 294  
273 295 }
274   - }
  296 + }
275 297 }
276 298  
277 299  
... ... @@ -291,16 +313,16 @@ module.exports = {
291 313 } else {
292 314 for (var ii in goods) {
293 315 var item = goods[ii];
294   - var gitem=get_num2(item);
295   - if(gitem && gitem.selected) {
  316 + var gitem = get_num2(item);
  317 + if (gitem && gitem.selected) {
296 318  
297   - gitem.need_downlow_num = gitem.goods_num;
  319 + gitem.need_downlow_num = gitem.goods_num;
298 320  
299   - if (item.offline_price && th.data.sales_rules==2) {
300   - offline_price += (item.goods_price - item.offline_price) * gitem.goods_num;
301   - offline_num += gitem.goods_num;
302   - }
303   - }
  321 + if (item.offline_price && th.data.sales_rules == 2) {
  322 + offline_price += (item.goods_price - item.offline_price) * gitem.goods_num;
  323 + offline_num += gitem.goods_num;
  324 + }
  325 + }
304 326 }
305 327 if (act.zhbuyqty - all_num > need_to_buy) {
306 328 need_to_buy = act.zhbuyqty - all_num;
... ... @@ -317,8 +339,8 @@ module.exports = {
317 339 }
318 340 } else {
319 341 var index = this.find_need_to(need_to, act);
320   - if(title=='')
321   - title = "再买" + need_to_buy + "件,下单立享【" + act.zhprice + "元任选" + act.zhbuyqty + "件】";
  342 + if (title == '')
  343 + title = "再买" + need_to_buy + "件,下单立享【" + act.zhprice + "元任选" + act.zhbuyqty + "件】";
322 344 if (index != -1) {
323 345 need_to[index].title = title;
324 346 } else {
... ... @@ -339,7 +361,7 @@ module.exports = {
339 361 tfeel += all_price;
340 362 }
341 363  
342   - console.log('nyf111');
  364 + console.log('nyf111');
343 365 console.log(car_item);
344 366  
345 367 var res = {
... ... @@ -352,7 +374,7 @@ module.exports = {
352 374  
353 375 },
354 376  
355   - find_need_to: function(list, iter) {
  377 + find_need_to: function (list, iter) {
356 378 if (!list || list.length <= 0) return -1;
357 379 for (var i in list) {
358 380 var item = list[i];
... ... @@ -364,30 +386,31 @@ module.exports = {
364 386 },
365 387  
366 388 //筛选组合购,纯粹的数组按活动id分组
367   - find_split: function(arr) {
  389 + find_split: function (arr) {
368 390 //过滤只有团购的商品
369   - var oarr = arr.goods.filter(function(ele) {
  391 + var oarr = arr.goods.filter(function (ele) {
370 392 return ele.prom_type == 7
371 393 })
372   - if(!oarr || oarr.length==0) return null;
  394 + if (!oarr || oarr.length == 0) return null;
373 395 //看一下有多少个不同的团购
374   - var map = {},dest = [];
  396 + var map = {},
  397 + dest = [];
375 398 for (var i = 0; i < oarr.length; i++) {
376 399 var ai = oarr[i];
377   - var index=map[ai.prom_id]
378   - if (!index) {
  400 + var index = map[ai.prom_id]
  401 + if (!index) {
379 402 dest.push({
380 403 prom_id: ai.prom_id,
381 404 data: [ai]
382 405 });
383   - map[ai.prom_id]=dest.length; //存储下标
384   - } else {
385   - var dj = dest[index-1];
386   - dj.data.push(ai);
  406 + map[ai.prom_id] = dest.length; //存储下标
  407 + } else {
  408 + var dj = dest[index - 1];
  409 + dj.data.push(ai);
387 410 }
388 411 }
389 412 return dest;
390 413 }
391 414  
392 415  
393 416 -}
  417 +}
394 418 \ No newline at end of file
... ...
pages/cart/cart2/cart2.js
... ... @@ -146,12 +146,20 @@ Page({
146 146 }
147 147 });
148 148  
149   - //阶梯购的立即购买
  149 + //阶梯购 或者 组合购的立即购买
150 150 if(t.state){
151 151 th.data.state=1;
152 152 }
153   -
154   -
  153 + getApp().promiseGet("/api/wx/weappSendlist/page", {
  154 + data: {
  155 + store_id: os.stoid,
  156 + typeid: "1001"
  157 + }}).then(res=>{
  158 + if (res.data.code == 0 && res.data.data.pageData.length > 0) {
  159 + var template_id = res.data.data.pageData[0].template_id;
  160 + th.setData({template_id:template_id});
  161 + }
  162 + })
155 163 },
156 164 onUnload: function () {
157 165 this.setData({isclose: 1})
... ... @@ -883,7 +891,6 @@ Page({
883 891 }
884 892 }
885 893  
886   -
887 894 gd.prom_type=gg.prom_type?gg.prom_type:0;
888 895 gd.prom_id=gg.prom_id?gg.prom_id:0;
889 896  
... ... @@ -1025,7 +1032,7 @@ Page({
1025 1032 th.data.old_cartlist = cart_arr;
1026 1033 }
1027 1034 th.setData({
1028   - bn_goods: t.data.data, bn_pickname: gg.pick_name, index: m_wind,
  1035 + bn_goods: gd, bn_pickname: gg.pick_name, index: m_wind,
1029 1036 bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
1030 1037 });
1031 1038  
... ... @@ -1333,7 +1340,7 @@ Page({
1333 1340 },
1334 1341  
1335 1342 //-------------------计算订单价格-------------------
1336   - calculatePrice: function (t, s) {
  1343 + calculatePrice : function (t, s) {
1337 1344 var th = this;
1338 1345 to.getConfig2(function (ee) {
1339 1346 to.getwuliuprice(async function (rs) {
... ... @@ -1353,10 +1360,11 @@ Page({
1353 1360  
1354 1361 var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0);
1355 1362 var freight_free = ee.freight_free; //全场满多少包邮
  1363 + var weight_free = ee.weight_free; //多少kg内包邮
1356 1364 var no_ex_id = ee.no_ex_id;
1357 1365 var no_ex_good = null;
1358 1366 var by_qc = {};
1359   -
  1367 + var out_of_weight=0; //超出多少重量
1360 1368 if (no_ex_id && freight_free > 0) {
1361 1369 //-----------获取不包邮区域,不包邮商品-------
1362 1370 await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
... ... @@ -1466,6 +1474,16 @@ Page({
1466 1474 o_price_no_zh += item[j].goods_price * item[j].goods_num;
1467 1475 }
1468 1476 o_price += item[j].goods_price * item[j].goods_num;
  1477 +
  1478 + //判断是否有设置限制重量包邮
  1479 + if(weight_free){
  1480 + if( item[j]['exp_sum_type']==2 ){
  1481 + if (goods_weight < 0) goods_weight = 0;
  1482 + //累积商品重量 每种商品的重量 * 数量
  1483 + goods_weight += item[j]['weight'] * item[j]['goods_num'];
  1484 + out_of_weight = (weight_free*1000) - goods_weight;
  1485 + }
  1486 + }
1469 1487 }
1470 1488 //判断是不是有组合购的金额
1471 1489 var f_o_price = o_price;
... ... @@ -1515,9 +1533,8 @@ Page({
1515 1533 //计算物流费用
1516 1534 cart_item.shipping_price = 0;
1517 1535  
1518   -
1519 1536 //--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额--
1520   - if (no_ex_id && freight_free > 0 && (o_price - quan_price) >= freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list)) {
  1537 + if (no_ex_id && freight_free > 0 && (o_price - quan_price) >= freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list) && out_of_weight > 0) {
1521 1538 //如果有设置不包邮区域的时候
1522 1539 if (by_qc.region_list != "" && by_qc.region_list != null && by_qc.region_list != undefined) {
1523 1540 if (th.check_by_area(by_qc.region_list)) {
... ... @@ -1640,13 +1657,13 @@ Page({
1640 1657 //统一运费
1641 1658 o_shipping_price += item[j]['uniform_exp_sum'];
1642 1659 break;
1643   - case 2:
1644   - +''
1645   - if (goods_weight < 0) goods_weight = 0;
1646   - //累积商品重量 每种商品的重量 * 数量
1647   - goods_weight += item[j]['weight'] * item[j]['goods_num'];
1648   -
1649   - break;
  1660 + // case 2: //1464行已计算 不必重复计算 注释为:判断是否有设置限制重量包邮
  1661 + // +''
  1662 + // if (goods_weight < 0) goods_weight = 0;
  1663 + // //累积商品重量 每种商品的重量 * 数量
  1664 + // goods_weight += item[j]['weight'] * item[j]['goods_num'];
  1665 + // out_of_weight = (weight_free*1000) - goods_weight;
  1666 + // break;
1650 1667 case 3:
1651 1668 if (goods_piece < 0) goods_piece = 0;
1652 1669 //累积商品数量
... ... @@ -1655,6 +1672,11 @@ Page({
1655 1672 }
1656 1673 }
1657 1674  
  1675 + }else{
  1676 + if(goods_weight && out_of_weight !==0){
  1677 + goods_weight=-1;
  1678 + out_of_weight=0;
  1679 + }
1658 1680 }
1659 1681 }
1660 1682  
... ... @@ -1665,7 +1687,7 @@ Page({
1665 1687 if (th.data.wu_arr && th.data.wu_arr[cart_item.wind])
1666 1688 code = th.data.wu_arr[cart_item.wind].code;
1667 1689 cart_item.shipping_price =
1668   - th.calculatewuliu(code, o_shipping_price, goods_weight,
  1690 + th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight,
1669 1691 goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs);
1670 1692  
1671 1693 if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) {
... ... @@ -1851,7 +1873,7 @@ Page({
1851 1873  
1852 1874  
1853 1875 //---------计算立即购买----------
1854   - calculatePrice2: function () {
  1876 + calculatePrice2 : function () {
1855 1877 var th = this, good = this.data.bn_goods;
1856 1878  
1857 1879 if (!good) return false;
... ... @@ -1893,7 +1915,11 @@ Page({
1893 1915 to.getConfig2(function (ee) {
1894 1916 to.getwuliuprice(async function (rs) {
1895 1917  
1896   - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
  1918 + var o_shipping_price = 0,goods_weight = -1,goods_piece = -1;
  1919 + var out_of_weight=null; //超出多少重量
  1920 + var freight_free = ee.freight_free; //全场满多少包邮
  1921 + var weight_free = ee.weight_free; //多少kg内包邮
  1922 + var no_ex_id = ee.no_ex_id;
1897 1923  
1898 1924 //---如果有选择优惠券的情况下---
1899 1925 var quan_price = 0, bn_pick = th.data.bn_pick;
... ... @@ -1959,8 +1985,10 @@ Page({
1959 1985 break;
1960 1986 case 2:
1961 1987 if (goods_weight < 0) goods_weight = 0;
  1988 + //dw
1962 1989 //累积商品重量 每种商品的重量 * 数量
1963 1990 goods_weight += good['weight'] * good['buynum'];
  1991 + out_of_weight = (weight_free * 1000 ) - goods_weight;
1964 1992 break;
1965 1993 case 3:
1966 1994 if (goods_piece < 0) goods_piece = 0;
... ... @@ -1971,8 +1999,7 @@ Page({
1971 1999  
1972 2000 var code = "";
1973 2001 if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
1974   - var freight_free = ee.freight_free; //全场满多少包邮
1975   - var no_ex_id = ee.no_ex_id;
  2002 +
1976 2003 th.data.is_no_by[th.data.bn_pick] = 0;
1977 2004  
1978 2005 var no_by_data = null;
... ... @@ -2008,12 +2035,12 @@ Page({
2008 2035 th.data.is_by[th.data.bn_pick] = 0;
2009 2036 //--------------开始计算物流------------------
2010 2037 var shipping_price =
2011   - th.calculatewuliu(code, o_shipping_price, goods_weight,
  2038 + th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight,
2012 2039 goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs);
2013 2040  
2014 2041 //如果有赠品的时候,也要计算赠品的物流费用
2015 2042 if (th.data.buy_now_gift_goods) {
2016   - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,
  2043 + shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,out_of_weight,
2017 2044 parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece);
2018 2045 }
2019 2046  
... ... @@ -2186,10 +2213,26 @@ Page({
2186 2213 });
2187 2214 },
2188 2215  
2189   - //--------------------提交订单-----------------------
2190   - async submitForm(t){
2191   - var sub_value = t;
  2216 + requestSubscribe(){
  2217 + const th=this;
  2218 + const template_id = this.data.template_id;
  2219 + wx.getSetting({
  2220 + withSubscriptions:true,
  2221 + success(res){
  2222 + let itemSettings=res.subscriptionsSetting.itemSettings;
  2223 + if(itemSettings && itemSettings[template_id]=="accept"){
  2224 + th.submit_func();
  2225 + }else{
  2226 + th.sendsm(function(){
  2227 + th.submit_func();
  2228 + })
  2229 + }
  2230 + }
  2231 + })
  2232 + },
2192 2233  
  2234 + //--------------------提交订单-----------------------
  2235 + async submit_func(){
2193 2236 if (this.data.is_summit_ing == 1) return false; //--提交中退出--
2194 2237 this.data.is_summit_ing = 1;
2195 2238 var th = this, pdata = new Array();
... ... @@ -2233,7 +2276,7 @@ Page({
2233 2276 'user_money': th.data.formData.user_money, //使用余额
2234 2277 'total_amount': th.data.formData.total_amount, //订单总价
2235 2278 'order_amount': th.data.formData.order_amount, //应付
2236   - 'user_note': t.detail.value.user_note, //用户备注
  2279 + 'user_note': th.data.user_note, //用户备注
2237 2280 'store_id': oo.stoid, //商家
2238 2281 'pickup_id': th.data.bn_pick, //门店
2239 2282 'exp_type': th.data.bn_exp_type, //配送方式
... ... @@ -2432,7 +2475,7 @@ Page({
2432 2475  
2433 2476 var addr = th.data.user_addr;
2434 2477 if (th.data.is_all_zt == 1) addr = null;
2435   - var val_arr = t.detail.value;
  2478 + var val_arr = th.data.user_note;
2436 2479  
2437 2480 if (th.data.is_all_zt != 1)
2438 2481 if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
... ... @@ -2465,7 +2508,7 @@ Page({
2465 2508 'user_money': t_item.user_money, //使用余额
2466 2509 'total_amount': t_item.total_amount, //订单总价
2467 2510 'order_amount': t_item.order_amount, //应付
2468   - 'user_note': val_arr['user_note_' + t_item.pickup_id], //用户备注
  2511 + 'user_note': val_arr[i], //用户备注
2469 2512 'store_id': oo.stoid, //商家
2470 2513 'pickup_id': t_item.pickup_id, //门店
2471 2514 'exp_type': t_item.exp_type, //配送方式
... ... @@ -2774,7 +2817,7 @@ Page({
2774 2817 } else if (res.confirm) {
2775 2818 th.data.is_continue = 1;
2776 2819 th.data.is_summit_ing = 0; //是否提交中
2777   - th.submitForm(sub_value);
  2820 + th.submit_func();
2778 2821 }
2779 2822 }
2780 2823 })
... ... @@ -2966,12 +3009,12 @@ Page({
2966 3009 th.calculatePrice();
2967 3010 },
2968 3011 //-------------------计算物流---------------
2969   - calculatewuliu: function (code, o_shipping_price, goods_weight,
  3012 + calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight,
2970 3013 goods_piece, user_addr, freight_free, o_price, rs) {
2971 3014 var price = 0, th = this;
2972 3015 price += parseFloat(o_shipping_price);
2973 3016 //如果是包邮
2974   - if (freight_free > 0 && o_price >= freight_free) {
  3017 + if (freight_free > 0 && o_price >= freight_free && out_of_weight>0) {
2975 3018 return 0;
2976 3019 }
2977 3020 if (user_addr == null) {
... ... @@ -2989,7 +3032,7 @@ Page({
2989 3032 item = item.config;
2990 3033 if (item == null) return o_shipping_price;
2991 3034 //------按重量----------
2992   - if (goods_weight >= 0 && item['money']) {
  3035 + if (goods_weight >= 0 && item['money'] && out_of_weight > 0) {
2993 3036 fw_price = parseFloat(item['money']);
2994 3037 if (goods_weight > item['first_weight']) {
2995 3038 var fw = goods_weight - item['first_weight'];
... ... @@ -2997,6 +3040,13 @@ Page({
2997 3040 fw_price = fw_price + n * parseFloat(item['add_money']);
2998 3041 }
2999 3042 }
  3043 + //------超出重量----------
  3044 + if(out_of_weight < 0){
  3045 + fw_price = parseFloat(item['money']);
  3046 + var out_of_weight = Math.abs(out_of_weight);
  3047 + var n = Math.ceil(out_of_weight / item['second_weight'])
  3048 + fw_price = fw_price + n * parseFloat(item['add_money']);
  3049 + }
3000 3050 //------按件数----------
3001 3051 if (goods_piece > 0 && item['piecemoney']) {
3002 3052 fp_price = parseFloat(item['piecemoney']);
... ... @@ -3875,7 +3925,7 @@ Page({
3875 3925 },
3876 3926  
3877 3927 //计算立即购买赠品的物流费用
3878   - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
  3928 + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
3879 3929 var good = this.data.buy_now_gift_goods;
3880 3930 var goods_weight = -1, goods_piece = -1;
3881 3931 var gift_shipping_price = 0;
... ... @@ -3892,6 +3942,7 @@ Page({
3892 3942 goods_weight += good['weight'] * good['buynum'];
3893 3943 if (goods_weight1 > 0) {
3894 3944 goods_weight += goods_weight1;
  3945 + out_of_weight = (gift_weight_free*1000) - goods_weight;
3895 3946 }
3896 3947 break;
3897 3948 case 3:
... ... @@ -3921,7 +3972,7 @@ Page({
3921 3972 }
3922 3973  
3923 3974 var t_shipping_price =
3924   - this.calculatewuliu(code, gift_shipping_price, goods_weight,
  3975 + this.calculatewuliu(code, gift_shipping_price, goods_weight,out_of_weight,
3925 3976 goods_piece, user_addr, gift_freight_free, allpice, rs);
3926 3977 return t_shipping_price;
3927 3978  
... ... @@ -4042,17 +4093,17 @@ Page({
4042 4093 });
4043 4094 },
4044 4095  
4045   - set_hid_inp:function (e) {
4046   - var index = e.currentTarget.dataset.index;
4047   - var txt = "cartlist[" + index + "].focus";
4048   - this.setData({[txt]:1})
4049   - },
4050   -
4051   - clear_hid_inp:function (e) {
4052   - var index = e.currentTarget.dataset.index;
4053   - var txt = "cartlist[" + index + "].focus";
4054   - this.setData({[txt]:0})
4055   - },
  4096 + // set_hid_inp:function (e) {
  4097 + // var index = e.currentTarget.dataset.index;
  4098 + // var txt = "cartlist[" + index + "].focus";
  4099 + // this.setData({[txt]:1})
  4100 + // },
  4101 + //
  4102 + // clear_hid_inp:function (e) {
  4103 + // var index = e.currentTarget.dataset.index;
  4104 + // var txt = "cartlist[" + index + "].focus";
  4105 + // this.setData({[txt]:0})
  4106 + // },
4056 4107  
4057 4108 go_url:function (e) {
4058 4109 var url = e.currentTarget.dataset.url;
... ... @@ -4124,7 +4175,23 @@ Page({
4124 4175 }
4125 4176 }
4126 4177 }
4127   - }
  4178 + },
  4179 + //订阅消息提醒
  4180 + sendsm:function(func)
  4181 + {
  4182 + var template_id = this.data.template_id;
  4183 + // //授权订阅
  4184 + wx.requestSubscribeMessage({
  4185 + tmplIds: [template_id],
  4186 + success(res) {
  4187 + func();
  4188 + },
  4189 + fail(res) {
  4190 + func();
  4191 + }
  4192 + })
  4193 +
  4194 + },
4128 4195  
4129 4196  
4130 4197 });
... ...
pages/cart/cart2/cart2.wxml
... ... @@ -2,38 +2,38 @@
2 2 <wxs src="filter.wxs" module="util"></wxs>
3 3 <wxs module="filters" src="../../../utils/filter.wxs"></wxs>
4 4  
5   -<form bindsubmit="submitForm">
  5 +<form>
6 6 <view class="container">
7   -
  7 +
8 8 <!-- 立即购买的时候 -->
9 9 <block wx:if="{{is_b_now==1}}">
10 10 <view class="tab-container">
11   - <view class="tab-wrapper">
12   - <view hidden="{{bn_t_exp_t==2}}" bindtap='setexptype' data-t='1' class="tab {{bn_exp_type == 1? 'active':''}}"
  11 + <view class="tab-wrapper">
  12 + <view hidden="{{bn_t_exp_t==2}}" bindtap='setexptype' data-t='1' class="tab {{bn_exp_type == 1? 'active':''}}"
13 13 data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >门店自提</view>
14   -
15   - <view hidden="{{bn_t_exp_t==1}}" bindtap='setexptype' data-t='0' class="tab {{bn_exp_type== 0 ? 'active':''}}"
  14 +
  15 + <view hidden="{{bn_t_exp_t==1}}" bindtap='setexptype' data-t='0' class="tab {{bn_exp_type== 0 ? 'active':''}}"
16 16 data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >快递邮寄</view>
17   -
  17 +
18 18 </view>
19 19 </view>
20   - </block>
  20 + </block>
21 21 <!-- 购物购买只有一单的时候 -->
22 22 <block wx:if="{{is_b_now==0 && cartlist.length==1}}">
23 23 <view class="tab-container">
24   - <view class="tab-wrapper">
25   - <view hidden="{{cartlist[0].distr_t==2}}" bindtap='setexptype_w' data-ind="0" data-t='1' class="tab {{cartlist[0].exp_type == 1? 'active':''}}"
  24 + <view class="tab-wrapper">
  25 + <view hidden="{{cartlist[0].distr_t==2}}" bindtap='setexptype_w' data-ind="0" data-t='1' class="tab {{cartlist[0].exp_type == 1? 'active':''}}"
26 26 data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >门店自提</view>
27   -
28   - <view hidden="{{cartlist[0].distr_t==1}}" bindtap='setexptype_w' data-ind="0" data-t='0' class="tab {{cartlist[0].exp_type== 0 ? 'active':''}}"
  27 +
  28 + <view hidden="{{cartlist[0].distr_t==1}}" bindtap='setexptype_w' data-ind="0" data-t='0' class="tab {{cartlist[0].exp_type== 0 ? 'active':''}}"
29 29 data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >快递邮寄</view>
30   -
  30 +
31 31 </view>
32 32 </view>
33   - </block>
34   -
35   -
36   - <!--要进行判断地址是否显示---->
  33 + </block>
  34 +
  35 +
  36 + <!--要进行判断地址是否显示---->
37 37 <view bindtap="enterAddressPage" class="user-mes mgt20" hidden='{{(bn_exp_type==1 && is_b_now==1) || (is_all_zt==1 && is_b_now==0)}}'>
38 38 <!---默认地址显示------>
39 39 <block wx:if="{{user_addr!=null}}">
... ... @@ -49,7 +49,7 @@
49 49 </view>
50 50 {{user_addr.more_address}}{{' '}}{{user_addr.address}}
51 51 </view>
52   -
  52 +
53 53 </view>
54 54 <view class="update-logistics">
55 55 <!-- <image class="arrow-rigth" src="{{imgUrl}}/miniapp/images/new_position.png"></image> -->
... ... @@ -108,19 +108,19 @@
108 108 <view class="card_bg ellipsis-1" style="margin-right: 10rpx;">
109 109 <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"></ image>
110 110 <text class="card_name">{{show_card.CardName}}</text>
111   - </view>
  111 + </view>
112 112 <view>立减 <text style="color:#f23030;">{{filters.toFix(item.card_cut_price,2) }}</text> 元</view>
113 113 </view>
114 114 <view>
115 115 <text style="color: #999;margin-left: 4rpx;">vip超级会员仅需{{show_card.CardFee}}元</text>
116   - </view>
  116 + </view>
117 117 <!-- 三角形 -->
118 118 <view class="car_tri_up"></view>
119 119 <!-- 立即开通跳转 -->
120   - <view bindtap="buycard" class="card_op">立即开通</view>
121   - </view>
122   -
123   -
  120 + <view bindtap="buycard" class="card_op">立即开通</view>
  121 + </view>
  122 +
  123 +
124 124 <!-----使用优惠券------>
125 125 <view class="xc-coupon-frame flex-center" data-bn="0" bindtap="open_coupon_list" wx:if="{{(item.quan_list && item.quan_list.length>0) || get_by_quan_list_cart[item.pickup_id]!=null}}"
126 126 data-cind="{{pidx}}" data-pickid="{{item.pickup_id}}">
... ... @@ -141,14 +141,14 @@
141 141 <icon color="#f23030" size="16" type="info"></icon>
142 142 {{order.store_prom}}
143 143 </view>
144   -
  144 +
145 145 <!-- 当是物流很多单的时候 -->
146 146 <view class="use-item flex-space-between" wx:if="{{cartlist.length>1}}">
147 147 <view class="flex-vertical" >
148   - <view bindtap='setexptype_w' data-ind="{{pidx}}" data-t='1' data-txt='cartlist[{{pidx}}].exp_type'
  148 + <view bindtap='setexptype_w' data-ind="{{pidx}}" data-t='1' data-txt='cartlist[{{pidx}}].exp_type'
149 149 style="padding-right:26rpx;display:{{item.distr_t==2?'none':'flex;align-items: center'}};">
150 150 <!-- <icon bindtap='setexptype_w' data-t='1' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==1?'red':'gray'}}" size="16" type="success"></icon> -->
151   -
  151 +
152 152 <block wx:if="{{item.exp_type==1}}">
153 153 <!-- <view class="circle white xc-hookt fs20 red-b sn"><text>Γ</text></view> -->
154 154 <icon data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="red" size="16" type="success"></icon>
... ... @@ -158,7 +158,7 @@
158 158 </block>
159 159 <view bindtap='setexptype_w' data-ind="{{pidx}}" data-t='1' data-txt='cartlist[{{pidx}}].exp_type' class="yu_er">门店自提</view>
160 160 </view>
161   -
  161 +
162 162 <view data-t='0' data-txt='cartlist[{{pidx}}].exp_type' data-ind="{{pidx}}" bindtap="setexptype_w" style="display:{{item.distr_t==1?'none':'flex;align-items: center'}};">
163 163 <!-- <icon bindtap='setexptype_w' data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==0?'red':'gray'}}" size="16" type="success"></icon> -->
164 164 <block wx:if="{{item.exp_type==0}}">
... ... @@ -168,49 +168,49 @@
168 168 <block wx:else>
169 169 <view class="circle xc-hookts on"></view>
170 170 </block>
171   -
  171 +
172 172 <view bindtap='setexptype_w' data-t='0' data-ind="{{pidx}}" data-txt='cartlist[{{pidx}}].exp_type' data-wl_txt='cartlist[{{pidx}}].wind'
173 173 class="yu_er">快递邮寄</view>
174 174 </view>
175 175 </view>
176   -
177   -
  176 +
  177 +
178 178 <!-- 点击显示物流选择,如果是默认使用的情况不成立 -->
179 179 <view wx:if="{{!is_default_logistics && item.exp_type!=1}}" class="flex-vertical" bindtap="show_wu_arr" data-txt='cartlist[{{pidx}}].wind' data-w_sele_index="{{pidx}}" style="padding-right:6rpx;">
180 180 <view>{{wu_arr[item.wind].name}}</view>
181 181 <view class="xc-right"></view>
182 182 </view>
183   -
  183 +
184 184 </view>
185   -
  185 +
186 186 <!-- 当是物流,只有一单的时候 -->
187   - <block wx:else >
188   - <view class="use-item flex-space-between" wx:if="{{item.exp_type==0 && !is_default_logistics}}">
  187 + <block wx:else >
  188 + <view class="use-item flex-space-between" wx:if="{{item.exp_type==0 && !is_default_logistics}}">
189 189 <view class="flex jc_sb" style="width: 100%; padding: 0 13rpx;">
190 190 <view>选择物流</view>
191 191 <view class="flex-vertical" bindtap="show_wu_arr" data-txt='cartlist[{{pidx}}].wind' data-w_sele_index="{{pidx}}" style="padding-right:6rpx;">
192 192 <view>{{wu_arr[item.wind].name}}</view>
193 193 <view class="xc-right"></view>
194 194 </view>
195   - </view>
196   - </view>
197   - </block>
198   -
199   -
  195 + </view>
  196 + </view>
  197 + </block>
  198 +
  199 +
200 200 </view>
201 201  
202 202 <!-- 留言 -->
203 203 <view class="coupon-mes flex-vertical">
204 204 <view>留言</view>
205 205 <view class="leave-word">
206   - <input hidden="{{!item.focus}}" bindinput="keyUpChangeNum" disabled="{{disabled}}"
207   - data-index="{{index}}" bindblur="clear_hid_inp" focus="{{item.focus}}" value="{{user_note[index]}}"
  206 + <input placeholder="给商家留言,最多100字" bindinput="keyUpChangeNum"
  207 + data-index="{{pidx}}" value="{{user_note[pidx]}}"
208 208 class="word-box" maxlength="100" name="user_note_{{item.pickup_id}}" />
209 209  
210   - <view class="{{user_note[index]?'':'c-a'}}" style="width: 80%;font-size: 26rpx" data-index="{{index}}"
211   - bindtap="set_hid_inp" wx:if="{{!item.focus}}">
212   - {{user_note[index]?user_note[index]:'给商家留言,最多100字'}}
213   - </view>
  210 +<!-- <view class="{{user_note[index]?'':'c-a'}}" style="width: 80%;font-size: 26rpx" data-index="{{index}}"-->
  211 +<!-- bindtap="set_hid_inp" wx:if="{{!item.focus}}">-->
  212 +<!-- {{user_note[index]?user_note[index]:}}-->
  213 +<!-- </view>-->
214 214 </view>
215 215 </view>
216 216  
... ... @@ -329,18 +329,18 @@
329 329 <view class="card_bg ellipsis-1" style="margin-right: 10rpx;">
330 330 <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"></ image>
331 331 <text class="card_name">{{show_card.CardName}}</text>
332   - </view>
  332 + </view>
333 333 <view>立减 <text style="color:#f23030;">{{filters.toFix(card_cut_price,2) }}</text> 元</view>
334 334 </view>
335 335 <view>
336 336 <text style="color: #999;margin-left: 4rpx;">vip超级会员仅需{{show_card.CardFee}}元</text>
337   - </view>
  337 + </view>
338 338 <!-- 三角形 -->
339 339 <view class="car_tri_up"></view>
340 340 <!-- 立即开通跳转 -->
341   - <view bindtap="buycard" class="card_op">立即开通</view>
342   - </view>
343   -
  341 + <view bindtap="buycard" class="card_op">立即开通</view>
  342 + </view>
  343 +
344 344  
345 345 <view class="set-mes bdr_b-14">
346 346 <view wx:if="{{order.store_prom}}">
... ... @@ -363,41 +363,41 @@
363 363 </view>
364 364 </view>
365 365  
366   - <view class="xc-coupon-frame" wx:if="{{bn_exp_type==0 && !is_default_logistics}}">
  366 + <view class="xc-coupon-frame" wx:if="{{bn_exp_type==0 && !is_default_logistics}}">
367 367 <view class="flex-space-between" style="padding: 20rpx 25rpx; font-size: 30rpx;">
368   - <view>选择物流</view>
  368 + <view>选择物流</view>
369 369 <view class="flex-vertical" bindtap="show_wu_arr" data-txt='index' style="margin-right: 12rpx;">
370 370 <view class="logistics-name">{{wu_arr[index].name}}</view>
371 371 <view class="xc-right"></view>
372 372 </view>
373   - </view>
  373 + </view>
374 374 </view>
375 375 </view>
376 376 <!-- 留言 -->
377   - <view class="coupon-mes flex-vertical">
378   - <view>留言</view>
379   - <view class="leave-word">
380   - <input placeholder-class="fs28" placeholder='给商家留言,最多100字' bindinput="keyUpChangeNum" disabled="{{disabled}}"
381   - class="word-box" maxlength="100" name="user_note"></input>
382   - </view>
383   - </view>
384   -
  377 +<!-- <view class="coupon-mes flex-vertical">-->
  378 +<!-- <view>留言</view>-->
  379 +<!-- <view class="leave-word">-->
  380 +<!-- <input placeholder-class="fs28" placeholder='给商家留言,最多100字' bindinput="keyUpChangeNum" disabled="{{disabled}}"-->
  381 +<!-- class="word-box" maxlength="100" name="user_note"></input>-->
  382 +<!-- </view>-->
  383 +<!-- </view>-->
  384 +
385 385 <!-- 是否参与店铺优惠 -->
386 386 <view class="coupon-mes flex-vertical" bindtap="bn_pop_offline" wx:if="{{bn_goods.offline_price}}">
387 387 <view>店铺优惠</view>
388 388 <view class="leave-word fs32" style="color: #999;">
389 389 省{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}元
390   - </view>
  390 + </view>
391 391 <block wx:if="{{bn_goods.is_offline}}">
392   - <text style="color: #d7642b;">-¥{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}</text>
  392 + <text style="color: #d7642b;">-¥{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}</text>
393 393 </block>
394 394 <block wx:else>
395   - <text style="color: #d7642b;">不使用优惠</text>
  395 + <text style="color: #d7642b;">不使用优惠</text>
396 396 </block>
397 397 <!-- 右边点击 -->
398 398 <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view>
399 399 </view>
400   -
  400 +
401 401  
402 402 <!-----使用余额------>
403 403 <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}">
... ... @@ -406,7 +406,7 @@
406 406 <view class="yu_er">使用余额 :¥{{yuer}} </view>
407 407 </view>
408 408 </view>
409   -
  409 +
410 410 </block>
411 411  
412 412 <view class="information bdr14">
... ... @@ -455,7 +455,7 @@
455 455 <view class="payable">应付金额:<text class="co-red"><text class="fs24">¥</text>{{formData.order_amount}}</text></view>
456 456 <!-- <view class="co-red big"></view> -->
457 457 </view>
458   - <button class="tips-btn" formType="submit" id="submitOrder">提交订单</button>
  458 + <button class="tips-btn" formType="submit" id="submitOrder" bindtap="requestSubscribe">提交订单</button>
459 459 </view>
460 460 </form>
461 461  
... ... @@ -671,9 +671,9 @@
671 671 <view style="background-color: #fff; width: 540rpx; margin: 0 auto; border-radius: 20rpx;">
672 672 <view class="fs32" style="text-align: center;height: 80rpx; line-height: 80rpx;">店铺优惠</view>
673 673 <view class="flex jc_sb ai-center fs28" style="height: 80rpx; width: 400rpx; margin-left: 70rpx;">
674   - <view catchtap="sure_offline" class="flex ai-center" >优惠¥{{show_off_price}}
  674 + <view catchtap="sure_offline" class="flex ai-center" >优惠¥{{show_off_price}}
675 675 <icon style="margin-left: 10rpx;" color="{{is_get_offline?'red':'gray'}}" size="14" type="success" role="img"></icon></view>
676   - <view catchtap="cancle_offline" class="flex ai-center" >不用优惠
  676 + <view catchtap="cancle_offline" class="flex ai-center" >不用优惠
677 677 <icon style="margin-left: 10rpx;" color="{{is_get_offline!=1?'red':'gray'}}" size="14" type="success" role="img"></icon> </view>
678 678 </view>
679 679 </view>
... ...
pages/cart/cart2/zh_calculate.js
... ... @@ -2,15 +2,18 @@ var regeneratorRuntime = require(&#39;../../../utils/runtime.js&#39;);
2 2 module.exports = {
3 3 //主要的作用,就是把组合购多余的商品进行拆分,
4 4 //如果没有达成组合购的要求,所有的商品都打回原价购买
5   - fir_set_arr: function (c_item,th) {
  5 + fir_set_arr: function (c_item, th) {
6 6 //组合活动,以及组合活动从表的商品
7 7 let zh_prom_goods = c_item.zh_prom_goods;
8   - let goods = c_item.goods; //一个门店中所有的商品
9   - let tfeel = 0,cut_price=0, offline_price = 0, offline_num = 0;
  8 + let goods = c_item.goods; //一个门店中所有的商品
  9 + let tfeel = 0,
  10 + cut_price = 0,
  11 + offline_price = 0,
  12 + offline_num = 0;
10 13 let txt_ite = c_item.need_list;
11 14 //多个活动要拿来循环一下
12 15 for (let i in zh_prom_goods) {
13   - let title = ""; //提示语;
  16 + let title = ""; //提示语;
14 17 //其中的一个活动
15 18 let act_item = zh_prom_goods[i];
16 19 let act_goos = act_item.gdlist;
... ... @@ -19,12 +22,12 @@ module.exports = {
19 22  
20 23 let all_num = 0; //商品数量之和
21 24 let all_price0 = 0; //商品数量之和
22   - let aprice=0; //达到活动条件的购买价格
  25 + let aprice = 0; //达到活动条件的购买价格
23 26 let need_to_buy = 0;
24 27 let all_zhqty = 0; //所有商品要求起购数之和
25 28 let no_in_arr = []; //剩余的未加入组合购
26   - let out_arr=[]; //超出活动限购的商品放入
27   -
  29 + let out_arr = []; //超出活动限购的商品放入
  30 + let zhqty_bz = []; //超量
28 31 //-- 寻找一下 --
29 32 function get_num2(ite) {
30 33 for (let v2 in goods) {
... ... @@ -39,35 +42,42 @@ module.exports = {
39 42 for (let j in act_goos) {
40 43 let item = act_goos[j];
41 44 let item_j = goods.find(function (ele) {
  45 + console.log('ele',ele);
42 46 return ele.goods_id == act_goos[j].goods_id;
43 47 })
44 48 //-- 如果有找到的话 --
45 49 if (item_j) {
46 50 act_goos[j].num = item_j.goods_num;
47 51 act_goos[j].goods_price = item_j.goods_price;
48   - var cart_num=item.cart_num =item_j.goods_num;
49   - var zh_b_num=item_j.promgoodsbuynum;
50   - if(item.buyqty>0){
51   -
52   - var key=item.goods_id+""+act.id;
53   - var cbuy=item.buyqty-zh_b_num;
54   - if(th.data.in_zhact_gdmap[key]){
55   - var cbuy=item.buyqty-zh_b_num-th.data.in_zhact_gdmap[key];
  52 + var cart_num = item.cart_num = item_j.goods_num;
  53 + var zh_b_num = item_j.promgoodsbuynum;
  54 + if (item.buyqty > 0) {
  55 +
  56 + var key = item.goods_id + "" + act.id;
  57 + var cbuy = item.buyqty - zh_b_num;
  58 + if (th.data.in_zhact_gdmap[key]) {
  59 + var cbuy = item.buyqty - zh_b_num - th.data.in_zhact_gdmap[key];
56 60 }
57 61  
58 62  
59 63 //当可买的数量为0
60   - if(cbuy<=0){
61   - item.num=0;
  64 + if (cbuy <= 0) {
  65 + item.num = 0;
62 66 out_arr.push({
63   - price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num
  67 + price: item.goods_price,
  68 + offline_price: item.offline_price,
  69 + goods_id: item.goods_id,
  70 + num: cart_num
64 71 })
65   - }else{
66   - if(cbuy>=cart_num) item.num =cart_num;
67   - else{
68   - item.num =cbuy;
  72 + } else {
  73 + if (cbuy >= cart_num) item.num = cart_num;
  74 + else {
  75 + item.num = cbuy;
69 76 out_arr.push({
70   - price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num-cbuy
  77 + price: item.goods_price,
  78 + offline_price: item.offline_price,
  79 + goods_id: item.goods_id,
  80 + num: cart_num - cbuy
71 81 })
72 82 }
73 83 }
... ... @@ -76,6 +86,7 @@ module.exports = {
76 86 all_num += item.num;
77 87 //当有起购数的控制的时候
78 88 if (item.zhqty) {
  89 + zhqty_bz.push(item);
79 90 all_zhqty += item.zhqty;
80 91 if (item.num < item.zhqty) {
81 92 need_to_buy += item.zhqty - item.num;
... ... @@ -83,14 +94,18 @@ module.exports = {
83 94 if (item.num > item.zhqty) {
84 95 for (let i = 0; i < item.num - item.zhqty; i++) {
85 96 no_in_arr.push({
86   - price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price
  97 + price: item.goods_price,
  98 + goods_id: item.goods_id,
  99 + offline_price: item_j.offline_price
87 100 })
88 101 }
89 102 }
90 103 } else {
91 104 for (let j = 0; j < item.num; j++) {
92 105 no_in_arr.push({
93   - price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price
  106 + price: item.goods_price,
  107 + goods_id: item.goods_id,
  108 + offline_price: item_j.offline_price
94 109 })
95 110 }
96 111 }
... ... @@ -105,47 +120,58 @@ module.exports = {
105 120  
106 121 //当满足组合的要求:总数要满足,起购数要满足
107 122 if (act && all_num >= act.zhbuyqty && !need_to_buy) {
108   -
109 123 //商品的列表
110 124 for (var u in act_goos) {
111   - var ite=act_goos[u];
112   - if(ite.buyqty>0 && ite.num>0){
113   - var key=ite.goods_id+""+act.id;
114   - if(th.data.in_zhact_gdmap[key]){
115   - th.data.in_zhact_gdmap[key]+=ite.num;
116   - }else{
117   - th.data.in_zhact_gdmap[key]=ite.num;
  125 + var ite = act_goos[u];
  126 + if (ite.buyqty > 0 && ite.num > 0) {
  127 + var key = ite.goods_id + "" + act.id;
  128 + if (th.data.in_zhact_gdmap[key]) {
  129 + th.data.in_zhact_gdmap[key] += ite.num;
  130 + } else {
  131 + th.data.in_zhact_gdmap[key] = ite.num;
118 132 }
119 133 }
120 134 }
121   -
122   -
123 135 function sortData(a, b) {
124 136 return a.price - b.price
125 137 }
126   -
127   - if(no_in_arr.length>0) no_in_arr.sort(sortData);
128   -
  138 + if (no_in_arr.length > 0) no_in_arr.sort(sortData);
129 139 aprice = act.zhprice;
130 140 if (act.zhbuyqty > all_zhqty) {
131   - for (let n = 0; n < act.zhbuyqty-all_zhqty; n++) {
  141 + for (let n = 0; n < act.zhbuyqty - all_zhqty; n++) {
132 142 no_in_arr.pop();
133 143 }
134 144 }
135 145 //看一下剩下的数量有没有满足组合购的要求,以及要不要倍增
136 146 if (act.is_bz && no_in_arr.length >= act.zhbuyqty) {
137 147 //看一下是几倍
138   - let be = parseInt(no_in_arr.length / act.zhbuyqty);
139   - aprice += be * act.zhprice;
140   - for (let m = 0; m < be * act.zhbuyqty; m++) {
141   - no_in_arr.pop();
142   - }
  148 + let num = 0;
  149 + let bz_num = 0;
  150 + let be = parseInt(no_in_arr.length / act.zhbuyqty);
  151 + if (act.is_bzyh && zhqty_bz.length > 0) {
  152 + for (let i = 0; i < zhqty_bz.length; i++) {
  153 + let item = zhqty_bz[i];
  154 + bz_num = be * item.zhqty;
  155 + for (let j = 0; j < no_in_arr.length; j++) {
  156 + let i = no_in_arr[j];
  157 + if (item.goods_id === i.goods_id) {
  158 + num++
  159 + }
  160 + }
  161 + }
  162 + }
  163 + if (bz_num <= num) {
  164 + aprice += be * act.zhprice;
  165 + for (var m = 0; m < be * act.zhbuyqty; m++) {
  166 + no_in_arr.pop();
  167 + }
  168 + }
  169 +
143 170 }
144 171  
145   -
146 172 let goods_map = {};
147 173 //算一下剩余的商品
148   - if(no_in_arr.length) {
  174 + if (no_in_arr.length) {
149 175 for (let ii in no_in_arr) {
150 176 let item = no_in_arr[ii];
151 177 if (item.offline_price) {
... ... @@ -162,24 +188,24 @@ module.exports = {
162 188 }
163 189  
164 190 //超量的部分也要计算一下
165   - if(out_arr.length){
  191 + if (out_arr.length) {
166 192 for (var m in out_arr) {
167 193 var item = out_arr[m];
168 194 if (item.offline_price) {
169   - offline_price += (item.price - item.offline_price)*item.num;
  195 + offline_price += (item.price - item.offline_price) * item.num;
170 196 offline_num += item.num;
171 197 }
172 198 if (goods_map[item.goods_id]) {
173 199 var num = goods_map[item.goods_id];
174   - num+=item.num
175   - goods_map[item.goods_id] =num;
  200 + num += item.num
  201 + goods_map[item.goods_id] = num;
176 202 } else {
177 203 goods_map[item.goods_id] = item.num;
178 204 }
179 205 }
180 206 }
181 207  
182   - if(Object.keys(goods_map).length) {
  208 + if (Object.keys(goods_map).length) {
183 209 //这里就开始拆分提交订单时的列表
184 210 for (let j in goods_map) {
185 211 //map中存的就是商品的数量
... ... @@ -196,24 +222,26 @@ module.exports = {
196 222 goods.push(new_g);
197 223  
198 224 //如果商品的数量已经为空了
199   - if(goods[idx].goods_num<=0){
200   - goods.splice(idx,1);
  225 + if (goods[idx].goods_num <= 0) {
  226 + goods.splice(idx, 1);
201 227 }
202 228 }
203 229 }
204 230  
205 231  
206 232 //-- 只统计是参与活动的商品 --
207   - for(var ij in goods){
208   - var iter=goods[ij];
209   - if(iter.prom_type!=7 || iter.prom_id!=act.id){ continue; }
210   - all_price0+=iter.goods_num*iter.goods_price;
  233 + for (var ij in goods) {
  234 + var iter = goods[ij];
  235 + if (iter.prom_type != 7 || iter.prom_id != act.id) {
  236 + continue;
  237 + }
  238 + all_price0 += iter.goods_num * iter.goods_price;
211 239 }
212 240 //-- 活动的条件已经满足 --
213 241 c_item.zh_prom_goods[act.id].is_has_zh = 1;
214 242 c_item.is_has_zh = 1;
215 243 c_item.zh_prom_goods[act.id].actual_price = aprice;
216   - c_item.zh_prom_goods[act.id].cut_price =all_price0-aprice;
  244 + c_item.zh_prom_goods[act.id].cut_price = all_price0 - aprice;
217 245  
218 246 //-- 设置还需要购买多少件,享受活动,前段显示 --
219 247 let need_to = c_item.need_list;
... ... @@ -257,7 +285,7 @@ module.exports = {
257 285 txt_ite = need_to;
258 286 }
259 287 tfeel += aprice;
260   - cut_price+=all_price0-aprice;;
  288 + cut_price += all_price0 - aprice;;
261 289 }
262 290  
263 291 c_item.zh_all_price = tfeel;
... ... @@ -315,10 +343,10 @@ module.exports = {
315 343 calc_zh_split_price: async function (c_arr, th) {
316 344 //-- 循环处理 --
317 345 for (var k in c_arr) {
318   - var cart_item = c_arr[k]; //就是每一单的意思
319   - var ord_goods = c_arr[k].goods; //就是每一单的从表的意思
  346 + var cart_item = c_arr[k]; //就是每一单的意思
  347 + var ord_goods = c_arr[k].goods; //就是每一单的从表的意思
320 348  
321   - var zh_prom_goods = cart_item.zh_prom_goods; //一单中所有的组合购的集合
  349 + var zh_prom_goods = cart_item.zh_prom_goods; //一单中所有的组合购的集合
322 350 var item_map = {};
323 351 for (let i in zh_prom_goods) {
324 352 let item = zh_prom_goods[i];
... ... @@ -330,14 +358,14 @@ module.exports = {
330 358 return ele.prom_type == 7 && ele.prom_id == i;
331 359 })
332 360 var all_good_price = 0;
333   - var post_gd=[];
  361 + var post_gd = [];
334 362 for (let j in glist) {
335 363 let item = glist[j];
336 364 all_good_price += item.goods_price * item.goods_num;
337   - var gitem={
338   - goods_id:item.goods_id,
339   - goods_num:item.goods_num,
340   - goods_price:item.goods_price
  365 + var gitem = {
  366 + goods_id: item.goods_id,
  367 + goods_num: item.goods_num,
  368 + goods_price: item.goods_price
341 369 }
342 370 post_gd.push(gitem);
343 371 }
... ... @@ -365,7 +393,7 @@ module.exports = {
365 393 'goods': post_gd
366 394 }
367 395 var pt_res = null;
368   - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
  396 + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
369 397 is_json: 1,
370 398 data: pt_data
371 399 }).then(res => {
... ... @@ -376,7 +404,7 @@ module.exports = {
376 404 if (pt_res) {
377 405 for (var io in glist) {
378 406 var goods_id = glist[io].goods_id;
379   - item_map[goods_id]={};
  407 + item_map[goods_id] = {};
380 408 //平摊赋值
381 409 item_map[goods_id].account_fir = th.arr_get_goods(goods_id, pt_res).fisrt_account;
382 410 item_map[goods_id].account_yu_fir = th.arr_get_goods(goods_id, pt_res).fisrt_account_yu;
... ... @@ -404,4 +432,4 @@ module.exports = {
404 432 }
405 433  
406 434  
407 435 -}
  436 +}
408 437 \ No newline at end of file
... ...
pages/giftpack/birthdaygift/birthdaygift.js
... ... @@ -119,7 +119,7 @@ Page({
119 119 var th = this;
120 120 th.setData({
121 121 getActId: options.actId,
122   - giftID: options.giftBagId
  122 + giftID: options.giftBagId,
123 123 })
124 124  
125 125 },
... ... @@ -131,6 +131,7 @@ Page({
131 131 return false;
132 132 }
133 133 this.GetList();
  134 + this.is_birthdayInfo()
134 135  
135 136 },
136 137 GetReceive: function() {
... ... @@ -175,6 +176,29 @@ Page({
175 176  
176 177 }
177 178 },
  179 + //获取生日有礼信息
  180 + is_birthdayInfo: function(e) {
  181 + var th = this;
  182 + var url = `/api/weshop/marketing/get/${a.stoid}/${th.data.getActId}`;
  183 + console.log(th.data.getActId);
  184 + getApp().request.promiseGet(url, {
  185 +
  186 + }).then(res => {
  187 + console.log(res,20000);
  188 + if (res.data.code == 0) {
  189 + let birthdayStyle=`
  190 + --bg-color:${res.data.data.actBgColor};
  191 + --color:${res.data.data.actFontColor};
  192 + `
  193 + th.setData({
  194 + bimg: res.data.data.actBoundImg,
  195 + birthdayStyle,
  196 + // actFontColor: res.data.actFontColor, //字体颜色
  197 + // actBgColor: res.data.actBgColor, //背景颜色
  198 + })
  199 + }
  200 + })
  201 + },
178 202 //界面跳转
179 203 goto: function(e) {
180 204 var url = e.currentTarget.dataset.url;
... ...
pages/giftpack/birthdaygift/birthdaygift.wxml
1   -<view>
  1 +<view style="{{birthdayStyle}}" class="font_and_bg">
2 2 <view class="image_box">
3   - <image src="{{iurl+'/miniapp/images/giftbag/birth00.png'}}" lazy-load="true"></image>
  3 + <image src="{{iurl}}{{bimg?bimg:'/miniapp/images/default_g_img.gif'}}" binderror="bind_bnerr1" data-errorimg="bimg" lazy-load="true"></image>
4 4 </view>
5 5 <block wx:if="{{itemShow}}">
6 6 <view class="top rel">
... ...
pages/giftpack/birthdaygift/birthdaygift.wxss
... ... @@ -246,7 +246,7 @@
246 246 }
247 247 .top_box_image button {
248 248 margin: 15rpx 95rpx 0rpx 95rpx;
249   - background: #fe6a6a;
  249 + background: var(--color);
250 250 border-radius: 50rpx;
251 251 line-height: 60rpx;
252 252 height: 60rpx;
... ... @@ -275,7 +275,7 @@
275 275 }
276 276 .button {
277 277 margin: 0 30rpx;
278   - background: #61d3dd;
  278 + background:var(--bg-color);
279 279 border-radius: 50rpx;
280 280 line-height: 80rpx;
281 281 height: 80rpx;
... ... @@ -308,7 +308,7 @@
308 308 width: 100%;
309 309 }
310 310 .foot_button_buy {
311   - background: #e4010c;
  311 + background:var(--color);
312 312 color: #FFFFFF;
313 313 width: 400rpx;
314 314 height: 70rpx;
... ... @@ -351,4 +351,9 @@ button::after {
351 351 width: 20rpx;
352 352 height: 90rpx;
353 353 z-index: 5;
  354 +}
  355 +
  356 +.font_and_bg {
  357 + background-color: var(--bg-color);
  358 + color:var(--color);
354 359 }
355 360 \ No newline at end of file
... ...
pages/goods/goodsInfo/buy_pt.wxml
... ... @@ -144,7 +144,7 @@
144 144 <view class="stitle" hidden="{{is_sec_mend==0}}" bindtap="hide_sec_mend">
145 145 <image class="tubiao" src="{{iurl}}/miniapp/images/icon-left.png"></image>{{sec_sto.name}}</view>
146 146 <view class="itemlists" hidden="{{is_sec_mend==0}}">
147   - <view wx:for="{{sec_sto.s_arr}}" wx:key="{{index}}" class="item" bindtap="hidemend" data-p_id="{{item.pickup_id}}" data-p_name="{{item.pickup_name}}" data-p_dis="{{item.distr_type}}">{{item.pickup_name}}
  147 + <view wx:for="{{sec_sto.s_arr}}" wx:key="index" class="item" bindtap="hidemend" data-p_id="{{item.pickup_id}}" data-p_name="{{item.pickup_name}}" data-p_dis="{{item.distr_type}}">{{item.pickup_name}}
148 148 </view>
149 149 </view>
150 150 </view>
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -254,7 +254,6 @@ Page({
254 254  
255 255 //------初始化加载----------
256 256 onLoad: function (t) {
257   -
258 257 var ee = this,
259 258 that = ee,
260 259 th = ee,
... ... @@ -408,7 +407,6 @@ Page({
408 407 var user = getApp().globalData.userInfo;
409 408 if (!user) return false;
410 409 clearInterval(ti);
411   -
412 410 if (user.card_field && user['card_expiredate']) {
413 411 var str = user['card_expiredate'].replace(/-/g, '/');
414 412 var end = new Date(str);
... ... @@ -691,7 +689,7 @@ Page({
691 689 mapurl_f_img = res1.data.data.video_img;
692 690 }
693 691 })
694   -
  692 + this.getHistoryBuy(); //获取历史购买
695 693 ee.setData({
696 694 gallery: gallery,
697 695 is_collect: is_collect,
... ... @@ -707,7 +705,6 @@ Page({
707 705  
708 706 //---展示---
709 707 onShow: function () {
710   - // console.log('djfijsaoifjoisadjfoij');
711 708 var goods_list = null, th = this, that = this;
712 709 var show_prew_img = this.data.show_prew_img
713 710 if (show_prew_img) {
... ... @@ -1525,38 +1522,36 @@ Page({
1525 1522 }
1526 1523 else {
1527 1524  
1528   - if(newd.prom_type==10){
1529   - //----先看会员在购物车中是否加入了该商品,立即购买的-----
1530   - getApp().request.get("/api/weshop/cart/page", {
1531   - data: {
1532   - store_id: e.data.stoid,
1533   - user_id: oo.user_id,
1534   - state:1
1535   - },
1536   - success: function (res) {
1537   - //-------如果购物车中有相关的数据---------
1538   - if (res.data.code==0 && res.data.data.total > 0) {
1539   - for(let j in res.data.data.pageData){
1540   - let item_j=res.data.data.pageData[j];
1541   - var url = '/api/weshop/cart/del/' +e.data.stoid+ '/' + item_j.id;
1542   - getApp().request.delete(url, {});
1543   - }
  1525 + //这一步主要是要让立即购买 走 购物车的逻辑 参与活动
  1526 + if(newd.prom_type==10 || newd.prom_type==7){
  1527 + //----先看会员在购物车中是否加入了该商品,立即购买的-----
  1528 + getApp().request.get("/api/weshop/cart/page", {
  1529 + data: {
  1530 + store_id: e.data.stoid,
  1531 + user_id: oo.user_id,
  1532 + state:1
  1533 + },
  1534 + success: function (res) {
  1535 + //-------如果购物车中有相关的数据---------
  1536 + if (res.data.code==0 && res.data.data.total > 0) {
  1537 + for(let j in res.data.data.pageData){
  1538 + let item_j=res.data.data.pageData[j];
  1539 + var url = '/api/weshop/cart/del/' +e.data.stoid+ '/' + item_j.id;
  1540 + getApp().request.delete(url, {});
1544 1541 }
1545   - newd.state=1;
1546   - getApp().request.post("/api/weshop/cart/save", {
1547   - data: newd,
1548   - success: function (t) {
1549   - th.closeSpecModal();
1550   - getApp().goto("/pages/cart/cart2/cart2?state=1");
1551   - }
1552   - });
1553   -
1554   -
1555   - }
1556   - })
1557   - return false;
1558   - }
1559   -
  1542 + }
  1543 + newd.state=1;
  1544 + getApp().request.post("/api/weshop/cart/save", {
  1545 + data: newd,
  1546 + success: function (t) {
  1547 + th.closeSpecModal();
  1548 + getApp().goto("/pages/cart/cart2/cart2?state=1");
  1549 + }
  1550 + });
  1551 + }
  1552 + })
  1553 + return false;
  1554 + }
1560 1555  
1561 1556 if (th.data.prom_goods) {
1562 1557 var prom_d = th.data.prom_goods;
... ... @@ -2414,9 +2409,9 @@ Page({
2414 2409 }
2415 2410 },
2416 2411  
2417   - //-----------选择属性的按钮事件----------
  2412 + //-----------选择属性的按钮事件----------
2418 2413 sele_spec: function (e) {
2419   - var that = this, ee = this, th = this;
  2414 + var that = this;
2420 2415 var gid = e.currentTarget.dataset.gid;
2421 2416 var nor = e.currentTarget.dataset.nor;
2422 2417  
... ... @@ -2435,25 +2430,33 @@ Page({
2435 2430 break
2436 2431 }
2437 2432 }
  2433 + console.log(item,2000);
  2434 + var cur_price = item.shop_price;
  2435 + if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) {
  2436 + var cfile = getApp().globalData.userInfo.card_field;
  2437 + console.log('cfile',cfile);
  2438 + if (item[cfile]) {
  2439 + cur_price =item[cfile];
  2440 + }
  2441 + }
  2442 + var txt = (cur_price / item.market_price * 10).toFixed(2).toString();
  2443 + txt = parseFloat(txt);
  2444 + item['disc'] = txt;
2438 2445 if (item) this.setData({
2439 2446 sele_g: item,
2440   - gid: gid
  2447 + gid: gid,
  2448 + data:item,
2441 2449 });
2442 2450  
2443 2451  
2444   -
2445   -
2446 2452 that.check_is_youhui(gid, that.data.is_normal);
2447 2453  
2448   - this.get_sto(that.data.is_normal);
2449   -
2450   -
2451 2454 //默认门店要拿下门店库存
2452 2455 if (that.data.sales_rules == 2 && that.data.def_pick_store) {
2453 2456 var lock = 0, plist = null;
2454 2457 //先读取门店的lock,采用链式写法,少用await
2455 2458 getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
2456   - data: { store_id: os.stoid, wareId: ee.data.sele_g.goods_id, storageId: that.data.def_pick_store.pickup_id, pageSize: 1000 }
  2459 + data: { store_id: os.stoid, wareId: that.data.sele_g.goods_id, storageId: that.data.def_pick_store.pickup_id, pageSize: 1000 }
2457 2460 }).then(res => {
2458 2461 if (res.data.code == 0 && res.data.data.total > 0) {
2459 2462 for (var i in res.data.data.pageData)
... ... @@ -2461,7 +2464,7 @@ Page({
2461 2464 }
2462 2465 //---通过接口获取门店的线下库存信息--
2463 2466 return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
2464   - data: { storageNos: that.data.def_pick_store.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid }
  2467 + data: { storageNos: that.data.def_pick_store.pickup_no, wareIds: encodeURIComponent(that.data.sele_g.erpwareid), storeId: os.stoid }
2465 2468 })
2466 2469 }).then(res => {
2467 2470 if (res.data.code == 0 && res.data.data.total > 0) {
... ... @@ -2473,11 +2476,9 @@ Page({
2473 2476 that.data.def_pick_store.CanOutQty = 0;
2474 2477 }
2475 2478 //--给门店赋值线下库存--
2476   - th.setData({ def_pick_store: that.data.def_pick_store });
  2479 + that.setData({ def_pick_store: that.data.def_pick_store });
2477 2480 })
2478 2481 }
2479   -
2480   -
2481 2482 this.sele_spec_chech_activity();
2482 2483 },
2483 2484  
... ... @@ -2581,6 +2582,7 @@ Page({
2581 2582  
2582 2583 //---------拿出门店分类和门店------------
2583 2584 get_sto(e) {
  2585 + console.log('get_sto')
2584 2586 var th = this, that = this;
2585 2587 var is_normal = e;
2586 2588  
... ... @@ -3103,6 +3105,7 @@ Page({
3103 3105  
3104 3106 //--------检查是否活动,活动是否开始,或者是否结束-------
3105 3107 async check_prom(gid, prom_type, prom_id) {
  3108 + console.log('check_prom');
3106 3109 var ee = this,th = ee;
3107 3110 var user_id=getApp().globalData.user_id;
3108 3111 if(!user_id) user_id=0;
... ... @@ -3383,8 +3386,8 @@ Page({
3383 3386 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
3384 3387 1: 1
3385 3388 }).then(res => {
3386   - console.log(res,3114);
3387 3389 var em = res;
  3390 + var flag=null;
3388 3391 if (em.data.code == 0) {
3389 3392 if (em.data.data <= 0) ee.setData({
3390 3393 prom_r_null: 1
... ... @@ -3392,8 +3395,7 @@ Page({
3392 3395 //拿取价格并且判断时间--
3393 3396 getApp().request.get("/api/weshop/teamlist/get/" +
3394 3397 os.stoid + "/" + prom_id, {
3395   - success: function (t) {
3396   - console.log(t,3124);
  3398 + success: async function (t) {
3397 3399 if (t.data.code != 0) {
3398 3400 ee.get_normal(gid);
3399 3401 return false;
... ... @@ -3432,25 +3434,40 @@ Page({
3432 3434 }
3433 3435 });
3434 3436 return false
3435   - ee.setData({
3436   - prom_type: 0,
3437   - isshow: 1,
3438   - });
3439   - ee.get_sku(os.stoid, ee.data.data, gid);
3440   - ee.get_sto();
3441   - return false;
3442 3437 }
3443 3438  
  3439 + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/1",{
  3440 + data:{
  3441 + store_id: os.stoid,
  3442 + is_end: 0,
  3443 + is_show: 1,
  3444 + user_id: getApp().globalData.user_id,
  3445 + pageSize:1000
  3446 + }
  3447 + }).then(res=>{
  3448 +
  3449 + let pd_list=res.data.data.pageData;
  3450 + if(res.data.code==0 && pd_list.length>0){
  3451 + flag =pd_list.some(pd=>{
  3452 + return pd.goods_id==gid
  3453 + })
  3454 + }
  3455 + })
  3456 + if(!flag){
  3457 + ee.get_normal(gid);
  3458 + return false;
  3459 +
  3460 + }
3444 3461 //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中-------
3445   - getApp().request.get("/api/weshop/order/page", {
  3462 + await getApp().request.promiseGet("/api/weshop/order/page", {
3446 3463 data: {
3447 3464 pt_prom_id: prom_id,
3448 3465 user_id: oo.user_id,
3449 3466 store_id: os.stoid,
3450 3467 pageSize: 1,
3451 3468 page: 1
3452   - },
3453   - success: function (e) {
  3469 + }
  3470 + }).then(e=>{
3454 3471 if (e.data.code == 0 && e.data.data.pageData.length > 0) {
3455 3472 var odr = e.data.data.pageData[0];
3456 3473 th.data.buy_order = odr;
... ... @@ -3496,8 +3513,7 @@ Page({
3496 3513 th.data.wk_order_id = odr.order_id;
3497 3514 }
3498 3515 }
3499   - },
3500   - });
  3516 + })
3501 3517  
3502 3518 //----------查看阶梯团------------
3503 3519 if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) {
... ... @@ -5782,7 +5798,7 @@ Page({
5782 5798 //调用接口判断订单优惠,
5783 5799 getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", {
5784 5800 success: function (res) {
5785   - console.log(res);
  5801 +
5786 5802 if (res.data.code == 0 && res.data.data) {
5787 5803 var r_data = res.data.data;
5788 5804 var max = 0, min = 0;
... ... @@ -5940,11 +5956,11 @@ Page({
5940 5956 })
5941 5957 },
5942 5958  
5943   - previewImage() {
  5959 + previewImage(e) {
5944 5960 this.data.show_prew_img = 1;
5945 5961 wx.previewImage({
5946 5962 //将图片预览出来
5947   - urls: [this.data.shareImgPath]
  5963 + urls: [this.data.sele_g.original_img]
5948 5964 });
5949 5965 },
5950 5966  
... ... @@ -6226,9 +6242,25 @@ Page({
6226 6242 go_more_ladder:function (e) {
6227 6243 var prom_id=e.currentTarget.dataset.id;
6228 6244 getApp().goto("/pages/goods/goodsList/goodsList?ladder_id="+prom_id);
6229   - }
6230   -
6231   -
6232   -
  6245 + },
6233 6246  
  6247 + getHistoryBuy() {
  6248 + let _this=this;
  6249 + let req_data = {
  6250 + store_id:os.stoid,
  6251 + goods_id:this.data.gid,
  6252 + pay_status:1,
  6253 + rndid:1
  6254 + };
  6255 + getApp().request.promiseGet('/api/weshop/ordergoods/list',{
  6256 + data:req_data,
  6257 + })
  6258 + .then(res=>{
  6259 + if(t.ajax_ok(res)){
  6260 + _this.setData({
  6261 + historyBuyInfo:res.data.data.pageData,
  6262 + })
  6263 + }
  6264 + })
  6265 + }
6234 6266 });
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -7,12 +7,30 @@
7 7 <block wx:if="{{isshow}}">
8 8 <view class="container">
9 9 <view class="type-navbar">
10   - <view class="type-box" wx:for="{{categories}}" wx:key="categories">
  10 + <view class="type-box" wx:for="{{categories}}" wx:key="id">
11 11 <view bindtap="tabClick" class="type-navbar-item {{activeCategoryId==item.id?'type-item-on':''}}" id="{{item.id}}">{{item.name}}</view>
12 12 </view>
13 13 </view>
14 14 <view class="goods-detail">
15   - <view class="goods-info" hidden="{{activeCategoryId==0?false:true}}">
  15 + <view class="goods-info" style="position: relative;" hidden="{{activeCategoryId==0?false:true}}">
  16 +
  17 + <!-- 历史购买记录 -->
  18 + <view class="swiper-container" wx:if="{{historyBuyInfo.length}}">
  19 + <swiper class="swiper" autoplay="true" circular="true" vertical="true" interval="3000">
  20 + <swiper-item class="swiper-item" wx:for="{{historyBuyInfo}}" wx:key="order_id">
  21 + <view class="item">
  22 + <view class="avatar-container">
  23 + <image src="{{item.head_pic}}"></image>
  24 + </view>
  25 + <view class="flex ai_c pd10">
  26 + <view class="nickname ellipsis-1x">{{item.nickname}}下单成功</view>
  27 + <!-- <view style="flex-shrink: 0;"></view> -->
  28 + </view>
  29 + </view>
  30 + </swiper-item>
  31 + </swiper>
  32 + </view>
  33 +
16 34 <view id="id" bindtouchstart="handletouchtart" bindtouchmove="handletouchmove">
17 35 <view class="xc-videos-picture rel">
18 36 <swiper autoplay="{{false}}" current="{{swiperCurrent}}" class="swiper_box swiperContainer rel" duration="{{1000}}" indicatorDots="{{mapurl?false:true}}" interval="{{3000}}" vertical="{{false}}" bindchange="swiperChange">
... ... @@ -219,71 +237,7 @@
219 237 </view>
220 238 </view>
221 239 </view>
222   -
223   - <!-- 幸运购 -->
224   - <view class="pt_fir se2 bdt16" wx:if="{{teamgroup}}" hidden="{{true}}">
225   - <view class="xc-partner-frame">
226   - <view class="zzk-1 flex jc_sb" bindtap="go_t_more">
227   - <view class="pdl10">已参团4人,还差<text class="c-red">1</text>人成团</view>
228   - <view class="ckgd flex ai_c">
229   - 查看奖励
230   - <view class="bg_right arrow-one"></view>
231   - </view>
232   - </view>
233   - </view>
234   - <view class='group'>
235   - <view class='group-list luck' bindtap="go_cj_team" data-ind="{{t_ind}}">
236   - <!-- <view class="flex ai_c"> -->
237   - <!-- //选项框头像 -->
238   - <view class='gtou' wx:for="{{teamgroup}}" wx:for-index="t_ind" wx:key="teamgroup">
239   - <image src='{{item.user.head_pic}}'></image>
240   - </view>
241   - <view class='gtou more'>
242   - <text class="iconfont icon-sandian"></text>
243   - </view>
244   - <!-- <view class='gtou'>
245   - <image src='{{item.user.head_pic}}'></image>
246   - </view> -->
247   - <!-- //等你来拼 -->
248   - <!-- <view class='gdn ellipsis-1'>{{item.user.nickname}}</view> -->
249   - <!-- </view> -->
250   - <!-- //还差几人,剩余时间 -->
251   - <!-- <view class="rel">
252   - <view class='ghaicha ellipsis-2'>
253   - <text class='gred' wx:if="{{prom_act.max_ct_num >0}}">
254   - <text class="flex" wx:if="{{prom_act.max_ct_num - item.open_num>0}}">
255   - 还差
256   - <text class="word-color">{{prom_act.max_ct_num - item.open_num}}</text>
257   - 人享最低优惠
258   - </text>
259   - <text wx:else>您已经享最低优惠</text>
260   - </text>
261   - <text class='gred' wx:else>
262   - 还差
263   - <text style='color:#ff2753'>{{prom_act.ct_num - item.open_num}}</text>
264   - 人成团
265   - </text>
266   - <view class="t_show">
267   - 剩余
268   - <text wx:if="{{timer[t_ind].day}}">{{timer[t_ind].day}}天:</text>
269   - <text>{{timer[t_ind].hou}}</text>
270   - :
271   - <text>{{timer[t_ind].min}}</text>
272   - :
273   - <text>{{timer[t_ind].sec}}</text>
274   - </view>
275   - </view>
276   - </view> -->
277   - <!-- //参加团 -->
278   - <!-- <view class='cjt t-c'>去参团</view> -->
279   - <!-- <view class="clear"></view> -->
280   - </view>
281   -
282   - <view class="fs24 pdh20 pdt20">*<text class="c-red">5</text>人成团,<text class="c-red">5</text>人得商品,<text class="c-red">5</text>人全额退款并获得<text class="c-red">惊喜礼品</text>!</view>
283   - </view>
284   - </view>
285   -
286   -
  240 +
287 241  
288 242 </view>
289 243 <!-- 积分购 -->
... ... @@ -328,12 +282,10 @@
328 282 <!-- 不是拼团,不是积分购 -->
329 283 <block wx:if="{{prom_type!=6 && prom_type!=4}}">
330 284  
331   -
332   -
333 285 <view class="goods-price">
334 286  
335 287 <view class="flex jc_sb">
336   - <view class="co-red" style="" wx:if="{{prom_type==0 || prom_type==3}}">
  288 + <view class="co-red" wx:if="{{prom_type==0 || prom_type==3}}">
337 289  
338 290 <view class="market-price flex" style="align-items: baseline;">
339 291 <block wx:if="{{card_field && data[card_field]>0}}">
... ... @@ -571,7 +523,7 @@
571 523 <view class="cx-frame flex" style="position: relative" wx:if="{{fir_quan.length>0}}">
572 524 <view class="cx-sizs fs30">领券</view>
573 525 <view class="flex ai_c f1 pdh20">
574   - <view class="xc-coupon-fram" wx:for="{{fir_quan}}" wx:key="{{index}}">
  526 + <view class="xc-coupon-fram" wx:for="{{fir_quan}}" wx:key="id">
575 527 <view class="circle xc-circular xc-one"></view>
576 528 <view class="xc-coupon t-c four-level-word">
577 529 满{{item.condition}}减{{item.money}}
... ... @@ -1197,7 +1149,7 @@
1197 1149 <view class="pding">
1198 1150 <icon bindtap="closeSpecModal" class="modal-close" color="black" size="22" type="cancel"></icon>
1199 1151 <view class="spec-goods">
1200   - <image class="wh100 spec-img xc-distance-bottom" src="{{sele_g.original_img}}" binderror="pop_err_img" data-errorimg="sele_g.original_img"></image>
  1152 + <image class="wh100 spec-img xc-distance-bottom" bindtap="previewImage" src="{{sele_g.original_img}}" binderror="pop_err_img" data-errorimg="sele_g.original_img"></image>
1201 1153 <view class="spec-goods-info">
1202 1154 <view class="spec-goods-name ellipsis-2">{{sele_g.goods_name}}</view>
1203 1155 <view class="flex ai_end xc-val-money">
... ... @@ -1403,7 +1355,7 @@
1403 1355 {{sec_sto.name}}
1404 1356 </view>
1405 1357 <view class="itemlists" hidden="{{is_sec_mend==0}}">
1406   - <view wx:for="{{sec_sto.s_arr}}" wx:key="{{index}}" class="item" bindtap="hidemend" data-p_id="{{item.pickup_id}}" data-p_name="{{item.pickup_name}}" data-p_dis="{{item.distr_type}}">
  1358 + <view wx:for="{{sec_sto.s_arr}}" wx:key="index" class="item" bindtap="hidemend" data-p_id="{{item.pickup_id}}" data-p_name="{{item.pickup_name}}" data-p_dis="{{item.distr_type}}">
1407 1359 {{item.pickup_name}}
1408 1360 </view>
1409 1361 </view>
... ... @@ -1428,7 +1380,7 @@
1428 1380 <view class="prom-model">
1429 1381 <icon bindtap="closePromModal" class="modal-close" color="gray" size="22" type="cancel"></icon>
1430 1382 <view class="prom-title">优惠信息</view>
1431   - <view class="logistics-item" wx:for="{{select.activity.data}}" wx:key="{{index}}">
  1383 + <view class="logistics-item" wx:for="{{select.activity.data}}" wx:key="index">
1432 1384 <view class="item-title">
1433 1385 <text class="prom-item">{{item.title}}</text>
1434 1386 </view>
... ... @@ -1495,7 +1447,7 @@
1495 1447 </view>
1496 1448 <view class="xc-coupon-right flex">
1497 1449 <view class="xc-detail-coupon">
1498   - <view class="four-level-word">订单金额满{{item.condition}}元可用</view>
  1450 + <view class="four-level-word">{{item.name}}</view>
1499 1451 <view class="four-level-word xc-below">
1500 1452 {{filters.replace_time2(item.start)}} 至 {{filters.replace_time2(item.end)}}
1501 1453 </view>
... ...
pages/goods/goodsInfo/goodsInfo.wxss
... ... @@ -3884,3 +3884,49 @@ button.custom-service::after {
3884 3884  
3885 3885 .jie_show{ display: inline-block; width: 40rpx; height: 40rpx; background-color:#ff0505;border-radius:50%;color: #fff;text-align: center; margin: 0 20rpx }
3886 3886  
  3887 +.jie_show{ display: inline-block; width: 40rpx; height: 40rpx; background-color:#ff0505;border-radius:50%;color: #fff;text-align: center; margin: 0 20rpx }
  3888 +/* 历史购买 */
  3889 +.swiper-container {
  3890 + position: absolute;
  3891 + top: 0;
  3892 + left: 0;
  3893 + padding: 20rpx 10rpx;
  3894 + width: 100%;
  3895 + box-sizing: border-box;
  3896 + z-index: 98;
  3897 +}
  3898 +
  3899 +.swiper {
  3900 + height: 60rpx;
  3901 + color: white;
  3902 + font-size: 26rpx;
  3903 +}
  3904 +
  3905 +.swiper-item {
  3906 + /* width: auto !important;
  3907 + background-color: rgba(0,0,0,.4);
  3908 + border-radius: 60rpx; */
  3909 + position: relative;
  3910 +}
  3911 +
  3912 +.swiper-item .item {
  3913 + position: absolute;
  3914 +}
  3915 +
  3916 +.item {
  3917 + /* position: absolute; */
  3918 + display: flex;
  3919 + align-items: center;
  3920 + /* justify-content: center; */
  3921 + border-radius: 60rpx;
  3922 + background-color: rgba(0,0,0,.4);
  3923 + /* position: absolute; */
  3924 +}
  3925 +
  3926 +.avatar-container {
  3927 + width: 60rpx;
  3928 + height: 60rpx;
  3929 + border-radius: 50%;
  3930 + overflow: hidden;
  3931 + flex-shrink: 0;
  3932 +}
... ...
pages/goods/search/search.js
... ... @@ -186,6 +186,28 @@ Page({
186 186 break;
187 187 case 6:
188 188 url = "/api/weshop/teamlist/get/" + oo.stoid + "/" + prom_id;
  189 + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/1",{
  190 + data:{
  191 + store_id: oo.stoid,
  192 + is_end: 0,
  193 + is_show: 1,
  194 + user_id: getApp().globalData.user_id,
  195 + pageSize:1000,
  196 + }
  197 + }).then(pd=>{
  198 + let pd_list=pd.data.data.pageData;
  199 + if(res.data.code==0 && pd_list.length>0){
  200 + var flag = pd_list.some(pd=>{
  201 + return pd.goods_id==item.goods_id
  202 + })
  203 +
  204 + if(!flag){
  205 + item.prom_type=0;
  206 + item.prom_id=0;
  207 + item.prom_price=null;
  208 + }
  209 + }
  210 + })
189 211 break;
190 212 case 8:
191 213 var presell_id = prom_id;
... ... @@ -212,7 +234,6 @@ Page({
212 234 if(url!=null && url!=''){
213 235 await getApp().request.promiseGet(url, {}).then(async res => {
214 236 var prom =null;
215   - var flag=null;
216 237 if(res.data.code==0 && res.data.data){
217 238 prom=res.data.data;
218 239  
... ...
pages/index/index/index.js
... ... @@ -73,7 +73,7 @@ Page({
73 73 max_sw_height: 0, //banner的最大高度
74 74 is_disgraceful: 0, //是否显示新人广告
75 75 new_image: "", //新人有礼弹窗图片
76   - new_nav: "", //新人页面跳转地址
  76 + new_nav: "", //新人页面跳转地址
77 77 w_holiday_pop: 0,
78 78  
79 79 showHongbao: false,
... ... @@ -176,7 +176,7 @@ Page({
176 176 })
177 177 }
178 178  
179   - // 判断是否有红包活动
  179 + // 判断是否有红包活动
180 180 getApp().request.promiseGet('/api/weshop/redmoney/redConfig/get/' + getApp().globalData.setting.stoid, {
181 181 data: {}
182 182 }).then(function (data) {
... ... @@ -194,7 +194,7 @@ Page({
194 194 });
195 195  
196 196  
197   - // console.log(9090909);
  197 + // console.log(9090909);
198 198 //看一下商家是否开通了权益
199 199 //--初始化是否有打勾--
200 200 getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {
... ... @@ -458,7 +458,7 @@ Page({
458 458 getApp().globalData.isLoad_ad = 1;
459 459 }
460 460 }, 1500)
461   -
  461 +
462 462  
463 463 },
464 464 //当隐藏的时候就关闭计时器
... ... @@ -536,6 +536,7 @@ Page({
536 536 wx.stopPullDownRefresh();
537 537 }
538 538 })
  539 + let user_id=getApp().globalData.user_id;
539 540  
540 541 //----拼单-----
541 542 await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", {
... ... @@ -543,7 +544,8 @@ Page({
543 544 store_id: os.stoid,
544 545 is_end: 0,
545 546 is_show: 1,
546   - pageSize: 6
  547 + pageSize: 6,
  548 + user_id,
547 549 }
548 550 }).then(res => {
549 551 var e = res;
... ... @@ -747,7 +749,7 @@ Page({
747 749 }
748 750 console.log("---首页---分享--");
749 751 var title = "商城首页"
750   - //分享
  752 + //分享
751 753 if (getApp().globalData.config && getApp().globalData.config.store_name) {
752 754 title = getApp().globalData.config.store_name;
753 755 } else if (getApp().globalData.setting.appName) {
... ... @@ -1182,7 +1184,7 @@ Page({
1182 1184 var url=e.currentTarget.dataset.url;
1183 1185 getApp().goto(url);
1184 1186 },
1185   -
1186 1187  
1187 1188  
1188   -});
1189 1189 \ No newline at end of file
  1190 +
  1191 +});
... ...
pages/team/team_ping/team_ping.js
... ... @@ -114,7 +114,7 @@ Page({
114 114 }).then(res => {
115 115 order_goods = res.data.data.pageData;
116 116 order[i].order_goods = order_goods;
117   - order[i].gimage = ee.data.imageurl + order_goods[0].original_img;
  117 + order[i].gimage = ee.data.imageurl + order_goods[0]?.original_img;
118 118 })
119 119  
120 120  
... ...
pages/team/team_ping/team_ping.wxml
1 1 <wxs module="filters" src="../../../utils/filter.wxs"></wxs>
2   -
  2 +
3 3 <!--选择款-->
4 4 <view class='top'>
5 5 <view class='tyi' class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">全部</view>
... ... @@ -10,113 +10,114 @@
10 10  
11 11 <!--单号显示-->
12 12 <view class='wu' wx:if="{{order.length>0}}">
13   -<view class='pd' wx:for="{{order}}" wx:key>
14   - <view class='pd-list' bindtap="go_team_success" data-ordsn="{{item.order_sn}}">
15   - <!--top-->
16   - <view class='pd-list-top'>
17   - <!-- <image src='{{iurl}}/miniapp/images/dianpu.png'></image> -->
18   - <text class='pd-wz'>订单编号:{{item.order_sn}}</text>
19   - <image class='jt' src='{{iurl}}/miniapp/images/icojiantou1.png'></image>
20   - </view>
21   - <!--image-->
22   - <view class='pd-list-image'>
23   - <view class="xc-list flex">
24   - <view class="frame">
25   - <image src='{{item.gimage}}' binderror='images_err' data-err="order[{{index}}].gimage"></image>
26   - </view>
27   - <view>
28   - <view class='pd-img-wz1 ellipsis-2'>{{item.order_goods[0].goods_name}}
  13 + <view class='pd' wx:for="{{order}}" wx:key>
  14 + <view class='pd-list' bindtap="go_team_success" data-ordsn="{{item.order_sn}}">
  15 + <!--top-->
  16 + <view class='pd-list-top'>
  17 + <!-- <image src='{{iurl}}/miniapp/images/dianpu.png'></image> -->
  18 + <text class='pd-wz'>订单编号:{{item.order_sn}}</text>
  19 + <image class='jt' src='{{iurl}}/miniapp/images/icojiantou1.png'></image>
29 20 </view>
30   -
31   -
32   - <view class="flex-space-between {{item.pt_status==1? 'xc-price-sn':'xc-price-no'}}">
33   - <view class="flex">
34   - <text class='fs24 xc-wc {{item.pt_status==1?"xc-rmbs":"xc-rmb"}}'>¥</text>
35   - <view class='pd-jg xc-wc'>{{item.order_goods[0].goods_price}}</view>
36   - <view class="flex word-line xc-ash {{item.pt_status==1?'xc-rmbs':'xc-rmb'}}"><text class="fs24 xc-black">零售价:</text><text class="fs24 xc-wc">¥</text><text class="fs26 xc-wc">{{item.order_goods[0].market_price}}</text> </view>
37   -</view>
38   -
39   - <view class="xc-img-frame" wx:if="{{item.pt_status==2 || item.pt_status==4 || item.pt_status==5 || item.pt_status==6}}">
40   - <image style='width' class=""src="{{iurl}}/miniapp/images/xc_qtcg.png"></image>
41   - </view>
42   - <view class="xc-img-frame" wx:if="{{item.pt_status==3}}">
43   - <image src="{{iurl}}/miniapp/images/xc-qtshibai.png"></image></view>
44   - </view>
  21 + <!--image-->
  22 + <view class='pd-list-image'>
  23 + <view class="xc-list flex">
  24 + <view class="frame">
  25 + <image src='{{item.gimage}}' binderror='images_err' data-err="order[{{index}}].gimage"></image>
  26 + </view>
  27 + <view>
  28 + <view class='pd-img-wz1 ellipsis-2'>{{item.order_goods[0].goods_name}}
  29 + </view>
45 30  
46   -<view class="xc-still-bad flex fs24" wx:if="{{item.pt_status==1}}">
47   - <block wx:if="{{item.ct_num-item.tx.length>0}}">
48   - 还差<text class="xc-wc">{{item.ct_num-item.tx.length}}</text>人成团
49   - </block>
50   - <block wx:elif="{{item.max_ct_num-item.tx.length>0}}">
51   - 还差<text class="xc-wc">{{item.max_ct_num-item.tx.length}}</text>人享受最价</block>
52   - <block wx:else>您已经可以享受最低价</block>
53   - </view>
54 31  
  32 + <view class="flex-space-between {{item.pt_status==1? 'xc-price-sn':'xc-price-no'}}">
  33 + <view class="flex">
  34 + <text class='fs24 xc-wc {{item.pt_status==1?"xc-rmbs":"xc-rmb"}}'>¥</text>
  35 + <view class='pd-jg xc-wc'>{{item.order_goods[0].goods_price}}</view>
  36 + <view class="flex word-line xc-ash {{item.pt_status==1?'xc-rmbs':'xc-rmb'}}"><text class="fs24 xc-black">零售价:</text><text class="fs24 xc-wc">¥</text><text class="fs26 xc-wc">{{item.order_goods[0].market_price}}</text> </view>
  37 + </view>
55 38  
  39 + <view class="xc-img-frame" wx:if="{{item.pt_status==2 || item.pt_status==4 || item.pt_status==5 || item.pt_status==6}}">
  40 + <image style='width' class="" src="{{iurl}}/miniapp/images/xc_qtcg.png"></image>
  41 + </view>
  42 + <view class="xc-img-frame" wx:if="{{item.pt_status==3}}">
  43 + <image src="{{iurl}}/miniapp/images/xc-qtshibai.png"></image>
  44 + </view>
  45 + </view>
  46 +
  47 + <view class="xc-still-bad flex fs24" wx:if="{{item.pt_status==1}}">
  48 + <block wx:if="{{item.ct_num-item.tx.length>0}}">
  49 + 还差<text class="xc-wc">{{item.ct_num-item.tx.length}}</text>人成团
  50 + </block>
  51 + <block wx:elif="{{item.max_ct_num-item.tx.length>0}}">
  52 + 还差<text class="xc-wc">{{item.max_ct_num-item.tx.length}}</text>人享受最价</block>
  53 + <block wx:else>您已经可以享受最低价</block>
  54 + </view>
  55 + </view>
56 56 </view>
57   -
58   - </view>
59   -
60   - </view>
61   - <!--foot-->
62   - <view style='width:100%;border-bottom:10rpx solid #eee; '>
63   - <view class='pd-list-foot'>
64   - <view class='foot-left flex'>
65   - 共{{item.order_goods[0].goods_num}}件,
66   - <view class="t-c">
67   - <block wx:if="{{item.is_zsorder==4}}">
68   - <block wx:if="{{item.pt_status==3 || item.pt_status==4 || item.pt_status==5 || item.pt_status==6}}">
69   - 金额:<text class="xc-wc">¥</text>
70   - <view class='foot-l-wz fs35'>{{filters.toFix(item.user_money+item.order_amount+item.pt_tail_money,2)}}</view>
71   - </block>
72   - <block wx:else>
  57 +
  58 + </view>
  59 + <!--foot-->
  60 + <view style='width:100%;border-bottom:10rpx solid #eee; '>
  61 + <view class='pd-list-foot'>
  62 + <view class='foot-left flex fdc'>
  63 + <view class="t-c flex {{item.pt_status==3?'jietitun':''}}">
  64 + <view>共{{item.order_goods[0].goods_num}}件,</view>
  65 + <block wx:if="{{item.is_zsorder==4}}">
  66 + <block wx:if="{{item.pt_status==3 || item.pt_status==4 || item.pt_status==5 || item.pt_status==6}}">
  67 + <view>金额:<text class="xc-wc">¥</text></view>
  68 + <view class='foot-l-wz fs35'>{{filters.toFix(item.user_money+item.order_amount+item.pt_tail_money,2)}}</view>
  69 + </block>
  70 + <block wx:else>
73 71 <view class='foot-l-wz fs35' wx:if="item.is_zsorder==4">
74   - 定金:¥{{filters.toFix(item.order_amount+item.user_money,2)}}</view>
  72 + 定金:¥{{filters.toFix(item.order_amount+item.user_money,2)}}</view>
75 73 <view class='foot-l-wz fs35' wx:else>金额:¥{{filters.toFix(item.order_amount+item.user_money,2)}}</view>
76   - <view class='foot-l-wz2 fs35' wx:if="{{item.pt_tail_money>0}}">尾款:¥{{item.pt_tail_money}}</view>
77   - </block>
78   -
79   - </block>
80   - <block wx:else>
81   - 金额:<text class="xc-wc">¥</text>
82   - <view class='foot-l-wz fs35'>{{filters.toFix(item.user_money+item.order_amount,2)}}</view>
83   - </block>
84   - </view>
85   - </view>
  74 + <view class='foot-l-wz2 fs35' wx:if="{{item.pt_tail_money>0}}">尾款:¥{{item.pt_tail_money}}</view>
  75 + </block>
86 76  
87   - <view class='foot-right'>
88   - <!--头像遍历-->
89   - <view class='foot-right-r'>
90   - <view class='foot-l-tx' style="margin-right:20rpx">
91   - <view wx:if="{{item.tx}}" style="display: flex">
92   - <image wx:for="{{item.tx}}" wx:for-item="aitem" src='{{aitem.head_pic}}'></image>
93   - <image src='{{iurl}}/miniapp/images/shafa.png' wx:for="{{item.sf_num}}" ></image>
94   - <view class="xc-ellipsis" wx:if="{{item.tx.length>3}}">...</view>
  77 + </block>
  78 + <block wx:else>
  79 + <view>金额:<text class="xc-wc">¥</text></view>
  80 + <view class='foot-l-wz fs35'>{{filters.toFix(item.user_money+item.order_amount,2)}}</view>
  81 + </block>
  82 +
  83 +
95 84 </view>
  85 + <view wx:if="{{item.pt_status==3}}" class="jietitun">退款时间:{{filters.format_time(item.is_back_time,1)}}</view>
96 86 </view>
97 87  
98   - <view class='C'>
99   - <view class='yao' wx:if="{{item.pt_status==1}}">邀请好友</view>
100   - <view class='s_and_f' wx:if="{{item.pt_status==2 || item.pt_status==3 || item.pt_status==4 || item.pt_status==5 }}">查看详情</view>
101   - <view class='s_and_f' wx:if="{{item.pt_status==6}}">支付尾款失败</view>
  88 + <view class='foot-right'>
  89 + <!--头像遍历-->
  90 + <view class='foot-right-r'>
  91 + <view class='foot-l-tx' style="margin-right:20rpx">
  92 + <view wx:if="{{item.tx}}" style="display: flex">
  93 + <image wx:for="{{item.tx}}" wx:for-item="aitem" src='{{aitem.head_pic}}'></image>
  94 + <image src='{{iurl}}/miniapp/images/shafa.png' wx:for="{{item.sf_num}}"></image>
  95 + <view class="xc-ellipsis" wx:if="{{item.tx.length>3}}">...</view>
  96 + </view>
  97 + </view>
  98 +
  99 + <view class='C'>
  100 + <view class='yao' wx:if="{{item.pt_status==1}}">邀请好友</view>
  101 + <view class='s_and_f' wx:if="{{item.pt_status==2 || item.pt_status==3 || item.pt_status==4 || item.pt_status==5 }}">查看详情</view>
  102 + <view class='s_and_f' wx:if="{{item.pt_status==6}}">支付尾款失败</view>
  103 + </view>
  104 +
  105 + </view>
  106 +
102 107 </view>
103   -
  108 +
  109 +
  110 + </view>
  111 + <view class='bodytimecen flex' wx:if="{{item.pt_status==1}}">
  112 + 剩余:
  113 + <span>{{item.djs.day}}</span>天
  114 + <span>{{item.djs.hou}}</span>时
  115 + <span>{{item.djs.min}}</span>分
  116 + <span>{{item.djs.sec}}</span>秒
104 117 </view>
105   -
106 118 </view>
107   -
108   -
109 119 </view>
110   - <view class='bodytimecen flex' wx:if="{{item.pt_status==1}}">
111   - 剩余:
112   - <span>{{item.djs.day}}</span>天
113   - <span>{{item.djs.hou}}</span>时
114   - <span>{{item.djs.min}}</span>分
115   - <span>{{item.djs.sec}}</span>秒
116   - </view>
117   -</view>
118 120 </view>
119   -</view>
120 121  
121 122  
122 123 </view>
... ...
pages/team/team_ping/team_ping.wxss
... ... @@ -191,11 +191,15 @@ height:222rpx;
191 191 }
192 192  
193 193 .foot-left{
194   -
195   - margin-left:19rpx;
196   - min-width: 360rpx;
197   - line-height: 100rpx;
198   - font-size:26rpx;
  194 + margin-left:19rpx;
  195 + min-width: 360rpx;
  196 + height: 100rpx;
  197 + line-height: 100rpx;
  198 + font-size:26rpx;
  199 +}
  200 +.foot-left .jietitun {
  201 + height: 50rpx;
  202 + line-height: 50rpx;
199 203 }
200 204  
201 205 .foot-right{
... ... @@ -211,6 +215,7 @@ height:222rpx;
211 215  
212 216 }
213 217  
  218 +
214 219 .foot-right-wz{
215 220  
216 221 padding: 6rpx 20rpx;
... ...
pages/togoin/togoin.js
1   -var t = require("../../utils/common.js");
  1 +var t = require("../../utils/common.js");
2 2 const app=getApp();
3 3 var os = app.globalData.setting;
4 4 var regeneratorRuntime = require('../../utils/runtime.js');
... ... @@ -18,53 +18,86 @@ Page({
18 18 canIUseGetUserProfile: true
19 19 })
20 20 }
21   -
22   - getApp().globalData.isLoad_ad=1;
  21 +
  22 + getApp().globalData.isLoad_ad=1;
23 23 //--判断是否有接受到邀请人的ID--
24 24 if(options.first_leader){
25 25 this.setData({first_leader:options.first_leader});
26 26 }else if(getApp().globalData.first_leader){
27   - this.setData({first_leader:getApp().globalData.first_leader});
28   - }
  27 + this.setData({first_leader:getApp().globalData.first_leader});
  28 + }
29 29 var th=this;
30 30 app.getConfig(function (e) {
31   - var logo=th.data.imghots+e.store_logo;
  31 + var logo=th.data.imghots+e.store_logo;
32 32 th.setData({ store: e,store_logo:logo});
33   - })
34   -
35   - //判断注册的条件
  33 + })
  34 +
  35 + //判断注册的条件
36 36 app.getConfig2(function (e) {
37   - if(e.reg_type==1){
38   - var arr=JSON.parse(e.reg_info);
  37 + if(e.reg_type==1){
  38 + var arr=JSON.parse(e.reg_info);
39 39 if(arr['name_state']==1) th.data.name_need_go=1;
40 40 if(arr['birthday_state']==1) th.data.birth_need_go=1;
41 41 if(arr['idcard_state']==1) th.data.idcard_need_go=1;
42 42 if(arr['address_state']==1) th.data.address_need_go=1;
43 43 if(arr['pick_state']==1) th.data.pick_need_go=1;
44 44 if(arr['sex_state']==1) th.data.sex_need_go=1;
45   - if(arr['introducer_state']==1) th.data.introducer_need_go=1;
46   - }
47   - },1)
  45 + if(arr['introducer_state']==1) th.data.introducer_need_go=1;
  46 + }
  47 + },1)
  48 +
  49 + getApp().promiseGet("/api/wx/weappSendlist/page", {
  50 + data: {
  51 + store_id: os.stoid,
  52 + typeid: "1007"
  53 + }}).then(res=>{
  54 + if (res.data.code == 0 && res.data.data.pageData.length > 0) {
  55 + var template_id = res.data.data.pageData[0].template_id;
  56 + th.setData({template_id:template_id});
  57 + }
  58 + })
48 59 },
  60 +
  61 +
49 62 //绑定手机号
50 63 getphone:function (e) {
51 64 //接下来写业务代码登录
52 65 e=e.detail;
53   - if (e.encryptedData==undefined){
  66 + if (e.encryptedData==undefined){
54 67 this.setData({show_bind:0})
55 68 return app.my_warnning("登录需要授权手机号码!", 0, this);
56 69 return false;
57   - }
58   - var th=this;
  70 + }
  71 + var th=this;
59 72 var sessionKey = getApp().globalData.sessionKey;
60 73 var openid = getApp().globalData.openid;
61   - var r=getApp().globalData.getu;
62   - th.save_the_data(r,e,sessionKey,openid)
  74 + var r=getApp().globalData.getu;
  75 +
  76 + if(e){
  77 + wx.showModal({
  78 + title: '授权通知',
  79 + content:'是否接受注册成功通知',
  80 + success(res){
  81 + if(res.confirm){
  82 + th.sendsm(function (){
  83 + th.save_the_data(r,e,sessionKey,openid)
  84 + })
  85 + }else if(res.cancel){
  86 + th.save_the_data(r,e,sessionKey,openid)
  87 + }
  88 + }
  89 +
  90 + })
  91 + }
  92 +
  93 +
63 94 },
  95 + requestSubscribe(){
  96 +
  97 + },
64 98  
65 99 //-- 会员授权 --
66 100 bindGetUserInfo: function(ee) {
67   -
68 101 if(!this.data.isAgree) {
69 102 wx.showToast({
70 103 title: '请您先阅读和勾选指定的内容',
... ... @@ -83,27 +116,27 @@ Page({
83 116 js_code:o.code,
84 117 store_id: os.stoid,
85 118 nickname: app.clear_word(app.globalData.getu.nickName),
86   - head_pic: app.clear_word(app.globalData.getu.avatarUrl)
87   - };
  119 + head_pic: app.clear_word(app.globalData.getu.avatarUrl)
  120 + };
88 121 //-- 导购会员ID --
89 122 if(getApp().globalData.guide_id){
90 123 dd.guide_id=getApp().globalData.guide_id;
91 124 }
92   -
  125 +
93 126 getApp().request.get("/api/weshop/users/openidandkey", {
94 127 data: dd,
95 128 success: function (e) {
96   - if(e.data.code==0){
97   - that.setData({user:user})
  129 + if(e.data.code==0){
  130 + that.setData({user:user})
98 131 //如果有会员的话,没有sessionKey
99 132 if(!e.data.data.sessionKey){
100 133 getApp().showWarning("登录成功");
101 134 getApp().globalData.userInfo=e.data.data;
102 135 getApp().globalData.user_id=e.data.data.user_id;
103 136 getApp().globalData.openid = e.data.data.weapp_openid;
104   - //把会员的信息存在内存
  137 + //把会员的信息存在内存
105 138 wx.setStorageSync("userinfo",e.data.data);
106   -
  139 +
107 140 setTimeout(function () {
108 141 getApp().globalData.login_back=1;
109 142 wx.navigateBack({ delta: 1}) //返回上一页
... ... @@ -111,45 +144,48 @@ Page({
111 144 }else{
112 145 getApp().globalData.sessionKey=e.data.data.sessionKey;
113 146 getApp().globalData.openid=e.data.data.openid;
114   - that.setData({show_bind:1});
  147 + that.setData({show_bind:1});
115 148 }
116 149 }else{
117   - getApp().confirmBox(e.data.msg);
  150 + getApp().confirmBox(e.data.msg);
118 151 }
119 152 }
120 153 });
121 154 }
122   - })
123   -
124   - })
  155 + })
  156 +
  157 + })
125 158 },
126   -
  159 +
127 160 //-- 调整后的获取会员信息 --
128 161 getUserProfile:function(func){
129   - var that=this;
  162 + var that=this;
130 163 wx.getUserProfile({
131 164 desc:'获取用户相关信息',
132 165 success:res=>{
133 166 console.log("getUserProfile",res);
134 167 //此处授权得到userInfo
135   - getApp().globalData.getu = res.userInfo;
136   - func(res.userInfo);
  168 + getApp().globalData.getu = res.userInfo;
  169 + func(res.userInfo);
137 170 }
138   - });
  171 + });
139 172 },
140   -
  173 +
141 174 //暂不登录,返回上一页
142 175 cancle_bind:function () {
143 176 wx.navigateBack({ delta: 1})
144 177 },
145   -
  178 +
146 179 close_pop:function(){
147 180 this.setData({show_bind:0})
148 181 },
149 182 show_bind_mobile:function(){
150   - this.setData({show_bind:1})
  183 + let th=this;
  184 + th.sendsm(function (){
  185 + th.setData({show_bind:1})
  186 + })
151 187 },
152   -
  188 +
153 189 save_the_data: async function (r,e,sessionKey,openid) {
154 190 var app=getApp(),a=app,th=this;
155 191 var dd = {
... ... @@ -174,39 +210,39 @@ Page({
174 210 dd.first_leader=th.data.first_leader;
175 211 }
176 212 }
177   - })
178   - }
  213 + })
  214 + }
179 215 //-- 导购会员ID --
180 216 if(getApp().globalData.guide_id){
181 217 dd.guide_id=getApp().globalData.guide_id;
182 218 }
183   -
  219 +
184 220 //门店的扫描识别码
185 221 if(getApp().globalData.store_number){
186 222 dd.SunCode=encodeURIComponent(getApp().globalData.store_number.trim());
187 223 }
188   -
189   - console.log("-----会员注册的信息-------");
  224 +
  225 + console.log("-----会员注册的信息-------");
190 226 console.log(dd);
191 227 app.request.get("/api/weshop/users/thirdLogin", {
192 228 data: dd,
193 229 success: function (e) {
194   -
  230 +
195 231 if (e.data.code == 0) {
196 232 app.globalData.user_id = e.data.data.user_id;
197 233 } else {
198 234 return app.showWarning("授权登入失败!"+e.data.msg);
199 235 }
200   -
201   -
202   - var need_go=0;
  236 +
  237 +
  238 + var need_go=0;
203 239 var t_user=e.data.data;
204 240  
205 241  
206 242 getApp().globalData.login_back=1;
207 243 wx.setStorageSync("userinfo",e.data.data);
208 244 wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(a.globalData.userInfo.head_pic);
209   -
  245 +
210 246 //如果有需要完善的信息没有完善,就需要跳转
211 247 if(!t_user['vipname'] && th.data.name_need_go){ need_go=1;}
212 248 if(!t_user['birthday'] && th.data.birth_need_go){ need_go=1;}
... ... @@ -215,15 +251,15 @@ Page({
215 251 if(!t_user['pickup_id'] && th.data.pick_need_go){ need_go=1;}
216 252 if(!t_user['sex'] && th.data.sex_need_go){ need_go=1;}
217 253 if(!t_user['fromuser_id'] && th.data.introducer_need_go){ need_go=1;}
218   -
  254 +
219 255 if(need_go){
220 256 getApp().goto("/packageA/pages/profile/profile");
221 257 }else{
222 258 wx.navigateBack({ delta: 1})
223 259 }
224   -
  260 +
225 261 },
226   - failStatus: function (t) {
  262 + failStatus: function (t) {
227 263 return app.my_warnning("授权登入失败,请稍后再试!", 0, that);
228 264 },
229 265 fail: function (t) {
... ... @@ -238,14 +274,14 @@ Page({
238 274 _errObj[_errImg] = this.data.imghots+"/miniapp/images/logo.png";
239 275 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
240 276 },
241   -
  277 +
242 278 //-- 会员授权 --
243 279 bindUserInfo: function(ee) {
244 280 var that = this;
245 281 var user=ee.detail.userInfo;
246 282 //此处授权得到userInfo
247 283 getApp().globalData.getu = user;
248   -
  284 +
249 285 //--拿下code--
250 286 wx.login({
251 287 success: function (o) {
... ... @@ -253,27 +289,27 @@ Page({
253 289 js_code:o.code,
254 290 store_id: os.stoid,
255 291 nickname: app.clear_word(app.globalData.getu.nickName),
256   - head_pic: app.clear_word(app.globalData.getu.avatarUrl)
257   - };
  292 + head_pic: app.clear_word(app.globalData.getu.avatarUrl)
  293 + };
258 294 //-- 导购会员ID --
259 295 if(getApp().globalData.guide_id){
260 296 dd.guide_id=getApp().globalData.guide_id;
261 297 }
262   -
  298 +
263 299 getApp().request.get("/api/weshop/users/openidandkey", {
264 300 data: dd,
265 301 success: function (e) {
266   - if(e.data.code==0){
267   - that.setData({user:user})
  302 + if(e.data.code==0){
  303 + that.setData({user:user})
268 304 //如果有会员的话,没有sessionKey
269 305 if(!e.data.data.sessionKey){
270 306 getApp().showWarning("登录成功");
271 307 getApp().globalData.userInfo=e.data.data;
272 308 getApp().globalData.user_id=e.data.data.user_id;
273 309 getApp().globalData.openid = e.data.data.weapp_openid;
274   - //把会员的信息存在内存
  310 + //把会员的信息存在内存
275 311 wx.setStorageSync("userinfo",e.data.data);
276   -
  312 +
277 313 setTimeout(function () {
278 314 getApp().globalData.login_back=1;
279 315 wx.navigateBack({ delta: 1}) //返回上一页
... ... @@ -281,26 +317,26 @@ Page({
281 317 }else{
282 318 getApp().globalData.sessionKey=e.data.data.sessionKey;
283 319 getApp().globalData.openid=e.data.data.openid;
284   - that.setData({show_bind:1});
  320 + that.setData({show_bind:1});
285 321 }
286 322 }else{
287   - getApp().confirmBox(e.data.msg);
  323 + getApp().confirmBox(e.data.msg);
288 324 }
289 325 }
290 326 });
291 327 }
292   - })
293   -
294   -
  328 + })
  329 +
  330 +
295 331 },
296   -
297   -
  332 +
  333 +
298 334 close_pop_back:function(){
299 335 this.close_pop();
300 336 wx.navigateBack({ delta: 1})
301 337 },
302   -
303   -
  338 +
  339 +
304 340 // 是否同意协议
305 341 isAgree(e) {
306 342 let isAgree = null;
... ... @@ -308,22 +344,37 @@ Page({
308 344 isAgree = true;
309 345 } else {
310 346 isAgree = false;
311   - };
  347 + };
312 348 // this.data.isAgree = isAgree;
313 349 this.setData({
314 350 isAgree,
315 351 });
316 352 },
317   -
318   -
  353 +
  354 +
319 355 //通过路径跳转到其他页面
320 356 goto: function(e) {
321 357 console.log('xxxx', e);
322 358 var url = e.currentTarget.dataset.url;
323 359 getApp().goto(url);
324 360 },
325   -
326   -
327   -
328   -
  361 +
  362 + //订阅消息提醒
  363 + sendsm:function(func)
  364 + {
  365 + var template_id = this.data.template_id;
  366 + // //授权订阅
  367 + wx.requestSubscribeMessage({
  368 + tmplIds: [template_id],
  369 + success(res) {
  370 + func();
  371 + },
  372 + fail(res) {
  373 + func();
  374 + }
  375 + })
  376 +
  377 + },
  378 +
  379 +
329 380 })
... ...
pages/togoin/togoin.wxml
... ... @@ -14,45 +14,45 @@
14 14 <!-- 登录按钮 -->
15 15 <view>
16 16 <view class="phones">
17   -
  17 +
18 18 <view bindtap="" class="user-name flex-vertical fs24 jc-center">
19 19 <checkbox-group bindchange="isAgree">
20 20 <checkbox value="true"/>
21 21 </checkbox-group>
22 22 <view class="user-name-txt">我已阅读同意 <text class="gray" bindtap="goto" data-url="/packageA/pages/parseHtml/parseHtml?t=0">《用户使用协议》</text>与<text class="gray" bindtap="goto" data-url="/packageA/pages/parseHtml/parseHtml?t=1">《隐私政策》</text></view>
23   - </view>
24   -
  23 + </view>
  24 +
25 25 <!-- 授权获取基础信息 -->
26   - <block wx:if="{{canIUseGetUserProfile}}">
  26 + <block wx:if="{{canIUseGetUserProfile}}">
27 27 <button hidden="{{user}}" class="getPhoneNumber" bindtap="bindGetUserInfo">
28 28 <view class="flex flex-center ali-c">
29 29 <image class="we_chat" src="{{imghots}}/miniapp/images/we_chat.png"></image>
30 30 <view>微信账号快捷登录</view>
31 31 </view>
32   - </button>
33   - </block>
  32 + </button>
  33 + </block>
34 34  
35   - <block wx:else>
36   - <!-- 授权获取基础信息 -->
  35 + <block wx:else>
  36 + <!-- 授权获取基础信息 -->
37 37 <button hidden="{{user}}" class="getPhoneNumber" open-type="getUserInfo" bindgetuserinfo="bindUserInfo">
38 38 <view class="flex flex-center ali-c">
39 39 <image class="we_chat" src="{{imghots}}/miniapp/images/we_chat.png"></image>
40 40 <view>微信账号快捷登录</view>
41 41 </view>
42   - </button>
43   - </block>
44   -
45   - <!-- 点击显示绑定手机的对话框 -->
  42 + </button>
  43 + </block>
  44 +
  45 + <!-- 点击显示绑定手机的对话框 -->
46 46 <button hidden="{{!user}}" class="getPhoneNumber" bindtap="show_bind_mobile">
47 47 <view class="flex flex-center2 ali-c" >
48 48 <image class="we_chat" src="{{imghots}}/miniapp/images/we_chat.png"></image>
49 49 <view>微信账号快捷登录</view>
50 50 </view>
51   - </button>
  51 + </button>
52 52 </view>
53 53  
54 54 <view class="userlongin flex-center2 flex fs30 jc_sb" style="margin: 0 130rpx">
55   - <view bindtap="cancle_bind">暂不登录</view>
  55 + <view bindtap="cancle_bind">暂不登录</view>
56 56 </view>
57 57  
58 58 </view>
... ... @@ -60,14 +60,14 @@
60 60 </view>
61 61  
62 62  
63   -<view wx:if="{{show_bind}}">
64   - <view class="cover-layer" bindtap="close_pop"></view>
  63 +<view wx:if="{{show_bind}}">
  64 + <view class="cover-layer" bindtap="close_pop"></view>
65 65 <view class="p_content">
66 66 <view class="p_title flex ali-c fs34">
67 67 登录手机号,同步会员信息以及订单记录
68 68 </view>
69 69 <view class="flex btn_view">
70   - <view bindtap="close_pop_back" style="height: 100%; line-height:normal;" class="txt-center f2 flex ali-c flex-center2 fs36 b_right">暂不授权</view>
  70 + <view bindtap="close_pop_back" style="height: 100%; line-height:normal;" class="txt-center f2 flex ali-c flex-center2 fs36 b_right">暂不授权</view>
71 71 <button style="height: 100%;" class="g_mobile f2 flex ali-c flex-center2 fs36 txt-red" open-type="getPhoneNumber" bindgetphonenumber="getphone">立即授权</button>
72 72 </view>
73 73 </view>
... ...
pages/user/index/index.js
... ... @@ -58,7 +58,6 @@ Page({
58 58 * 生命周期函数--监听页面加载
59 59 */
60 60 onLoad: function(options) {
61   -
62 61 var th=this;
63 62 //-- 读取会员中心按钮列表 --
64 63 getApp().request.get("/api/weshop/userTool/page?pageSize=100", {
... ... @@ -99,9 +98,6 @@ Page({
99 98 * 生命周期函数--监听页面显示
100 99 */
101 100 onShow: function() {
102   - this.getTabBar().setData({
103   - cartGoodsNum: getApp().globalData.cartGoodsNum,
104   - })
105 101 //看一下小程序是不是过期了
106 102 getApp().getConfig2(function(config2){
107 103 if(config2 && config2.is_overdue==1){
... ... @@ -739,8 +735,6 @@ Page({
739 735  
740 736 }
741 737 })
742   -
743   -
744 738 },
745 739 clike_banne: function() {
746 740 var th = this;
... ... @@ -755,6 +749,7 @@ Page({
755 749 getApp().showWarning("请稍后重试");
756 750 }
757 751 },
  752 +
758 753 // 判断助力活动是不是存在
759 754 is_assistance: function() {
760 755 var th = this,r=Math.random()*100;
... ...
utils/util.js
... ... @@ -13,7 +13,22 @@ function trim(str) { return str.replace(/(^s*)|(s*$)/g, &quot;&quot;);}
13 13 function e(e) {
14 14 var r = ""; for (var t in e) r += (r ? "&" : "") + t + "=" + e[t]; return r;
15 15 }
16   -
  16 +//节流
  17 +let _throttle =function (fn, interval) {
  18 + var enterTime = 0;//触发的时间
  19 + console.log(1);
  20 +
  21 + var gapTime = interval || 300 ;//间隔时间,如果interval不传,则默认300ms
  22 + return function() {
  23 + console.log(2);
  24 + var context = this;
  25 + var backTime = new Date();//第一次函数return即触发的时间
  26 + if (backTime - enterTime > gapTime) {
  27 + fn.call(context,arguments);
  28 + enterTime = backTime;//赋值给第一次触发的时间,这样就保存了第二次触发的时间
  29 + }
  30 + };
  31 +}.bind(this);
17 32 function utf16to8(str) {
18 33 var out, i, len, c; out = ""; len = str.length;
19 34 for (i = 0; i < len; i++) {
... ... @@ -577,6 +592,7 @@ module.exports = {
577 592 });
578 593 },
579 594 unserialize: unserialize,
  595 + _throttle:_throttle,
580 596 unserialize_o: unserialize_o,
581 597 trim: trim, //去空格
582 598 isEmptyObject: isEmptyObject, //判断空对象
... ...
utils/wxParse/wxParse.wxml
1 1 <template name="wxParse11">
2 2 <block wx:if="{{item.node=='element'}}">
3 3 <button size="mini" type="default" wx:if="{{item.tag=='button'}}">
4   - <template is="wxParse12" data="{{item:item}}" wx:for="{{item.nodes}}"></template>
  4 + <template is="wxParse12" data="{{item:item}}" wx:for="{{item.nodes}}" wx:key="index"></template>
5 5 </button>
6 6 <view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}" wx:elif="{{item.tag=='li'}}">
7 7 <view class="{{item.classStr}} wxParse-li-inner">
... ... @@ -16,7 +16,7 @@
16 16 <template is="wxParseVideo" data="{{item:item}}" wx:elif="{{item.tag=='video'}}"></template>
17 17 <template is="wxParseImg" data="{{item:item}}" wx:elif="{{item.tag=='img'}}"></template>
18 18 <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}" wx:elif="{{item.tag=='a'}}">
19   - <template is="wxParse12" data="{{item:item}}" wx:for="{{item.nodes}}"></template>
  19 + <template is="wxParse12" data="{{item:item}}" wx:for="{{item.nodes}}" wx:key="index"></template>
20 20 </view>
21 21 <template is="WxParseBr" data wx:elif="{{item.tag=='br'}}"></template>
22 22 <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}" wx:elif="{{item.tagType=='block'}}">
... ...