|
|
|
<template>
|
|
|
|
<view class="tongcheng">
|
|
|
|
<!-- #ifdef APP-PLUS -->
|
|
|
|
<zego-local-view style="height: 403.84rpx;flex: 1;"></zego-local-view>
|
|
|
|
<!-- #endif -->
|
|
|
|
<!-- #ifdef H5 -->
|
|
|
|
<video id="local_video" style="height: 403.84rpx;flex: 1;" autoplay playsinline :muted="true"></video>
|
|
|
|
<!-- #endif -->
|
|
|
|
<zego-remote-view
|
|
|
|
class="video-view"
|
|
|
|
:streamID="playStreamID"
|
|
|
|
>
|
|
|
|
</zego-remote-view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import permision from "@/js_sdk/wa-permission/permission.js"
|
|
|
|
//导入 ZEGO Express SDK
|
|
|
|
import ZegoExpressEngine from '@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/lib/ZegoExpressEngine';
|
|
|
|
import ZegoRemoteView from "@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/zego-view/ZegoRemoteView";
|
|
|
|
import ZegoLocalView from "@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/zego-view/ZegoLocalView";
|
|
|
|
|
|
|
|
let roomConfig = {};
|
|
|
|
roomConfig.isUserStatusNotify = true;
|
|
|
|
const profile = {
|
|
|
|
appID : 267111980,
|
|
|
|
appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e',
|
|
|
|
scenario : 0
|
|
|
|
};
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
ZegoLocalView,
|
|
|
|
ZegoRemoteView,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
playStreamID: "",
|
|
|
|
title: "视频语音",
|
|
|
|
background: {
|
|
|
|
// 导航栏背景图
|
|
|
|
background: 'url(https://api.lyiyuan.cn/profile/upload/static/yuyin-bg.png) center top no-repeat',
|
|
|
|
// 还可以设置背景图size属性
|
|
|
|
backgroundSize: '100 auto',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onLoad(o) {
|
|
|
|
this.id = o.id;
|
|
|
|
this.type=o.type;
|
|
|
|
console.log(o)
|
|
|
|
},
|
|
|
|
onReady() {
|
|
|
|
// // #ifdef APP-PLUS
|
|
|
|
// if (uni.getSystemInfoSync().platform === "android") {
|
|
|
|
// const res = await permision.requestAndroidPermission(
|
|
|
|
// "android.permission.RECORD_AUDIO"
|
|
|
|
// );
|
|
|
|
// const res1 = await permision.requestAndroidPermission(
|
|
|
|
// "android.permission.CAMERA"
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// // #endif
|
|
|
|
ZegoExpressEngine.createEngineWithProfile(profile);
|
|
|
|
console.log(123565)
|
|
|
|
this.loginRoom();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async loginRoom(){
|
|
|
|
console.log("sxq",{
|
|
|
|
userId: uni.getStorageSync("userInfo").id,
|
|
|
|
sellerId: this.id
|
|
|
|
})
|
|
|
|
const res = await this.$api.findZegoToken({
|
|
|
|
userId: uni.getStorageSync("userInfo").id,
|
|
|
|
sellerId: this.id
|
|
|
|
})
|
|
|
|
console.log("sxq1",res)
|
|
|
|
return ;
|
|
|
|
if(code == 200){
|
|
|
|
// 获取token传入
|
|
|
|
roomConfig.token = data.token;
|
|
|
|
this.playStreamID = data.roomID;
|
|
|
|
console.log(data)
|
|
|
|
// 登录房间
|
|
|
|
// 开始登录房间
|
|
|
|
ZegoExpressEngine.instance().loginRoom(data.roomID, {'userID': uni.getStorageSync("userInfo").id, 'userName': uni.getStorageSync("userInfo").nickname}, roomConfig);
|
|
|
|
setTimeout(()=>{
|
|
|
|
this.toLa();
|
|
|
|
},100)
|
|
|
|
// 以下为常用的房间相关回调
|
|
|
|
|
|
|
|
ZegoExpressEngine.instance().on('roomStateUpdate', (roomID, state, errorCode, extendedData) => {
|
|
|
|
// 房间状态更新回调,登录房间后,当房间连接状态发生变更(如出现房间断开,登录认证失败等情况),SDK会通过该回调通知
|
|
|
|
}); ;
|
|
|
|
|
|
|
|
ZegoExpressEngine.instance().on('roomUserUpdate', (roomID, updateType, userList) => {
|
|
|
|
// 用户状态更新,登录房间后,当房间内有用户新增或删除时,SDK会通过该回调通知
|
|
|
|
});
|
|
|
|
|
|
|
|
ZegoExpressEngine.instance().on('roomStreamUpdate', (roomID, updateType, streamList) => {
|
|
|
|
// 流状态更新,登录房间后,当房间内有用户新推送或删除音视频流时,SDK会通过该回调通知
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async toLa() {
|
|
|
|
await ZegoExpressEngine.instance().startPreview()
|
|
|
|
await ZegoExpressEngine.instance().startPlayingStream(this.playStreamID)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.tongcheng{
|
|
|
|
width: 750px;
|
|
|
|
background: #0d0b15;
|
|
|
|
}
|
|
|
|
</style>
|