命名空间engine
example
// 在组件内的使用方式
// 组件监听事件
this.bridge.on('engine', 'event', () => {});
// action为方法名
// param为action方法的参数
const param = { expression: 'v1=v1+1' };
this.bridge.invoke('engine', 'action', param);
Static
interactInfoUpdate• interactInfoUpdate: string
description
互动信息更新事件
param
ICfgNode
example
this.bridge.on('engine', 'interactInfoUpdate', (node: ICfgNode) => {});
Static
videoNodeChange• videoNodeChange: string
description
视频切换事件
param
IVideoInfo
example
this.bridge.on('engine', 'videoNodeChange', (videoInfo: IVideoInfo) => {});
Static
videoPlay• videoPlay: string
description
视频播放事件
param
IVideoInfo
example
this.bridge.on('engine', 'videoPlay', (videoInfo: IVideoInfo) => {});
Static
videoTimeUpdate• videoTimeUpdate: string
description
视频播放事件更新事件
param
当前播放时间
example
this.bridge.on('engine', 'videoTimeUpdate', (time: number) => {});
▸ action(action
: IAction): Promise‹void›
通过action方法,执行配置的行为动作
example
const param = { expression: 'v1=v1+1' };
this.bridge.invoke('engine', 'action', param);
Parameters:
Name | Type |
---|---|
action |
IAction |
Returns: Promise‹void›
▸ destroy(): void
销毁
Returns: void
▸ fetch(params
: any): Promise‹unknown›
组件使用网络请求
example
// 在互动组件内
const res = await this.bridge.invoke('engine', 'fetch', {
method: 'post',
url: 'https://api.weishi.qq.com/trpc...',
data: {
msg: '...',
},
});
Parameters:
Name | Type | Description |
---|---|---|
params |
any | 如果 new InteractVideo({ ... fetchLib: axios }) 则参照 axios api |
Returns: Promise‹unknown›
▸ getMetaId(): string
获取剧id
example
const dramaId = await this.bridge.invoke('engine', 'getMetaId')
Returns: string
▸ getPayState(param
: object): Promise‹any›
查询支付状态
example
const result = await this.bridge.invoke('engine', 'getPayState', {
productId: '',
})
Parameters:
▪ param: object
Name | Type |
---|---|
isTest? |
boolean |
productId |
string |
Returns: Promise‹any›
▸ getProductList(param
: object): Promise‹any›
拉取道具列表
example
const result = await this.bridge.invoke('engine', 'getProductList', {
vid: '',
});
Parameters:
▪Default value
param: object= {}
Name | Type |
---|---|
isTest? |
boolean |
vid? |
string |
Returns: Promise‹any›
▸ getRankList(param
: object): Promise‹any›
排行榜
example
const result = await this.bridge.invoke('engine', 'getRankList', {
rankId: '',
pageNum: 1,
pageSize: 10,
})
Parameters:
▪ param: object
Name | Type |
---|---|
isTest? |
boolean |
pageNum? |
number |
pageSize? |
number |
rankId |
string |
Returns: Promise‹any›
▸ getString(keys
: Array‹string›): Promise‹any›
读 Key-Value 存储
example
// 假设 Key 为 name 的存储,Value 为 iv
const name = await this.bridge.invoke('engine', 'getString', ['name']);
// name == 'iv'
Parameters:
Name | Type | Description |
---|---|---|
keys |
Array‹string› | 需要获取的 Key 的列表 |
Returns: Promise‹any›
▸ hideBackBtn(): void
隐藏直出页左上角的返回按钮
example
this.bridge.invoke('engine', 'hideBackBtn')
Returns: void
▸ on(eventName
: string, callback
: function): void
description
事件监听
Parameters:
▪ eventName: string
事件名
▪ callback: function
回调函数
▸ (...args
: any[]): void
Parameters:
Name | Type |
---|---|
...args |
any[] |
Returns: void
▸ pay(param
: object): Promise‹IResult›
单点支付
example
const result = await this.bridge.invoke('engine', 'pay', {
productId: 'xx',
});
Parameters:
▪ param: object
Name | Type |
---|---|
isTest? |
boolean |
productId |
string |
Returns: Promise‹IResult›
▸ setString(kv
: object): Promise‹any›
写 Key-Value 存储
example
// 假设需要把 Key 为 name 的存储的 Value 设置为 iv1
const result = await this.bridge.invoke('engine', 'setString', {
key: 'name',
value: 'iv1'
});
Parameters:
▪ kv: object
需要设置的 Key-Value 对象
Name | Type |
---|---|
key |
string |
value |
string |
Returns: Promise‹any›
▸ showBackBtn(): void
显示直出页左上角的返回按钮
example
this.bridge.invoke('engine', 'showBackBtn')
Returns: void