vhall-mini-sdk 0.4.0 → 0.4.3
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/CHANGELOG.md +4 -0
- package/dist/components/gift/gift-display/gift-display.js +118 -0
- package/dist/components/gift/gift-display/gift-display.json +3 -0
- package/dist/components/gift/gift-display/gift-display.wxml +16 -0
- package/dist/components/gift/gift-display/gift-display.wxss +1 -0
- package/dist/components/gift/gift-sender/gift-sender.js +63 -0
- package/dist/components/gift/gift-sender/gift-sender.json +6 -0
- package/dist/components/gift/gift-sender/gift-sender.wxml +19 -0
- package/dist/components/gift/gift-sender/gift-sender.wxss +1 -0
- package/dist/components/lottery/lottery-accept/index.js +249 -0
- package/dist/components/lottery/lottery-accept/index.json +4 -0
- package/dist/components/lottery/lottery-accept/index.wxml +49 -0
- package/dist/components/lottery/lottery-accept/index.wxss +1 -0
- package/dist/components/lottery/lottery-history/index.js +36 -0
- package/dist/components/lottery/lottery-history/index.json +3 -0
- package/dist/components/lottery/lottery-history/index.wxml +28 -0
- package/dist/components/lottery/lottery-history/index.wxss +1 -0
- package/dist/components/lottery/lottery-shake/lottery-shake.js +328 -0
- package/dist/components/lottery/lottery-shake/lottery-shake.json +1 -0
- package/dist/components/lottery/lottery-shake/lottery-shake.wxml +52 -0
- package/dist/components/lottery/lottery-shake/lottery-shake.wxss +1 -0
- package/dist/components/lottery/lottery-slot/lottery-slot.js +230 -0
- package/dist/components/lottery/lottery-slot/lottery-slot.json +1 -0
- package/dist/components/lottery/lottery-slot/lottery-slot.wxml +62 -0
- package/dist/components/lottery/lottery-slot/lottery-slot.wxss +1 -0
- package/dist/components/lottery/lottery-wheel/lottery-wheel.js +153 -0
- package/dist/components/lottery/lottery-wheel/lottery-wheel.json +4 -0
- package/dist/components/lottery/lottery-wheel/lottery-wheel.wxml +91 -0
- package/dist/components/lottery/lottery-wheel/lottery-wheel.wxss +1 -0
- package/dist/components/lottery/lottery-winners/index.js +101 -0
- package/dist/components/lottery/lottery-winners/index.json +4 -0
- package/dist/components/lottery/lottery-winners/index.wxml +39 -0
- package/dist/components/lottery/lottery-winners/index.wxss +1 -0
- package/dist/components/lottery/lottery.js +388 -0
- package/dist/components/lottery/lottery.json +11 -0
- package/dist/components/lottery/lottery.wxml +78 -0
- package/dist/components/lottery/lottery.wxss +1 -0
- package/dist/components/lottery/wheel.json +49 -0
- package/dist/components/mall-reward/common/reward-card.wxss +0 -0
- package/dist/components/mall-reward/duration-icon/index.js +101 -0
- package/dist/components/mall-reward/duration-icon/index.json +3 -0
- package/dist/components/mall-reward/duration-icon/index.wxml +7 -0
- package/dist/components/mall-reward/duration-icon/index.wxss +1 -0
- package/dist/components/mall-reward/f-count-down/index.js +61 -0
- package/dist/components/mall-reward/f-count-down/index.json +3 -0
- package/dist/components/mall-reward/f-count-down/index.wxml +9 -0
- package/dist/components/mall-reward/f-count-down/index.wxss +1 -0
- package/dist/components/mall-reward/f-empty/index.js +11 -0
- package/dist/components/mall-reward/f-empty/index.json +3 -0
- package/dist/components/mall-reward/f-empty/index.wxml +8 -0
- package/dist/components/mall-reward/f-empty/index.wxss +1 -0
- package/dist/components/mall-reward/f-history/index.js +84 -0
- package/dist/components/mall-reward/f-history/index.json +4 -0
- package/dist/components/mall-reward/f-history/index.wxml +38 -0
- package/dist/components/mall-reward/f-history/index.wxss +1 -0
- package/dist/components/mall-reward/f-open/index.js +36 -0
- package/dist/components/mall-reward/f-open/index.json +3 -0
- package/dist/components/mall-reward/f-open/index.wxml +10 -0
- package/dist/components/mall-reward/f-open/index.wxss +1 -0
- package/dist/components/mall-reward/f-receive/index.js +36 -0
- package/dist/components/mall-reward/f-receive/index.json +3 -0
- package/dist/components/mall-reward/f-receive/index.wxml +9 -0
- package/dist/components/mall-reward/f-receive/index.wxss +1 -0
- package/dist/components/mall-reward/index.js +374 -0
- package/dist/components/mall-reward/index.json +8 -0
- package/dist/components/mall-reward/index.wxml +4 -0
- package/dist/components/mall-reward/index.wxss +0 -0
- package/dist/components/mall-reward/main-popup/index.js +46 -0
- package/dist/components/mall-reward/main-popup/index.json +12 -0
- package/dist/components/mall-reward/main-popup/index.wxml +16 -0
- package/dist/components/mall-reward/main-popup/index.wxss +1 -0
- package/dist/components/praise/praise.js +150 -0
- package/dist/components/praise/praise.json +5 -0
- package/dist/components/praise/praise.wxml +17 -0
- package/dist/components/praise/praise.wxss +1 -0
- package/dist/components/product/product-card/product-card.js +109 -0
- package/dist/components/product/product-card/product-card.json +3 -0
- package/dist/components/product/product-card/product-card.wxml +47 -0
- package/dist/components/product/product-card/product-card.wxss +1 -0
- package/dist/components/product/product-detail/product-detail.js +127 -0
- package/dist/components/product/product-detail/product-detail.json +3 -0
- package/dist/components/product/product-detail/product-detail.wxml +57 -0
- package/dist/components/product/product-detail/product-detail.wxss +1 -0
- package/dist/components/product/product-item/product-item.js +56 -0
- package/dist/components/product/product-item/product-item.json +3 -0
- package/dist/components/product/product-item/product-item.wxml +35 -0
- package/dist/components/product/product-item/product-item.wxss +1 -0
- package/dist/components/product/product-list/product-list.js +67 -0
- package/dist/components/product/product-list/product-list.json +6 -0
- package/dist/components/product/product-list/product-list.wxml +16 -0
- package/dist/components/product/product-list/product-list.wxss +1 -0
- package/dist/components/product/product-order/product-order.js +394 -0
- package/dist/components/product/product-order/product-order.json +3 -0
- package/dist/components/product/product-order/product-order.wxml +75 -0
- package/dist/components/product/product-order/product-order.wxss +1 -0
- package/dist/pubComponents/popup/popup.wxss +1 -0
- package/dist/sdk/config/index.js +1 -0
- package/dist/sdk/plugins/InteractServer.js +1 -0
- package/dist/sdk/plugins/LotteryServer.js +1 -0
- package/dist/sdk/plugins/MallRewardServer.js +1 -0
- package/dist/sdk/plugins/ProductServer.js +1 -0
- package/lib/components/announcement/announ-banner/index.wxml +1 -1
- package/lib/components/chat-recommend/index.wxml +1 -1
- package/lib/components/player/components/controls/controls.wxml +6 -3
- package/lib/components/player/components/controls/controls.wxss +1 -1
- package/lib/components/player/player.wxml +26 -24
- package/lib/components/player/player.wxss +1 -1
- package/lib/sdk/main/index.js +2 -2
- package/lib/shared/mpUtils.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
Component({
|
|
2
|
+
properties: {
|
|
3
|
+
sdkInstance: {
|
|
4
|
+
type: Object,
|
|
5
|
+
value: null,
|
|
6
|
+
},
|
|
7
|
+
},
|
|
8
|
+
data: {
|
|
9
|
+
visible: false,
|
|
10
|
+
lotteryStatus: '',
|
|
11
|
+
currentLottery: null,
|
|
12
|
+
winners: [],
|
|
13
|
+
animating: false,
|
|
14
|
+
isWinner: false,
|
|
15
|
+
prizeName: '',
|
|
16
|
+
prizeImage: '',
|
|
17
|
+
nickname: '',
|
|
18
|
+
winnersList: [],
|
|
19
|
+
receiveAwardWay: '',
|
|
20
|
+
showReceiveModal: false,
|
|
21
|
+
showHistory: false,
|
|
22
|
+
showHistoryIcon: false,
|
|
23
|
+
lotteryCount: 0,
|
|
24
|
+
winLotteryHistory: [],
|
|
25
|
+
showAwardPool: false,
|
|
26
|
+
awardList: [],
|
|
27
|
+
drawAwareFiled: {},
|
|
28
|
+
showWinnersList: false,
|
|
29
|
+
},
|
|
30
|
+
observers: {
|
|
31
|
+
sdkInstance: function sdkInstance(_sdkInstance) {
|
|
32
|
+
if (!_sdkInstance) return;
|
|
33
|
+
this.sdkInstance = _sdkInstance;
|
|
34
|
+
this.initSubscribe();
|
|
35
|
+
this.initEventListener();
|
|
36
|
+
this.initLotteryHistory(); // 初始化抽奖历史相关
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
lifetimes: {
|
|
40
|
+
attached() {},
|
|
41
|
+
detached() {
|
|
42
|
+
this.lotteryListUnsub && this.lotteryListUnsub();
|
|
43
|
+
this.unlistener && this.unlistener();
|
|
44
|
+
this._resultTimer && clearTimeout(this._resultTimer);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
// 初始化订阅监听
|
|
49
|
+
initSubscribe() {
|
|
50
|
+
// 监听 lotteryList 变化
|
|
51
|
+
this.lotteryListUnsub && this.lotteryListUnsub();
|
|
52
|
+
const store = this.sdkInstance.store;
|
|
53
|
+
this.lotteryListUnsub = store.get({
|
|
54
|
+
lotteryList: (lotteryList) => {
|
|
55
|
+
if (!lotteryList || !Array.isArray(lotteryList)) return;
|
|
56
|
+
const winHistory = lotteryList.filter((item) => item.win == 1);
|
|
57
|
+
this.setData({
|
|
58
|
+
showHistoryIcon: lotteryList.length > 0,
|
|
59
|
+
lotteryCount: lotteryList.length,
|
|
60
|
+
winLotteryHistory: winHistory,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
// 初始化事件监听
|
|
66
|
+
initEventListener() {
|
|
67
|
+
this.unlistener && this.unlistener();
|
|
68
|
+
const obj = {};
|
|
69
|
+
|
|
70
|
+
// 抽奖开始
|
|
71
|
+
obj[this.sdkInstance.EVENT.LOTTERY_START] = (data) => {
|
|
72
|
+
data.lotteryStatus = 0;
|
|
73
|
+
this.setData({ currentLottery: data });
|
|
74
|
+
this.showLottery(data);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// 抽奖结束
|
|
78
|
+
obj[this.sdkInstance.EVENT.LOTTERY_END] = (data, curLottery) => {
|
|
79
|
+
// console.log('LOTTERY_END', data, curLottery);
|
|
80
|
+
// 抽奖已结束,兜底清除该抽奖"进行中"缓存(即便对应组件当时未渲染)
|
|
81
|
+
const endedLotteryId = curLottery && (curLottery.lottery_id || curLottery.id);
|
|
82
|
+
if (endedLotteryId) wx.removeStorageSync(`lottery_${endedLotteryId}_cache`);
|
|
83
|
+
const isWinner = data && data.award_name;
|
|
84
|
+
const user = this.sdkInstance?.store?.get('user') || {};
|
|
85
|
+
const resultData = {
|
|
86
|
+
visible: true,
|
|
87
|
+
lotteryStatus: 1,
|
|
88
|
+
isWinner: !!isWinner,
|
|
89
|
+
prizeName: data?.award_name || '',
|
|
90
|
+
prizeImage: data?.image_url || '',
|
|
91
|
+
nickname: user.nickname,
|
|
92
|
+
receiveAwardWay: data?.receive_award_way,
|
|
93
|
+
drawAwareFiled: JSON.parse(curLottery?.draw_aware_filed || '[]')[0],
|
|
94
|
+
animating: false,
|
|
95
|
+
currentLottery: curLottery,
|
|
96
|
+
};
|
|
97
|
+
// 通过消息控制动画停止:先平滑减速,过渡结束后再展示结果
|
|
98
|
+
const mode = this.data.currentLottery && this.data.currentLottery.img_order;
|
|
99
|
+
const wheel = this.selectComponent('#lotteryWheel');
|
|
100
|
+
const slot = this.selectComponent('#lotterySlot');
|
|
101
|
+
const shake = this.selectComponent('#lotteryShake');
|
|
102
|
+
if (mode == 3 && shake && this.data.lotteryStatus === 0) {
|
|
103
|
+
// 摇奖机模式:停止弹跳球聚落
|
|
104
|
+
const stopped = shake.stop();
|
|
105
|
+
if (stopped) {
|
|
106
|
+
this._resultTimer && clearTimeout(this._resultTimer);
|
|
107
|
+
this._resultTimer = setTimeout(() => {
|
|
108
|
+
this.setData(resultData);
|
|
109
|
+
}, 2500); // 等摇奖机球停止聚落
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (mode == 2 && slot && this.data.lotteryStatus === 0) {
|
|
114
|
+
// 老虎机模式:停止滚轴,传入是否中奖(决定三轴落定在谢谢参与/恭喜中奖)
|
|
115
|
+
const stopped = slot.stop(resultData.isWinner);
|
|
116
|
+
if (stopped) {
|
|
117
|
+
this._resultTimer && clearTimeout(this._resultTimer);
|
|
118
|
+
this._resultTimer = setTimeout(() => {
|
|
119
|
+
this.setData(resultData);
|
|
120
|
+
}, 3200); // 等老虎机三轴依次停止
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (mode != 2 && wheel && this.data.lotteryStatus === 0) {
|
|
125
|
+
// 转盘模式(默认):平滑减速
|
|
126
|
+
const stopped = wheel.stop();
|
|
127
|
+
if (stopped) {
|
|
128
|
+
this._resultTimer && clearTimeout(this._resultTimer);
|
|
129
|
+
this._resultTimer = setTimeout(() => {
|
|
130
|
+
this.setData(resultData);
|
|
131
|
+
}, 4200); // 略大于减速过渡时长(4s)
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
this.setData(resultData);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// 切回前台刷新:重新拉取抽奖列表与历史(时机与后台时长由 sdk 统一控制)
|
|
139
|
+
obj[this.sdkInstance.EVENT.FOREGROUND_REFRESH] = () => {
|
|
140
|
+
this.initLotteryHistory();
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
this.unlistener = this.sdkInstance.on(obj);
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
showLottery(data) {
|
|
147
|
+
this.closeAllModals();
|
|
148
|
+
this.setData({
|
|
149
|
+
visible: true,
|
|
150
|
+
lotteryStatus: data.lotteryStatus,
|
|
151
|
+
currentLottery: data,
|
|
152
|
+
animating: data.lotteryStatus == 0,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
if (data.lotteryStatus == 1) {
|
|
156
|
+
this.checkWinner(data);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
// 检查是否中奖
|
|
161
|
+
checkWinner(data) {
|
|
162
|
+
const user = this.sdkInstance?.store?.get('user') || {};
|
|
163
|
+
const currentUserId = user.id || user.uid || user.openid || '';
|
|
164
|
+
const winners = data.lottery_winners || '';
|
|
165
|
+
const winnerIds = winners.split(',').map((id) => id.trim());
|
|
166
|
+
const isWinner = winnerIds.includes(currentUserId);
|
|
167
|
+
|
|
168
|
+
let prizeName = '';
|
|
169
|
+
let prizeImage = '';
|
|
170
|
+
const winnersAward = data.lottery_winners_award || [];
|
|
171
|
+
|
|
172
|
+
if (isWinner && winnersAward.length > 0) {
|
|
173
|
+
const userAward = winnersAward.find((award) => award.uid == currentUserId);
|
|
174
|
+
if (userAward) {
|
|
175
|
+
prizeName = userAward.award_name;
|
|
176
|
+
prizeImage = userAward.image_url;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const winnersList = winnersAward.map((item) => ({
|
|
181
|
+
uid: item.uid,
|
|
182
|
+
prizeName: item.award_name || item.prize_name || item.name || '',
|
|
183
|
+
imageUrl: item.image_url || item.image || item.img || '',
|
|
184
|
+
}));
|
|
185
|
+
|
|
186
|
+
this.setData({
|
|
187
|
+
isWinner,
|
|
188
|
+
prizeName,
|
|
189
|
+
prizeImage,
|
|
190
|
+
winnersList,
|
|
191
|
+
animating: false,
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
closeAllModals() {
|
|
196
|
+
this.setData({
|
|
197
|
+
visible: false,
|
|
198
|
+
animating: false,
|
|
199
|
+
showReceiveModal: false,
|
|
200
|
+
showHistory: false,
|
|
201
|
+
showAwardPool: false,
|
|
202
|
+
showWinnersList: false,
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
// 用户点击转盘中心按钮触发的抽奖意图(透传,可在此接入服务端抽奖)
|
|
207
|
+
onWheelDraw() {
|
|
208
|
+
// 当前抽奖由 SDK 的 LOTTERY_START/LOTTERY_END 驱动,点击仅作为动画开始信号;
|
|
209
|
+
// 若需要点击即发起服务端抽奖,可在此调用对应接口。
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
// 转盘减速停止完成回调(结果已在 LOTTERY_END 中延时展示,这里可做兜底)
|
|
213
|
+
onWheelStopped() {},
|
|
214
|
+
|
|
215
|
+
// 老虎机用户点击抽奖
|
|
216
|
+
onSlotDraw() {},
|
|
217
|
+
|
|
218
|
+
// 老虎机停止回调
|
|
219
|
+
onSlotStopped() {},
|
|
220
|
+
|
|
221
|
+
// 摇奖机用户点击抽奖
|
|
222
|
+
onShakeDraw() {},
|
|
223
|
+
|
|
224
|
+
// 摇奖机停止回调
|
|
225
|
+
onShakeStopped() {},
|
|
226
|
+
|
|
227
|
+
onClose() {
|
|
228
|
+
this.closeAllModals();
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
receiveAward() {
|
|
232
|
+
if (this.data.receiveAwardWay == 4) {
|
|
233
|
+
wx.openUrl({
|
|
234
|
+
url: this.data.drawAwareFiled.custom_link,
|
|
235
|
+
success() {},
|
|
236
|
+
fail(err) {
|
|
237
|
+
wx.showToast({
|
|
238
|
+
title: '请联系主办方',
|
|
239
|
+
icon: 'error',
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
this.closeAllModals();
|
|
246
|
+
this.setData({ showReceiveModal: true });
|
|
247
|
+
},
|
|
248
|
+
onReceiveModalClose() {
|
|
249
|
+
this.setData({ showReceiveModal: false });
|
|
250
|
+
},
|
|
251
|
+
onReceiveSuccess() {},
|
|
252
|
+
|
|
253
|
+
// 初始化抽奖历史(获取列表 + 监听变化)
|
|
254
|
+
initLotteryHistory() {
|
|
255
|
+
this.closeAllModals();
|
|
256
|
+
// 获取抽奖列表
|
|
257
|
+
const lotteryServer = this.sdkInstance.get('lotteryServer');
|
|
258
|
+
if (!lotteryServer) return;
|
|
259
|
+
const webinarId = this.sdkInstance.store.get('webinarId');
|
|
260
|
+
lotteryServer
|
|
261
|
+
.getLotteryList({ webinar_id: webinarId || '' })
|
|
262
|
+
.then((res) => {
|
|
263
|
+
if (res && res.data && res.data.length > 0) {
|
|
264
|
+
const ongoingLottery = res.data.find((item) => item.lottery_status == 0);
|
|
265
|
+
if (ongoingLottery) {
|
|
266
|
+
this.showLottery({
|
|
267
|
+
...ongoingLottery,
|
|
268
|
+
lotteryStatus: 0,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
.catch((err) => {
|
|
274
|
+
console.error('获取抽奖列表失败:', err);
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
showLotteryHistory() {
|
|
279
|
+
const lotteryServer = this.sdkInstance.get('lotteryServer');
|
|
280
|
+
if (!lotteryServer) return;
|
|
281
|
+
const webinarId = this.sdkInstance.store.get('webinarId');
|
|
282
|
+
lotteryServer
|
|
283
|
+
.getLotteryList({ webinar_id: webinarId || '' })
|
|
284
|
+
.then((res) => {
|
|
285
|
+
if (!res || !res.data) return;
|
|
286
|
+
const lotteryList = res.data;
|
|
287
|
+
let ongoingLottery = null;
|
|
288
|
+
let hasWinner = false;
|
|
289
|
+
for (let i = 0, len = lotteryList.length; i < len; i++) {
|
|
290
|
+
const item = lotteryList[i];
|
|
291
|
+
if (!ongoingLottery && item.lottery_status == 0) {
|
|
292
|
+
ongoingLottery = item;
|
|
293
|
+
}
|
|
294
|
+
if (!hasWinner && item.win == 1) {
|
|
295
|
+
hasWinner = true;
|
|
296
|
+
}
|
|
297
|
+
if (ongoingLottery && hasWinner) break;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
this.closeAllModals();
|
|
301
|
+
|
|
302
|
+
// 无抽奖数据时不展示任何面板
|
|
303
|
+
if (lotteryList.length === 0) return;
|
|
304
|
+
|
|
305
|
+
if (ongoingLottery) {
|
|
306
|
+
this.setData({
|
|
307
|
+
visible: true,
|
|
308
|
+
lotteryStatus: 0,
|
|
309
|
+
currentLottery: ongoingLottery,
|
|
310
|
+
animating: true,
|
|
311
|
+
});
|
|
312
|
+
} else if (!hasWinner) {
|
|
313
|
+
this.setData({
|
|
314
|
+
visible: true,
|
|
315
|
+
lotteryStatus: 1,
|
|
316
|
+
isWinner: false,
|
|
317
|
+
});
|
|
318
|
+
} else {
|
|
319
|
+
this.setData({ showHistory: true });
|
|
320
|
+
}
|
|
321
|
+
})
|
|
322
|
+
.catch((err) => {
|
|
323
|
+
console.error('获取抽奖列表失败:', err);
|
|
324
|
+
this.closeAllModals();
|
|
325
|
+
this.setData({ showHistory: true });
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
onHistoryClose() {
|
|
329
|
+
this.closeAllModals();
|
|
330
|
+
},
|
|
331
|
+
onTakeAward(e) {
|
|
332
|
+
this.closeAllModals();
|
|
333
|
+
this.setData({
|
|
334
|
+
showReceiveModal: true,
|
|
335
|
+
currentLottery: e.detail,
|
|
336
|
+
});
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
onHistoryItemClick(e) {
|
|
340
|
+
const lottery = e.detail;
|
|
341
|
+
this.closeAllModals();
|
|
342
|
+
this.setData({
|
|
343
|
+
visible: true,
|
|
344
|
+
lotteryStatus: 1,
|
|
345
|
+
isWinner: true,
|
|
346
|
+
prizeName: lottery.award_snapshoot?.award_name || '',
|
|
347
|
+
prizeImage: lottery.award_snapshoot?.image_url || '',
|
|
348
|
+
receiveAwardWay: lottery.receive_award_way,
|
|
349
|
+
drawAwareFiled: JSON.parse(lottery?.draw_aware_filed || '[]')[0],
|
|
350
|
+
currentLottery: lottery,
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
|
|
354
|
+
async showAwardPool() {
|
|
355
|
+
const lotteryServer = this.sdkInstance.get('lotteryServer');
|
|
356
|
+
if (!lotteryServer) return;
|
|
357
|
+
const currentLottery = this.data.currentLottery;
|
|
358
|
+
if (!currentLottery) return;
|
|
359
|
+
|
|
360
|
+
this.closeAllModals();
|
|
361
|
+
|
|
362
|
+
const res = await lotteryServer.getAwardList({
|
|
363
|
+
lottery_id: currentLottery.lottery_id || currentLottery.id,
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
if (res.code == 200) {
|
|
367
|
+
this.setData({
|
|
368
|
+
awardList: res.data.list || [],
|
|
369
|
+
showAwardPool: true,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
onAwardPoolClose() {
|
|
375
|
+
this.closeAllModals();
|
|
376
|
+
this.setData({ visible: true });
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
viewWinnersList() {
|
|
380
|
+
this.closeAllModals();
|
|
381
|
+
this.setData({ showWinnersList: true });
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
onWinnersClose() {
|
|
385
|
+
this.closeAllModals();
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"component": true,
|
|
3
|
+
"usingComponents": {
|
|
4
|
+
"lottery-wheel":"./lottery-wheel/lottery-wheel",
|
|
5
|
+
"lottery-slot":"./lottery-slot/lottery-slot",
|
|
6
|
+
"lottery-shake":"./lottery-shake/lottery-shake",
|
|
7
|
+
"lottery-accept":"./lottery-accept",
|
|
8
|
+
"lottery-history":"./lottery-history",
|
|
9
|
+
"lottery-winners":"./lottery-winners"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<view class="lottery-container mode-{{currentLottery.img_order}} display-{{currentLottery.display_of_results}}" wx:if="{{visible}}" catchtouchmove="true">
|
|
2
|
+
<!-- <view class="lottery-overlay" bindtap="onClose"></view> -->
|
|
3
|
+
<view class="lottery-modal">
|
|
4
|
+
<!-- 抽奖进行中 -->
|
|
5
|
+
<view wx:if="{{lotteryStatus==0}}" class="lottery-content">
|
|
6
|
+
<!-- 抽奖形式由 img_order 决定:1=转盘,2=老虎机,3=摇奖机 -->
|
|
7
|
+
<!-- 摇奖机模式 (img_order == 3) -->
|
|
8
|
+
<lottery-shake wx:if="{{currentLottery.img_order == 3}}" id="lotteryShake" lotteryId="{{currentLottery.lottery_id || currentLottery.id}}" remark="{{currentLottery.remark}}" autoplay loop bind:draw="onShakeDraw" bind:stopped="onShakeStopped" />
|
|
9
|
+
<!-- 老虎机模式 (img_order == 2) -->
|
|
10
|
+
<lottery-slot wx:elif="{{currentLottery.img_order == 2}}" id="lotterySlot" lotteryId="{{currentLottery.lottery_id || currentLottery.id}}" remark="{{currentLottery.remark}}" autoplay loop bind:draw="onSlotDraw" bind:stopped="onSlotStopped" />
|
|
11
|
+
<!-- 转盘模式(默认回退:img_order == 1 或其它未识别值都走转盘) -->
|
|
12
|
+
<lottery-wheel wx:else id="lotteryWheel" type="{{currentLottery.img_order || 1}}" lotteryId="{{currentLottery.lottery_id || currentLottery.id}}" autoplay loop remark="{{currentLottery.remark}}" bind:draw="onWheelDraw" bind:stopped="onWheelStopped" />
|
|
13
|
+
<!-- 新增形式:在对应位置插入 wx:elif="{{currentLottery.img_order == N}}" 分支即可 -->
|
|
14
|
+
<view wx:if="{{currentLottery && currentLottery.can_look_award_pool == 1}}" class="lottery-award-pool-btn" bindtap="showAwardPool">
|
|
15
|
+
<text class="lottery-award-pool-text">查看奖池 ></text>
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
<!-- 中奖结果展示 -->
|
|
19
|
+
<view wx:if="{{lotteryStatus==1}}" class="lottery-content">
|
|
20
|
+
<!-- 中奖 -->
|
|
21
|
+
<view wx:if="{{isWinner}}" class="lottery-result lottery-win">
|
|
22
|
+
<text class="lottery-win-title stroked-text" data-text="恭喜您中奖啦">恭喜您中奖啦</text>
|
|
23
|
+
<text class="lottery-win-nickname">{{nickname}}</text>
|
|
24
|
+
<view class="prize-card">
|
|
25
|
+
<image wx:if="{{prizeImage}}" class="prize-image" src="{{prizeImage}}" mode="aspectFit"></image>
|
|
26
|
+
</view>
|
|
27
|
+
<text class="prize-name">奖品【{{prizeName}}】</text>
|
|
28
|
+
<view wx:if="{{receiveAwardWay&&receiveAwardWay!=3}}" class="receive-btn" bindtap="receiveAward">
|
|
29
|
+
{{receiveAwardWay==4?drawAwareFiled.custom_btn_txt:'立即领奖'}}
|
|
30
|
+
</view>
|
|
31
|
+
<button wx:if="{{receiveAwardWay==3 && currentLottery.publish_winner == 1}}" class="lottery-success-btn" bindtap="viewWinnersList">
|
|
32
|
+
查看中奖名单
|
|
33
|
+
</button>
|
|
34
|
+
</view>
|
|
35
|
+
<!-- 未中奖 -->
|
|
36
|
+
<view wx:else class="lottery-result lottery-lose">
|
|
37
|
+
<view class="lottery-lose-content">
|
|
38
|
+
<text class="lottery-lose-title stroked-text" data-text="谢谢参与">谢谢参与</text>
|
|
39
|
+
</view>
|
|
40
|
+
<button wx:if="{{currentLottery.publish_winner == 1}}" class="lottery-success-btn" bindtap="viewWinnersList">
|
|
41
|
+
查看中奖名单
|
|
42
|
+
</button>
|
|
43
|
+
</view>
|
|
44
|
+
</view>
|
|
45
|
+
<view class="lottery-close-btn" bindtap="onClose">
|
|
46
|
+
<icon class="lottery-close-icon" type="cancel" size="{{currentLottery.display_of_results==1?'30':'40'}}" color="#fff" />
|
|
47
|
+
</view>
|
|
48
|
+
</view>
|
|
49
|
+
</view>
|
|
50
|
+
<!-- 右下角抽奖历史图标 -->
|
|
51
|
+
<view wx:if="{{showHistoryIcon}}" class="lottery-history-icon" bindtap="showLotteryHistory">
|
|
52
|
+
<image class="history-icon-img" src="https://cnstatic01.e.vhall.com/common-static/saas-wap/static/img/icon.f669b92c.png" mode="aspectFit"></image>
|
|
53
|
+
<view wx:if="{{showHistoryBadge}}" class="history-badge"></view>
|
|
54
|
+
</view>
|
|
55
|
+
<!-- 领奖弹框组件 -->
|
|
56
|
+
<lottery-accept visible="{{showReceiveModal}}" lotteryId="{{currentLottery && (currentLottery.lottery_id || currentLottery.id)}}" sdkInstance="{{sdkInstance}}" publishWinner="{{currentLottery && currentLottery.publish_winner}}" bind:close="onReceiveModalClose" bind:success="onReceiveSuccess" bind:viewWinners="viewWinnersList"></lottery-accept>
|
|
57
|
+
<!-- 抽奖历史弹窗组件 -->
|
|
58
|
+
<lottery-history visible="{{showHistory}}" winLotteryHistory="{{winLotteryHistory}}" bind:takeAward="onTakeAward" bind:close="onHistoryClose" bind:itemClick="onHistoryItemClick"></lottery-history>
|
|
59
|
+
<!-- 奖池底部弹窗 -->
|
|
60
|
+
<view wx:if="{{showAwardPool}}" class="award-pool-modal">
|
|
61
|
+
<view class="award-pool-mask" bindtap="onAwardPoolClose"></view>
|
|
62
|
+
<view class="award-pool-content">
|
|
63
|
+
<view class="award-pool-title">奖池奖品</view>
|
|
64
|
+
<view class="award-pool-wrap-container">
|
|
65
|
+
<scroll-view class="award-pool-wrap" scroll-y>
|
|
66
|
+
<view wx:for="{{awardList}}" wx:key="id" class="award-pool-item">
|
|
67
|
+
<image class="award-pool-item__img" src="{{item.award_img_url}}" mode="aspectFill" />
|
|
68
|
+
<view class="award-pool-item__content">
|
|
69
|
+
<p class="award-pool-item-name">{{item.award_name}}</p>
|
|
70
|
+
<p class="award-pool-item-desc">{{item.award_desc}}</p>
|
|
71
|
+
</view>
|
|
72
|
+
</view>
|
|
73
|
+
</scroll-view>
|
|
74
|
+
</view>
|
|
75
|
+
</view>
|
|
76
|
+
</view>
|
|
77
|
+
<!-- 中奖名单弹窗组件 -->
|
|
78
|
+
<lottery-winners visible="{{showWinnersList}}" lotteryId="{{currentLottery && (currentLottery.lottery_id || currentLottery.id)}}" sdkInstance="{{sdkInstance}}" bind:close="onWinnersClose"></lottery-winners>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.lottery-container{align-items:center;background:rgba(0,0,0,.7);display:flex;height:100%;justify-content:center;left:0;position:fixed;top:0;width:100%;z-index:10000}.lottery-container.display-1{background:url(https://s1.e.vhall.com/common-static/saas-wap/static/img/popupBg.35704976.png) no-repeat top;background-size:100% 100%;bottom:0;height:auto;top:56.25vw}.lottery-container.display-1 .lottery-close-btn{border-radius:50%;height:60rpx;position:absolute;right:20rpx;top:20rpx;width:60rpx}.lottery-overlay{background:rgba(0,0,0,.7);height:100%;left:0;position:absolute;top:0;width:100%}.lottery-modal{border-radius:24rpx;box-sizing:border-box;flex-direction:column;height:100%;position:relative;width:100%}.lottery-close,.lottery-modal{display:flex;justify-content:center}.lottery-close{align-items:center;height:50rpx;position:absolute;right:20rpx;top:20rpx;width:50rpx}.lottery-close .lottery-close-icon{height:40rpx;width:40rpx}.lottery-header{margin-bottom:30rpx;text-align:center}.lottery-title{color:#fff;font-size:36rpx;font-weight:700;text-shadow:0 2rpx 4rpx rgba(0,0,0,.3)}.lottery-content{align-items:center;display:flex;flex-direction:column;justify-content:center;margin-bottom:30rpx}.svga-canvas{height:400rpx;width:400rpx}.lottery-footer{margin-bottom:20rpx;text-align:center}.lottery-join-btn{animation:bounce .6s ease-in-out infinite;background:linear-gradient(135deg,#ffd32a,#ff9f1a);border:none;border-radius:50rpx;box-shadow:0 6rpx 20rpx rgba(255,159,26,.5);color:#d63031;display:inline-block;font-size:32rpx;font-weight:700;padding:20rpx 60rpx}.lottery-join-btn:after{border:none}.lottery-hint{animation:pulse 1s ease-in-out infinite;color:#fff;display:block;font-size:28rpx}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.lottery-winners{background:hsla(0,0%,100%,.95);border-radius:16rpx;max-height:200rpx;padding:20rpx}.lottery-winners-title{color:#d63031;font-size:26rpx;font-weight:700;margin-bottom:15rpx;text-align:center}.lottery-winners-list{max-height:150rpx}.lottery-winner-item{align-items:center;display:flex;padding:10rpx 0}.lottery-winner-item:not(:last-child){border-bottom:1rpx solid #f0f0f0}.lottery-winner-avatar{border-radius:50%;height:50rpx;margin-right:15rpx;width:50rpx}.lottery-winner-name{color:#333;font-size:24rpx}.lottery-close-btn{border-radius:50%;height:80rpx;margin:0rpx auto;width:80rpx}.lottery-close-btn,.lottery-result{align-items:center;display:flex;justify-content:center}.lottery-result{flex-direction:column;padding:40rpx;text-align:center}.lottery-win-title{margin-bottom:20rpx}.stroked-text{color:#fff;font-size:48rpx;font-weight:700;letter-spacing:5px;transform:matrix(.99,0,-.15,1,0,0)}.stroked-text:after,.stroked-text:before{content:attr(data-text);left:0;position:absolute;top:0}.stroked-text:before{-webkit-text-stroke:5px #fb2626;z-index:-1}.stroked-text:after{-webkit-text-stroke:8px #ffecb7;z-index:-2}.lottery-win-nickname{background:linear-gradient(270deg,rgba(255,107,38,0) 5.07%,#ff6b26 25.41%,#f52c03);border-radius:50rpx 0 0 50rpx;color:#fff;display:inline-block;margin-bottom:20rpx;max-width:340rpx;padding:6rpx 40rpx 6rpx 20rpx}.lottery-prize{background:linear-gradient(135deg,#ffd32a,#ff9f1a);border-radius:40rpx;color:#fff;font-size:36rpx;font-weight:700;padding:20rpx 40rpx}.lottery-lose-content{align-items:center;background:url(https://cnstatic01.e.vhall.com/common-static/saas-wap/static/img/lottery-miss.5a1292bf.png) no-repeat 50%;background-size:contain;display:flex;flex-direction:row;height:420rpx;justify-content:center;width:420rpx}@keyframes bounce{0%,to{transform:scale(1)}50%{transform:scale(1.2)}}.lottery-animation{padding:40rpx}.lottery-animation,.lottery-spinner{align-items:center;display:flex;justify-content:center}.lottery-spinner{animation:spin 2s linear infinite;background:linear-gradient(135deg,#ffd32a,#ff9f1a);border-radius:50%;box-shadow:0 10rpx 30rpx rgba(255,159,26,.5);height:200rpx;width:200rpx}.lottery-ball{animation:bounce .6s ease-in-out infinite;background:#fff;border-radius:50%;height:60rpx;width:60rpx}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.lottery-result{background:url(https://cnstatic01.e.vhall.com/common-static/saas-wap/static/img/lottery-win-gold-coin.1bcfdf22.png) no-repeat 50%;background-size:contain}.lottery-win{align-items:center;display:flex;flex-direction:column;padding:40rpx}.win-icon{animation:bounce .5s ease;font-size:100rpx;margin-bottom:20rpx}.prize-card{align-items:center;background:url(https://cnstatic01.e.vhall.com/common-static/saas-wap/static/img/lottery-win-annulus.ec2c80bd.png) no-repeat 50%;background-size:contain;display:flex;flex-direction:column;margin-top:-100rpx;padding:160rpx}.prize-image{border-radius:140rpx;height:280rpx;width:280rpx}.prize-name{background:linear-gradient(270deg,rgba(255,226,73,0) 2.54%,#ffeb32 32.61%,#ffeb32 59.83%,rgba(255,215,73,0) 94.2%);color:#d63031;display:block;font-size:32rpx;line-height:60rpx;margin-top:-140rpx;width:100%}.lottery-win-hint{color:hsla(0,0%,100%,.8);font-size:26rpx;margin-top:10rpx}.lottery-success-btn,.receive-btn{background:#fb2626;border-radius:50rpx;color:#fff;margin-top:30rpx;padding:20rpx 60rpx}.lottery-success-btn .receive-btn-text,.receive-btn .receive-btn-text{color:#fff;font-size:32rpx}.lottery-history-icon{align-items:center;border-radius:50%;bottom:200rpx;display:flex;justify-content:center;position:fixed;right:40rpx;z-index:500}.lottery-history-icon .history-icon-img{height:70rpx;width:70rpx}.lottery-history-icon .history-badge{background-color:#fb2626;border:4rpx solid #fff;border-radius:50%;height:24rpx;position:absolute;right:-4rpx;top:-4rpx;width:24rpx}.lottery-award-pool-btn .lottery-award-pool-text{color:#fce09e;font-size:32rpx}.award-pool-modal{bottom:0;display:flex;flex-direction:column;justify-content:flex-end;left:0;position:fixed;right:0;top:0;z-index:10001}.award-pool-mask{background:rgba(0,0,0,.5);bottom:0;left:0;position:absolute;right:0;top:0}.award-pool-content{background:linear-gradient(37.94deg,#fffbe8 3.86%,#fbf0e6 84.36%);border-radius:32rpx 32rpx 0 0;max-height:70vh;overflow:hidden;padding:0 40rpx 80rpx;position:relative}.award-pool-title{border-bottom:2rpx solid #f0f0f0;color:#333;font-size:38rpx;font-weight:600;height:100rpx;line-height:100rpx;text-align:center}.award-pool-wrap-container{padding-right:4rpx}.award-pool-wrap{max-height:432rpx;min-height:128rpx}.award-pool-item-wrapper{margin-bottom:24rpx}.award-pool-item{align-items:center;background:#fff;border-radius:24rpx;display:flex;flex-direction:row;padding:28rpx 32rpx}.award-pool-item__img{border:2rpx solid #d9d9d9;border-radius:24rpx;flex-shrink:0;height:160rpx;width:160rpx}.award-pool-item__content{display:flex;flex:1;flex-direction:column;height:100%;justify-content:center;margin-left:30rpx;width:0}.award-pool-item-name{color:#262626;font-size:32rpx;font-weight:500;line-height:48rpx;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.award-pool-item-desc{color:#8c8c8c;font-size:28rpx;line-height:36rpx;margin-top:8rpx}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"v":"5.12.0",
|
|
3
|
+
"fr":30,
|
|
4
|
+
"ip":0,
|
|
5
|
+
"op":60,
|
|
6
|
+
"w":300,
|
|
7
|
+
"h":300,
|
|
8
|
+
"nm":"抽奖转盘",
|
|
9
|
+
"ddd":0,
|
|
10
|
+
"assets":[],
|
|
11
|
+
"layers":[
|
|
12
|
+
{
|
|
13
|
+
"ddd":0,
|
|
14
|
+
"ind":1,
|
|
15
|
+
"ty":1,
|
|
16
|
+
"nm":"转盘底座",
|
|
17
|
+
"sr":1,
|
|
18
|
+
"ks":{
|
|
19
|
+
"o":{"a":0,"k":100},
|
|
20
|
+
"r":{"a":1,"k":[{"t":0,"s":[0]},{"t":60,"s":[720]}]},
|
|
21
|
+
"p":{"a":0,"k":[150,150,0]},
|
|
22
|
+
"a":{"a":0,"k":[150,150,0]}
|
|
23
|
+
},
|
|
24
|
+
"shapes":[
|
|
25
|
+
{
|
|
26
|
+
"ty":"gr",
|
|
27
|
+
"it":[
|
|
28
|
+
{
|
|
29
|
+
"ty":"el",
|
|
30
|
+
"s":{"a":0,"k":[150,150]},
|
|
31
|
+
"p":{"a":0,"k":[0,0]}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"ty":"st",
|
|
35
|
+
"c":{"a":0,"k":[1,0.8,0.2]},
|
|
36
|
+
"o":{"a":0,"k":100},
|
|
37
|
+
"w":{"a":0,"k":8}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"ty":"fl",
|
|
41
|
+
"c":{"a":0,"k":[0.95,0.25,0.25]},
|
|
42
|
+
"o":{"a":0,"k":100}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { formatSeconds2Time } from '../../../shared/utils';
|
|
2
|
+
Component({
|
|
3
|
+
properties: {
|
|
4
|
+
showIcon: {
|
|
5
|
+
type: Boolean,
|
|
6
|
+
value: false,
|
|
7
|
+
},
|
|
8
|
+
mallRewardInfo: {
|
|
9
|
+
type: Object,
|
|
10
|
+
value: null,
|
|
11
|
+
},
|
|
12
|
+
activeMallReward: {
|
|
13
|
+
type: Object,
|
|
14
|
+
value: null,
|
|
15
|
+
},
|
|
16
|
+
onlineDuration: {
|
|
17
|
+
type: Number,
|
|
18
|
+
value: 0,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
data: {
|
|
22
|
+
x: 20,
|
|
23
|
+
y: 100,
|
|
24
|
+
startX: 0,
|
|
25
|
+
startY: 0,
|
|
26
|
+
hasMoved: false,
|
|
27
|
+
|
|
28
|
+
second: 0, // 倒计时秒数
|
|
29
|
+
displayText: '--:--', // 倒计时展示内容
|
|
30
|
+
},
|
|
31
|
+
observers: {
|
|
32
|
+
onlineDuration: function () {
|
|
33
|
+
this.updateOnlineDuration(this.properties.onlineDuration);
|
|
34
|
+
},
|
|
35
|
+
'activeMallReward.reward_id': function () {
|
|
36
|
+
this.calcSecond(this.properties.onlineDuration);
|
|
37
|
+
},
|
|
38
|
+
'mallRewardInfo.is_received': function () {
|
|
39
|
+
this.calcSecond(this.properties.onlineDuration);
|
|
40
|
+
},
|
|
41
|
+
'mallRewardInfo.list.length': function () {
|
|
42
|
+
this.calcSecond(this.properties.onlineDuration);
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
methods: {
|
|
46
|
+
fmtDuration(ss) {
|
|
47
|
+
// 无当前活动红包信息,但显示小图标,说明参与过有记录
|
|
48
|
+
if (!this.properties.activeMallReward) {
|
|
49
|
+
return this.properties.mallRewardInfo?.is_received === 1 ? '已领取' : '领福利';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 当前活动红包信息是无条件红包
|
|
53
|
+
if (this.properties.activeMallReward?.viewing_minutes == 0) return '领福利';
|
|
54
|
+
|
|
55
|
+
// 当前活动红包信息是时长红包
|
|
56
|
+
if (this.properties.activeMallReward?.viewing_minutes > 0 && !isNaN(ss)) {
|
|
57
|
+
if (ss <= 0) return '领福利';
|
|
58
|
+
|
|
59
|
+
return formatSeconds2Time(ss);
|
|
60
|
+
}
|
|
61
|
+
return '--:--';
|
|
62
|
+
},
|
|
63
|
+
// 更新在线时长
|
|
64
|
+
updateOnlineDuration(ol) {
|
|
65
|
+
if (this.properties.activeMallReward?.viewing_minutes > 0 && this.data.second > 0) {
|
|
66
|
+
this.calcSecond(ol);
|
|
67
|
+
if (this.data.second < 1) {
|
|
68
|
+
// 倒计时完成
|
|
69
|
+
this.triggerEvent('countdownEnd', this.properties.activeMallReward);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
// 计时倒计时秒数
|
|
74
|
+
calcSecond(ol) {
|
|
75
|
+
const ss = Math.max(this.properties.activeMallReward?.viewing_minutes * 60 - ol || 0, 0);
|
|
76
|
+
const text = this.fmtDuration(ss);
|
|
77
|
+
this.setData({
|
|
78
|
+
second: ss,
|
|
79
|
+
displayText: text,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
onTouchStart(e) {
|
|
84
|
+
this.setData({ hasMoved: false });
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
onTouchEnd(e) {
|
|
88
|
+
this.data.hasMoved = false;
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
onDragChange(e) {
|
|
92
|
+
const { x, y } = e.detail;
|
|
93
|
+
this.setData({ x, y, hasMoved: true });
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
onTapIcon() {
|
|
97
|
+
if (this.data.hasMoved) return;
|
|
98
|
+
this.triggerEvent('onTapIcon');
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<movable-area class="drag-area">
|
|
2
|
+
<movable-view class="drag-view" direction="all" x="{{x}}" y="{{y}}" damping="{{40}}" out-of-bounds="{{false}}" bindchange="onDragChange" bindtouchstart="onTouchStart" bindtouchend="onTouchEnd">
|
|
3
|
+
<view class="mall-reward-icon" bindtap="onTapIcon">
|
|
4
|
+
<view class="mall-reward-icon-content {{second>=3600?'is-long':''}}">{{displayText}}</view>
|
|
5
|
+
</view>
|
|
6
|
+
</movable-view>
|
|
7
|
+
</movable-area>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.drag-area{height:100vh;left:0;pointer-events:none;position:fixed;top:0;width:100vw;z-index:100}.drag-view{height:160rpx;pointer-events:auto;width:140rpx}.mall-reward-icon{background-image:url(https://cnstatic01.e.vhall.com/common-static/images/mp/dr_bg.png);height:120rpx;position:relative;width:120rpx}.mall-reward-icon,.mall-reward-icon-content{background-repeat:no-repeat;background-size:100% 100%}.mall-reward-icon-content{align-items:center;background-image:url(https://cnstatic01.e.vhall.com/common-static/images/mp/dr_time_bg.png);background-position:50%;border-radius:100rpx;bottom:-14rpx;color:#fff;display:flex;font-size:.79rem;justify-content:center;left:10rpx;overflow:visible;position:absolute;text-align:center;white-space:nowrap;width:100rpx}.mall-reward-icon-content.is-long{left:4rpx;width:112rpx}
|