<template>
<view class="container">
<input placeholder="请输入类型" v-model="inputType" />
<button class="mt20" style="padding: 20rpx 0rpx;" @click="openChat">确定</button>
<button class="mt20 " style="padding: 20rpx 0rpx;" v-if="inputType === '1' || inputType === '2'" @click="toChat('video')">视频会话</button>
<button class="mt20" style="padding: 20rpx 0rpx;" v-if="inputType === '1' || inputType === '2'" @click="toChat('voice')">语音会话</button>
tips:1是患者端发起。2是医生端发起
</view>
</template>
<script>
export default {
data() {
return {
inputType: '',
}
},
methods: {
toChat(type) {
if (this.inputType === '1') {
wx.join1v1Chat({
caller: {
nickname: '高乐',
openid: 'oHowN5o0E5hQofZqwsnV9t_3UiJk'
},
listener: {
nickname: '张6',
openid: 'ohpu74r2z831zNKLq682YoBXAeFg'
},
roomType: type,
success: res1 => {
console.log(res1)
},
fail: e1 => {
console.log(e1)
uni.showToast({
title: '开启会话失败',
icon: 'none'
})
}
})
} else if (this.inputType === '2') {
wx.join1v1Chat({
caller: {
nickname: '张6',
openid: 'ohpu74r2z831zNKLq682YoBXAeFg'
},
listener: {
nickname: '高乐',
openid: 'oHowN5o0E5hQofZqwsnV9t_3UiJk'
},
roomType: type,
success: res1 => {
console.log(res1)
},
fail: e1 => {
console.log(e1)
uni.showToast({
title: '开启会话失败',
icon: 'none'
})
}
})
}
},
openChat() {
if (!this.inputType) {
return uni.showToast({
title: '先输入类型1或者2',
icon: 'none'
})
}
wx.setEnable1v1Chat({
enable: true,
success: res => {
uni.showToast({
title: '支持音视频',
duration: 2000
})
},
fail: e => {
console.log(e)
uni.showToast({
title: `${JSON.stringify(e.errMsg)},错误码:${e.errCode}`,
icon: 'none',
duration: 2500
})
}
})
}
}
}
</script>
wx.setEnable1v1Chat的enable设置为true了,对方收不到
appid:wxb80ba3190eeb8909