互動接收模組
更新時間:2026-06-17 16:58:37
互動接收模組主要用於接收和處理直播間的各種互動功能,包括簽到、卡片推播、條件抽獎、商品庫等模組。
一、互動配置
1.1 取得互動設定資訊
用於取得管理後台設定的互動功能資訊。
Api 方法: getInteractSetting(): InteractSetting
回傳值說明: InteractSetting 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
productEnabled |
商品庫開關 | boolean |
productTrackEnabled |
商品庫資料上報開關 | boolean |
productLinkJumpTipEnabled |
商品庫連結跳轉提示開關 | boolean |
productHotEffectEnabled |
商品熱賣特效開關 | boolean |
productHotEffectTips |
商品熱賣特效提示 | ProductHotEffectTips |
範例:
const settingInfo = watchCore.interactReceive.getInteractSetting();
console.log('商品库开关', settingInfo.productEnabled);
1.2 取得掛件列表
說明: 取得直播間的掛件列表,包括福利抽獎等掛件
Api 方法: getPendantList(): Promise<InteractPendantItem[]>
回傳值說明: 掛件列表資料,Promise<InteractPendantItem[]> 類型
範例:
const pendantList = await watchCore.interactReceive.getPendantList();
console.log('挂件列表', pendantList);
二、事件說明
2.1 商品庫點擊事件
說明: 觀眾點擊商品後觸發該事件。
Event 事件: InteractReceiveEvents.ProductClick
回呼參數: Object 物件,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
nickname |
使用者暱稱 | string |
name |
商品名稱 | string |
type |
商品類型 | 'delivery' |
範例:
watchCore.interactReceive.eventEmitter.on(InteractReceiveEvents.ProductClick, (data) => {
toast.info(`${data.nickname}点击了${data.name}`);
});
2.2 商品庫開關修改事件
說明: 管理後台的商品庫開關更改後觸發該事件。
Event 事件: InteractReceiveEvents.ProductEnabledChange
回呼參數: Object 物件,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
productEnabled |
商品庫開關 | boolean |
範例:
watchCore.interactReceive.eventEmitter.on(InteractReceiveEvents.ProductEnabledChange, (data) => {
if (data.productEnabled) {
console.log('商品库打开,显示商品库');
} else {
console.log('商品库关闭,隐藏商品库');
}
});
