接口调用

main
123456 1 month ago
parent f9b51ee29f
commit 01a0364aa5
  1. 8
      main.js
  2. 2
      pages/index/index.vue
  3. 256
      pages/pipei/shipin/detail.nvue
  4. 5
      pages/pipei/shipin/index.vue
  5. 18
      pages/users/chat/index.vue
  6. 138
      unpackage/dist/dev/app-plus/app-service.js
  7. 587
      unpackage/dist/dev/app-plus/pages/pipei/shipin/detail.js

@ -16,9 +16,6 @@ Vue.component('share', share)
Vue.component('dashan', dashan)
Vue.config.productionTip = false
// import ZIM from '@/js_sdk/zego-ZIMUniplugin-JS/lib/index.js';
// ZIM.create({ appID: 267111980, appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e' });
// Vue.prototype.$ZIM = ZIM.getInstance();
const bgAudioManager = uni.getBackgroundAudioManager();
uni.$on("playAudio",res=>{
@ -37,8 +34,6 @@ const app = new Vue({
})
app.$mount()
// #endif
let timer = null;
//socket
uni.$on("openSocket",function(res){
@ -53,6 +48,7 @@ uni.$on("openSocket",function(res){
});
uni.onSocketMessage(function (res) {
const obj = res.data?JSON.parse(res.data):{}
console.log("onSocketMessage",obj)
if(obj.topic == 'message'){
if(obj.type>=8){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
@ -147,7 +143,7 @@ uni.$on("openSocket",function(res){
clearInterval(timer)
uni.closeSocket();
uni.removeStorageSync("isOpen")
console.log('WebSocket 已关闭!');
console.log('WebSocket 已关闭!');
});
})

@ -255,7 +255,7 @@
}
}else{
console.log("挂断了")
}
}
});

@ -1,20 +1,35 @@
<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 class="room" :style="{'width': winWidth+'px', 'height': winHeight+'px'}">
<view class="room-hd">
<zego-remote-view class="video-view" :style="{'width': winWidth+'px', 'height': winHeight+'px'}" :streamID="sellerStreamId"></zego-remote-view>
<zego-local-view class="shitu"></zego-local-view>
</view>
<view class="room-fd" :style="{'width': winWidth+'px'}">
<view class="item">
<view class="pic">
<image class="pimg" src="@/static/yuyin-01-on.png"></image>
</view>
<view class="txt"><text>开启</text></view>
</view>
<view class="item">
<view class="pic">
<image class="pimg" src="@/static/yuyin-02.png"></image>
</view>
<view class="txt"><text>开启</text></view>
</view>
<view class="item">
<view class="pic">
<image class="pimg" src="@/static/yuyin-03.png"></image>
</view>
<view class="txt"><text>开启</text></view>
</view>
</view>
</view>
</template>
<script>
import api from '@/api/index.js'
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';
@ -35,7 +50,10 @@
},
data() {
return {
playStreamID: "",
winWidth: 0,
winHeight: 0,
userInfo: {},
playStreamId: "",
title: "视频语音",
background: {
// 导航栏背景图
@ -43,77 +61,203 @@
// 还可以设置背景图size属性
backgroundSize: '100 auto',
},
engine: null,
roomId: "",
sellerStreamId: ""
}
},
onLoad(o) {
this.id = o.id;
this.type=o.type;
console.log(o)
this.winWidth = uni.getSystemInfoSync().windowWidth;
this.winHeight = uni.getSystemInfoSync().windowHeight;
},
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();
mounted() {
this.toPermission();
},
methods: {
async toPermission() {
// #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"
);
this.getUserInfo();
return ;
}
// #endif
this.getUserInfo();
},
//查询个人信息
async getUserInfo() {
const { code, data , msg} = await api.findUserInfo({userId: uni.getStorageSync("userInfo").id});
if(code == 200){
console.log("getUserInfo",data)
this.userInfo = data;
this.loginRoom();
}else{
uni.showToast({
title: msg,
position: "bottom",
icon: "none",
})
}
},
async loginRoom(){
console.log("sxq",{
userId: uni.getStorageSync("userInfo").id,
sellerId: this.id
})
const res = await this.$api.findZegoToken({
const that = this;
const res = await api.findZegoToken({
userId: uni.getStorageSync("userInfo").id,
sellerId: this.id
})
console.log("sxq1",res)
return ;
if(code == 200){
if(res.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)
// 以下为常用的房间相关回调
roomConfig.token = res.data.token;
this.playStreamId = res.data.userStreamId;
this.sellerStreamId = res.data.userStreamId;
this.roomId = res.data.roomId;
console.log("loginRoom11",res.data)
this.engine = await ZegoExpressEngine.createEngineWithProfile(profile);
this.engine.enableCamera(this.type == 1?true:false)
this.engine.enableEffectsBeauty(true);
ZegoExpressEngine.instance().on('roomStateUpdate', (roomID, state, errorCode, extendedData) => {
// 创建美颜参数对象
let beautyParam = {};
// 美白、红润、磨皮、锐化
beautyParam.whitenIntensity = this.userInfo.reserved5;
beautyParam.rosyIntensity = this.userInfo.reserved6;
beautyParam.smoothIntensity = this.userInfo.reserved7;
beautyParam.sharpenIntensity = this.userInfo.reserved8;
// 设置美颜参数
this.engine.setEffectsBeautyParam(beautyParam);
this.engine.useFrontCamera(true)
// 以下为常用的房间相关回调
this.engine.on('roomStateUpdate', (roomID, state, errorCode, extendedData) => {
console.log("roomStateUpdate",roomID)
// 房间状态更新回调,登录房间后,当房间连接状态发生变更(如出现房间断开,登录认证失败等情况),SDK会通过该回调通知
}); ;
ZegoExpressEngine.instance().on('roomUserUpdate', (roomID, updateType, userList) => {
this.engine.on('roomUserUpdate', (roomID, updateType, userList) => {
// 用户状态更新,登录房间后,当房间内有用户新增或删除时,SDK会通过该回调通知
console.log("roomUserUpdate",roomID,userList)
});
ZegoExpressEngine.instance().on('roomStreamUpdate', (roomID, updateType, streamList) => {
this.engine.on('playerStateUpdate', (roomID, updateType, streamList) => {
console.log("playerStateUpdate",roomID)
// 调用拉流接口成功后,当拉流器状态发生变更,如出现网络中断导致推流异常等情况,SDK在重试拉流的同时,会通过该回调通知
});
this.engine.on('roomStreamUpdate', (roomID, updateType, streamList) => {
console.log("playerStateUpdate",streamList)
// 流状态更新,登录房间后,当房间内有用户新推送或删除音视频流时,SDK会通过该回调通知
// this.sellerStreamId = streamList[0].streamID;
});
// 调用推流接口成功后,当推流器状态发生变更,如出现网络中断导致推流异常等情况,SDK在重试推流的同时,会通过该回调通知
that.engine.on('publisherStateUpdate', (streamID, state, errorCode, extendedData) => {
console.log("publisherStateUpdate",streamID)
});
// 登录房间
// 开始登录房间
this.engine.loginRoom(res.data.roomId,
{
'userID': uni.getStorageSync("userInfo").id,
'userName': uni.getStorageSync("userInfo").nickname
},
roomConfig
);
this.engine.startPreview();
this.engine.startPublishingStream(this.playStreamId);
setTimeout(()=>{
this.toTuiliu()
},100)
}
},
async toLa() {
await ZegoExpressEngine.instance().startPreview()
await ZegoExpressEngine.instance().startPlayingStream(this.playStreamID)
},
toTuiliu() {
const that = this;
console.log(this.sellerStreamId)
that.engine.startPlayingStream(this.sellerStreamId);
ZegoExpressEngine.instance().on("playerStateUpdate", (streamID, state, errorCode, extendedData) => {
/** 调用拉流接口成功后,当拉流器状态发生变更,如出现网络中断导致推流异常等情况,SDK在重试拉流的同时,会通过该回调通知 */
console.log("playerStateUpdate",roomID)
});
}
},
onBackPress() {
uni.sendSocketMessage({data:JSON.stringify({
"userId": uni.getStorageSync("userInfo").id,
type: 11,
"topic":"message"
})})
/** 停止推流 */
this.engine?.stopPublishingStream();
/** 停止本地预览 */
this.engine?.stopPreview();
/** 停止拉流 */
this.engine?.stopPlayingStream(this.sellerStreamId);
/** 退出房间 */
this.engine?.logoutRoom(this.roomId);
}
}
</script>
<style lang="scss">
.tongcheng{
width: 750px;
background: #0d0b15;
.room{
&-hd{
flex-direction: column;
position: relative;
.shitu{
width: 300rpx;
height: 300rpx;
border-radius: 10rpx;
overflow: hidden;
position: fixed;
right: 20rpx;
top: 150rpx;
z-index: 1222;
}
}
&-fd{
height: 220rpx;
position: fixed;
left: 0;
bottom: 40rpx;
z-index: 44;
flex-direction: row;
.item{
flex: 1;
text-align: center;
font-size: 30rpx;
font-weight: 400;
display: flex;
justify-content: center;
align-items: center;
.txt{
margin-top: 20rpx;
text{
font-size: 30rpx;
color: #ffffff;
}
}
.pic{
width: 130rpx;
height: 130rpx;
background-color: rgba(0, 0, 0,0.36);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
margin-bottom: 10rpx;
.pimg{
width: 130rpx;
height: 130rpx;
}
}
}
}
}
</style>

@ -116,14 +116,12 @@
if(obj.type>= 8){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.type == 10){
that.toPage(2,obj.userId);
setTimeout(()=>{that.toPage(2,obj.userId)},500)
}else if(obj.type == 11){
that.isSucess = 1
that.toPage(1);
}
}
}else{
console.log("挂断了")
}
}
});
@ -173,6 +171,7 @@
if(code == 200){
this.isSucess = 2;
this.info = data
console.log("userSpeedDating",data)
uni.sendSocketMessage({data:JSON.stringify({
"userId": uni.getStorageSync("userInfo").id,
sellerId: data.id,

@ -193,7 +193,7 @@
const obj = res.data?JSON.parse(res.data):{}
if(obj.topic == 'message'){
console.log(obj)
if(obj.type!=7){
if(obj.type<=7){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
that.page = 1;
that.getChatList();
@ -202,8 +202,19 @@
that.page = 1;
that.getChatList();
}
}else{
}
if(obj.type>= 8){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.type == 10){
setTimeout(()=>{
uni.navigateTo({
url: "/pages/pipei/shipin/detail?type=2&id="+that.id
})
},500)
}else if(obj.type == 11){
}
}
}
}
});
@ -483,8 +494,7 @@
return ;
}
uni.chooseImage({
count: 1,
sizeType: ["original"], //
count: 1, //
sourceType: ["album", "camera"],
success: (res1) => {
console.log(res1)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save