xiaoe_mp_npm 0.5.44 → 0.5.45-test1

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.
Files changed (133) hide show
  1. package/.gitlab-ci.yml +45 -45
  2. package/miniprogram_dist/ConfirmOrder/components/ConfirmOrderContent/index.scss +44 -44
  3. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/index.js +433 -433
  4. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/index.scss +222 -222
  5. package/miniprogram_dist/ConfirmOrder/components/IntegralSelect/index.scss +90 -90
  6. package/miniprogram_dist/ConfirmOrder/components/Invoice/index.scss +60 -60
  7. package/miniprogram_dist/ConfirmOrder/components/LeaveWord/index.scss +39 -39
  8. package/miniprogram_dist/ConfirmOrder/components/PayBar/index.scss +61 -61
  9. package/miniprogram_dist/ConfirmOrder/components/PayDetail/index.scss +40 -40
  10. package/miniprogram_dist/ConfirmOrder/index.js +110 -110
  11. package/miniprogram_dist/CopGoodsCard/images/ex.png +0 -0
  12. package/miniprogram_dist/CopGoodsCard/index.js +148 -0
  13. package/miniprogram_dist/CopGoodsCard/index.json +3 -0
  14. package/miniprogram_dist/CopGoodsCard/index.scss +102 -0
  15. package/miniprogram_dist/CopGoodsCard/index.wxml +20 -0
  16. package/miniprogram_dist/CopGoodsCard/index.wxss +94 -0
  17. package/miniprogram_dist/CouponList/components/CouponItem/index.js +308 -308
  18. package/miniprogram_dist/CouponList/components/CouponItem/index.scss +591 -591
  19. package/miniprogram_dist/CouponList/components/CouponItem/index.wxml +195 -195
  20. package/miniprogram_dist/CouponList/couponColumn/index.scss +117 -117
  21. package/miniprogram_dist/CustomPopup/index.js +82 -82
  22. package/miniprogram_dist/CustomPopup/index.wxml +25 -25
  23. package/miniprogram_dist/GoodsItem/index.js +667 -667
  24. package/miniprogram_dist/GoodsItem/index.less +299 -299
  25. package/miniprogram_dist/GoodsItem/index.scss +331 -331
  26. package/miniprogram_dist/GoodsItem/index.wxml +90 -90
  27. package/miniprogram_dist/GoodsRecommend/fun.wxs +37 -37
  28. package/miniprogram_dist/GoodsRecommend/index.js +91 -91
  29. package/miniprogram_dist/GoodsRecommend/index.json +3 -3
  30. package/miniprogram_dist/GoodsRecommend/index.less +129 -129
  31. package/miniprogram_dist/GoodsRecommend/index.scss +162 -162
  32. package/miniprogram_dist/GoodsRecommend/index.wxml +47 -47
  33. package/miniprogram_dist/LiveGoodsList/Header/index.scss +78 -78
  34. package/miniprogram_dist/LiveGoodsList/index.js +480 -480
  35. package/miniprogram_dist/LiveGoodsList/index.scss +92 -92
  36. package/miniprogram_dist/LiveGoodsList/index.wxml +107 -107
  37. package/miniprogram_dist/PayModule/button/index.scss +44 -44
  38. package/miniprogram_dist/Sku/commSelect/index.js +654 -423
  39. package/miniprogram_dist/Sku/commSelect/index.json +3 -1
  40. package/miniprogram_dist/Sku/commSelect/index.less +11 -0
  41. package/miniprogram_dist/Sku/commSelect/index.wxml +57 -43
  42. package/miniprogram_dist/Sku/commSelect/index.wxss +8 -0
  43. package/miniprogram_dist/Sku/goods-info/index.js +6 -1
  44. package/miniprogram_dist/Sku/goods-info/index.wxml +1 -1
  45. package/miniprogram_dist/Sku/index/index.js +5 -1
  46. package/miniprogram_dist/Sku/index/index.wxml +1 -0
  47. package/miniprogram_dist/TeacherGoodsList/index.wxml +41 -41
  48. package/miniprogram_dist/common/api/confirmOrder.js +217 -217
  49. package/miniprogram_dist/common/api/liveGoodsList.js +81 -81
  50. package/miniprogram_dist/common/api/sku.js +73 -58
  51. package/miniprogram_dist/common/utils/constants.js +8 -1
  52. package/miniprogram_dist/common/utils/helper.js +3 -0
  53. package/miniprogram_dist/common/utils/index.js +69 -69
  54. package/miniprogram_dist/coupon/components/CouponItem/index.less +208 -208
  55. package/miniprogram_dist/coupon/components/CouponItem/index.scss +246 -246
  56. package/miniprogram_dist/coupon/components/CouponSelect/index.scss +330 -330
  57. package/miniprogram_dist/coupon/index.js +237 -237
  58. package/miniprogram_dist/coupon/index.scss +83 -83
  59. package/package.json +78 -78
  60. package/src/ConfirmOrder/components/ConfirmOrderContent/index.scss +44 -44
  61. package/src/ConfirmOrder/components/ConfirmOrderContent/index.wxss +51 -51
  62. package/src/ConfirmOrder/components/GoodsInfo/index.js +433 -433
  63. package/src/ConfirmOrder/components/GoodsInfo/index.scss +222 -222
  64. package/src/ConfirmOrder/components/GoodsInfo/index.wxss +673 -673
  65. package/src/ConfirmOrder/components/IntegralSelect/index.scss +90 -90
  66. package/src/ConfirmOrder/components/IntegralSelect/index.wxss +218 -218
  67. package/src/ConfirmOrder/components/Invoice/index.scss +60 -60
  68. package/src/ConfirmOrder/components/Invoice/index.wxss +93 -93
  69. package/src/ConfirmOrder/components/LeaveWord/index.scss +39 -39
  70. package/src/ConfirmOrder/components/LeaveWord/index.wxss +34 -34
  71. package/src/ConfirmOrder/components/PayBar/index.scss +61 -61
  72. package/src/ConfirmOrder/components/PayBar/index.wxss +108 -108
  73. package/src/ConfirmOrder/components/PayDetail/index.scss +40 -40
  74. package/src/ConfirmOrder/components/PayDetail/index.wxss +50 -50
  75. package/src/ConfirmOrder/index.js +110 -110
  76. package/src/CopGoodsCard/images/ex.png +0 -0
  77. package/src/CopGoodsCard/index.js +148 -0
  78. package/src/CopGoodsCard/index.json +3 -0
  79. package/src/CopGoodsCard/index.scss +102 -0
  80. package/src/CopGoodsCard/index.wxml +20 -0
  81. package/src/CopGoodsCard/index.wxss +1 -0
  82. package/src/CouponList/components/CouponItem/index.js +308 -308
  83. package/src/CouponList/components/CouponItem/index.scss +591 -591
  84. package/src/CouponList/components/CouponItem/index.wxml +195 -195
  85. package/src/CouponList/components/CouponItem/index.wxss +1715 -1715
  86. package/src/CouponList/couponColumn/index.scss +117 -117
  87. package/src/CouponList/couponColumn/index.wxss +265 -265
  88. package/src/CustomPopup/index.js +82 -82
  89. package/src/CustomPopup/index.wxml +25 -25
  90. package/src/GoodsItem/index.js +667 -667
  91. package/src/GoodsItem/index.less +299 -299
  92. package/src/GoodsItem/index.scss +331 -331
  93. package/src/GoodsItem/index.wxml +90 -90
  94. package/src/GoodsItem/index.wxss +1172 -1172
  95. package/src/GoodsRecommend/fun.wxs +37 -37
  96. package/src/GoodsRecommend/index.js +91 -91
  97. package/src/GoodsRecommend/index.json +3 -3
  98. package/src/GoodsRecommend/index.less +129 -129
  99. package/src/GoodsRecommend/index.scss +162 -162
  100. package/src/GoodsRecommend/index.wxml +47 -47
  101. package/src/GoodsRecommend/index.wxss +537 -537
  102. package/src/LiveGoodsList/Header/index.scss +78 -78
  103. package/src/LiveGoodsList/Header/index.wxss +190 -190
  104. package/src/LiveGoodsList/index.js +480 -480
  105. package/src/LiveGoodsList/index.scss +92 -92
  106. package/src/LiveGoodsList/index.wxml +107 -107
  107. package/src/LiveGoodsList/index.wxss +230 -230
  108. package/src/PayModule/button/index.scss +44 -44
  109. package/src/PayModule/button/index.wxss +58 -58
  110. package/src/Sku/commSelect/index.js +654 -423
  111. package/src/Sku/commSelect/index.json +3 -1
  112. package/src/Sku/commSelect/index.less +11 -0
  113. package/src/Sku/commSelect/index.wxml +57 -43
  114. package/src/Sku/commSelect/index.wxss +54 -46
  115. package/src/Sku/goods-info/index.js +6 -1
  116. package/src/Sku/goods-info/index.wxml +1 -1
  117. package/src/Sku/index/index.js +5 -1
  118. package/src/Sku/index/index.wxml +1 -0
  119. package/src/TeacherGoodsList/index.wxml +41 -41
  120. package/src/common/api/confirmOrder.js +217 -217
  121. package/src/common/api/liveGoodsList.js +81 -81
  122. package/src/common/api/sku.js +73 -58
  123. package/src/common/utils/constants.js +8 -1
  124. package/src/common/utils/helper.js +3 -0
  125. package/src/common/utils/index.js +69 -69
  126. package/src/coupon/components/CouponItem/index.less +208 -208
  127. package/src/coupon/components/CouponItem/index.scss +246 -246
  128. package/src/coupon/components/CouponItem/index.wxss +821 -821
  129. package/src/coupon/components/CouponSelect/index.scss +330 -330
  130. package/src/coupon/components/CouponSelect/index.wxss +1132 -1132
  131. package/src/coupon/index.js +237 -237
  132. package/src/coupon/index.scss +83 -83
  133. package/src/coupon/index.wxss +216 -216
@@ -1,434 +1,434 @@
1
- // src/ConfirmOrder/components/GoodsInfo/index.js
2
- import {
3
- RESOURCE_TYPES,
4
- OLC_TYPE,
5
- ENTITY_GOODS,
6
- VALUE_COUPON,
7
- OFFLINE_CLASS,
8
- MARKETING_LIMIT_DISCOUNT,
9
- MARKETING_SEC_KILL,
10
- MEMBER,
11
- IMG_TEXT,
12
- AUDIO,
13
- VIDEO,
14
- LIVE,
15
- SPECIAL_COLUMN,
16
- E_BOOK,
17
- TRAINING_CAMP,
18
- SERVICE_GOODS,
19
- SVIP_SPU_TYPE,
20
- } from "../../../common/utils/constants";
21
- import {
22
- isEmptyObject
23
- } from "../../../common/utils/index"
24
- const computedBehavior = require('miniprogram-computed').behavior
25
-
26
- Component({
27
- behaviors: [computedBehavior],
28
- /**
29
- * 组件的属性列表
30
- */
31
- properties: {
32
- goodsInfo: {
33
- type: Object,
34
- value: () => {},
35
- observer(val) {
36
- if (val?.sku_min_purchase && this.data.baseInfo?.count <= val?.sku_min_purchase) {
37
- this.setData({
38
- count: val.sku_min_purchase
39
- })
40
- }
41
- }
42
- },
43
- baseInfo: {
44
- type: Object,
45
- value: () => {}
46
- },
47
- cartGoodsList: {
48
- type: Array,
49
- value: () => [],
50
- },
51
- confirmOrderInfo: {
52
- type: Object,
53
- value: () => {},
54
- },
55
- isCart: {
56
- type: Number,
57
- value: 0,
58
- },
59
- cartInfoLoaded: {
60
- type: Boolean,
61
- value: false,
62
- },
63
- svipInfo: {
64
- type: Object,
65
- value: () => {},
66
- },
67
- marketingData: {
68
- type: Object,
69
- value: () => {},
70
- },
71
- businessConf: {
72
- type: Object,
73
- value: () => {},
74
- },
75
- selectedSku: {
76
- type: Object,
77
- value: () => {},
78
- },
79
- prePayParams: {
80
- type: Object,
81
- value: () => {},
82
- },
83
- isFullScreen: {
84
- type: Boolean,
85
- value: false
86
- },
87
- },
88
-
89
- /**
90
- * 组件的初始数据
91
- */
92
- data: {
93
- goodsCount: 1,
94
- first: true,
95
- },
96
- computed: {
97
- historyBuy(data) {
98
- return data.goodsInfo?.has_buy_num
99
- },
100
- minCount(data) {
101
- return data.goodsInfo?.sku_min_purchase || 1;
102
- },
103
- maxCount(data) {
104
- // 下面三个判断语句都是判断活动的库存限购
105
- // 商品限购要跟库存对比。
106
- var maxCount = 0
107
- if (data.isTeam) {
108
- if (data.marketingData && data.marketingData.can_buy_num >= 0) {
109
- maxCount = data.marketingData.can_buy_num;
110
- }
111
- }
112
- if (data.isDiscounted) {
113
- if (
114
- data.marketingData &&
115
- data.marketingData.now_stock > 0 &&
116
- data.marketingData.all_stock > 0
117
- ) {
118
- maxCount = data.marketingData.now_stock;
119
- }
120
- }
121
- if (data.isSecKill) {
122
- if (
123
- data.marketingData &&
124
- data.marketingData.event_has_stock &&
125
- data.marketingData.event_stocks_left > 0
126
- ) {
127
- maxCount = data.marketingData.event_stocks_left;
128
- }
129
- }
130
- if (data.sendFriend) {
131
- return 1000;
132
- }
133
-
134
- //设置了限购
135
- if (maxCount === 0 || maxCount > data.goodsInfo?.stock) {
136
- maxCount = data.goodsInfo?.stock
137
- }
138
-
139
- if (data.goodsInfo?.limit_purchase) {
140
- let count = data.goodsInfo?.limit_purchase - (data.goodsInfo?.has_buy_num || 0)
141
- count < 0 ? count = 0 : count
142
- return count < maxCount ? count : maxCount
143
- } else {
144
- return maxCount
145
- }
146
- },
147
- showStepper(data) {
148
- let spuTypes = [ENTITY_GOODS, VALUE_COUPON, SERVICE_GOODS];
149
- return (
150
- (spuTypes.includes(data.baseInfo?.spu_type) || data.sendFriend) &&
151
- !data.goodsInfo.is_goods_package
152
- );
153
- },
154
- marketingTag(data) {
155
- if (data.isDiscounted) {
156
- return "限时折扣";
157
- } else if (data.isTeam) {
158
- return "拼团";
159
- } else if (data.isSecKill) {
160
- if (data.noSubscribe) {
161
- return "";
162
- }
163
- return "秒杀";
164
- }
165
- return "";
166
- },
167
- // 是否送好友下单
168
- sendFriend(data) {
169
- if (data.baseInfo?.pre_pay_type == 2) {
170
- return true;
171
- }
172
- return false;
173
- },
174
- goodsPrice(data) {
175
- if (data.useSvipPrice) {
176
- return data.svipPrice;
177
- }
178
- // 有营销信息,优先取营销价格
179
- if (data.marketingPrice) {
180
- return data.marketingPrice;
181
- }
182
-
183
- return data.goodsInfo?.piece_price;
184
- },
185
- specification(data) {
186
- if (data.goodsInfo?.spu_type === MEMBER) {
187
- return data.memberSpec;
188
- }
189
- return (
190
- (data.goodsInfo?.attr_value &&
191
- data.goodsInfo?.attr_value
192
- .map((spec) => {
193
- return spec?.attr_value;
194
- })
195
- .join(";")) ||
196
- (data.selectedSku &&
197
- Object.keys(data.selectedSku)
198
- .map((skuKey) => {
199
- return data.selectedSku[skuKey];
200
- })
201
- .join(";"))
202
- );
203
- },
204
- goodsTitleTag(data) {
205
- return data.OLCConf && OLC_TYPE[data.OLCConf.teaching_model];
206
- },
207
- OLCConf(data) {
208
- return data.businessConf[OFFLINE_CLASS];
209
- },
210
- hasGoodsInfo(data) {
211
- return !isEmptyObject(data.goodsInfo) || data.cartGoodsList.length;
212
- },
213
- goodsImgSrc(data) {
214
- if (Array.isArray(data.goodsInfo?.goods_img)) {
215
- return data.goodsInfo?.goods_img[0];
216
- }
217
- return data.goodsInfo?.goods_img;
218
- },
219
- goodsTag(data) {
220
- return data.goodsInfo?.goods_tag || RESOURCE_TYPES[data.baseInfo?.spu_type];
221
- },
222
- useSvipPrice(data) {
223
- return (
224
- data.supportSvip &&
225
- data.svipPrice > 0 &&
226
- (data.svipPrice < data.marketingPrice || !data.marketingPrice) &&
227
- data.baseInfo?.pre_pay_type != 2
228
- );
229
- },
230
- supportSvip(data) {
231
- let svipAvailableGoods = SVIP_SPU_TYPE;
232
- return svipAvailableGoods.includes(data.baseInfo?.spu_type);
233
- },
234
- // 超级会员价
235
- svipPrice(data) {
236
- let skuPriceInfo = data.svipInfo.sku_svip_price_list;
237
- if (skuPriceInfo && data.isSvip) {
238
- return skuPriceInfo[data.baseInfo.sku];
239
- }
240
- return 0;
241
- },
242
- isSvip(data) {
243
- if (data.svipInfo.svip_info && data.svipInfo.svip_info.user_svip_info) {
244
- return data.svipInfo.svip_info.user_svip_info.state === 1;
245
- }
246
- return false;
247
- },
248
- // 营销价格
249
- marketingPrice(data) {
250
- if (data.marketingData && data.joinMarketingActivity) {
251
- if (data.noSubscribe) {
252
- return 0;
253
- }
254
- let skuInfo =
255
- (data.marketingData.specs_info || []).find((specs) => {
256
- return specs.specs_id === data.baseInfo.sku;
257
- }) || {};
258
-
259
- if (skuInfo.stage_prices && data.baseInfo.step) {
260
- let step = Number(data.baseInfo.step);
261
- if (skuInfo.stage_prices[step]) {
262
- return skuInfo.stage_prices[step].member;
263
- }
264
- }
265
-
266
- return skuInfo.price || data.marketingData.low_price;
267
- }
268
- return 0;
269
- },
270
- // 是否参与了营销活动
271
- joinMarketingActivity(data) {
272
- return data.isDiscounted || data.isTeam || data.isSecKill;
273
- },
274
- isDiscounted(data) {
275
- return data.marketingData?.activity_type === MARKETING_LIMIT_DISCOUNT;
276
- },
277
- isSecKill(data) {
278
- return (
279
- data.marketingData?.activity_type === MARKETING_SEC_KILL &&
280
- data.marketingData.in_activity === 1 &&
281
- data.marketingData.event_has_stock === 1
282
- );
283
- },
284
- // 是否参加拼团
285
- isTeam(data) {
286
- return data.baseInfo?.isTeam == "true";
287
- },
288
- // 如果是秒杀但没有预约
289
- noSubscribe(data) {
290
- return (
291
- data.isSecKill &&
292
- data.marketingData.is_subscribe === 1 &&
293
- data.marketingData.user_subscribed === 0
294
- );
295
- },
296
- count(data) {
297
- return data.prePayParams?.count || data.baseInfo?.count || 1
298
- }
299
- },
300
- observers: {
301
- minCount(count) {
302
- let event = {
303
- detail: count
304
- }
305
- if (count != 1 && this.data.goodsInfo.sku_min_purchase <= 1) {
306
- this.changeVal(event)
307
- }
308
- }
309
- },
310
- lifetimes: {
311
- attached: function () {
312
- this.initStepper();
313
- },
314
- },
315
- /**
316
- * 组件的方法列表
317
- */
318
- methods: {
319
- initStepper() {
320
- // 抛出count初始值
321
- this.setData({
322
- goodsCount: this.data.count
323
- })
324
- this.countBlur(true);
325
- },
326
- overlimit(limitType) {
327
- if (limitType.detail === 'plus') {
328
- if (this.data.goodsInfo?.stock === this.data.count || this.data.count > this.data.goodsInfo?.stock) {
329
- wx.showToast({
330
- title: '该商品库存不足',
331
- icon: 'none',
332
- duration: 2000
333
- })
334
- return
335
- }
336
- //限购
337
- if (this.data.maxCount === this.data.count) {
338
- this.data.historyBuy ?
339
- wx.showToast({
340
- title: `该商品限购${this.data.goodsInfo?.limit_purchase}件哦,你已购买${this.data.historyBuy}件`,
341
- icon: 'none',
342
- duration: 2000
343
- }) :
344
- wx.showToast({
345
- title: `该商品限购${this.data.goodsInfo?.limit_purchase}件哦`,
346
- icon: 'none',
347
- duration: 2000
348
- })
349
- }
350
- if (this.data.maxCount < this.data.count) {
351
- this.data.historyBuy ?
352
- wx.showToast({
353
- title: `该商品限购${this.data.goodsInfo?.limit_purchase}件哦,你已购买${this.data.historyBuy}件`,
354
- icon: 'none',
355
- duration: 2000
356
- }) :
357
- wx.showToast({
358
- title: `该商品限购${this.data.goodsInfo?.limit_purchase}件哦`,
359
- icon: 'none',
360
- duration: 2000
361
- })
362
- }
363
- }
364
- if (limitType.detail === 'minus') {
365
- if (this.data.minCount === this.data.count || this.data.minCount > this.data.count) {
366
- wx.showToast({
367
- title: `该商品${this.data.minCount}件起售哦`,
368
- icon: 'none',
369
- duration: 2000
370
- })
371
- }
372
- }
373
- },
374
- changeVal(event) {
375
- console.log('event',event)
376
- let data = event.detail
377
- if (data <= 0) {
378
- data = 1
379
- }
380
- if (data > 1000) {
381
- wx.setStorageSync('toastWarn', 'true')
382
- }
383
- this.setData({
384
- goodsCount: (this.data.first === true && this.data.baseInfo?.count && this.data.baseInfo?.count > Number(data)) ? this.data.baseInfo?.count : Number(data)
385
- // (this.data.baseInfo?.count && this.data.baseInfo?.count > Number(data)) ? this.data.baseInfo?.count : Number(data),
386
- }, () => {
387
- this.setData({
388
- first: false
389
- })
390
- this.countBlur();
391
- })
392
- },
393
- // init 是否初次触发
394
- countBlur(init) {
395
- if (this.data.count === this.data.goodsCount && init !== true) {
396
- return false;
397
- }
398
- if (!this.data.showStepper) {
399
- this.setData({
400
- count: 1,
401
- goodsCount: 1
402
- })
403
- }
404
- let count = this.data.goodsCount;
405
- if (count > this.data.maxCount && this.data.maxCount > 0) {
406
- count = this.data.maxCount;
407
- }
408
- this.triggerEvent("dataChange", {
409
- name: "goodsInfo",
410
- prePayParams: {
411
- count: count,
412
- },
413
- payParams: {
414
- count: count,
415
- },
416
- });
417
- let obj = {
418
- ...this.data.baseInfo,
419
- count: count
420
- };
421
- this.triggerEvent("updataData", {
422
- baseInfoQuery: obj
423
- })
424
- if (this.data.first) {
425
- this.setData({
426
- first: false
427
- })
428
- }
429
- },
430
- toPrice(value) {
431
- return `¥${((value || 0) / 100).toFixed(2)}`;
432
- },
433
- }
1
+ // src/ConfirmOrder/components/GoodsInfo/index.js
2
+ import {
3
+ RESOURCE_TYPES,
4
+ OLC_TYPE,
5
+ ENTITY_GOODS,
6
+ VALUE_COUPON,
7
+ OFFLINE_CLASS,
8
+ MARKETING_LIMIT_DISCOUNT,
9
+ MARKETING_SEC_KILL,
10
+ MEMBER,
11
+ IMG_TEXT,
12
+ AUDIO,
13
+ VIDEO,
14
+ LIVE,
15
+ SPECIAL_COLUMN,
16
+ E_BOOK,
17
+ TRAINING_CAMP,
18
+ SERVICE_GOODS,
19
+ SVIP_SPU_TYPE,
20
+ } from "../../../common/utils/constants";
21
+ import {
22
+ isEmptyObject
23
+ } from "../../../common/utils/index"
24
+ const computedBehavior = require('miniprogram-computed').behavior
25
+
26
+ Component({
27
+ behaviors: [computedBehavior],
28
+ /**
29
+ * 组件的属性列表
30
+ */
31
+ properties: {
32
+ goodsInfo: {
33
+ type: Object,
34
+ value: () => {},
35
+ observer(val) {
36
+ if (val?.sku_min_purchase && this.data.baseInfo?.count <= val?.sku_min_purchase) {
37
+ this.setData({
38
+ count: val.sku_min_purchase
39
+ })
40
+ }
41
+ }
42
+ },
43
+ baseInfo: {
44
+ type: Object,
45
+ value: () => {}
46
+ },
47
+ cartGoodsList: {
48
+ type: Array,
49
+ value: () => [],
50
+ },
51
+ confirmOrderInfo: {
52
+ type: Object,
53
+ value: () => {},
54
+ },
55
+ isCart: {
56
+ type: Number,
57
+ value: 0,
58
+ },
59
+ cartInfoLoaded: {
60
+ type: Boolean,
61
+ value: false,
62
+ },
63
+ svipInfo: {
64
+ type: Object,
65
+ value: () => {},
66
+ },
67
+ marketingData: {
68
+ type: Object,
69
+ value: () => {},
70
+ },
71
+ businessConf: {
72
+ type: Object,
73
+ value: () => {},
74
+ },
75
+ selectedSku: {
76
+ type: Object,
77
+ value: () => {},
78
+ },
79
+ prePayParams: {
80
+ type: Object,
81
+ value: () => {},
82
+ },
83
+ isFullScreen: {
84
+ type: Boolean,
85
+ value: false
86
+ },
87
+ },
88
+
89
+ /**
90
+ * 组件的初始数据
91
+ */
92
+ data: {
93
+ goodsCount: 1,
94
+ first: true,
95
+ },
96
+ computed: {
97
+ historyBuy(data) {
98
+ return data.goodsInfo?.has_buy_num
99
+ },
100
+ minCount(data) {
101
+ return data.goodsInfo?.sku_min_purchase || 1;
102
+ },
103
+ maxCount(data) {
104
+ // 下面三个判断语句都是判断活动的库存限购
105
+ // 商品限购要跟库存对比。
106
+ var maxCount = 0
107
+ if (data.isTeam) {
108
+ if (data.marketingData && data.marketingData.can_buy_num >= 0) {
109
+ maxCount = data.marketingData.can_buy_num;
110
+ }
111
+ }
112
+ if (data.isDiscounted) {
113
+ if (
114
+ data.marketingData &&
115
+ data.marketingData.now_stock > 0 &&
116
+ data.marketingData.all_stock > 0
117
+ ) {
118
+ maxCount = data.marketingData.now_stock;
119
+ }
120
+ }
121
+ if (data.isSecKill) {
122
+ if (
123
+ data.marketingData &&
124
+ data.marketingData.event_has_stock &&
125
+ data.marketingData.event_stocks_left > 0
126
+ ) {
127
+ maxCount = data.marketingData.event_stocks_left;
128
+ }
129
+ }
130
+ if (data.sendFriend) {
131
+ return 1000;
132
+ }
133
+
134
+ //设置了限购
135
+ if (maxCount === 0 || maxCount > data.goodsInfo?.stock) {
136
+ maxCount = data.goodsInfo?.stock
137
+ }
138
+
139
+ if (data.goodsInfo?.limit_purchase) {
140
+ let count = data.goodsInfo?.limit_purchase - (data.goodsInfo?.has_buy_num || 0)
141
+ count < 0 ? count = 0 : count
142
+ return count < maxCount ? count : maxCount
143
+ } else {
144
+ return maxCount
145
+ }
146
+ },
147
+ showStepper(data) {
148
+ let spuTypes = [ENTITY_GOODS, VALUE_COUPON, SERVICE_GOODS];
149
+ return (
150
+ (spuTypes.includes(data.baseInfo?.spu_type) || data.sendFriend) &&
151
+ !data.goodsInfo.is_goods_package
152
+ );
153
+ },
154
+ marketingTag(data) {
155
+ if (data.isDiscounted) {
156
+ return "限时折扣";
157
+ } else if (data.isTeam) {
158
+ return "拼团";
159
+ } else if (data.isSecKill) {
160
+ if (data.noSubscribe) {
161
+ return "";
162
+ }
163
+ return "秒杀";
164
+ }
165
+ return "";
166
+ },
167
+ // 是否送好友下单
168
+ sendFriend(data) {
169
+ if (data.baseInfo?.pre_pay_type == 2) {
170
+ return true;
171
+ }
172
+ return false;
173
+ },
174
+ goodsPrice(data) {
175
+ if (data.useSvipPrice) {
176
+ return data.svipPrice;
177
+ }
178
+ // 有营销信息,优先取营销价格
179
+ if (data.marketingPrice) {
180
+ return data.marketingPrice;
181
+ }
182
+
183
+ return data.goodsInfo?.piece_price;
184
+ },
185
+ specification(data) {
186
+ if (data.goodsInfo?.spu_type === MEMBER) {
187
+ return data.memberSpec;
188
+ }
189
+ return (
190
+ (data.goodsInfo?.attr_value &&
191
+ data.goodsInfo?.attr_value
192
+ .map((spec) => {
193
+ return spec?.attr_value;
194
+ })
195
+ .join(";")) ||
196
+ (data.selectedSku &&
197
+ Object.keys(data.selectedSku)
198
+ .map((skuKey) => {
199
+ return data.selectedSku[skuKey];
200
+ })
201
+ .join(";"))
202
+ );
203
+ },
204
+ goodsTitleTag(data) {
205
+ return data.OLCConf && OLC_TYPE[data.OLCConf.teaching_model];
206
+ },
207
+ OLCConf(data) {
208
+ return data.businessConf[OFFLINE_CLASS];
209
+ },
210
+ hasGoodsInfo(data) {
211
+ return !isEmptyObject(data.goodsInfo) || data.cartGoodsList.length;
212
+ },
213
+ goodsImgSrc(data) {
214
+ if (Array.isArray(data.goodsInfo?.goods_img)) {
215
+ return data.goodsInfo?.goods_img[0];
216
+ }
217
+ return data.goodsInfo?.goods_img;
218
+ },
219
+ goodsTag(data) {
220
+ return data.goodsInfo?.goods_tag || RESOURCE_TYPES[data.baseInfo?.spu_type];
221
+ },
222
+ useSvipPrice(data) {
223
+ return (
224
+ data.supportSvip &&
225
+ data.svipPrice > 0 &&
226
+ (data.svipPrice < data.marketingPrice || !data.marketingPrice) &&
227
+ data.baseInfo?.pre_pay_type != 2
228
+ );
229
+ },
230
+ supportSvip(data) {
231
+ let svipAvailableGoods = SVIP_SPU_TYPE;
232
+ return svipAvailableGoods.includes(data.baseInfo?.spu_type);
233
+ },
234
+ // 超级会员价
235
+ svipPrice(data) {
236
+ let skuPriceInfo = data.svipInfo.sku_svip_price_list;
237
+ if (skuPriceInfo && data.isSvip) {
238
+ return skuPriceInfo[data.baseInfo.sku];
239
+ }
240
+ return 0;
241
+ },
242
+ isSvip(data) {
243
+ if (data.svipInfo.svip_info && data.svipInfo.svip_info.user_svip_info) {
244
+ return data.svipInfo.svip_info.user_svip_info.state === 1;
245
+ }
246
+ return false;
247
+ },
248
+ // 营销价格
249
+ marketingPrice(data) {
250
+ if (data.marketingData && data.joinMarketingActivity) {
251
+ if (data.noSubscribe) {
252
+ return 0;
253
+ }
254
+ let skuInfo =
255
+ (data.marketingData.specs_info || []).find((specs) => {
256
+ return specs.specs_id === data.baseInfo.sku;
257
+ }) || {};
258
+
259
+ if (skuInfo.stage_prices && data.baseInfo.step) {
260
+ let step = Number(data.baseInfo.step);
261
+ if (skuInfo.stage_prices[step]) {
262
+ return skuInfo.stage_prices[step].member;
263
+ }
264
+ }
265
+
266
+ return skuInfo.price || data.marketingData.low_price;
267
+ }
268
+ return 0;
269
+ },
270
+ // 是否参与了营销活动
271
+ joinMarketingActivity(data) {
272
+ return data.isDiscounted || data.isTeam || data.isSecKill;
273
+ },
274
+ isDiscounted(data) {
275
+ return data.marketingData?.activity_type === MARKETING_LIMIT_DISCOUNT;
276
+ },
277
+ isSecKill(data) {
278
+ return (
279
+ data.marketingData?.activity_type === MARKETING_SEC_KILL &&
280
+ data.marketingData.in_activity === 1 &&
281
+ data.marketingData.event_has_stock === 1
282
+ );
283
+ },
284
+ // 是否参加拼团
285
+ isTeam(data) {
286
+ return data.baseInfo?.isTeam == "true";
287
+ },
288
+ // 如果是秒杀但没有预约
289
+ noSubscribe(data) {
290
+ return (
291
+ data.isSecKill &&
292
+ data.marketingData.is_subscribe === 1 &&
293
+ data.marketingData.user_subscribed === 0
294
+ );
295
+ },
296
+ count(data) {
297
+ return data.prePayParams?.count || data.baseInfo?.count || 1
298
+ }
299
+ },
300
+ observers: {
301
+ minCount(count) {
302
+ let event = {
303
+ detail: count
304
+ }
305
+ if (count != 1 && this.data.goodsInfo.sku_min_purchase <= 1) {
306
+ this.changeVal(event)
307
+ }
308
+ }
309
+ },
310
+ lifetimes: {
311
+ attached: function () {
312
+ this.initStepper();
313
+ },
314
+ },
315
+ /**
316
+ * 组件的方法列表
317
+ */
318
+ methods: {
319
+ initStepper() {
320
+ // 抛出count初始值
321
+ this.setData({
322
+ goodsCount: this.data.count
323
+ })
324
+ this.countBlur(true);
325
+ },
326
+ overlimit(limitType) {
327
+ if (limitType.detail === 'plus') {
328
+ if (this.data.goodsInfo?.stock === this.data.count || this.data.count > this.data.goodsInfo?.stock) {
329
+ wx.showToast({
330
+ title: '该商品库存不足',
331
+ icon: 'none',
332
+ duration: 2000
333
+ })
334
+ return
335
+ }
336
+ //限购
337
+ if (this.data.maxCount === this.data.count) {
338
+ this.data.historyBuy ?
339
+ wx.showToast({
340
+ title: `该商品限购${this.data.goodsInfo?.limit_purchase}件哦,你已购买${this.data.historyBuy}件`,
341
+ icon: 'none',
342
+ duration: 2000
343
+ }) :
344
+ wx.showToast({
345
+ title: `该商品限购${this.data.goodsInfo?.limit_purchase}件哦`,
346
+ icon: 'none',
347
+ duration: 2000
348
+ })
349
+ }
350
+ if (this.data.maxCount < this.data.count) {
351
+ this.data.historyBuy ?
352
+ wx.showToast({
353
+ title: `该商品限购${this.data.goodsInfo?.limit_purchase}件哦,你已购买${this.data.historyBuy}件`,
354
+ icon: 'none',
355
+ duration: 2000
356
+ }) :
357
+ wx.showToast({
358
+ title: `该商品限购${this.data.goodsInfo?.limit_purchase}件哦`,
359
+ icon: 'none',
360
+ duration: 2000
361
+ })
362
+ }
363
+ }
364
+ if (limitType.detail === 'minus') {
365
+ if (this.data.minCount === this.data.count || this.data.minCount > this.data.count) {
366
+ wx.showToast({
367
+ title: `该商品${this.data.minCount}件起售哦`,
368
+ icon: 'none',
369
+ duration: 2000
370
+ })
371
+ }
372
+ }
373
+ },
374
+ changeVal(event) {
375
+ console.log('event',event)
376
+ let data = event.detail
377
+ if (data <= 0) {
378
+ data = 1
379
+ }
380
+ if (data > 1000) {
381
+ wx.setStorageSync('toastWarn', 'true')
382
+ }
383
+ this.setData({
384
+ goodsCount: (this.data.first === true && this.data.baseInfo?.count && this.data.baseInfo?.count > Number(data)) ? this.data.baseInfo?.count : Number(data)
385
+ // (this.data.baseInfo?.count && this.data.baseInfo?.count > Number(data)) ? this.data.baseInfo?.count : Number(data),
386
+ }, () => {
387
+ this.setData({
388
+ first: false
389
+ })
390
+ this.countBlur();
391
+ })
392
+ },
393
+ // init 是否初次触发
394
+ countBlur(init) {
395
+ if (this.data.count === this.data.goodsCount && init !== true) {
396
+ return false;
397
+ }
398
+ if (!this.data.showStepper) {
399
+ this.setData({
400
+ count: 1,
401
+ goodsCount: 1
402
+ })
403
+ }
404
+ let count = this.data.goodsCount;
405
+ if (count > this.data.maxCount && this.data.maxCount > 0) {
406
+ count = this.data.maxCount;
407
+ }
408
+ this.triggerEvent("dataChange", {
409
+ name: "goodsInfo",
410
+ prePayParams: {
411
+ count: count,
412
+ },
413
+ payParams: {
414
+ count: count,
415
+ },
416
+ });
417
+ let obj = {
418
+ ...this.data.baseInfo,
419
+ count: count
420
+ };
421
+ this.triggerEvent("updataData", {
422
+ baseInfoQuery: obj
423
+ })
424
+ if (this.data.first) {
425
+ this.setData({
426
+ first: false
427
+ })
428
+ }
429
+ },
430
+ toPrice(value) {
431
+ return `¥${((value || 0) / 100).toFixed(2)}`;
432
+ },
433
+ }
434
434
  })