连云港陪玩陪聊
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chunwan/pages/pipei/shipin/detail.nvue

120 lines
3.8 KiB

3 months ago
<template>
<view class="tongcheng">
3 months ago
<!-- #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 -->
3 months ago
<zego-remote-view
class="video-view"
:streamID="playStreamID"
>
3 months ago
</zego-remote-view>
3 months ago
</view>
</template>
<script>
3 months ago
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';
3 months ago
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";
3 months ago
let roomConfig = {};
roomConfig.isUserStatusNotify = true;
const profile = {
appID : 267111980,
appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e',
scenario : 0
};
3 months ago
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',
},
}
},
3 months ago
onLoad(o) {
this.id = o.id;
this.type=o.type;
console.log(o)
},
3 months ago
onReady() {
3 months ago
// // #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();
3 months ago
},
methods: {
3 months ago
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)
},
3 months ago
}
}
</script>
<style lang="scss">
.tongcheng{
width: 750px;
background: #0d0b15;
}
</style>