内网开发

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

@@ -1,4 +1,8 @@
export default class config{
static prod="online"
static getZnzqApiUrl(){
return process.env.NODE_ENV === 'development' ? 'http://work.ii999.live:19002/znzq' :'http://172.16.2.3:19000/znzq';
}
static getBaseApiUrl(){
//return process.env.NODE_ENV === 'development' ? 'http://119.45.242.222:8989' :'http://172.16.2.3:8989';
return process.env.NODE_ENV === 'development' ? 'http://119.45.242.222:8989' :'/base_api';
@@ -10,4 +14,26 @@ export default class config{
static getImAppId(){
return 10000;
}
static getVideoRoomUrl(room,userid,isPublish=0,isPlayer=1){
if(process.env.NODE_ENV === 'development' ){
return `http://localhost:8080/hd-glasses-app/#/call_room?isPublish=${isPublish}&isPlayer=${isPlayer}&uid=${userid}&room=${room}`
}else{
if(this.prod=="online"){
return `https://119.45.242.222/hd-glasses-app/#/call_room?isPublish=${isPublish}&isPlayer=${isPlayer}&uid=${userid}&room=${room}`
}else{
return `https://172.16.3.19/hd-glasses-app/#/call_room?isPublish=${isPublish}&isPlayer=${isPlayer}&uid=${userid}&room=${room}`
}
}
}
static getSRSUrl(){
if(process.env.NODE_ENV === 'development' ){
return 'webrtc://119.45.242.222/'
}else{
if(this.prod=="online"){
return 'webrtc://119.45.242.222/'
}else{
return 'webrtc://172.16.3.19/'
}
}
}
}

View File

@@ -0,0 +1,45 @@
import Request from 'luch-request' // 使用npm
import conf from "@/common/config.js"
const customHttp = new Request({
timeout: 300000, //超时时长5分钟,
header: {
'Content-Type': 'application/json;charset=UTF-8;'
}
});
//请求拦截器
customHttp.interceptors.request.use((config) => {
if (config.custom.target != undefined) {
if (config.custom.target == "znzq") {
config.baseURL = conf.getZnzqApiUrl()
const token = uni.getStorageSync('token');
config.headers["X-Access-Token"] = token;
}
}
console.log(config)
return config
}, error => {
return Promise.resolve(error)
})
// 响应拦截器
customHttp.interceptors.response.use((response) => {
console.log(response)
return response
}, (error) => {
//未登录时清空缓存跳转
if (error.statusCode == 401) {
uni.clearStorageSync();
uni.switchTab({
url: "/pages/index/index.vue"
})
}
return Promise.resolve(error)
})
export default {
customHttp
}

File diff suppressed because one or more lines are too long

View File

@@ -2,8 +2,7 @@ import http from '@/common/request'
import browser from '@/common/browser'
import store from '../store'
import pinyin from '@/common/pinyin.js';
import * as dayjs from 'dayjs'
import dayjs from "dayjs"
export default {
// 获取字典
@@ -327,7 +326,6 @@ export default {
},
//接收推送消息
getPush(resbody) {
console.log(resbody)
var pushType = resbody.pushType //推送类型
if (pushType == 'MSG') {
/*
@@ -457,7 +455,6 @@ export default {
if (msgType == 'TRTC_VIDEO_END') {
msgTypeLabel = '[视频通话]'
}
console.log(userId)
store.dispatch('createChatObj', {
userId: userId,
windowType: windowType,
@@ -471,7 +468,6 @@ export default {
var data2 = this.getKeyObjectStorage(store.state.userInfo.userId + '_' +
'chatlistData')
// var _num=data2[userId].num||
console.log("===========data2:",JSON.stringify(data2[userId]))
// 找到数组中对象属性值一样的对象并返回
function arrfindobject({
@@ -517,7 +513,7 @@ export default {
nickName: fromInfo.nickName,
portrait: fromInfo.portrait,
content: msgTypeLabel,
time: dayjs(time).format("YYYY/MM/DD HH:mm:ss"),
time: dayjs().format("YYYY/MM/DD HH:mm:ss"),
num: disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1),
windowType: windowType,
disturb: "N", //是否静默消息
@@ -683,6 +679,7 @@ export default {
// TODO
// 发送完成之后设置消息状态
//TODO
// msgSendType = 'error';
msgOffline.sendtype = msgSendType;
msgOffline.msgId = "1231"
@@ -1001,9 +998,19 @@ export default {
},
formatMessage(msg){
msg.pushType="MSG"
var msgType="TEXT"
const _data=JSON.parse(msg.messageBody)
// try{
// console.log("=======================formatMessage")
// console.log(_data)
// _data.content=JSON.parse(_data.content)
// msgType=_data.content.type
// }catch(e){
// console.error(e)
// //TODO handle the exception
// }
msg.msgContent={
msgType:"TEXT",
msgType:_data.msgType,
content:_data.content,
disturb:false,
top:false,

View File

@@ -224,6 +224,13 @@ function put(url, data, con, success) {
function uploadFile(con) {
init(con);
console.log("========================")
console.log("========================")
console.log("========================")
console.error(con.url)
console.error(con.url)
console.error(con.url)
console.error(con.url)
let config = {
url: con.url ? con.url : http.baseUrl,
files: con.files,

View File

@@ -30,12 +30,11 @@ export default {
console.log("重连成功");
},
onOfflineMessage: (e) => {
console.log("====================拉取到离线消息")
console.log(e)
// console.log("====================拉取到离线消息")
// console.log(e)
setTimeout(function() {
if (e.length > 0) {
e.map((msg) => {
console.log(msg)
setTimeout(()=>{
const _data = publicFc.formatMessage(msg)
uni.$emit('onP2PMessage', _data);

46
im-uniapp/common/utils.js Normal file
View File

@@ -0,0 +1,46 @@
/**
* getUrlKey 截取地址栏参数
* @param value
* @returns {String}
*/
export function getUrlParam(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
let url = window.location.href.split('#')[0];
let search = url.split('?')[1];
console.log(search);
if (search) {
var r = search.substr(0).match(reg);
if (r !== null) {
return unescape(r[2]);
}
return null;
} else return null;
}
export function appInit(ms) {
return new Promise((resolve, reject) => {
var i = 0;
let timer = setInterval(() => {
var hd_token = localStorage.getItem("im_imUserSign")
var im_userId = localStorage.getItem("im_userId")
i = i + 1;
if (i > 10) {
reject("error")
}
if (hd_token) {
localStorage.setItem("imUserSign",hd_token)
localStorage.setItem("appId",10000)
if(im_userId){
localStorage.setItem("userId",im_userId)
}
clearInterval(timer)
timer = null
resolve("ok")
}
}, ms);
})
}