vhall-mini-sdk 0.2.1 → 0.3.1
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 +44 -0
- package/lib/components/announcement/announ-banner/index.js +40 -0
- package/lib/components/announcement/announ-banner/index.json +4 -0
- package/lib/components/announcement/announ-banner/index.wxml +13 -0
- package/lib/components/announcement/announ-banner/index.wxss +1 -0
- package/lib/components/announcement/announ-icon/index.js +69 -0
- package/lib/components/announcement/announ-icon/index.json +3 -0
- package/lib/components/announcement/announ-icon/index.wxml +10 -0
- package/lib/components/announcement/announ-icon/index.wxss +1 -0
- package/lib/components/announcement/announ-popup/index.js +44 -0
- package/lib/components/announcement/announ-popup/index.json +7 -0
- package/lib/components/announcement/announ-popup/index.wxml +39 -0
- package/lib/components/announcement/announ-popup/index.wxss +1 -0
- package/lib/components/announcement/index.js +223 -0
- package/lib/components/announcement/index.json +9 -0
- package/lib/components/announcement/index.wxml +6 -0
- package/lib/components/announcement/index.wxss +0 -0
- package/lib/components/live-landscape/live-landscape.js +7 -1
- package/lib/components/live-landscape/live-landscape.json +2 -0
- package/lib/components/live-landscape/live-landscape.wxml +7 -4
- package/lib/components/live-portrait/live-portrait.js +10 -2
- package/lib/components/live-portrait/live-portrait.json +3 -1
- package/lib/components/live-portrait/live-portrait.wxml +8 -4
- package/lib/components/mall-reward/index.js +47 -29
- package/lib/components/product/product-card/product-card.js +5 -6
- package/lib/components/product/product-detail/product-detail.js +6 -6
- package/lib/components/product/product-list/product-list.js +2 -3
- package/lib/sdk/main/index.js +2 -2
- package/lib/sdk/plugins/MallRewardServer.js +1 -1
- package/package.json +8 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<
|
|
1
|
+
<error-page wx:if="{{errorResp && errorResp.code}}" errorResp="{{errorResp}}"></error-page>
|
|
2
|
+
<view class="live_portrait" wx:elif="{{isReady}}">
|
|
2
3
|
<view class="live_portrait_player">
|
|
3
4
|
<vhall-player sdkInstance="{{sdkInstance}}" objectFit="{{playerObjectFit}}"></vhall-player>
|
|
4
5
|
</view>
|
|
@@ -99,8 +100,11 @@
|
|
|
99
100
|
</scroll-view>
|
|
100
101
|
</view>
|
|
101
102
|
</vh-popup>
|
|
102
|
-
|
|
103
|
+
<!-- 抽奖组件 -->
|
|
104
|
+
<vhall-lottery wx:if="{{webinarStatus==1}}" sdkInstance="{{sdkInstance}}" />
|
|
103
105
|
<!-- 商城奖励 -->
|
|
104
|
-
<vhall-mall-reward sdkInstance="{{sdkInstance}}" />
|
|
106
|
+
<vhall-mall-reward wx:if="{{webinarStatus==1||webinarStatus==5}}" sdkInstance="{{sdkInstance}}" />
|
|
107
|
+
<!-- 公告组件 -->
|
|
108
|
+
<vhall-announcement wx:if="{{webinarStatus==1||webinarStatus==5}}" sdkInstance="{{sdkInstance}}" mode="{{0}}" />
|
|
105
109
|
</view>
|
|
106
|
-
|
|
110
|
+
|
|
@@ -35,12 +35,11 @@ Component({
|
|
|
35
35
|
if (!_sdkInstance) return;
|
|
36
36
|
log.info('mall-reward sdkInstance');
|
|
37
37
|
this.sdkInstance = _sdkInstance;
|
|
38
|
-
this.setData({
|
|
39
|
-
initTime: Date.now(),
|
|
40
|
-
});
|
|
41
38
|
this.initEventListener();
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
if (this.sdkInstance.isReady()) {
|
|
40
|
+
// 已经 ready 了,立刻刷新(事件已发过,不等)
|
|
41
|
+
this.onSdkReady();
|
|
42
|
+
}
|
|
44
43
|
},
|
|
45
44
|
},
|
|
46
45
|
lifetimes: {
|
|
@@ -58,6 +57,11 @@ Component({
|
|
|
58
57
|
this.unlistener?.();
|
|
59
58
|
const obj = {};
|
|
60
59
|
|
|
60
|
+
// 直接调用 sdkInstance.init()触发
|
|
61
|
+
obj[this.sdkInstance.EVENT.SDK_READY] = () => {
|
|
62
|
+
this.onSdkReady();
|
|
63
|
+
};
|
|
64
|
+
|
|
61
65
|
// 推送商城奖励
|
|
62
66
|
obj[this.sdkInstance.EVENT.MALL_REWARD_PUSH] = (msg) => {
|
|
63
67
|
log.info('mallReward open msg:', JSON.stringify(msg));
|
|
@@ -66,6 +70,7 @@ Component({
|
|
|
66
70
|
if (!this.webinarType != 1) {
|
|
67
71
|
return;
|
|
68
72
|
}
|
|
73
|
+
this.sdkInstance.BRSAgent?.customLog('checkAndFetchMallRewardInfo from=push');
|
|
69
74
|
this.checkAndFetchMallRewardInfo('push', { reward_id: msg.data?.id });
|
|
70
75
|
// 消息推送
|
|
71
76
|
// const data = {
|
|
@@ -109,41 +114,54 @@ Component({
|
|
|
109
114
|
});
|
|
110
115
|
};
|
|
111
116
|
|
|
112
|
-
//
|
|
113
|
-
obj[this.sdkInstance.EVENT.
|
|
114
|
-
log.info('mallReward ------
|
|
115
|
-
// 监听上线消息,刷新商城奖励数据条件:
|
|
116
|
-
//(1)上线的人是自己;( 支持多端上线)
|
|
117
|
-
//(2)间隔初始化请求时间超过3s(否则每次刷新调用两次请求;是否可以仅使用JOIN消息请求?不行,因为join消息不可靠,有时候收不到)
|
|
117
|
+
// 连接状态变化(以 socket connected/disconnect 为准,比 JOIN_MSG 广播更可靠)
|
|
118
|
+
obj[this.sdkInstance.EVENT.ONLINE_STATE_CHANGE] = (data) => {
|
|
119
|
+
log.info('mallReward ------handleOnlineStateChange data:', data);
|
|
118
120
|
if (!this.sdkInstance) return;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
if (data?.online) {
|
|
122
|
+
// 上线(连接建立成功):刷新商城奖励数据(与 FOREGROUND_REFRESH 共用防抖,避免重复请求)
|
|
123
|
+
if (this._shouldRefreshByEvent()) {
|
|
124
|
+
this.sdkInstance.BRSAgent?.customLog('checkAndFetchMallRewardInfo from=refresh, online_state_change');
|
|
125
|
+
this.checkAndFetchMallRewardInfo('refresh');
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
// 下线(连接断开):暂停计时器
|
|
129
|
+
log.info('mallReward ------onlineStateChange offline, 倒计时暂停');
|
|
130
|
+
this.destroyTimer();
|
|
124
131
|
}
|
|
125
132
|
};
|
|
126
133
|
|
|
127
|
-
//
|
|
128
|
-
obj[this.sdkInstance.EVENT.
|
|
129
|
-
log.info('mallReward ------
|
|
134
|
+
// 切回前台刷新(JOIN_MSG 有限频不可靠,以此事件兜底刷新商城奖励数据)
|
|
135
|
+
obj[this.sdkInstance.EVENT.FOREGROUND_REFRESH] = (data) => {
|
|
136
|
+
log.info('mallReward ------handleForegroundRefresh data:', data);
|
|
130
137
|
if (!this.sdkInstance) return;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const msgContex = safeJsonParse(msg?.context);
|
|
135
|
-
/* prettier-ignore */ // 自己下线了,计时器暂停
|
|
136
|
-
if (localKickMark && localKickID && msgContex.kick_id === localKickID && msgContex.kick_mark === localKickMark) {
|
|
137
|
-
console.log('mallReward 倒计时暂停');
|
|
138
|
-
this.destroyTimer();
|
|
138
|
+
this.sdkInstance.BRSAgent?.customLog('checkAndFetchMallRewardInfo from=refresh, foreground_refresh');
|
|
139
|
+
if (this._shouldRefreshByEvent()) {
|
|
140
|
+
this.checkAndFetchMallRewardInfo('refresh');
|
|
139
141
|
}
|
|
140
142
|
};
|
|
141
143
|
|
|
142
144
|
this.unlistener = this.sdkInstance.on(obj);
|
|
143
145
|
},
|
|
146
|
+
onSdkReady() {
|
|
147
|
+
log.info('mall-reward onSdkReady');
|
|
148
|
+
this.setData({ initTime: Date.now() });
|
|
149
|
+
this.sdkInstance.BRSAgent?.customLog('checkAndFetchMallRewardInfo from=refresh, onSdkReady');
|
|
150
|
+
this.checkAndFetchMallRewardInfo('refresh');
|
|
151
|
+
},
|
|
152
|
+
// 事件触发的刷新防抖:JOIN_MSG / FOREGROUND_REFRESH 等共用冷却,避免接口重复触发
|
|
153
|
+
_shouldRefreshByEvent() {
|
|
154
|
+
const now = Date.now();
|
|
155
|
+
// 距离上次事件刷新(或 onSdkReady 初始化刷新)不足 3s 时跳过,避免接口重复请求
|
|
156
|
+
const last = this._lastRefreshTime || this.data.initTime || 0;
|
|
157
|
+
if (last && now - last < 2000) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
this._lastRefreshTime = now;
|
|
161
|
+
return true;
|
|
162
|
+
},
|
|
144
163
|
async checkAndFetchMallRewardInfo(from, extra) {
|
|
145
|
-
|
|
146
|
-
log.info('mall-reward checkAndFetchMallRewardInfo start');
|
|
164
|
+
log.info('mall-reward checkAndFetchMallRewardInfo call')
|
|
147
165
|
const mallRewardServer = this.sdkInstance.get('mallRewardServer');
|
|
148
166
|
if (!mallRewardServer) return;
|
|
149
167
|
|
|
@@ -6,7 +6,7 @@ Component({
|
|
|
6
6
|
sdkInstance: {
|
|
7
7
|
type: Object,
|
|
8
8
|
value: null,
|
|
9
|
-
observer: function(newVal) {
|
|
9
|
+
observer: function (newVal) {
|
|
10
10
|
if (newVal) {
|
|
11
11
|
this.initStoreListener();
|
|
12
12
|
// 初始加载商品数据
|
|
@@ -38,7 +38,7 @@ Component({
|
|
|
38
38
|
if (this.unsub) {
|
|
39
39
|
this.unsub();
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
this.unsub = this.properties.sdkInstance.store.get({
|
|
43
43
|
productList: (val) => {
|
|
44
44
|
if (val) {
|
|
@@ -46,7 +46,6 @@ Component({
|
|
|
46
46
|
const filteredProducts = val.filter(product => product.push_status === 1);
|
|
47
47
|
// 最多显示3个商品卡片
|
|
48
48
|
const products = filteredProducts.slice(0, 3);
|
|
49
|
-
this.properties.sdkInstance.get('logReportServer').report('116999', { stage: 'productCardUpdate', logData: products });
|
|
50
49
|
this.setData({
|
|
51
50
|
products: products
|
|
52
51
|
});
|
|
@@ -70,12 +69,12 @@ Component({
|
|
|
70
69
|
console.error('商品数据不存在');
|
|
71
70
|
return;
|
|
72
71
|
}
|
|
73
|
-
|
|
72
|
+
|
|
74
73
|
// 检查是否已抢光或待开价
|
|
75
74
|
if (product.sale_status === 0 || product.covered_status === 1) {
|
|
76
75
|
return;
|
|
77
76
|
}
|
|
78
|
-
|
|
77
|
+
|
|
79
78
|
// 检查 buy_type
|
|
80
79
|
if (product.buy_type === 4 && product?.mini_program_config?.mini_program_path) {
|
|
81
80
|
// 跳转到小程序路径
|
|
@@ -99,7 +98,7 @@ Component({
|
|
|
99
98
|
// 点击关闭按钮(通过改变本地数据关闭卡片)
|
|
100
99
|
onCloseCard(e) {
|
|
101
100
|
const productId = e.currentTarget.dataset.productId;
|
|
102
|
-
|
|
101
|
+
|
|
103
102
|
// 从本地数据中移除该商品
|
|
104
103
|
const updatedProducts = this.data.products.filter(product => product.goods_id !== productId);
|
|
105
104
|
this.setData({
|
|
@@ -15,7 +15,7 @@ Component({
|
|
|
15
15
|
sdkInstance: {
|
|
16
16
|
type: Object,
|
|
17
17
|
value: null,
|
|
18
|
-
observer: function(newVal) {
|
|
18
|
+
observer: function (newVal) {
|
|
19
19
|
if (newVal) {
|
|
20
20
|
this.initStoreListener();
|
|
21
21
|
}
|
|
@@ -42,7 +42,7 @@ Component({
|
|
|
42
42
|
},
|
|
43
43
|
observers: {
|
|
44
44
|
// 监听显示状态变化
|
|
45
|
-
show: function(show) {
|
|
45
|
+
show: function (show) {
|
|
46
46
|
if (show) {
|
|
47
47
|
// 重置数据
|
|
48
48
|
this.setData({
|
|
@@ -57,7 +57,7 @@ Component({
|
|
|
57
57
|
if (this.unsub) {
|
|
58
58
|
this.unsub();
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
this.unsub = this.properties.sdkInstance.store.get({
|
|
62
62
|
productList: (val) => {
|
|
63
63
|
if (val && this.properties.product && this.properties.product.goods_id) {
|
|
@@ -83,17 +83,17 @@ Component({
|
|
|
83
83
|
// 购买商品
|
|
84
84
|
buyProduct() {
|
|
85
85
|
const product = this.data.product;
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
if (!product) {
|
|
88
88
|
console.error('商品数据不存在');
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
// 检查是否已抢光或待开价
|
|
93
93
|
if (product.sale_status === 0 || product.covered_status === 1) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
// 检查 buy_type
|
|
98
98
|
if (product.buy_type === 4 && product?.mini_program_config?.mini_program_path) {
|
|
99
99
|
// 跳转到小程序路径
|
|
@@ -3,7 +3,7 @@ Component({
|
|
|
3
3
|
sdkInstance: {
|
|
4
4
|
type: Object,
|
|
5
5
|
value: null,
|
|
6
|
-
observer: function(newVal) {
|
|
6
|
+
observer: function (newVal) {
|
|
7
7
|
if (newVal) {
|
|
8
8
|
this.initStoreListener();
|
|
9
9
|
}
|
|
@@ -46,11 +46,10 @@ Component({
|
|
|
46
46
|
if (this.unsub) {
|
|
47
47
|
this.unsub();
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
this.unsub = this.properties.sdkInstance.store.get({
|
|
51
51
|
productList: (val) => {
|
|
52
52
|
if (val) {
|
|
53
|
-
this.properties.sdkInstance.get('logReportServer').report('116999', { stage: 'productListUpdate', logData: val });
|
|
54
53
|
this.setData({ productList: val });
|
|
55
54
|
}
|
|
56
55
|
}
|