<template>
<view class="container">
<input type="text" v-model="inputID" :placeholder=" isLogin ? 'please enter a caller userID' : 'please enter your login userID' " />
<text v-show="isLogin"> your userID: {{ userID }} </text>
<button v-show="!isLogin" @click="handleLogin"> Login </button>
<button v-show="isLogin" @click="handleCall"> start call </button>
</view>
</template>
<script>
const TUICallKit = uni.requireNativePlugin('TencentCloud-TUICallKit');
uni.$TUICallKit = TUICallKit;
import { genTestUserSig } from '../../debug/GenerateTestUserSig.js'
export default {
data() {
return {
inputID: '',
isLogin: false,
userID: '',
}
},
methods: {
handleLogin() {
this.userID = this.inputID;
const { userSig, sdkAppID: SDKAppID } = genTestUserSig(this.userID);
const loginParams = { SDKAppID, userID: this.userID, userSig };
uni.$TUICallKit.login( loginParams, res => {
if (res.code === 0) {
this.isLogin = true;
this.inputID = '';
console.log('[TUICallKit] login success.');
} else {
console.error('[TUICallKit] login failed, failed message = ', res.msg, params);
}
}
);
},
handleCall() {
try {
const callParams = {
userID: this.inputID,
callMediaType: 2,
callParams: { roomID: 234, strRoomID: '2323423', timeout:30 },
};
uni.$TUICallKit.call( callParams, res => {
console.log('[TUICallKit] call params: ', JSON.stringify(res));
}
);
this.inputID = '';
} catch (error) {
console.log('[TUICallKit] call error: ', error);
}
}
}
}
</script>
<style>
.container {
margin: 30px;
}
.container input {
height: 50px;
border: 1px solid;
}
.container button {
margin-top: 30px;
}
</style>
本页内容是否解决了您的问题?