本地开发

This commit is contained in:
2023-11-16 10:52:39 +08:00
parent 75000d846b
commit 9a57e4aaab
18 changed files with 700 additions and 484 deletions

View File

@@ -436,56 +436,74 @@
}
});
},
sendVideoCall() {
sendVideoCall(hasVideo = 1) {
//发起视频
uni.showLoading({
title: '发起视频通话'
title: '发起通话'
});
var formdata = {
userId: this.talkTo.userId,
msgType: 'TRTC_VIDEO_START',
content: 'TRTC_VIDEO_START'
};
// this.sendMsg(formdata,formdata.msgType)
var formdata = null;
const userId=localStorage.getItem("userId")
const roomId=userId
const roomInfo={
roomId:userId,//后面改成发起人的手机号或者id
roomName:`${userId}发起的视频聊天`,
creatorId:userId,
creatorName:userId,
publishId:userId,
publishName:userId,
isOver:0,
webrtcUrl:config.getSRSUrl()+`/${roomId}/${userId}`,
type:"webrtc",
offline:0,
invitedUserList:[this.talkTo.userId]
if (hasVideo == 1) {
formdata = {
userId: this.talkTo.userId,
msgType: 'TRTC_VIDEO_START',
content: 'TRTC_VIDEO_START'
}
} else if (hasVideo == 0) {
formdata = {
userId: this.talkTo.userId,
msgType: 'TRTC_VOICE_START',
content: 'TRTC_VOICE_START'
}
}
// this.sendMsg(formdata,formdata.msgType)
const userId = localStorage.getItem("userId")
const roomId = userId
const userInfo = uni.getStorageSync("userInfo")
const roomInfo = {
roomId: userId, //后面改成发起人的手机号或者id
roomName: `${userInfo.nickName}发起的视频聊天`,
creatorId: userId,
creatorName: userInfo.nickName,
publishId: userId,
publishName: userInfo.nickName,
isOver: 0,
webrtcUrl: config.getSRSUrl() + `/${roomId}/${userId}`,
type: "webrtc",
offline: 0,
invitedUserList: [this.talkTo.userId],
hasVideo:hasVideo,
isForce:0
}
this.$store
.dispatch('createRoom', roomInfo)
.then(res => {
customHttp.customHttp.post("/api/im/app/wsMsg",{
msgType:"10000",
msgId:JSON.stringify(roomInfo),
cmd:"",
msgTxt:""
},{
customHttp.customHttp.post("/api/im/app/wsMsg", {
msgType: "10000",
msgId: JSON.stringify(roomInfo),
cmd: "",
msgTxt: ""
}, {
dataType: 'json',
custom: {target: "znzq"} ,
}).then((res1)=>{
location.href=config.getVideoRoomUrl(roomInfo.roomId,roomInfo.creatorId,1,1)
custom: {
target: "znzq"
},
}).then((res1) => {
location.href = config.getVideoRoomUrl(roomInfo.roomId, roomInfo.creatorId, 1, 1,hasVideo)
})
})
if(1>0){
return false;
}
this.$http.request({
if (1 > 0) {
return false;
}
this.$http.request({
url: '/chat/sendMsg',
method: 'POST',
data: JSON.stringify(formdata),
@@ -540,22 +558,21 @@
this.open();
break;
case '音视频':
this.sendVideoCall();
// uni.showActionSheet({
// itemList: ['视频通话', '语音通话'],
// success: res => {
// switch (res.tapIndex) {
// case 0:
// this.sendVideoCall();
// break;
// case 1:
// this.sendVoiceCall();
// break;
// default:
// break;
// }
// }
// });
uni.showActionSheet({
itemList: ['视频通话', '语音通话'],
success: res => {
switch (res.tapIndex) {
case 0:
this.sendVideoCall(1);
break;
case 1:
this.sendVideoCall(0);
break;
default:
break;
}
}
});
break;
case '收藏':
this.openpopup('popupfavorites');
@@ -703,44 +720,46 @@
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 => {
})
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: config.getImApiUrl() + '/file/upload',
filePath: filePath,
@@ -787,8 +806,8 @@
}
},
sendMsg(e, msgType) {
if (!e) {
return;
}
@@ -1078,4 +1097,4 @@
justify-content: center;
align-items: center;
}
</style>
</style>

View File

@@ -179,6 +179,7 @@
},
loginDone(data) {
uni.setStorageSync('appId', data.appId);
uni.setStorageSync('im_userId', data.id);
uni.setStorageSync('userId', data.id);
uni.setStorageSync('im_userCSign', data.userSign);

View File

@@ -21,7 +21,9 @@
</template>
<script>
import {
getUrlParam
} from "../../common/utils"
export default {
data() {
@@ -54,7 +56,49 @@
return this.$store.state.friendApply;
}
},
onLoad() {
onLoad(options) {
console.log("首页获取到url参数")
console.log(options)
console.log(location.href)
if (options.imUserSign) {
uni.showLoading({
title: "加载中...",
mask: true
});
/*
uni.setStorageSync("imUserSign",getUrlParam("imUserSign"))
uni.setStorageSync("im_imUserSign",getUrlParam("imUserSign"))
uni.setStorageSync("userId",getUrlParam("uid"))
uni.setStorageSync("hd_userid",getUrlParam("uid"))
uni.setStorageSync("hd_token",getUrlParam("token"))
uni.setStorageSync("token",getUrlParam("token"))
*/
uni.setStorageSync("imUserSign", options.imUserSign)
uni.setStorageSync("im_imUserSign", options.imUserSign)
uni.setStorageSync("userId", options.uid)
uni.setStorageSync("hd_userid", options.uid)
uni.setStorageSync("hd_token", options.token)
uni.setStorageSync("token", options.token)
const timer = setInterval(() => {
if (uni.getStorageSync("initReady") == 1) {
console.log("==========进入首页 initReady为1开始跳转")
clearInterval(timer)
uni.hideLoading();
uni.navigateTo({
url: '../chatWindow/index?userId=' + options.tuid + '&windowType=' + options
.windowType
});
}
}, 500)
}
// uni.setStorageSync("token",hd_token)
// uni.setStorageSync("userId",hd_userId)
this.clickToSubmitSure = this.$fc.debounce(
e => {
uni.navigateTo({
@@ -65,10 +109,10 @@
true
);
},
filters:{
contentFilter(value){
filters: {
contentFilter(value) {
console.warn(value)
return "KKKKK"+value
return "KKKKK" + value
}
},
watch: {
@@ -141,14 +185,14 @@
toplist.push(obj[k]);
}
if (obj[k]['userId'] && obj[k]['top'] == 'N') {
try{
var _data=JSON.parse(obj[k].content)
if(_data.type=="IMAGE"){
obj[k].content="【图片】"
}else{
try {
var _data = JSON.parse(obj[k].content)
if (_data.type == "IMAGE") {
obj[k].content = "【图片】"
} else {
console.error(_data)
}
}catch(e){
} catch (e) {
//TODO handle the exception
}
NOTtoplist.push(obj[k]);
@@ -173,7 +217,7 @@
this.$store.dispatch('tabBarpull');
},
mounted() {
},
methods: {
longpressItem(e, i, v) {
@@ -219,4 +263,4 @@
text-align: center;
font-size: 28rpx;
}
</style>
</style>