内网开发

This commit is contained in:
2023-10-26 21:02:51 +08:00
parent 368ca335fe
commit 4e190cec87
308 changed files with 7135 additions and 2175 deletions

View File

@@ -39,12 +39,14 @@
<view v-else @click="changeTool" class="zfb-tk-send-tool-more wxfont gengduo"></view>
</view>
<view v-if="showtool" class="zfb-tk-send-tools">
<view class="zfb-tk-send-tools-item" v-for="(v, i) in toolist" @click="toolClick(v)">
<view class="zfb-tk-send-tools-icon">
<view class="wxfont" :class="v.icon"></view>
<template v-for="(v, i) in toolist">
<view class="zfb-tk-send-tools-item" @click="toolClick(v)" v-if="v.show">
<view class="zfb-tk-send-tools-icon">
<view class="wxfont" :class="v.icon"></view>
</view>
<view class="zfb-tk-send-tools-text">{{ v.title }}</view>
</view>
<view class="zfb-tk-send-tools-text">{{ v.title }}</view>
</view>
</template>
</view>
<scroll-view :scroll-y="true" v-if="showEmojitool" class="wxemojitool">
<view class="wxemojitool-content">
@@ -56,8 +58,9 @@
<zmm-upload-image chooseType="chooseMedia" :show="false" ref="upload" @allComplete="upLoadallComplete"
@oneComplete="upLoadoneComplete"></zmm-upload-image>
<!-- #ifndef H5 -->
<view class="zfb-tk-recorder" v-show="showRecorder"><zmm-recorder :show="showRecorder" ref="rec"
@recorderStop="recorderStop"></zmm-recorder></view>
<view class="zfb-tk-recorder" v-show="showRecorder">
<zmm-recorder :show="showRecorder" ref="rec" @recorderStop="recorderStop"></zmm-recorder>
</view>
<!-- #endif -->
</view>
</template>
@@ -71,6 +74,8 @@
import chatItem from './chat-item.vue';
import sendCard from './sendCard.vue';
import config from "@/common/config.js"
import customHttp from "@/common/customHttp.js"
export default {
components: {
@@ -92,27 +97,33 @@
showVice: false,
toolist: [{
title: '相册',
icon: 'tupian'
icon: 'tupian',
show: true
},
{
title: '拍摄',
icon: 'xiangji'
icon: 'xiangji',
show: false
},
{
title: '位置',
icon: 'dingwei'
icon: 'dingwei',
show: false
},
{
title: '语音',
icon: 'yrecord'
icon: 'yrecord',
show: false
},
{
title: '名片',
icon: 'mingpian'
icon: 'mingpian',
show: false
},
{
title: '收藏',
icon: 'shoucang'
icon: 'shoucang',
show: false
}
],
msgFocus: false,
@@ -127,7 +138,7 @@
// chatWindowData:[],
localData: {},
showtitleNViewBtns: true,
list:[]
list: []
};
},
computed: {
@@ -172,10 +183,16 @@
}
},
onLoad(e) {
// // 监听接收聊天信息
uni.$on('onP2PMessage', this.onMessage)
this.toolist.push({
title: '音视频',
icon: 'yspin',
show: true
});
this.talkTo = e;
console.log(this.talkTo)
// 根据Id
@@ -186,9 +203,9 @@
})
.then(res => {
this.localData = res.data;
console.log(res.data)
if (e.windowType == 'SINGLE') {
uni.setNavigationBarTitle({
title: this.localData.fromInfo.nickName
@@ -196,6 +213,9 @@
}
this.$store.dispatch('getchatDatalist');
this.$store.dispatch('getChatList');
if (this.localData.fromInfo && this.localData.fromInfo.userType == 'normal') {
this.toolist.push({
title: '音视频',
@@ -265,19 +285,19 @@
},
methods: {
onMessage(message) {
//判断当前是单聊还是群聊
if (this.talkTo.windowType != 'SINGLE') {
return;
}
//如果是单聊,则判断当前消息发送人是不是当前窗口的聊天对象
if(this.talkTo.userId!=message.fromId){
return;
}
console.log("message 聊天页收到回调")
console.log(message)
//如果当前消息发送人和当前窗口的聊天对象一致,则发送已读回执
console.log("########### 此时需要发送已读回执 ###########")
this.$store.dispatch('sendP2PMessageReciveAck',message)
//判断当前是单聊还是群聊
if (this.talkTo.windowType != 'SINGLE') {
return;
}
//如果是单聊,则判断当前消息发送人是不是当前窗口的聊天对象
if (this.talkTo.userId != message.fromId) {
return;
}
console.log("message 聊天页收到回调")
console.log(message)
//如果当前消息发送人和当前窗口的聊天对象一致,则发送已读回执
console.log("########### 此时需要发送已读回执 ###########")
this.$store.dispatch('sendP2PMessageReciveAck', message)
},
addMsg(e) {
this.msg += e;
@@ -426,6 +446,28 @@
msgType: 'TRTC_VIDEO_START',
content: 'TRTC_VIDEO_START'
};
this.sendMsg(formdata,formdata.msgType)
const roomInfo={
roomId:"call_room",//后面改成发起人的手机号或者id
roomName:"某某发起人的视频聊天",
creatorId:"creatorId",
creatorName:"发起人的昵称",
isOver:0,
webrtcUrl:config.getSRSUrl()+"/call_room/uid13",
type:"webrtc",
offline:0
}
this.$store
.dispatch('createRoom', roomInfo)
.then(res => {
location.href=config.getVideoRoomUrl(roomInfo.roomId,roomInfo.creatorId,1,1)
})
this.$http.request({
url: '/chat/sendMsg',
method: 'POST',
@@ -481,21 +523,22 @@
this.open();
break;
case '音视频':
uni.showActionSheet({
itemList: ['视频通话', '语音通话'],
success: res => {
switch (res.tapIndex) {
case 0:
this.sendVideoCall();
break;
case 1:
this.sendVoiceCall();
break;
default:
break;
}
}
});
this.sendVideoCall();
// uni.showActionSheet({
// itemList: ['视频通话', '语音通话'],
// success: res => {
// switch (res.tapIndex) {
// case 0:
// this.sendVideoCall();
// break;
// case 1:
// this.sendVoiceCall();
// break;
// default:
// break;
// }
// }
// });
break;
case '收藏':
this.openpopup('popupfavorites');
@@ -641,9 +684,48 @@
}
function sendPhoto(filePath) {
//TODO
//发送图片
customHttp.upload(config.getImApiUrl() + '/file/upload', {
params: {}, /* 会加在url上 */
// #ifdef APP-PLUS || H5
files: [], // 需要上传的文件列表。使用 files 时filePath 和 name 不生效。App、H5 2.6.15+
// #endif
// #ifdef MP-ALIPAY
fileType: 'image/video/audio', // 仅支付宝小程序,且必填。
// #endif
filePath: filePath, // 要上传文件资源的路径。
// 注如果局部custom与全局custom有同名属性则后面的属性会覆盖前面的属性相当于Object.assign(全局,局部)
name: 'file', // 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
// #ifdef H5 || APP-PLUS
timeout: 60000, // H5(HBuilderX 2.9.9+)、APP(HBuilderX 2.9.9+)
// #endif
header: {}, /* 会与全局header合并如有同名属性局部覆盖全局 */
formData: {}, // HTTP 请求中其他额外的 form data
// 返回当前请求的task, options。请勿在此处修改options。非必填
getTask: (task, options) => {
// task.onProgressUpdate((res) => {
// console.log('上传进度' + res.progress);
// console.log('已经上传的数据长度' + res.totalBytesSent);
// console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
//
// // 测试条件,取消上传任务。
// if (res.progress > 50) {
// uploadTask.abort();
// }
// });
},
//validateStatus: (statusCode) => { // statusCode 必存在。此处示例为全局默认配置。演示,非必填选项
// return statusCode >= 200 && statusCode < 300
//}
}).then(res => {
// 返回的res.data 已经进行JSON.parse
}).catch(err => {
})
_this.$http.uploadFile({
url: '/file/upload',
url: config.getImApiUrl() + '/file/upload',
filePath: filePath,
name: 'file',
fileType: 'image',
@@ -663,7 +745,7 @@
function sendVideo(filePath) {
//发送视频
_this.$http.uploadFile({
url: '/file/uploadVideo',
url: config.getImApiUrl() + '/file/upload',
filePath: filePath,
name: 'file',
fileType: 'video',
@@ -688,18 +770,20 @@
}
},
sendMsg(e, msgType) {
if (!e) {
return;
}
this.$fc.pushOutMsg({
msgContent: e,
msgType: msgType,
windowType: this.talkTo.windowType,
userId: this.talkTo.userId
});
this.msg = '';
this.msg = '';
// #ifdef H5
this.msgFocus = false;
this.$nextTick(() => {
@@ -977,4 +1061,4 @@
justify-content: center;
align-items: center;
}
</style>
</style>