xiaoe_mp_npm 0.5.42-test13 → 0.5.42-test14
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.
|
@@ -16,6 +16,18 @@ import {
|
|
|
16
16
|
import { rpxToVmin } from '../common/utils/index.js'
|
|
17
17
|
const computedBehavior = require('miniprogram-computed').behavior
|
|
18
18
|
|
|
19
|
+
let activityCountdownTimer = null // 活动倒计时计时器
|
|
20
|
+
let hadActivity = false
|
|
21
|
+
let activityList = [] // 参与活动的商品
|
|
22
|
+
|
|
23
|
+
// 预热模块
|
|
24
|
+
let preheatTimer = null // 预热倒计时计时器
|
|
25
|
+
let hadPreheat = false
|
|
26
|
+
let preheatList = [] // 参与活动的商品
|
|
27
|
+
|
|
28
|
+
let hasActivity = false // 是否有参与活动的商品
|
|
29
|
+
let hasPreheat = false // 是否有参与预热的商品
|
|
30
|
+
|
|
19
31
|
const MARKET_ACTIVITY_MAP = {
|
|
20
32
|
3: "限时折扣",
|
|
21
33
|
4: "好友助力",
|
|
@@ -60,6 +72,12 @@ Component({
|
|
|
60
72
|
newVal && this.data.explainingGoods.length && this.getExplainingGoodsInfo()
|
|
61
73
|
newVal && this.getPreferentialPriceSetting()
|
|
62
74
|
newVal && this.onLoad()
|
|
75
|
+
if(!newVal){
|
|
76
|
+
clearInterval(activityCountdownTimer)
|
|
77
|
+
activityCountdownTimer = null
|
|
78
|
+
clearInterval(preheatTimer)
|
|
79
|
+
preheatTimer = null
|
|
80
|
+
}
|
|
63
81
|
}
|
|
64
82
|
},
|
|
65
83
|
// 讲解中商品
|
|
@@ -163,6 +181,56 @@ Component({
|
|
|
163
181
|
},
|
|
164
182
|
},
|
|
165
183
|
methods: {
|
|
184
|
+
// 商品总活动倒计时
|
|
185
|
+
startActivityCountdown(list) {
|
|
186
|
+
clearInterval(activityCountdownTimer)
|
|
187
|
+
activityCountdownTimer = setInterval(() => {
|
|
188
|
+
hadActivity = false
|
|
189
|
+
list.forEach((i) => {
|
|
190
|
+
let targetDate = new Date(i.time.replace(/-/g, '/')).getTime() - new Date().getTime()
|
|
191
|
+
if (targetDate <= 0) return
|
|
192
|
+
hadActivity = true
|
|
193
|
+
let temp = `goodsInfo[${i.index}].activityCountdown`
|
|
194
|
+
this.setData({
|
|
195
|
+
[temp]: targetDate,
|
|
196
|
+
})
|
|
197
|
+
})
|
|
198
|
+
if (!hadActivity) {
|
|
199
|
+
clearInterval(activityCountdownTimer)
|
|
200
|
+
activityCountdownTimer = null
|
|
201
|
+
}
|
|
202
|
+
}, 1000)
|
|
203
|
+
},
|
|
204
|
+
// 预热倒计时
|
|
205
|
+
startPreheatCountdown(list) {
|
|
206
|
+
clearInterval(preheatTimer)
|
|
207
|
+
preheatTimer = setInterval(() => {
|
|
208
|
+
hadPreheat = false
|
|
209
|
+
list.forEach((i) => {
|
|
210
|
+
let targetDate = new Date(i.time.replace(/-/g, '/')).getTime() - new Date().getTime()
|
|
211
|
+
if (targetDate <= 0) {
|
|
212
|
+
activityList.push({
|
|
213
|
+
time: this.data.goodsInfo[i.index].end_at,
|
|
214
|
+
index: i.index,
|
|
215
|
+
})
|
|
216
|
+
this.setData({
|
|
217
|
+
[`goodsInfo[${i.index}].preheatTime`]: 0,
|
|
218
|
+
})
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
hadPreheat = true
|
|
222
|
+
let temp = `goodsInfo[${i.index}].preheatTime`
|
|
223
|
+
this.setData({
|
|
224
|
+
[temp]: targetDate,
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
if (!hadPreheat) {
|
|
228
|
+
clearInterval(preheatTimer)
|
|
229
|
+
preheatTimer = null
|
|
230
|
+
}
|
|
231
|
+
}, 1000)
|
|
232
|
+
},
|
|
233
|
+
|
|
166
234
|
/**
|
|
167
235
|
* 带货/优惠券实时同步
|
|
168
236
|
* @param {object} msgData im消息体
|
|
@@ -420,7 +488,45 @@ Component({
|
|
|
420
488
|
//下拉刷新的时候直接赋值
|
|
421
489
|
goodsInfo = JSON.parse(JSON.stringify(data))
|
|
422
490
|
}
|
|
423
|
-
this.setData({goodsInfo})
|
|
491
|
+
this.setData({goodsInfo},()=>{
|
|
492
|
+
this.getActivityStatus(this.data.goodsInfo)
|
|
493
|
+
})
|
|
494
|
+
},
|
|
495
|
+
getActivityStatus(data){
|
|
496
|
+
activityList = []
|
|
497
|
+
preheatList = []
|
|
498
|
+
data.forEach((item, index) => {
|
|
499
|
+
if (item.is_activity && item.end_at) {
|
|
500
|
+
hasActivity = true
|
|
501
|
+
item.activityCountdown = 0
|
|
502
|
+
activityList.push({
|
|
503
|
+
time: item.end_at,
|
|
504
|
+
index,
|
|
505
|
+
})
|
|
506
|
+
}
|
|
507
|
+
// this.data.isSeckill && this.data.preheating
|
|
508
|
+
if (item.activity_type === 8 && item.sec_kill_is_preheat === 1) {
|
|
509
|
+
//预热开始时间
|
|
510
|
+
let startTime = (item.start_at && new Date(item.start_at.replace(/-/g, '/'))) || new Date()
|
|
511
|
+
let times = startTime.getTime() - item.sec_kill_preheat_time * 1000
|
|
512
|
+
let preHeatTime = new Date(times) || new Date()
|
|
513
|
+
|
|
514
|
+
let startTime2 = (item.start_at && new Date(item.start_at.replace(/-/g, '/'))) || new Date()
|
|
515
|
+
let nowTime = new Date().getTime()
|
|
516
|
+
let preheating = nowTime > preHeatTime.getTime() && startTime2.getTime() > nowTime
|
|
517
|
+
|
|
518
|
+
if (preheating) {
|
|
519
|
+
hasPreheat = true
|
|
520
|
+
item.preheatTime = 0
|
|
521
|
+
preheatList.push({
|
|
522
|
+
time: item.start_at,
|
|
523
|
+
index,
|
|
524
|
+
})
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
})
|
|
528
|
+
if (hasActivity) this.startActivityCountdown(activityList) //活动倒计时
|
|
529
|
+
if (hasPreheat) this.startPreheatCountdown(preheatList) // 预热倒计时
|
|
424
530
|
},
|
|
425
531
|
formatItem(e) {
|
|
426
532
|
e.resourceTypeName = e.resource_type_name // 商品类型
|
package/package.json
CHANGED
|
@@ -16,6 +16,18 @@ import {
|
|
|
16
16
|
import { rpxToVmin } from '../common/utils/index.js'
|
|
17
17
|
const computedBehavior = require('miniprogram-computed').behavior
|
|
18
18
|
|
|
19
|
+
let activityCountdownTimer = null // 活动倒计时计时器
|
|
20
|
+
let hadActivity = false
|
|
21
|
+
let activityList = [] // 参与活动的商品
|
|
22
|
+
|
|
23
|
+
// 预热模块
|
|
24
|
+
let preheatTimer = null // 预热倒计时计时器
|
|
25
|
+
let hadPreheat = false
|
|
26
|
+
let preheatList = [] // 参与活动的商品
|
|
27
|
+
|
|
28
|
+
let hasActivity = false // 是否有参与活动的商品
|
|
29
|
+
let hasPreheat = false // 是否有参与预热的商品
|
|
30
|
+
|
|
19
31
|
const MARKET_ACTIVITY_MAP = {
|
|
20
32
|
3: "限时折扣",
|
|
21
33
|
4: "好友助力",
|
|
@@ -60,6 +72,12 @@ Component({
|
|
|
60
72
|
newVal && this.data.explainingGoods.length && this.getExplainingGoodsInfo()
|
|
61
73
|
newVal && this.getPreferentialPriceSetting()
|
|
62
74
|
newVal && this.onLoad()
|
|
75
|
+
if(!newVal){
|
|
76
|
+
clearInterval(activityCountdownTimer)
|
|
77
|
+
activityCountdownTimer = null
|
|
78
|
+
clearInterval(preheatTimer)
|
|
79
|
+
preheatTimer = null
|
|
80
|
+
}
|
|
63
81
|
}
|
|
64
82
|
},
|
|
65
83
|
// 讲解中商品
|
|
@@ -163,6 +181,56 @@ Component({
|
|
|
163
181
|
},
|
|
164
182
|
},
|
|
165
183
|
methods: {
|
|
184
|
+
// 商品总活动倒计时
|
|
185
|
+
startActivityCountdown(list) {
|
|
186
|
+
clearInterval(activityCountdownTimer)
|
|
187
|
+
activityCountdownTimer = setInterval(() => {
|
|
188
|
+
hadActivity = false
|
|
189
|
+
list.forEach((i) => {
|
|
190
|
+
let targetDate = new Date(i.time.replace(/-/g, '/')).getTime() - new Date().getTime()
|
|
191
|
+
if (targetDate <= 0) return
|
|
192
|
+
hadActivity = true
|
|
193
|
+
let temp = `goodsInfo[${i.index}].activityCountdown`
|
|
194
|
+
this.setData({
|
|
195
|
+
[temp]: targetDate,
|
|
196
|
+
})
|
|
197
|
+
})
|
|
198
|
+
if (!hadActivity) {
|
|
199
|
+
clearInterval(activityCountdownTimer)
|
|
200
|
+
activityCountdownTimer = null
|
|
201
|
+
}
|
|
202
|
+
}, 1000)
|
|
203
|
+
},
|
|
204
|
+
// 预热倒计时
|
|
205
|
+
startPreheatCountdown(list) {
|
|
206
|
+
clearInterval(preheatTimer)
|
|
207
|
+
preheatTimer = setInterval(() => {
|
|
208
|
+
hadPreheat = false
|
|
209
|
+
list.forEach((i) => {
|
|
210
|
+
let targetDate = new Date(i.time.replace(/-/g, '/')).getTime() - new Date().getTime()
|
|
211
|
+
if (targetDate <= 0) {
|
|
212
|
+
activityList.push({
|
|
213
|
+
time: this.data.goodsInfo[i.index].end_at,
|
|
214
|
+
index: i.index,
|
|
215
|
+
})
|
|
216
|
+
this.setData({
|
|
217
|
+
[`goodsInfo[${i.index}].preheatTime`]: 0,
|
|
218
|
+
})
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
hadPreheat = true
|
|
222
|
+
let temp = `goodsInfo[${i.index}].preheatTime`
|
|
223
|
+
this.setData({
|
|
224
|
+
[temp]: targetDate,
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
if (!hadPreheat) {
|
|
228
|
+
clearInterval(preheatTimer)
|
|
229
|
+
preheatTimer = null
|
|
230
|
+
}
|
|
231
|
+
}, 1000)
|
|
232
|
+
},
|
|
233
|
+
|
|
166
234
|
/**
|
|
167
235
|
* 带货/优惠券实时同步
|
|
168
236
|
* @param {object} msgData im消息体
|
|
@@ -420,7 +488,45 @@ Component({
|
|
|
420
488
|
//下拉刷新的时候直接赋值
|
|
421
489
|
goodsInfo = JSON.parse(JSON.stringify(data))
|
|
422
490
|
}
|
|
423
|
-
this.setData({goodsInfo})
|
|
491
|
+
this.setData({goodsInfo},()=>{
|
|
492
|
+
this.getActivityStatus(this.data.goodsInfo)
|
|
493
|
+
})
|
|
494
|
+
},
|
|
495
|
+
getActivityStatus(data){
|
|
496
|
+
activityList = []
|
|
497
|
+
preheatList = []
|
|
498
|
+
data.forEach((item, index) => {
|
|
499
|
+
if (item.is_activity && item.end_at) {
|
|
500
|
+
hasActivity = true
|
|
501
|
+
item.activityCountdown = 0
|
|
502
|
+
activityList.push({
|
|
503
|
+
time: item.end_at,
|
|
504
|
+
index,
|
|
505
|
+
})
|
|
506
|
+
}
|
|
507
|
+
// this.data.isSeckill && this.data.preheating
|
|
508
|
+
if (item.activity_type === 8 && item.sec_kill_is_preheat === 1) {
|
|
509
|
+
//预热开始时间
|
|
510
|
+
let startTime = (item.start_at && new Date(item.start_at.replace(/-/g, '/'))) || new Date()
|
|
511
|
+
let times = startTime.getTime() - item.sec_kill_preheat_time * 1000
|
|
512
|
+
let preHeatTime = new Date(times) || new Date()
|
|
513
|
+
|
|
514
|
+
let startTime2 = (item.start_at && new Date(item.start_at.replace(/-/g, '/'))) || new Date()
|
|
515
|
+
let nowTime = new Date().getTime()
|
|
516
|
+
let preheating = nowTime > preHeatTime.getTime() && startTime2.getTime() > nowTime
|
|
517
|
+
|
|
518
|
+
if (preheating) {
|
|
519
|
+
hasPreheat = true
|
|
520
|
+
item.preheatTime = 0
|
|
521
|
+
preheatList.push({
|
|
522
|
+
time: item.start_at,
|
|
523
|
+
index,
|
|
524
|
+
})
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
})
|
|
528
|
+
if (hasActivity) this.startActivityCountdown(activityList) //活动倒计时
|
|
529
|
+
if (hasPreheat) this.startPreheatCountdown(preheatList) // 预热倒计时
|
|
424
530
|
},
|
|
425
531
|
formatItem(e) {
|
|
426
532
|
e.resourceTypeName = e.resource_type_name // 商品类型
|