jufubao-food 1.0.12-beta8 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jufubao-food",
3
- "version": "1.0.12-beta8",
3
+ "version": "1.0.12",
4
4
  "private": false,
5
5
  "description": "聚福宝业务组件餐饮插件包",
6
6
  "main": "index.js",
@@ -15,11 +15,25 @@ module.exports = [
15
15
  cart_order_id: ['cart_order_id', 'String', true],
16
16
  delivery_method: ['投递方式', 'String', false],
17
17
  blessings: ['祝福语', 'String', false],
18
- subscribeTimeInfo: ['配送时间', 'String', false]
18
+ subscribeTimeInfo: ['配送时间', 'String', false],
19
+ switch_resource_shop_id: ['切换门店的资源id', 'String', false]
19
20
  },
20
21
  isConsole: true,
21
22
  disabled: true
22
23
  },
24
+ {
25
+ title: "购物车 - 清空购物车",
26
+ path: "/hourdash/v1/:xnamespace/:shop_id/cart/clear",
27
+ mapFnName: "clearFoodCart",
28
+ data: {
29
+ xnamespace: ["命名空间", "String", "必选"],
30
+ shop_id: ["门店id", "String", "必选"],
31
+ consume_mode: ["消费模式", "String", "必选"],
32
+ cart_order_id: ["购物车订单id", "String", "必选"]
33
+ },
34
+ isConsole: true,
35
+ disabled: true,
36
+ },
23
37
  {
24
38
  mapFnName: 'getFoodCardList',
25
39
  title: '展示可选卡列表',
@@ -18,7 +18,7 @@
18
18
  <view class="jfb-food-confirm-v-2__body" :style="[bodyStyleComp]">
19
19
  <view class="section">
20
20
  <view class="delivery_wrap">
21
- <view class="shop_wrap" @click="handleSwitchShop">
21
+ <view class="shop_wrap" @click="toSwitchShop">
22
22
  <view class="shop_info">
23
23
  <view class="_name"><xd-font-icon icon="iconshouye" :color="mainColor" size="36" style="margin-right: 8rpx;"></xd-font-icon>{{ shopInfo.shop_name }}</view>
24
24
  <view class="_dist">{{ shopInfo.distance_conversion}}
@@ -94,6 +94,12 @@
94
94
  <xd-unit :price="orderInfo.product_total_amount" :isOld="false" :fontSize="24" :iconSize="0.3"></xd-unit>
95
95
  </xd-list-item>
96
96
  </view>
97
+ <view v-if="isShowPlusSaveMoney" class="section">
98
+ <xd-list-item label="" paddingLR="60rpx" size="small">
99
+ <view slot="label" style="color: #86541E;">PLUS专享立减</view>
100
+ <xd-unit :price="-plus_saving_money" :largeZero="false" :isOld="false" :fontSize="24" :iconSize="0.3"></xd-unit>
101
+ </xd-list-item>
102
+ </view>
97
103
 
98
104
  <view class="section">
99
105
  <template v-for="item in otherPayMethod">
@@ -215,8 +221,8 @@
215
221
  </view>
216
222
  </view>
217
223
  <view slot="btn" style="display: flex;margin-top: 40rpx;">
218
- <xd-button type="info" size="small" @click="handleChangeStop">更换门店</xd-button>
219
- <xd-button type="primary" size="small" style="margin-left: 40rpx;" @click="handleCreatePayConfirm">就是这家</xd-button>
224
+ <xd-button v-if="shopInfo.is_switch_shop==='Y'" style="margin-right: 40rpx;"type="info" size="small" @click="handleChangeStop">更换门店</xd-button>
225
+ <xd-button type="primary" size="small" @click="handleCreatePayConfirm">就是这家</xd-button>
220
226
  </view>
221
227
  </XdDailog>
222
228
 
@@ -229,7 +235,7 @@
229
235
  </view>
230
236
  </view>
231
237
  <view slot="btn" style="display: flex;margin-top: 40rpx;">
232
- <xd-button type="info" size="small" @click="showDialogChangeShop=false">放弃更换</xd-button>
238
+ <xd-button type="info" size="small" @click="giveUpChange">放弃更换</xd-button>
233
239
  <xd-button type="primary" size="small" style="margin-left: 40rpx;" @click="handleSwitchShop">继续更换</xd-button>
234
240
  </view>
235
241
  </XdDailog>
@@ -247,6 +253,7 @@
247
253
  import XdWalletChose from "@/components/XdWalletChose/XdWalletChose"
248
254
  import CusCouponChose from '@/components/CusCouponChose/CusCouponChose'
249
255
  import XdDailog from "@/components/XdDailog/XdDailog"
256
+ import CusVipList from "@/components/CusVipList/CusVipList"
250
257
  import { jfbRootExec } from "@/utils/xd.event";
251
258
  import JfbFoodConfirmV2Mixin from "./JfbFoodConfirmV2Mixin";
252
259
  import { getContainerPropsValue, gCPVal } from "@/utils/xd.base";
@@ -265,13 +272,17 @@
265
272
  XdCardPayChose,
266
273
  XdWalletChose,
267
274
  CusCouponChose,
268
- XdDailog
275
+ XdDailog,
276
+ CusVipList
269
277
  },
270
278
  mixins: [
271
279
  componentsMixins, extsMixins, JfbFoodConfirmV2Mixin, OrderMixin
272
280
  ],
273
281
  data() {
274
282
  return {
283
+ isVip: false,
284
+ options: {},
285
+ consume_mode: "",
275
286
  order_id: "", //订单ID
276
287
  comment: "", //订单备注
277
288
  buyer_phone_number: "", //订购人手机号
@@ -287,6 +298,7 @@
287
298
  vip_card_id: "",
288
299
  plus_saving_money: 0,
289
300
  main_order_id: "",
301
+ resource_shop_id: "",
290
302
 
291
303
  showDialogConfirmShop: false,
292
304
  showDialogChangeShop: false,
@@ -331,6 +343,7 @@
331
343
  payPath: "",
332
344
  paySuccessPath: "",
333
345
  switchStorePath: "",
346
+ productListPath: "",
334
347
  }
335
348
  },
336
349
  computed: {
@@ -395,6 +408,11 @@
395
408
  let result = this.$xdUniHelper.cutFloatNumber(total_amount, total);
396
409
  return result;
397
410
  },
411
+ //是否展示vip减免
412
+ isShowPlusSaveMoney(){
413
+ if(this.is_show_vip_card_list === 'Y') return this.vip_card_id;
414
+ else return this.isVip && this.plus_saving_money;
415
+ },
398
416
  },
399
417
  watch: {
400
418
  container(value, oldValue) {
@@ -405,13 +423,17 @@
405
423
  created() {
406
424
  this.is_plus_site = this.projectAttr.headers['X-Site-Group']==="vip";
407
425
  this.init(this.container);
408
-
426
+ this.isVip = this.getTokenForKey('user_level') === 'VIP';
409
427
  //todo
410
428
  },
411
429
  methods: {
412
430
  async onJfbLoad(options) {
431
+ this.options = options || {};
413
432
  this.setNameSpace(options);
433
+ this.consume_mode = options.consume_mode || 'HDSELF';
414
434
  this.order_id = options.order_id || '';
435
+ this.resource_shop_id = options.resource_shop_id || '';
436
+ this.main_order_id = options.main_order_id || '';
415
437
  await this.p_getCartConfirm();
416
438
  this.validImageAPIUrl = this.brandInfo['api_host'] + '/common/v1/valid_code/image/show'
417
439
  // #ifdef H5
@@ -439,6 +461,7 @@
439
461
  this.payPath = getContainerPropsValue(container, 'content.payPath', { value: "/system/system/pay" }).value;
440
462
  this.paySuccessPath = getContainerPropsValue(container, 'content.paySuccessPath', {value: "/system/order/success"}).value;
441
463
  this.switchStorePath = getContainerPropsValue(container, 'content.switchStorePath',{value: ""}).value;
464
+ this.productListPath = getContainerPropsValue(container, 'content.productListPath', {value: ""}).value;
442
465
 
443
466
  this.bindCard = getContainerPropsValue(container,"content.bindCard","1");
444
467
  this.skipTip = getContainerPropsValue(container, "content.skipTip", "N");
@@ -487,7 +510,8 @@
487
510
  longitude: this.stateLocation.longitude,
488
511
  card_id: this.vip_card_id,
489
512
  meal_method: this.meal_method,
490
- main_order_id: this.main_order_id
513
+ main_order_id: this.main_order_id,
514
+ switch_resource_shop_id: this.resource_shop_id
491
515
  }
492
516
  }).then(res => {
493
517
  this.$xdHideLoading();
@@ -499,6 +523,10 @@
499
523
  },150)
500
524
  },
501
525
  handlerConfirmRes(res){
526
+ //更换门店后,价格有变动
527
+ if(res.is_price_change === 'Y'){
528
+ this.showDialogChangeShop = true;
529
+ }
502
530
  // this.is_first_use_card = res.is_first_use_card || "Y";
503
531
  // this.is_use_jfb_pay = res.is_use_jfb_pay || "Y";
504
532
  this.is_show_vip_card_list = res.is_show_vip_card_list;
@@ -513,7 +541,7 @@
513
541
  if(!this.meal_method && mealMethods.length){
514
542
  this.meal_method = mealMethods[0].value;
515
543
  }
516
- this.plus_saving_money = res.plus_saving_money || 0;
544
+ this.plus_saving_money = res.order_info.plus_saving_money || 0;
517
545
  this.main_order_id = res.order_info.main_order_id
518
546
 
519
547
  //支付方式跟用户相关,与订单无关。
@@ -606,15 +634,49 @@
606
634
  duration: 0
607
635
  })
608
636
  },
637
+ toSwitchShop(){
638
+ if(this.shopInfo.is_switch_shop !== 'Y') return;
639
+
640
+ //切换门店
641
+ let curPage = this.$xdUniHelper.getCurrentPages();
642
+ let query = {...curPage.query};
643
+ if(this.main_order_id) query.main_order_id = this.main_order_id;
644
+ let callback= Base64.encode(curPage.path + '?' + this.$xdUniHelper.jsonToParams(query));
645
+ this.$xdUniHelper.redirectTo({
646
+ url: this.switchStorePath + '?brand_id=' + this.shopInfo.brand_id + '&callback=' + callback
647
+ })
648
+ },
649
+ //放弃更换
650
+ giveUpChange(){
651
+ this.showDialogChangeShop = false;
652
+ let curPage = this.$xdUniHelper.getCurrentPages();
653
+ let {resource_shop_id, ...otherParams} = curPage.query;
654
+ this.$xdUniHelper.redirectTo({
655
+ url: curPage.path + '?' + this.$xdUniHelper.jsonToParams(otherParams)
656
+ })
657
+ },
609
658
  handleSwitchShop(){
610
659
  this.showDialogChangeShop = false;
611
- this.$xdUniHelper.navigateTo({
612
- url: this.switchStorePath + '?brand_id=' + this.shopInfo.brand_id,
660
+ //清空购物车
661
+ this.$xdShowLoading({})
662
+ jfbRootExec("clearFoodCart", {
663
+ vm: this,
664
+ data: {
665
+ namespace: this.xnamespace,
666
+ shop_id: this.shopInfo.shop_id,
667
+ consume_mode: this.consume_mode,
668
+ cart_order_id: this.order_id
669
+ }
670
+ }).then(res => {
671
+ this.$xdHideLoading();
672
+ this.$xdUniHelper.redirectTo({
673
+ url: this.productListPath + '?resource_shop_id=' + this.resource_shop_id,
674
+ })
613
675
  })
614
676
  },
615
677
  handleChangeStop(){
616
- this.showDialogChangeShop = true;
617
678
  this.showDialogConfirmShop = false;
679
+ this.toSwitchShop();
618
680
  },
619
681
  async handleCardPay(){
620
682
  if(!this.getCreateOrderParams()) return false;
@@ -718,7 +780,7 @@
718
780
  return false;
719
781
  }
720
782
  return {
721
- phone: this.buyer_phone_number,
783
+ buyer_phone_number: this.buyer_phone_number,
722
784
  comment: this.comment,
723
785
  meal_method: this.meal_method,
724
786
  };
@@ -41,6 +41,19 @@ export default (data)=>{
41
41
  groupKey:'advanced',
42
42
  className: 'input100',
43
43
  },
44
+ {
45
+ label: '商品列表',
46
+ ele: 'xd-select-pages-path',
47
+ valueKey: 'productListPath',
48
+ placeholder: '请选择商品列表页跳转地址',
49
+ value: data.productListPath || null,
50
+ setting: {
51
+ router: XdBus.getParentApi('getPagesTree'),
52
+ },
53
+ labelInline: true,
54
+ groupKey:'advanced',
55
+ className: 'input100',
56
+ },
44
57
 
45
58
  {
46
59
  label: '版本号:',
@@ -35,7 +35,7 @@
35
35
  <view class="prod_title_number">
36
36
  <view class="prod_title">{{ baseInfo.product_name }}</view>
37
37
  <view class="prod_number">
38
- <xd-number v-model="number" :min="1" :max="99"></xd-number>
38
+ <xd-number v-model="number" :min="1" :max="99" circle></xd-number>
39
39
  </view>
40
40
  </view>
41
41
 
@@ -53,7 +53,7 @@
53
53
  <view class="fixed_bottom" :style="prod_bottom">
54
54
  <view class="prod_bottom_body">
55
55
  <view class="">
56
- <CusPrice :isPlus="is_plus_site" type="order" :showPrice="productShowPrice"></CusPrice>
56
+ <CusPrice :isPlus="is_plus_site" type="order" salePriceFontSize="32" :showPrice="productShowPrice"></CusPrice>
57
57
  </view>
58
58
  <view class="btns" :style="[bottomBtnWrapStyle]">
59
59
  <xd-button
@@ -125,6 +125,9 @@
125
125
 
126
126
  is_plus_site: false,
127
127
  //面板
128
+ isShowDiscount: "Y", //是否展示划线价
129
+ differ: 1, //原价与现价的差值
130
+
128
131
  shopBtnBgColor: "",
129
132
  bottomBtnRadius: "100",
130
133
  bottomBtnHeight: "",
@@ -236,7 +239,8 @@
236
239
  product_id: this.product_id,
237
240
  category_id: this.category_id,
238
241
  consume_mode: this.consume_mode,
239
- shop_id: this.shop_id
242
+ shop_id: this.shop_id,
243
+ is_show_uprice: this.isShowDiscount !== 'Y' ? 0 : this.multiply(this.differ),
240
244
  }
241
245
  }).then(res => {
242
246
  this.$xdHideLoading()
@@ -249,6 +253,9 @@
249
253
  this.$xdHideLoading()
250
254
  })
251
255
  },
256
+ multiply(num){
257
+ return this.$xdUniHelper.multiplyFloatNumber(num, 100);
258
+ },
252
259
  addCart(){
253
260
  let specs = [];
254
261
  if(this.$refs['mySpu']){
@@ -10,9 +10,10 @@
10
10
  <image class="spec_img" :src="opt.image" mode=""></image>
11
11
  <view class="spec_main">
12
12
  <view class="spec_name">{{ opt.name }}</view>
13
- <view class="spec_price">
13
+ <view v-if="item.showPrice" class="spec_price">
14
14
  <template v-if="opt.price">+{{ opt.price/100 }}元</template>
15
15
  </view>
16
+ <view v-else style="height: 16rpx;"></view>
16
17
  <view v-if="item.multiple" class="spec_num" @click.stop>
17
18
  <!-- <xd-number v-if="!checkIsDisabled(i, ii)" width="160" v-model="opt.num" :min="0" :max="99" @change="val => handleSpeNum(val, i, ii)"></xd-number> -->
18
19
  <view v-if="!checkIsDisabled(i, ii)" class="num_box">
@@ -76,10 +77,13 @@ export default {
76
77
  list: {
77
78
  handler(val){
78
79
  this.uiList = val.map(item => {
80
+ let showPrice = false;
79
81
  item.values = item.values.map(opt => {
80
82
  if(!opt.checked) opt.num = 0;
83
+ if(opt.price > 0) showPrice = true;
81
84
  return opt;
82
85
  })
86
+ item.showPrice = showPrice;
83
87
  return item;
84
88
  });
85
89
  },
@@ -213,6 +217,7 @@ export default {
213
217
  }
214
218
 
215
219
  .specs_img_item{
220
+ width: 212rpx;
216
221
  border: 1px solid #F8F8F8;
217
222
  border-radius: 8rpx;
218
223
  display: flex;
@@ -260,6 +265,9 @@ export default {
260
265
  }
261
266
  .spec_name{
262
267
  margin-top: 16rpx;
268
+ width: 100%;
269
+ text-align: center;
270
+ padding: 0 8rpx;
263
271
  }
264
272
  .spec_price{
265
273
  height: 28rpx;
@@ -68,7 +68,7 @@
68
68
  <view class="prod_specs" v-if="item.sub_name">{{item.sub_name}}</view>
69
69
  <view class="prod_price">
70
70
  <view style="display:flex;align-items:center">
71
- <CusPrice :isPlus="is_plus_site" :isShowIcon="false" :showPrice="item.show_prices"></CusPrice>
71
+ <CusPrice :isPlus="is_plus_site" :isShowIcon="false" salePriceFontSize="32" :showPrice="item.show_prices"></CusPrice>
72
72
  </view>
73
73
  <view style="font-size: 28rpx;color:#999">
74
74
  <view v-if="item.has_choose" class="chose_spu" @click="toProductDetail(item)">
@@ -76,8 +76,9 @@
76
76
  <view v-if="item.num" class="cart_edg">{{ item.num }}</view>
77
77
  </view>
78
78
  <view v-else>
79
- <xd-number v-if="item.num" v-model="item.num" @change="val => handleCartNumChange(val, item)"></xd-number>
80
- <xd-font-icon v-else icon="iconaddcart" :color="mainColor" size="46"></xd-font-icon>
79
+ <xd-number v-if="item.num" v-model="item.num" circle @change="val => handleCartNumChange(val, item)"></xd-number>
80
+ <!-- <xd-font-icon v-else icon="iconaddcart" :color="mainColor" size="46"></xd-font-icon> -->
81
+ <view class="icon_add_cart" v-else @click="toProductDetail(item)">+</view>
81
82
  </view>
82
83
  </view>
83
84
  </view>
@@ -200,6 +201,7 @@
200
201
  prodScrollIntoView: "",
201
202
  prodScrollTop: 0,
202
203
  scrollUpTimer: null,
204
+ scrollTimer: null,
203
205
 
204
206
  scrollBoxHeight: 0, // 商品滚动盒子高度
205
207
  triggerHeight: 100, // 触发加载更多高度
@@ -226,6 +228,8 @@
226
228
  is_plus_site: false,
227
229
 
228
230
  //面板
231
+ isShowDiscount: "Y", //是否展示划线价
232
+ differ: 1, //原价与现价的差值
229
233
  foodDetailPath: "",
230
234
  confirmPath: "",
231
235
  switchStorePath: "",
@@ -392,49 +396,86 @@
392
396
  }
393
397
  })
394
398
  },
399
+ // this.$xdUniHelper.multiplyFloatNumber(res.total_price, 1);
400
+ multiply(num){
401
+ return this.$xdUniHelper.multiplyFloatNumber(num, 100);
402
+ },
403
+ getList(options = {}){
404
+ return new Promise((resolve, reject) => {
405
+ jfbRootExec("getFoodProductList", {
406
+ vm: this,
407
+ data: {
408
+ xnamespace: this.xnamespace,
409
+ shop_id: this.shopInfo.shop_id,
410
+ consume_mode: this.consume_mode,
411
+ page_token: options.page_token || 1,
412
+ page_size: this.page_size,
413
+ category_id: options.category_id,
414
+ is_show_uprice: this.isShowDiscount !== 'Y' ? 0 : this.multiply(this.differ),
415
+ ...options,
416
+ }
417
+ }).then(res => {
418
+ let productList = res.lists;
419
+ this.categoryList = this.categoryList.map((item, index) => {
420
+ if(item.category_id === options.category_id){
421
+ let prodList = [];
422
+ if(item.productList && item.productList.length){
423
+ prodList = item.productList.concat(productList);
424
+ }else{
425
+ prodList = productList;
426
+ }
427
+ prodList = prodList.map(prod => {
428
+ prod.key = `${item.category_id}_${prod.product_id}`;
429
+ return prod;
430
+ })
431
+ prodList = prodList.reduce((pre, cur) => {
432
+ if(!pre[cur.key]){
433
+ pre[cur.key] = cur;
434
+ }
435
+ return pre;
436
+ }, {});
437
+ item.productList = Object.values(prodList);
438
+ item.total_size = res.total_size;
439
+ item.next_page_token = res.next_page_token;
440
+ }
441
+ return item;
442
+ })
443
+ resolve(res);
444
+ }).catch(err => {
445
+ reject(err);
446
+ })
447
+ })
448
+ },
395
449
  //获取门店商品列表
396
450
  p_getFoodProductList(){
397
451
  let curLoadCate = this.categoryList[this.loadCateIndex];
398
- if(!curLoadCate) return;
452
+ if(!curLoadCate) return Promise.resolve();
399
453
  this.$xdShowLoading({});
400
- jfbRootExec("getFoodProductList", {
401
- vm: this,
402
- data: {
403
- xnamespace: this.xnamespace,
404
- shop_id: this.shopInfo.shop_id,
405
- consume_mode: this.consume_mode,
406
- page_token: curLoadCate.next_page_token || 1,
407
- page_size: this.page_size,
408
- category_id: curLoadCate.category_id,
409
- }
410
- }).then(res => {
411
- // this.productList = res.lists;
412
- this.$xdHideLoading();
413
- let productList = res.lists;
414
- this.categoryList = this.categoryList.map((item, index) => {
415
- if(index === this.loadCateIndex){
416
- if(item.productList && item.productList.length){
417
- item.productList = item.productList.concat(productList);
418
- }else{
419
- item.productList = productList;
420
- }
421
- item.productList = item.productList.map(prod => {
422
- prod.key = `${item.category_id}_${prod.product_id}`;
423
- return prod;
424
- })
425
- item.total_size = res.total_size;
426
- item.next_page_token = res.next_page_token;
454
+ let options = {
455
+ page_token: curLoadCate.next_page_token || 1,
456
+ category_id: curLoadCate.category_id,
457
+ };
458
+ return new Promise((resolve,reject) => {
459
+ this.getList(options).then(async res => {
460
+ this.$xdHideLoading();
461
+ if(res.total_size < 3){
462
+ await this.loadNextCateProduct(this.loadCateIndex)
427
463
  }
428
- return item;
464
+ this.$nextTick(() => {
465
+ setTimeout(() => {
466
+ this.setCategoryRect();
467
+ this.isLoading = false;
468
+ }, 300)
469
+ });
470
+ resolve(res);
471
+ }).catch(err => {
472
+ this.$xdHideLoading();
473
+ reject(err);
429
474
  })
430
- this.$nextTick(() => {
431
- this.setCategoryRect();
432
- this.isLoading = false;
433
- })
434
- console.log(this.categoryList, 'categoryList')
435
475
  })
436
476
  },
437
477
  setCategoryRect(){
478
+ console.log("setCategoryRect")
438
479
  const query = uni.createSelectorQuery().in(this);
439
480
  this.categoryList = this.categoryList.map(cate => {
440
481
  let id = this.getID(cate);
@@ -458,12 +499,16 @@
458
499
  getID(cate) {
459
500
  return `category_${cate.category_id}`;
460
501
  },
461
- switchCate(index){
502
+ async switchCate(index){
462
503
  this.pointerScroll = false;
463
504
  this.cateIndex = index;
464
505
  this.loadCateIndex = index;
465
506
  let curCate = this.categoryList[this.cateIndex];
466
507
  this.prodScrollIntoView = this.getID(curCate);
508
+ //是否最后一个分类
509
+ if(this.cateIndex === this.categoryList.length - 1){
510
+ await this.loadPreCateProduct(index);
511
+ }
467
512
  if(curCate.productList && curCate.productList.length===0){
468
513
  this.p_getFoodProductList();
469
514
  }
@@ -488,8 +533,23 @@
488
533
  this.handleCurCate(e);
489
534
  }
490
535
  this.lastScrollTop = scrollTop;
491
-
536
+
537
+ //滚动结束后,触发纠错机制
538
+ if(this.scrollTimer) clearTimeout(this.scrollTimer);
539
+ this.scrollTimer = setTimeout(() => {
540
+ this.getProductIsEmpty();
541
+ }, 200)
542
+ },
543
+ //滚动过快,当前项未加载
544
+ getProductIsEmpty(){
545
+ let curCate = this.categoryList[this.cateIndex];
546
+ if(!curCate) return;
547
+ if(curCate.productList && curCate.productList.length===0){
548
+ console.log("当前分类商品列表为空,重新加载数据");
549
+ this.switchCate(this.cateIndex);
550
+ }
492
551
  },
552
+
493
553
  productBoxScrollUp(e){
494
554
  let scrollTop = e.detail.scrollTop
495
555
  let curIndex = this.categoryList.findIndex(item => {
@@ -545,10 +605,11 @@
545
605
  this.isLoading = true;
546
606
  //判断是否需要加载更多, 继续加载当前分类,还是加载下一个分类
547
607
  if(curCate.productList && curCate.productList.length < curCate.total_size){
608
+ console.log("继续加载当前分类商品 categoryList")
548
609
  this.loadCateIndex = curIndex;
549
610
  this.p_getFoodProductList();
550
611
  }else{
551
- // console.log("加载下一个分类商品 categoryList")
612
+ console.log("加载下一个分类商品 categoryList")
552
613
  this.loadCateIndex = curIndex + 1;
553
614
  let nextCate = this.categoryList[this.loadCateIndex];
554
615
  if(nextCate && nextCate.productList && nextCate.productList.length < nextCate.total_size){
@@ -560,6 +621,46 @@
560
621
  return;
561
622
  }
562
623
  },
624
+ loadPreCateProduct(curCateIndex){
625
+ let preCateIndex = curCateIndex - 1;
626
+ let preCate = this.categoryList[preCateIndex];
627
+ if(!preCate) return Promise.resolve();
628
+ if(preCate.productList && preCate.productList.length === 0){
629
+ let options = {
630
+ page_token: 1,
631
+ category_id: preCate.category_id,
632
+ }
633
+ return new Promise((resolve, reject) => {
634
+ this.getList(options).then(async res => {
635
+ if(res.lists.length < 3 ) {
636
+ await this.loadPreCateProduct(preCateIndex)
637
+ }
638
+ resolve();
639
+ }).catch(err => {
640
+ reject(err);
641
+ })
642
+ })
643
+ }
644
+ return Promise.resolve();
645
+ },
646
+ loadNextCateProduct(curCateIndex){
647
+ console.log("loadNextCateProduct")
648
+ let nextCateIndex = curCateIndex + 1;
649
+ let nextCate = this.categoryList[nextCateIndex];
650
+ if(!nextCate) return Promise.resolve();
651
+ if(nextCate.productList && nextCate.productList.length === 0){
652
+ let options = {
653
+ page_token: 1,
654
+ category_id: nextCate.category_id,
655
+ }
656
+ this.getList(options).then(async res => {
657
+ if(res.lists.length < 3 ) {
658
+ await this.loadNextCateProduct(nextCateIndex)
659
+ }
660
+ })
661
+ }
662
+ return Promise.resolve();
663
+ },
563
664
 
564
665
  toProductDetail(product){
565
666
  if(product.has_choose){
@@ -827,6 +928,20 @@
827
928
  display: flex;
828
929
  align-items: flex-end;
829
930
  justify-content: space-between;
931
+
932
+ .icon_add_cart{
933
+ background-color: var(--main-color);
934
+ border: 1px solid var(--main-color);
935
+ border-radius: 50%;
936
+ color: #FFFFFF;
937
+ font-size: 28rpx;
938
+ width: 48rpx;
939
+ height: 48rpx;
940
+ display: flex;
941
+ align-items: center;
942
+ justify-content: center;
943
+ box-sizing: border-box;
944
+ }
830
945
  }
831
946
  }
832
947
  }