有奖捉虫:办公协同&微信生态&物联网文档专题 HOT

通用 API

login — 登录

参数
类型
必填
备注
options
sdkAppId
String
腾讯云联络中心应用 SdkAppId
jsCode
String
通过 wx.login 获取
dataEnv
String
wx.getUserProfile 的 encryptedData
dataIv
String
wx.getUserProfile 的 iv
mobileEnv
String
通过 button open-type="getPhoneNumber" 方式获取
mobileIv
String
通过 button open-type="getPhoneNumber" 方式获取

checkLogin — 检查是否已登录

参数
类型
必填
备注
options
sdkAppId
String
腾讯云联络中心应用 SdkAppId
import { login, checkLogin } from 'tccc-wx-sdk/login'
const sdkAppId = '1400000000'
// 登录示例代码
checkLogin({ sdkAppId })
.then((result) => {
if (result) {
// 检查登录成功
} else {
throw new Error('登录已过期')
}
}).catch(() => {
wx.login({
success: ({ code }) => {
// 登录tccc
login({
jsCode: code,
sdkAppId
}).then(() => {
// 登录成功
}).catch(e => {
wx.showToast({
icon: 'error',
title: e.message
})
})
}
})
})

音频呼叫 API

startCall — 发起音频通话

参数
类型
必填
备注
options
channelId
String
IVR 入口 ID
try {
const channelId = 'xxx'
const { sessionId } = await this.selectComponent('#tcccSdk').startCall({ channelId })
} catch (e) {
wx.showToast({
icon: 'error',
title: e.message
})
}

endCall — 挂断通话

this.selectComponent('#tcccSdk').endCall();

sendDigits — 发送 DTMF(双音多频信号)

参数
类型
必填
备注
options
digits
String
DTMF digits 参数是一个字符串,可以包含字符 0-9、*、#。
this.selectComponent('#tcccSdk').sendDigits(options)

视频呼叫 API

startSession — 发起视频通话

参数
类型
必填
备注
options
channelId
String
IVR 入口 ID
try {
const channelId = 'xxx'
const { sessionId } = await this.selectComponent('#tcccSdk').startSession({ channelId })
} catch (e) {
wx.showToast({
icon: 'error',
title: e.message
})
}

endSession — 挂断视频通话

this.selectComponent('#tcccSdk').endSession();

switchCamera — 切换摄像头

this.selectComponent('#tcccSdk').switchCamera();

disableCamera — 关闭摄像头

this.selectComponent('#tcccSdk').disableCamera();

enableCamera — 开启摄像头

this.selectComponent('#tcccSdk').enableCamera();

会话通用 API

setSoundMode — 设置声音输出方式

参数
类型
必填
备注
soundMode
'ear' | 'speaker'
string
speaker:扬声器,ear:听筒

muteAudio — 静音

this.selectComponent('#tcccSdk').muteAudio();

unmnuteAudio — 取消静音

this.selectComponent('#tcccSdk').unmnuteAudio();

通用事件

sessionStart — 会话开始

<tccc-wx-sdk bind:sessionStart="handleStart"/>
handleStart() {
wx.showToast({
icon: 'success',
title: '通话开始'
})
}

accepted — 对方接听

<tccc-wx-sdk bind:accept="handleAccepted"/>
handleAccepted() {
wx.showToast({
icon: 'nonce', // 自选合适的图标
title: '对方已接听'
})
}

sessionEnded — 会话结束

<tccc-wx-sdk bind:sessionEnded="handleSessionEnded"/>
handleSessionEnded({ closeBy }) {
if (closeBy === 'admin') {
wx.showToast({
icon: 'none', // 自选合适的图标
title: '系统原因挂断'
})
} else if(cloeBy === 'seat') {
wx.showToast({
icon: 'none', // 自选合适的图标
title: '通话结束,对方已挂断'
})
} else {
// 挂断成功
}
}

error — 通话错误

<tccc-wx-sdk bind:error="handleError"/>
handleError(error) {
wx.showToast({
icon: 'error',
title: error.message || '发生错误,请重试'
})
}
?


http://www.vxiaotou.com