jufubao-food 1.0.12-beta7 → 1.0.12-beta9

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-beta7",
3
+ "version": "1.0.12-beta9",
4
4
  "private": false,
5
5
  "description": "聚福宝业务组件餐饮插件包",
6
6
  "main": "index.js",
@@ -135,7 +135,10 @@
135
135
  </xd-list-item>
136
136
  </view>
137
137
 
138
- <view :style="{height: '100rpx'}"></view>
138
+ <view class="placeholderBottom" :style="bottomFixedStylePlaceholder"></view>
139
+ <view v-if="orderInfo.order_status === 'N'" class="alert_bottom" :style="alertBottomStyleComp">
140
+ {{ orderInfo.error_tip }}
141
+ </view>
139
142
  <!-- 靠低支付 -->
140
143
  <view class="fixe_bottom" :style="prod_bottom">
141
144
  <view class="fixed_bottom_body" :style="[bottomBoxStyle]">
@@ -145,7 +148,7 @@
145
148
  </view>
146
149
  <view>
147
150
  <xd-button type="primary" width="200rpx" size="small"
148
- :disabled="is_can_buy!=='Y'"
151
+ :disabled="orderInfo.order_status!=='Y'"
149
152
  :radius="bottomBtnRadius + 'rpx'"
150
153
  :style="{
151
154
  height: bottomBtnHeight + 'rpx',
@@ -346,6 +349,13 @@
346
349
  prod_bottom() {
347
350
  return this.fixedStyle({height: 0, zIndex: 111});
348
351
  },
352
+ alertBottomStyleComp(){
353
+ return this.fixedStyle({paddingBottom: 106, zIndex: 110})
354
+ },
355
+ bottomFixedStylePlaceholder() {
356
+ let tipAlert = this.orderInfo && this.orderInfo.order_status==='N' ? 120: 0
357
+ return this.fixedStyle({paddingBottom: tipAlert, zIndex: 110}, 'bottom', false);
358
+ },
349
359
  bottomBoxStyle(){
350
360
  return {
351
361
  padding: '20rpx'
@@ -913,6 +923,25 @@
913
923
  font-size: unit(24,rpx);
914
924
  }
915
925
  }
926
+ .placeholderBottom{
927
+
928
+ }
929
+ .alert_bottom{
930
+ background: rgba(255, 244, 191, 0.9);
931
+ color: rgba(255, 102, 26, 1);
932
+ display: flex;
933
+ justify-content: center;
934
+ text-align: center;
935
+ height: 60rpx;
936
+ line-height: 60rpx;
937
+ font-size: 28rpx;
938
+ position: fixed;
939
+ right:0;
940
+ left:0;
941
+ bottom:0;
942
+ width: 100%;
943
+ z-index: 111;
944
+ }
916
945
  .fixe_bottom{
917
946
  background: #FFF;
918
947
  box-shadow: 0 0 unit(16, rpx) rgba(0,0,0,.05);
@@ -146,6 +146,7 @@
146
146
  return {
147
147
  '--main-color': this.mainColor,
148
148
  '--bg-color': this.mainColorAlpha,
149
+ '--bg-main-color': this.mainColorAlpha,
149
150
  }
150
151
  },
151
152
  prod_bottom() {
@@ -363,18 +364,19 @@
363
364
  font-size: 32rpx;
364
365
  color: #333333;
365
366
  padding-right: 20rpx;
367
+ font-weight: 500;
366
368
  }
367
369
  }
368
370
  .sku_wrap{
369
371
  background-color: #FFFFFF;
370
- padding: 32rpx;
371
- margin: 20rpx;
372
+ padding: 24rpx;
373
+ margin: 16rpx;
372
374
  border-radius: 16rpx;
373
375
  }
374
376
  .attr_wrap{
375
377
  background-color: #FFFFFF;
376
- padding: 32rpx;
377
- margin: 20rpx;
378
+ padding: 24rpx;
379
+ margin: 16rpx;
378
380
  border-radius: 16rpx;
379
381
  }
380
382
  .fixed_bottom{
@@ -16,6 +16,68 @@ module.exports = {
16
16
  {
17
17
  product_sku: "",
18
18
  specs: [
19
+ {
20
+ code: "mahua_1",
21
+ name: "单选",
22
+ required: true,
23
+ multiple: false,
24
+ multiple_min: 1,
25
+ multiple_max: -1,
26
+ is_show_image: true,
27
+ values: [
28
+ {
29
+ code: "507887",
30
+ name: "奥利奥麦旋风",
31
+ image:
32
+ "https://menu-img.mcd.cn/pcm/prod/menu/20220713a/product/MS_507887_320.png",
33
+ price: 0,
34
+ num: 1,
35
+ checked: true,
36
+ enabled: true
37
+ },
38
+ {
39
+ code: "507888",
40
+ name: "草莓麦旋风",
41
+ image:
42
+ "https://menu-img.mcd.cn/pcm/prod/menu/20220713a/product/MS_507888_320.png",
43
+ price: 0,
44
+ num: 1,
45
+ checked: false,
46
+ enabled: true
47
+ },
48
+ {
49
+ code: "507889",
50
+ name: "草莓麦旋风",
51
+ image:
52
+ "https://menu-img.mcd.cn/pcm/prod/menu/20220713a/product/MS_507888_320.png",
53
+ price: 2,
54
+ num: 1,
55
+ checked: false,
56
+ enabled: true
57
+ },
58
+ {
59
+ code: "507890",
60
+ name: "草莓麦旋风",
61
+ image:
62
+ "https://menu-img.mcd.cn/pcm/prod/menu/20220713a/product/MS_507888_320.png",
63
+ price: 2,
64
+ num: 1,
65
+ checked: false,
66
+ enabled: true
67
+ },
68
+ {
69
+ code: "507891",
70
+ name: "草莓麦旋风",
71
+ image:
72
+ "https://menu-img.mcd.cn/pcm/prod/menu/20220713a/product/MS_507888_320.png",
73
+ price: 3,
74
+ num: 1,
75
+ checked: false,
76
+ enabled: true
77
+ },
78
+ ]
79
+ },
80
+
19
81
  {
20
82
  code: "Cupsize",
21
83
  name: "杯型",
@@ -267,7 +267,8 @@ export default {
267
267
  }
268
268
  .tag_tit{
269
269
  font-size: 28rpx;
270
- color: #242424;
270
+ color: #333333;
271
+ font-weight: 500;
271
272
  margin-bottom: 20rpx;
272
273
  display: flex;
273
274
  align-items: center;
@@ -291,14 +292,14 @@ export default {
291
292
  border-radius: 12rpx;
292
293
  background-color: #EDEDED;
293
294
  font-size: 28rpx;
294
- color: #666666;
295
- line-height: 60rpx;
295
+ color: #333333;
296
+ line-height: 70rpx;
296
297
  padding: 0 32rpx;
297
298
  margin-right: 20rpx;
298
299
  margin-bottom: 20rpx;
299
300
  // max-width: 208rpx;
300
301
  box-sizing: border-box;
301
- .uni-one-cut(60);
302
+ .uni-one-cut(70);
302
303
 
303
304
  &.is-img{
304
305
  border: none;
@@ -1,23 +1,33 @@
1
1
  <template>
2
2
  <view class="xd_spu">
3
3
  <view class="spu_group" v-for="(item, i) in uiList" :key="item.code">
4
- <view class="spu_title">{{ item.name }}</view>
4
+ <view class="spu_title">{{ item.name }} <text v-if="item.multiple_max > 0">(请选择{{item.multiple_max}}份)</text></view>
5
5
  <view class="specs_list img_list" v-if="item.is_show_image">
6
6
  <view v-for="(opt, ii) in item.values" :key="opt.code"
7
7
  class="specs_img_item" :class="{ 'active': opt.checked }"
8
8
  @click="handleCheck(i, ii)"
9
9
  >
10
10
  <image class="spec_img" :src="opt.image" mode=""></image>
11
- <view class="spec_name">{{ opt.name }}</view>
12
- <view>+{{ opt.price }}元</view>
13
- <view class="spec_num" @click.stop>
14
- <xd-number width="160" :disabled="checkIsDisabled(i, ii)" v-model="opt.num" :min="1" :max="99"></xd-number>
11
+ <view class="spec_main">
12
+ <view class="spec_name">{{ opt.name }}</view>
13
+ <view class="spec_price">
14
+ <template v-if="opt.price">+{{ opt.price/100 }}元</template>
15
+ </view>
16
+ <view v-if="item.multiple" class="spec_num" @click.stop>
17
+ <!-- <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
+ <view v-if="!checkIsDisabled(i, ii)" class="num_box">
19
+ <view class="opt_box num_minus" @click="handleNumMinus(opt, i, ii)">-</view>
20
+ <view class="num_text">{{ opt.num }}</view>
21
+ <view class="opt_box num_plus" @click="handleNumAdd(opt, i, ii)">+</view>
22
+ </view>
23
+ </view>
15
24
  </view>
16
- <view class="p_t_r">
25
+ <!-- <view class="p_t_r">
17
26
  <xd-radio v-if="item.multiple" :disabled="checkIsDisabled(i, ii)" class="xdCheckbox" v-model="opt.checked" :isClickEvent="false"></xd-radio>
18
27
  <xd-radio v-else class="xdRadio" v-model="opt.checked" :isClickEvent="false"></xd-radio>
19
- </view>
28
+ </view> -->
20
29
  </view>
30
+ <view v-if="item.values.length%3===2" style="width:200rpx;height:1px;"></view>
21
31
  </view>
22
32
  <view class="specs_list" v-else>
23
33
  <view v-for="(opt, ii) in item.values" :key="opt.code"
@@ -47,7 +57,7 @@ export default {
47
57
  type: Array,
48
58
  default: ()=>[
49
59
  {
50
- "code":"Cupsize","name":"杯型","required":false,"multiple":true,"multiple_min":1,"multiple_max":-1,"is_show_image": true,
60
+ "code":"Cupsize","name":"杯型","required":true,"multiple":true,"multiple_min":1,"multiple_max":2,"is_show_image": true,
51
61
  "values":[
52
62
  {"code":"Tall","name":"中杯","image":"https://image.quanma51.com/self/mahua/sbk/product/6cdc540a91a84b2eb6b58ac510725a48!img","price":0,"num":1,"checked":true,"enabled":true},
53
63
  {"code":"Grande","name":"大杯","image":"https://image.quanma51.com/self/mahua/sbk/product/782ac850a8c14bd38b7b5a22f03d6c74!img","price":600,"num":1,"checked":false,"enabled":true},
@@ -65,7 +75,13 @@ export default {
65
75
  watch: {
66
76
  list: {
67
77
  handler(val){
68
- this.uiList = val;
78
+ this.uiList = val.map(item => {
79
+ item.values = item.values.map(opt => {
80
+ if(!opt.checked) opt.num = 0;
81
+ return opt;
82
+ })
83
+ return item;
84
+ });
69
85
  },
70
86
  immediate: true,
71
87
  },
@@ -78,10 +94,44 @@ export default {
78
94
  }
79
95
  },
80
96
  methods: {
97
+ handleNumAdd(opt, i, ii){
98
+ let parent = this.uiList[i];
99
+ let maxNum = parent.multiple_max;
100
+ let curNum = 0;
101
+ for(let j = 0; j < parent.values.length; j++){
102
+ if(parent.values[j].checked){
103
+ curNum += parent.values[j].num;
104
+ }
105
+ }
106
+ if(curNum >= maxNum) return;
107
+ if(this.checkIsDisabled(i, ii)) return;
108
+ this.$set(this.uiList[i].values[ii], 'num', opt.num + 1);
109
+ this.$set(this.uiList[i].values[ii], 'checked', true)
110
+ },
111
+ handleNumMinus(opt, i, ii){
112
+ let curNum = opt.num;
113
+ let parent = this.uiList[i];
114
+ if(curNum <= 0) return;
115
+ //如果是必选项,且最后一个选中项,则不允许减少到0
116
+ if(parent.required){
117
+ let checkedArr = this.uiList[i].values.filter(opt => opt.checked);
118
+ if(checkedArr.length === 1 && checkedArr[0].num === 1) return;
119
+ }
120
+
121
+ let nextVal = opt.num - 1;
122
+ this.$set(this.uiList[i].values[ii], 'num', nextVal);
123
+ if(nextVal === 0){
124
+ this.$set(this.uiList[i].values[ii], 'checked', false)
125
+ }
126
+ },
81
127
  handleCheck(i, ii){
128
+ let firstChild = this.uiList[i];
129
+ if(firstChild.multiple) return;
82
130
  let curVal = this.uiList[i].values[ii];
83
131
  if(!curVal.enabled) return;
84
-
132
+ this.setUIListChecked(i, ii);
133
+ },
134
+ setUIListChecked(i, ii){
85
135
  this.uiList = this.uiList.map((item, j) => {
86
136
  if(j === i){
87
137
  let checkedArr = item.values.filter(opt => opt.checked);
@@ -151,7 +201,8 @@ export default {
151
201
  .spu_title{
152
202
  font-size: 28rpx;
153
203
  color: #333333;
154
- margin-bottom: 16rpx;
204
+ margin-bottom: 24rpx;
205
+ font-weight: 500;
155
206
  }
156
207
  .specs_list{
157
208
  display: flex;
@@ -162,21 +213,25 @@ export default {
162
213
  }
163
214
 
164
215
  .specs_img_item{
165
- width: 200rpx;
166
- height: 320rpx;
167
- border: 1px solid #EEEEEE;
168
- border-radius: 4rpx;
216
+ border: 1px solid #F8F8F8;
217
+ border-radius: 8rpx;
169
218
  display: flex;
170
219
  flex-direction: column;
171
220
  align-items: center;
172
221
  font-size: 24rpx;
173
222
  box-sizing: border-box;
174
- padding: 16rpx;
175
223
  color: #333333;
176
224
  position: relative;
225
+ margin-bottom: 16rpx;
226
+ overflow: hidden;
177
227
 
178
228
  &.active{
179
- border-color: #FF6C00;
229
+ border-color: var(--main-color);
230
+
231
+ .spec_main{
232
+ background-color: var(--bg-main-color);
233
+ color: var(--main-color);
234
+ }
180
235
  }
181
236
  .p_t_r{
182
237
  position: absolute;
@@ -190,14 +245,60 @@ export default {
190
245
  }
191
246
 
192
247
  .spec_img{
193
- width: 160rpx;
194
- height: 160rpx;
248
+ width: 212rpx;
249
+ height: 212rpx;
250
+ }
251
+ .spec_main{
252
+ background-color: #F8F8F8;
253
+ width: 100%;
254
+ display: flex;
255
+ flex-direction: column;
256
+ align-items: center;
257
+ font-size: 28rpx;
258
+ color: #333333;
259
+ flex: 1;
195
260
  }
196
261
  .spec_name{
197
262
  margin-top: 16rpx;
198
263
  }
264
+ .spec_price{
265
+ height: 28rpx;
266
+ margin: 14rpx 0 20rpx;
267
+ line-height: 1;
268
+ }
199
269
  .spec_num{
200
- margin-top: 12rpx;
270
+ margin-bottom: 20rpx;
271
+ }
272
+ .num_box{
273
+ display: flex;
274
+ justify-content: center;
275
+ align-items: center;
276
+
277
+ .num_text{
278
+ padding: 0 40rpx;
279
+ }
280
+
281
+ .opt_box{
282
+ border-radius: 50%;
283
+ width: 40rpx;
284
+ height: 40rpx;
285
+ display: flex;
286
+ justify-content: center;
287
+ align-items: center;
288
+ font-size: 28rpx;
289
+ box-sizing: border-box;
290
+ padding-bottom: 4rpx;
291
+
292
+ &.num_plus{
293
+ background-color: var(--main-color);
294
+ color: #FFFFFF;
295
+ }
296
+ &.num_minus{
297
+ border: 1px solid var(--main-color);
298
+ color: var(--main-color);
299
+ background-color: #FFFFFF;
300
+ }
301
+ }
201
302
  }
202
303
  ::v-deep .uni-numbox{
203
304
  height: 40rpx;
@@ -219,16 +320,18 @@ export default {
219
320
 
220
321
  .specs_item{
221
322
  padding: 16rpx 32rpx;
222
- background-color: #EEEEEE;
223
- color: #999999;
224
- font-size: 24rpx;
225
- border-radius: 4rpx;
323
+ background-color: #F8F8F8;
324
+ color: #333333;
325
+ font-size: 28rpx;
326
+ border-radius: 8rpx;
226
327
  margin-bottom: 16rpx;
227
328
  margin-right: 16rpx;
329
+ border: 1px solid #F8F8F8;
228
330
 
229
331
  &.active{
230
- background-color: #FF6C00;
231
- color: #FFFFFF;
332
+ background-color: var(--bg-main-color);
333
+ color: var(--main-color);
334
+ border: 1px solid var(--main-color);
232
335
  }
233
336
  }
234
337
  }
@@ -47,7 +47,7 @@
47
47
  :scroll-top="prodScrollTop"
48
48
  @scroll="handleScroll"
49
49
  >
50
- <view v-for="(cate, i) in categoryList" :key="cate.category_id"
50
+ <view v-for="(cate, i) in showCategoryList" :key="cate.category_id"
51
51
  class="product_group"
52
52
  :id="getID(cate)"
53
53
  :data-next="cate.nextHeight"
@@ -68,28 +68,21 @@
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" type="order" :showPrice="item.show_prices"></CusPrice>
71
+ <CusPrice :isPlus="is_plus_site" :isShowIcon="false" :showPrice="item.show_prices"></CusPrice>
72
72
  </view>
73
- <view style="font-size: 28rpx;color:#999" @click="toProductDetail(item)">
74
- <view v-if="item.has_choose" class="chose_spu">选规格</view>
75
- <xd-font-icon v-else icon="iconaddcart" :color="mainColor" size="46"></xd-font-icon>
73
+ <view style="font-size: 28rpx;color:#999">
74
+ <view v-if="item.has_choose" class="chose_spu" @click="toProductDetail(item)">
75
+ 选规格
76
+ <view v-if="item.num" class="cart_edg">{{ item.num }}</view>
77
+ </view>
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>
81
+ </view>
76
82
  </view>
77
83
  </view>
78
84
  </view>
79
85
  </view>
80
- <!-- <cus-product
81
- :image-radius="imageRadius"
82
- :brand-color="brandColor"
83
- :height="200"
84
- :cell="column_num"
85
- :name-font="itemFontStyle"
86
- :product-config="productConfig"
87
- :isPlus="is_plus_site"
88
- :item="item"
89
- :row-spacing="rowSpacing"
90
- :cell-spacing="itemSpacing"
91
- @on-product-detail="toProductDetail"
92
- ></cus-product> -->
93
86
  </view>
94
87
  </view>
95
88
  <view class="product_list" v-else>
@@ -113,7 +106,7 @@
113
106
  <xd-unit :price="cartPrice" :isOld="false"></xd-unit>
114
107
  </view>
115
108
  <view>
116
- <xd-button width="200rpx" size="small" type="primary" :disabled="!cartProductList.length" @click="handleSubmitCart">选好了</xd-button>
109
+ <xd-button width="170rpx" size="small" type="primary" :disabled="!cartProductList.length" @click="handleSubmitCart">选好了</xd-button>
117
110
  </view>
118
111
  </view>
119
112
  <view class="cart_product_modal" v-if="cartProductShow">
@@ -134,7 +127,7 @@
134
127
  <view class="prod_info">
135
128
  <view class="prod_tit"
136
129
  :class="{
137
- prod_tit_one:prod.product_sku_name
130
+ prod_tit_one:prod.sub_name
138
131
  }">{{prod.product_name}}</view>
139
132
  <!-- <view class="prod_brand" :style="{color:brandTextColor}" v-if="prod.brand_name">{{prod.brand_name}}</view> -->
140
133
  <view class="prod_specs" v-if="prod.sub_name">{{prod.sub_name}}</view>
@@ -150,7 +143,7 @@
150
143
  </view>
151
144
  </view>
152
145
  <view v-else class="prod_list">
153
- <xd-no-data>购物车暂无商品</xd-no-data>
146
+ <xd-no-data height="250rpx" :scaleSize="0.8">购物车暂无商品</xd-no-data>
154
147
  </view>
155
148
  </view>
156
149
  </view>
@@ -207,6 +200,7 @@
207
200
  prodScrollIntoView: "",
208
201
  prodScrollTop: 0,
209
202
  scrollUpTimer: null,
203
+ scrollTimer: null,
210
204
 
211
205
  scrollBoxHeight: 0, // 商品滚动盒子高度
212
206
  triggerHeight: 100, // 触发加载更多高度
@@ -267,6 +261,16 @@
267
261
  fixed_bottom() {
268
262
  return this.fixedStyle({height: 30, zIndex: 111});
269
263
  },
264
+ showCategoryList(){
265
+ return this.categoryList.map(item => {
266
+ item.productList = (item.productList || []).map(prod => {
267
+ let cartProd = this.cartProductList.find(item => item.product_id === prod.product_id);
268
+ prod.num = cartProd ? cartProd.num : 0;
269
+ return prod;
270
+ });
271
+ return item;
272
+ })
273
+ },
270
274
  },
271
275
  watch: {
272
276
  container(value, oldValue) {
@@ -389,49 +393,81 @@
389
393
  }
390
394
  })
391
395
  },
396
+ getList(options = {}){
397
+ return new Promise((resolve, reject) => {
398
+ jfbRootExec("getFoodProductList", {
399
+ vm: this,
400
+ data: {
401
+ xnamespace: this.xnamespace,
402
+ shop_id: this.shopInfo.shop_id,
403
+ consume_mode: this.consume_mode,
404
+ page_token: options.page_token || 1,
405
+ page_size: this.page_size,
406
+ category_id: options.category_id,
407
+ ...options,
408
+ }
409
+ }).then(res => {
410
+ let productList = res.lists;
411
+ this.categoryList = this.categoryList.map((item, index) => {
412
+ if(item.category_id === options.category_id){
413
+ let prodList = [];
414
+ if(item.productList && item.productList.length){
415
+ prodList = item.productList.concat(productList);
416
+ }else{
417
+ prodList = productList;
418
+ }
419
+ prodList = prodList.map(prod => {
420
+ prod.key = `${item.category_id}_${prod.product_id}`;
421
+ return prod;
422
+ })
423
+ prodList = prodList.reduce((pre, cur) => {
424
+ if(!pre[cur.key]){
425
+ pre[cur.key] = cur;
426
+ }
427
+ return pre;
428
+ }, {});
429
+ item.productList = Object.values(prodList);
430
+ item.total_size = res.total_size;
431
+ item.next_page_token = res.next_page_token;
432
+ }
433
+ return item;
434
+ })
435
+ resolve(res);
436
+ }).catch(err => {
437
+ reject(err);
438
+ })
439
+ })
440
+ },
392
441
  //获取门店商品列表
393
442
  p_getFoodProductList(){
394
443
  let curLoadCate = this.categoryList[this.loadCateIndex];
395
- if(!curLoadCate) return;
444
+ if(!curLoadCate) return Promise.resolve();
396
445
  this.$xdShowLoading({});
397
- jfbRootExec("getFoodProductList", {
398
- vm: this,
399
- data: {
400
- xnamespace: this.xnamespace,
401
- shop_id: this.shopInfo.shop_id,
402
- consume_mode: this.consume_mode,
403
- page_token: curLoadCate.next_page_token || 1,
404
- page_size: this.page_size,
405
- category_id: curLoadCate.category_id,
406
- }
407
- }).then(res => {
408
- // this.productList = res.lists;
409
- this.$xdHideLoading();
410
- let productList = res.lists;
411
- this.categoryList = this.categoryList.map((item, index) => {
412
- if(index === this.loadCateIndex){
413
- if(item.productList && item.productList.length){
414
- item.productList = item.productList.concat(productList);
415
- }else{
416
- item.productList = productList;
417
- }
418
- item.productList = item.productList.map(prod => {
419
- prod.key = `${item.category_id}_${prod.product_id}`;
420
- return prod;
421
- })
422
- item.total_size = res.total_size;
423
- item.next_page_token = res.next_page_token;
446
+ let options = {
447
+ page_token: curLoadCate.next_page_token || 1,
448
+ category_id: curLoadCate.category_id,
449
+ };
450
+ return new Promise((resolve,reject) => {
451
+ this.getList(options).then(async res => {
452
+ this.$xdHideLoading();
453
+ if(res.total_size < 3){
454
+ await this.loadNextCateProduct(this.loadCateIndex)
424
455
  }
425
- return item;
456
+ this.$nextTick(() => {
457
+ setTimeout(() => {
458
+ this.setCategoryRect();
459
+ this.isLoading = false;
460
+ }, 300)
461
+ });
462
+ resolve(res);
463
+ }).catch(err => {
464
+ this.$xdHideLoading();
465
+ reject(err);
426
466
  })
427
- this.$nextTick(() => {
428
- this.setCategoryRect();
429
- this.isLoading = false;
430
- })
431
- console.log(this.categoryList, 'categoryList')
432
467
  })
433
468
  },
434
469
  setCategoryRect(){
470
+ console.log("setCategoryRect")
435
471
  const query = uni.createSelectorQuery().in(this);
436
472
  this.categoryList = this.categoryList.map(cate => {
437
473
  let id = this.getID(cate);
@@ -455,12 +491,16 @@
455
491
  getID(cate) {
456
492
  return `category_${cate.category_id}`;
457
493
  },
458
- switchCate(index){
494
+ async switchCate(index){
459
495
  this.pointerScroll = false;
460
496
  this.cateIndex = index;
461
497
  this.loadCateIndex = index;
462
498
  let curCate = this.categoryList[this.cateIndex];
463
499
  this.prodScrollIntoView = this.getID(curCate);
500
+ //是否最后一个分类
501
+ if(this.cateIndex === this.categoryList.length - 1){
502
+ await this.loadPreCateProduct(index);
503
+ }
464
504
  if(curCate.productList && curCate.productList.length===0){
465
505
  this.p_getFoodProductList();
466
506
  }
@@ -485,8 +525,23 @@
485
525
  this.handleCurCate(e);
486
526
  }
487
527
  this.lastScrollTop = scrollTop;
488
-
528
+
529
+ //滚动结束后,触发纠错机制
530
+ if(this.scrollTimer) clearTimeout(this.scrollTimer);
531
+ this.scrollTimer = setTimeout(() => {
532
+ this.getProductIsEmpty();
533
+ }, 200)
534
+ },
535
+ //滚动过快,当前项未加载
536
+ getProductIsEmpty(){
537
+ let curCate = this.categoryList[this.cateIndex];
538
+ if(!curCate) return;
539
+ if(curCate.productList && curCate.productList.length===0){
540
+ console.log("当前分类商品列表为空,重新加载数据");
541
+ this.switchCate(this.cateIndex);
542
+ }
489
543
  },
544
+
490
545
  productBoxScrollUp(e){
491
546
  let scrollTop = e.detail.scrollTop
492
547
  let curIndex = this.categoryList.findIndex(item => {
@@ -542,10 +597,11 @@
542
597
  this.isLoading = true;
543
598
  //判断是否需要加载更多, 继续加载当前分类,还是加载下一个分类
544
599
  if(curCate.productList && curCate.productList.length < curCate.total_size){
600
+ console.log("继续加载当前分类商品 categoryList")
545
601
  this.loadCateIndex = curIndex;
546
602
  this.p_getFoodProductList();
547
603
  }else{
548
- // console.log("加载下一个分类商品 categoryList")
604
+ console.log("加载下一个分类商品 categoryList")
549
605
  this.loadCateIndex = curIndex + 1;
550
606
  let nextCate = this.categoryList[this.loadCateIndex];
551
607
  if(nextCate && nextCate.productList && nextCate.productList.length < nextCate.total_size){
@@ -557,6 +613,46 @@
557
613
  return;
558
614
  }
559
615
  },
616
+ loadPreCateProduct(curCateIndex){
617
+ let preCateIndex = curCateIndex - 1;
618
+ let preCate = this.categoryList[preCateIndex];
619
+ if(!preCate) return Promise.resolve();
620
+ if(preCate.productList && preCate.productList.length === 0){
621
+ let options = {
622
+ page_token: 1,
623
+ category_id: preCate.category_id,
624
+ }
625
+ return new Promise((resolve, reject) => {
626
+ this.getList(options).then(async res => {
627
+ if(res.lists.length < 3 ) {
628
+ await this.loadPreCateProduct(preCateIndex)
629
+ }
630
+ resolve();
631
+ }).catch(err => {
632
+ reject(err);
633
+ })
634
+ })
635
+ }
636
+ return Promise.resolve();
637
+ },
638
+ loadNextCateProduct(curCateIndex){
639
+ console.log("loadNextCateProduct")
640
+ let nextCateIndex = curCateIndex + 1;
641
+ let nextCate = this.categoryList[nextCateIndex];
642
+ if(!nextCate) return Promise.resolve();
643
+ if(nextCate.productList && nextCate.productList.length === 0){
644
+ let options = {
645
+ page_token: 1,
646
+ category_id: nextCate.category_id,
647
+ }
648
+ this.getList(options).then(async res => {
649
+ if(res.lists.length < 3 ) {
650
+ await this.loadNextCateProduct(nextCateIndex)
651
+ }
652
+ })
653
+ }
654
+ return Promise.resolve();
655
+ },
560
656
 
561
657
  toProductDetail(product){
562
658
  if(product.has_choose){
@@ -651,7 +747,20 @@
651
747
 
652
748
  .jfb-food-product-list {
653
749
  &__body{
654
- background-color: #f8f8f8;
750
+ background-color: #FFFFFF;
751
+
752
+ .cart_edg{
753
+ position: absolute;
754
+ right: -8rpx;
755
+ top: -24rpx;
756
+ color: #FFFFFF;
757
+ background-color: #FF4D4F;
758
+ border-radius: 24rpx;
759
+ padding: 0 12rpx;
760
+ font-size: 24rpx;
761
+ // box-sizing: border-box;
762
+ border: 4rpx solid #FFFFFF;
763
+ }
655
764
  .flex-center{
656
765
  display: flex;
657
766
  align-items: center;
@@ -665,6 +774,7 @@
665
774
  background-color: #FFFFFF;
666
775
  box-sizing: border-box;
667
776
  margin-bottom: 20rpx;
777
+ border-bottom: 1px solid #F8F8F8;
668
778
  padding: 30rpx;
669
779
  position: fixed;
670
780
  top: 0;
@@ -681,18 +791,17 @@
681
791
  text-overflow: ellipsis;
682
792
  max-width: 460rpx;
683
793
  flex: 1;
794
+ font-weight: 500;
684
795
  }
685
796
  }
686
797
  .section_main{
687
798
  display: flex;
688
- padding-top: 16rpx;
689
799
  box-sizing: border-box;
690
800
  .left_nav{
691
801
  width: 160rpx;
692
- background-color: #FFFFFF;
802
+ background-color: #F8F8F8;
693
803
  font-size: 24rpx;
694
- border-radius: 16rpx;
695
- margin-left: 16rpx;
804
+ color: #333333;
696
805
  .nav_item{
697
806
  padding: 24rpx;
698
807
  text-align: center;
@@ -711,14 +820,15 @@
711
820
  }
712
821
 
713
822
  &.active{
714
- color: var(--main-color);
823
+ // color: var(--main-color);
824
+ font-weight: 500;
715
825
  &::after{
716
826
  content: '';
717
827
  position: absolute;
718
828
  left: 0;
719
- top: 24rpx;
720
- bottom: 24rpx;
721
- width: 6rpx;
829
+ top: 28rpx;
830
+ bottom: 28rpx;
831
+ width: 12rpx;
722
832
  background-color: var(--main-color);
723
833
  }
724
834
  }
@@ -726,17 +836,19 @@
726
836
  }
727
837
  .right_product{
728
838
  flex: 1;
729
- margin: 0 16rpx;
839
+ margin: 0 16rpx 0 32rpx;
730
840
 
731
841
  .product_group{
732
842
  .group_title{
733
843
  font-size: 24rpx;
844
+ color: #333333;
845
+ font-weight: 500;
734
846
  background-color: #FFFFFF;
735
847
  margin-bottom: 16rpx;
736
848
  height: 64rpx;
737
849
  line-height: 64rpx;
738
- text-align: center;
739
850
  border-radius: 16rpx;
851
+ padding-left: 16rpx;
740
852
  }
741
853
  .product_list{
742
854
  .product_loading{
@@ -760,13 +872,14 @@
760
872
  font-size: 24rpx;
761
873
  border-radius: 40rpx;
762
874
  box-sizing: border-box;
875
+ position: relative;
763
876
  }
764
877
 
765
878
  .prod_img{
766
879
  width: 200rpx;
767
880
  height: 200rpx;
768
- margin-right: 32rpx;
769
- // background: #f8f8f8;
881
+ margin-right: 16rpx;
882
+ background: #f8f8f8;
770
883
  // border-radius: 16rpx;
771
884
  image{
772
885
  width: 100%;
@@ -893,7 +1006,7 @@
893
1006
  .prod_specs{
894
1007
  padding-top: unit(10, rpx);
895
1008
  display: block;
896
- font-size: 26rpx;
1009
+ font-size: 28rpx;
897
1010
  color: #999999;
898
1011
  line-height: unit(32, rpx);
899
1012
  }