xiaoe_mp_npm 1.0.46 → 1.0.47

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 (55) hide show
  1. package/miniprogram_dist/ConfirmOrder/components/Header/index.wxss +1 -0
  2. package/miniprogram_dist/ConfirmOrder/components/OrderBubble/index.js +247 -0
  3. package/miniprogram_dist/ConfirmOrder/components/OrderBubble/index.json +4 -0
  4. package/miniprogram_dist/ConfirmOrder/components/OrderBubble/index.scss +57 -0
  5. package/miniprogram_dist/ConfirmOrder/components/OrderBubble/index.wxml +10 -0
  6. package/miniprogram_dist/ConfirmOrder/components/OrderBubble/index.wxss +94 -0
  7. package/miniprogram_dist/ConfirmOrder/index.js +2 -2
  8. package/miniprogram_dist/ConfirmOrder/index.json +1 -1
  9. package/miniprogram_dist/ConfirmOrder/index.wxml +8 -2
  10. package/miniprogram_dist/GoodsBubble/index.js +418 -0
  11. package/miniprogram_dist/GoodsBubble/index.json +4 -0
  12. package/miniprogram_dist/GoodsBubble/index.scss +70 -0
  13. package/miniprogram_dist/GoodsBubble/index.wxml +16 -0
  14. package/miniprogram_dist/GoodsBubble/index.wxss +136 -0
  15. package/miniprogram_dist/GoodsItem/index.js +1170 -1108
  16. package/miniprogram_dist/GoodsItem/index.json +11 -10
  17. package/miniprogram_dist/GoodsItem/index.wxml +234 -218
  18. package/miniprogram_dist/LiveGoodsList/index.js +1008 -941
  19. package/miniprogram_dist/LiveGoodsList/index.json +13 -9
  20. package/miniprogram_dist/LiveGoodsList/index.wxml +144 -127
  21. package/miniprogram_dist/ShoppingCartBubble/index.js +156 -0
  22. package/miniprogram_dist/ShoppingCartBubble/index.json +4 -0
  23. package/miniprogram_dist/ShoppingCartBubble/index.scss +55 -0
  24. package/miniprogram_dist/ShoppingCartBubble/index.wxml +11 -0
  25. package/miniprogram_dist/ShoppingCartBubble/index.wxss +90 -0
  26. package/miniprogram_dist/common/api/liveGoodsList.js +14 -0
  27. package/miniprogram_dist/common/utils/index.js +17 -1
  28. package/package.json +1 -1
  29. package/src/ConfirmOrder/components/Header/index.wxss +1 -0
  30. package/src/ConfirmOrder/components/OrderBubble/index.js +247 -0
  31. package/src/ConfirmOrder/components/OrderBubble/index.json +4 -0
  32. package/src/ConfirmOrder/components/OrderBubble/index.scss +57 -0
  33. package/src/ConfirmOrder/components/OrderBubble/index.wxml +10 -0
  34. package/src/ConfirmOrder/components/OrderBubble/index.wxss +1 -0
  35. package/src/ConfirmOrder/index.js +2 -2
  36. package/src/ConfirmOrder/index.json +1 -1
  37. package/src/ConfirmOrder/index.wxml +8 -2
  38. package/src/GoodsBubble/index.js +418 -0
  39. package/src/GoodsBubble/index.json +4 -0
  40. package/src/GoodsBubble/index.scss +70 -0
  41. package/src/GoodsBubble/index.wxml +16 -0
  42. package/src/GoodsBubble/index.wxss +1 -0
  43. package/src/GoodsItem/index.js +1170 -1108
  44. package/src/GoodsItem/index.json +11 -10
  45. package/src/GoodsItem/index.wxml +234 -218
  46. package/src/LiveGoodsList/index.js +1008 -941
  47. package/src/LiveGoodsList/index.json +13 -9
  48. package/src/LiveGoodsList/index.wxml +144 -127
  49. package/src/ShoppingCartBubble/index.js +156 -0
  50. package/src/ShoppingCartBubble/index.json +4 -0
  51. package/src/ShoppingCartBubble/index.scss +55 -0
  52. package/src/ShoppingCartBubble/index.wxml +11 -0
  53. package/src/ShoppingCartBubble/index.wxss +1 -0
  54. package/src/common/api/liveGoodsList.js +14 -0
  55. package/src/common/utils/index.js +17 -1
@@ -8,6 +8,7 @@
8
8
  position: sticky;
9
9
  top: 0;
10
10
  left: 0;
11
+ border-radius: 24rpx 24rpx 0 0 !important;
11
12
  background-color: #ffffff;
12
13
  }
13
14
  .header-content .header-back {
@@ -0,0 +1,247 @@
1
+ const computedBehavior = require('miniprogram-computed').behavior
2
+ import { getOrderBarrage } from '../../../common/api/liveGoodsList'
3
+
4
+ const TYPE_MAP = {
5
+ LOOKING_AT: 'looking_at',
6
+ REPURCHASE: 'repurchase',
7
+ HOT_SALES: 'hot_sales',
8
+ RETURN_GOODS: 'return_goods',
9
+ }
10
+ const INTERVAL_TIME = 3000 // 单次动画间隔时间
11
+ const DURATION_TIME = 2500 // 动画总时间
12
+ const DEFAULT_ANIMATION_TIME = 400 // 动画时间
13
+
14
+ Component({
15
+ behaviors: [computedBehavior],
16
+ properties: {
17
+ aliveInfo: {
18
+ type: Object,
19
+ value: {}
20
+ },
21
+ baseInfoQuery: {
22
+ type: Object,
23
+ value: {
24
+ id: "SPU_ENT_1729059559e6mMMc9fTL4Gq",
25
+ spu_id: "SPU_ENT_1729059559e6mMMc9fTL4Gq",
26
+ resource_type: 21,
27
+ resource_id: "g_670f5ae705e71_mJ3uBJF424",
28
+ spu_type: "ENT",
29
+ sku: "SKU_ENT_17290595593NTuSgczj9",
30
+ isCollectCoupons: true,
31
+ count: 1,
32
+ isAlive: 1,
33
+ aliveId: 'l_670f5b28e4b0694c94ebec6f'
34
+ }
35
+ },
36
+ isShowViewCount: {
37
+ type: Boolean,
38
+ value: false,
39
+ },
40
+ // 区分商品变化处理
41
+ goodsId: {
42
+ type: String,
43
+ value: '',
44
+ },
45
+ },
46
+ data: {
47
+ isInit: false,
48
+ bubbleList: [], // 气泡数组
49
+ currentBubbleIndex: 0,
50
+ bubbleInterval: null,
51
+ animationTimer: null,
52
+ orderAnimationData: {},
53
+ snap_up_nums: 0,
54
+ sales: 0,
55
+ repurchase_count: 0,
56
+ alipay_insure_eligible: null,
57
+ resourceType: null
58
+ },
59
+ lifetimes: {
60
+ attached() {
61
+ setTimeout(() => {
62
+ this.handleInit()
63
+ }, 1500)
64
+ },
65
+ },
66
+ computed: {
67
+ // 爆卖
68
+ displaySalesMessage(data) {
69
+ const hotSalesNum = data.sales;
70
+ const thresholds = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000];
71
+ let maxThreshold = thresholds[0];
72
+ for (let threshold of thresholds) {
73
+ if (hotSalesNum >= threshold) {
74
+ maxThreshold = threshold; // 更新最大阈值
75
+ }
76
+ }
77
+ return `爆卖 ${maxThreshold}+ 件`;
78
+ },
79
+ orderBubbleMap(data) {
80
+ return {
81
+ [TYPE_MAP.LOOKING_AT]: {
82
+ icon: 'https://commonresource-1252524126.cdn.xiaoeknow.com/image/m7czx1m70ckd.png',
83
+ txt: `${data.snap_up_nums} 人正在看`,
84
+ },
85
+ [TYPE_MAP.HOT_SALES]: {
86
+ icon: 'https://commonresource-1252524126.cdn.xiaoeknow.com/image/m7czx1lz0b1a.png',
87
+ txt: data.displaySalesMessage,
88
+ },
89
+ [TYPE_MAP.REPURCHASE]: {
90
+ icon: 'https://commonresource-1252524126.cdn.xiaoeknow.com/image/m7czx1m60wex.png',
91
+ txt: `超 ${data.repurchase_count} 用户回购`,
92
+ },
93
+ // [TYPE_MAP.RETURN_GOODS]: {
94
+ // icon: 'https://commonresource-1252524126.cdn.xiaoeknow.com/image/m7czx1m50afi.png',
95
+ // txt: '退货包运费',
96
+ // },
97
+ }
98
+ }
99
+ },
100
+ watch: {
101
+ goodsId() {
102
+ if (!this.data.initialized) return
103
+ this.handleInitGood()
104
+ },
105
+ },
106
+ methods: {
107
+ handleInitGood() {
108
+ this.resetAll(() => {
109
+ this.handleInit()
110
+ })
111
+ },
112
+ handleInit() {
113
+ console.log("this.properties.baseInfoQuery;", this.properties.baseInfoQuery)
114
+ let bubbleList = []
115
+ const { app_id, user_id, alive_id } = this.properties.aliveInfo;
116
+ const { spu_type, spu_id, resource_type, distributionPattern } = this.properties.baseInfoQuery;
117
+ const params = { app_id, user_id, alive_id, spu_type, spu_id }
118
+ getOrderBarrage(params).then(res => {
119
+ // 弹幕开关是否开启
120
+ if (res.data.code === 0 && res.data.data?.state === true) {
121
+ const { snap_up_nums, sales, repurchase_count, alipay_insure_eligible } = res.data.data
122
+ this.setData({
123
+ snap_up_nums ,
124
+ sales,
125
+ repurchase_count,
126
+ alipay_insure_eligible,
127
+ })
128
+
129
+ // 正在看 观看配置开启即可
130
+ if (this.properties.isShowViewCount && +snap_up_nums > 0) {
131
+ bubbleList.push(this.data.orderBubbleMap[TYPE_MAP.LOOKING_AT])
132
+ }
133
+ // 超出1000就展示爆卖
134
+ if (this.data.sales > 1000) {
135
+ bubbleList.push(this.data.orderBubbleMap[TYPE_MAP.HOT_SALES])
136
+ }
137
+ // 超出100 展示回购
138
+ if (this.data.repurchase_count >= 100) {
139
+ bubbleList.push(this.data.orderBubbleMap[TYPE_MAP.REPURCHASE])
140
+ }
141
+
142
+ // 退货包运费
143
+ // if (this.data.alipay_insure_eligible && resource_type === 21 && [-1, 1].includes(distributionPattern)) {
144
+ // bubbleList.push(this.data.orderBubbleMap[TYPE_MAP.RETURN_GOODS])
145
+ // }
146
+
147
+ this.setData({
148
+ bubbleList,
149
+ })
150
+
151
+ if (bubbleList.length <= 0) {
152
+ this.resetAll()
153
+ return
154
+ }
155
+ if (bubbleList.length > 1) {
156
+ this.startBubbleRotation()
157
+ } else {
158
+ this.displayBubble(bubbleList[0])
159
+ }
160
+ }
161
+ }).catch(err => {
162
+ this.resetAll()
163
+ })
164
+ },
165
+ startBubbleRotation() {
166
+ this.displayBubble(this.data.bubbleList[this.data.currentBubbleIndex])
167
+ let bubbleInterval = setInterval(() => {
168
+ this.setData({
169
+ currentBubbleIndex: (this.data.currentBubbleIndex + 1) % this.data.bubbleList.length,
170
+ })
171
+ this.displayBubble(this.data.bubbleList[this.data.currentBubbleIndex])
172
+ }, INTERVAL_TIME)
173
+ this.setData({
174
+ bubbleInterval,
175
+ })
176
+ },
177
+ displayBubble(bubble) {
178
+ this.setData({
179
+ bubbleIcon: bubble.icon,
180
+ bubbleDesc: bubble.txt
181
+ })
182
+ this.handleInitAnimation()
183
+ },
184
+ handleInitAnimation() {
185
+ if (!this.data.isInit) {
186
+ this.setData({
187
+ isInit: true,
188
+ })
189
+ }
190
+ const animation = wx.createAnimation({
191
+ duration: DEFAULT_ANIMATION_TIME,
192
+ timingFunction: 'ease',
193
+ })
194
+ animation.translateY(-30).opacity(1).step();
195
+ this.setData({
196
+ orderAnimationData: animation.export(),
197
+ });
198
+
199
+ if (this.data.bubbleList.length > 1) {
200
+ let animationTimer = setTimeout(() => {
201
+ const slideOutAnimation = wx.createAnimation({
202
+ duration: DEFAULT_ANIMATION_TIME,
203
+ timingFunction: 'ease',
204
+ })
205
+ slideOutAnimation.translateY(-35).opacity(0).step();
206
+ this.setData({
207
+ orderAnimationData: slideOutAnimation.export(),
208
+ });
209
+
210
+ setTimeout(() => {
211
+ const resetAnimation = wx.createAnimation({
212
+ duration: 0,
213
+ timingFunction: 'ease',
214
+ })
215
+ resetAnimation.translateY(0).opacity(0).step() // 恢复到初始位置
216
+ this.setData({
217
+ orderAnimationData: resetAnimation.export(),
218
+ })
219
+ }, DEFAULT_ANIMATION_TIME + 20)
220
+
221
+ }, DURATION_TIME);
222
+ this.setData({
223
+ animationTimer
224
+ })
225
+ }
226
+ },
227
+ resetAll(cb = () => {}) {
228
+ clearInterval(this.data.bubbleInterval)
229
+ clearTimeout(this.data.animationTimer)
230
+ this.setData(
231
+ {
232
+ bubbleInterval: null,
233
+ animationTimer: null,
234
+ showBubble: false,
235
+ currentBubbleIndex: 0,
236
+ },
237
+ () => {
238
+ cb()
239
+ },
240
+ )
241
+ },
242
+ detached() {
243
+ clearInterval(this.data.bubbleInterval)
244
+ clearTimeout(this.data.animationTimer)
245
+ },
246
+ },
247
+ })
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,57 @@
1
+ $deviceWidth: 750;
2
+ @function vmin($rpx) {
3
+ @return #{$rpx * 100 / $deviceWidth}vmin;
4
+ }
5
+
6
+ @mixin order-bubble {
7
+ position: absolute;
8
+ left: vmin(22);
9
+ width: auto;
10
+ opacity: 1;
11
+ transform: translateY(vmin(-56));
12
+
13
+ .order-bubble-info {
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ font-size: vmin(28);
18
+ color: rgba(255, 255, 255, 1);
19
+ font-weight: 700;
20
+ background: rgba(0, 0, 0, 0.6);
21
+ border-radius: vmin(50);
22
+ padding: vmin(4) vmin(16);
23
+ }
24
+
25
+ .order-info-img {
26
+ width: vmin(40);
27
+ height: vmin(40);
28
+ }
29
+ }
30
+
31
+ .order-bubble {
32
+ @include order-bubble
33
+ }
34
+ // 竖屏pad
35
+ @media screen and (min-width: 768px) and (orientation: portrait) {
36
+ $deviceWidth: 1536 !global;
37
+
38
+ .order-bubble {
39
+ @include order-bubble
40
+ }
41
+ }
42
+ // PC 放大适配
43
+ @media screen and (min-height: 630px) and (orientation: landscape) {
44
+ $deviceWidth: 1260 !global;
45
+
46
+ .order-bubble {
47
+ @include order-bubble;
48
+ }
49
+ }
50
+ // 横屏pad
51
+ @media screen and (min-height: 768px) and (orientation: landscape) {
52
+ $deviceWidth: 1536 !global;
53
+
54
+ .order-bubble {
55
+ @include order-bubble;
56
+ }
57
+ }
@@ -0,0 +1,10 @@
1
+ <view
2
+ class="order-bubble"
3
+ wx:if="{{ isInit }}"
4
+ animation="{{ orderAnimationData }}"
5
+ >
6
+ <view class="order-bubble-info">
7
+ <image class="order-info-img" src="{{ bubbleIcon }}" />
8
+ <text class="order-info-desc">{{ bubbleDesc }}</text>
9
+ </view>
10
+ </view>
@@ -0,0 +1,94 @@
1
+ .order-bubble {
2
+ position: absolute;
3
+ left: 2.93333vmin;
4
+ width: auto;
5
+ opacity: 1;
6
+ transform: translateY(-7.46667vmin);
7
+ }
8
+ .order-bubble .order-bubble-info {
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: center;
12
+ font-size: 3.73333vmin;
13
+ color: #fff;
14
+ font-weight: 700;
15
+ background: rgba(0, 0, 0, 0.6);
16
+ border-radius: 6.66667vmin;
17
+ padding: 0.53333vmin 2.13333vmin;
18
+ }
19
+ .order-bubble .order-info-img {
20
+ width: 5.33333vmin;
21
+ height: 5.33333vmin;
22
+ }
23
+ @media screen and (min-width: 768px) and (orientation: portrait) {
24
+ .order-bubble {
25
+ position: absolute;
26
+ left: 1.43229vmin;
27
+ width: auto;
28
+ opacity: 1;
29
+ transform: translateY(-3.64583vmin);
30
+ }
31
+ .order-bubble .order-bubble-info {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ font-size: 1.82292vmin;
36
+ color: #fff;
37
+ font-weight: 700;
38
+ background: rgba(0, 0, 0, 0.6);
39
+ border-radius: 3.25521vmin;
40
+ padding: 0.26042vmin 1.04167vmin;
41
+ }
42
+ .order-bubble .order-info-img {
43
+ width: 2.60417vmin;
44
+ height: 2.60417vmin;
45
+ }
46
+ }
47
+ @media screen and (min-height: 630px) and (orientation: landscape) {
48
+ .order-bubble {
49
+ position: absolute;
50
+ left: 1.74603vmin;
51
+ width: auto;
52
+ opacity: 1;
53
+ transform: translateY(-4.44444vmin);
54
+ }
55
+ .order-bubble .order-bubble-info {
56
+ display: flex;
57
+ align-items: center;
58
+ justify-content: center;
59
+ font-size: 2.22222vmin;
60
+ color: #fff;
61
+ font-weight: 700;
62
+ background: rgba(0, 0, 0, 0.6);
63
+ border-radius: 3.96825vmin;
64
+ padding: 0.31746vmin 1.26984vmin;
65
+ }
66
+ .order-bubble .order-info-img {
67
+ width: 3.1746vmin;
68
+ height: 3.1746vmin;
69
+ }
70
+ }
71
+ @media screen and (min-height: 768px) and (orientation: landscape) {
72
+ .order-bubble {
73
+ position: absolute;
74
+ left: 1.43229vmin;
75
+ width: auto;
76
+ opacity: 1;
77
+ transform: translateY(-3.64583vmin);
78
+ }
79
+ .order-bubble .order-bubble-info {
80
+ display: flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ font-size: 1.82292vmin;
84
+ color: #fff;
85
+ font-weight: 700;
86
+ background: rgba(0, 0, 0, 0.6);
87
+ border-radius: 3.25521vmin;
88
+ padding: 0.26042vmin 1.04167vmin;
89
+ }
90
+ .order-bubble .order-info-img {
91
+ width: 2.60417vmin;
92
+ height: 2.60417vmin;
93
+ }
94
+ }
@@ -259,7 +259,7 @@ Component({
259
259
  },
260
260
  computed:{
261
261
  customStyle(properties){
262
- return properties.popPosition === "bottom" ? "height: 80%;background: rgba(245,245,245,1)" : "height: 100%;width: 100vmin;background: rgba(245,245,245,1)"
262
+ return properties.popPosition === "bottom" ? "height: 80%;background: rgba(245,245,245,1);overflow-y: unset !important" : "height: 100%;width: 100vmin;background: rgba(245,245,245,1);"
263
263
  },
264
264
  }
265
- })
265
+ })
@@ -7,4 +7,4 @@
7
7
  "CustomPopup": "../CustomPopup",
8
8
  "van-dialog": "@vant/weapp/dialog/index"
9
9
  }
10
- }
10
+ }
@@ -1,5 +1,5 @@
1
1
  <!--src/ConfirmOrder/index.wxml-->
2
- <view class="confirm-order">
2
+ <view class="confirm-order" style="{{ popPosition === 'bottom' ? 'position: relative;' : '' }}">
3
3
  <view>{{countdown}}</view>
4
4
  <button bindtap="openPopup">显示确认订单</button>
5
5
  <van-dialog id="van-dialog" />
@@ -20,7 +20,13 @@
20
20
  z-index="{{zIndex}}"
21
21
  overlay="{{popPosition === 'right' ? false : true}}"
22
22
  hasHeader="{{showHeader}}"
23
+ popupHeaderStyle="{{ popPosition === 'bottom' ? popupHeaderStyle : '' }}"
24
+ contentStyle="{{ popPosition === 'bottom' ? contentStyle : '' }}"
23
25
  >
26
+ <!-- 气泡 -->
27
+ <view slot="custom" wx:if="{{ showOrderBubble && showPopup }}">
28
+ <order-bubble id="orderBubble" aliveInfo="{{ aliveInfo }}" baseInfoQuery="{{ baseInfoQuery }}" isShowViewCount="{{ isShowViewCount }}" />
29
+ </view>
24
30
  <view slot="header" wx:if="{{ showPopup }}" >
25
31
  <Header id="header" bindonClose="onClose" bind:backClick="backClick" wx:if="{{ showPopup }}" showClose="{{showClose}}" isFullscreen="{{ popPosition === 'right' }}" zIndex="{{zIndex}}"></Header>
26
32
  </view>
@@ -46,4 +52,4 @@
46
52
  </ConfirmOrderContent>
47
53
  </view>
48
54
  </CustomPopup>
49
- </view>
55
+ </view>