聊天功能模块 功能API 说明
###调用方式: VHALL_ZK.init完成之后
API列表 使用VHALL_ZK.$chat作为句柄调用
API名 | 功能描述 | 参数 | 返回值 | 备注 |
---|---|---|---|---|
sendChat | 发送聊天 | string | Promise | 返回结果中有,消息id |
onChat | 监听聊天 | function | Object | 聊天内容 |
getEmojiArr | 获取标签列表 | 无 | Array | 执行之后,文档还原到初始状态 |
getChatHistroy | 获取历史聊天 | 页面信息 | Object | 返回聊天历史消息 |
代码示例
VHALL_ZK.$chat.sendChat('哈喽,这是我发的第一条聊天内容')
/* 获取聊天所有表情 */
const faceArr = VHALL_ZK.$chat.getEmojiArr()
[
{'[微笑]': '1'},
{'[撇嘴]': '2'},
...
]
/* 对应表情图片 */
[
https://cnstatic01.e.vhall.com/static/img/arclist/Expression_1@2x.png,
https://cnstatic01.e.vhall.com/static/img/arclist/Expression_2@2x.png,
...
]
/* 监听聊天消息 */
VHALL_ZK.$chat.onChat(listenChat)
funciton listenChat (msg) {
console.log('聊天内容', msg)
}
/* 获取历史聊天 */
VHALL_ZK.$chat.getChatHistroy({
activity_id: this.activity_id, // 活动id
page: 1, // 页码
page_size: 50 // 每页条数
}).then((res) => {
console.log('聊天历史记录', res)
})