UNPKG

fcc-core

Version:

Fusion communication center.

24 lines (23 loc) 773 B
import EventBus, { OnComfirmIM } from '../../../utils/event-bus' export default async function (xw, params) { await xw.validate(params, { // 入参校验 msgContent: { type: 'string', required: true }, msgType: { type: 'number' }, toUserId: { type: 'string', required: true } }) params.flags = 1 params.fromUserId = xw.userInfo.USER_CODE params.msgId = new Date().getTime() return new Promise((resolve, reject) => { xw.im.sendMyDate(params) let timeout = setTimeout(() => { reject(new xw.BaseException(433, '超时未收到确认信息')) }, 10000) EventBus.$on(OnComfirmIM, data => { if (+data.msgId === +params.msgId) { clearTimeout(timeout) resolve(params) } }) }) }