内网开发

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

@@ -6,6 +6,7 @@
import {
versionName
} from '@/manifest.json'
import {appInit} from "@/common/utils.js"
import consoleImgs from '@/common/consoleImgs.js'
// #ifdef APP-PLUS
import appUpgrade from '@/common/appUpgrade.js';
@@ -13,6 +14,15 @@
// #endif
export default {
onLaunch: function() {
appInit(500).then((res)=>{
console.log("获取到token创建长链接")
console.log(this.$socketTask.socketTask)
this.$socketTask.connectSocket()
}).then((error)=>{
console.log("未获取到IM的token")
})
// #ifdef H5
console.log(
`%c 考拉Team ${name} %c v${version} `,

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);
})
}

View File

@@ -118,7 +118,7 @@
},
showAdd: {
type: Boolean,
default: true
default: false
}
},
data() {

View File

@@ -24,7 +24,7 @@
</view>
<view class="uni-list-chat__content">
<view class="uni-list-chat__content-main">
<text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text>
<text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text>
<text class="uni-list-chat__content-note uni-ellipsis">{{ note }}</text>
</view>
<view class="uni-list-chat__content-extra">

View File

@@ -13,6 +13,8 @@
<script>
import zmmUploadImageDrag from './zmm-upload-image-drag.vue';
import http from '@/common/request.js';
import customHttp from "@/common/customHttp.js"
import config from "@/common/config.js"
export default {
components: {
zmmUploadImageDrag
@@ -67,12 +69,12 @@ export default {
fileAction: {
//后台文件上传接口
type: String,
default: http.baseUrl + '/file/upload'
default: config.getImApiUrl() + '/file/upload'
},
videoAction: {
//后台上传接口
type: String,
default: http.baseUrl + '/file/uploadVideo'
default: config.getImApiUrl() + '/file/uploadVideo'
},
formData: {
//上传所附带数据
@@ -253,9 +255,12 @@ export default {
}
// console.log('success to upload image: ' + res.data)
var resItem=JSON.parse(res.data)
console.error(resItem)
_self.$emit('oneComplete', {
name: resItem.data.fileName,
url: resItem.data.fullPath,
name: resItem.data,
url: resItem.data,
type:'IMAGE'
},_self.chooseType);
resolve(res.data);

View File

@@ -3,7 +3,10 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./static/ol/ol.css">
<script type="text/javascript" src="./vconsole.min.js"></script>
<script>
// var vConsole = new VConsole();
</script>
<title></title>
<!--preload-links-->
<!--app-context-->

View File

@@ -1,5 +1,5 @@
{
"name": "微聊",
"name": "hs-im",
"version": "1.1.0",
"description": "",
"main": "main.js",
@@ -9,10 +9,11 @@
"repository": {
"type": "git"
},
"author": "zmm2113@qq.com",
"author": "php_echo@163.com",
"license": "ISC",
"dependencies": {
"dayjs": "^1.11.10",
"localforage": "^1.10.0"
"localforage": "^1.10.0",
"luch-request": "^3.1.1"
}
}

View File

@@ -68,18 +68,6 @@
"iconPath": "static/wx/n01.png",
"selectedIconPath": "static/wx/n01_on.png",
"text": "通讯录"
},
{
"pagePath": "wx/tabbar3/index",
"iconPath": "static/wx/n02.png",
"selectedIconPath": "static/wx/n02_on.png",
"text": "发现"
},
{
"pagePath": "wx/tabbar4/index",
"iconPath": "static/wx/n03.png",
"selectedIconPath": "static/wx/n03_on.png",
"text": "我"
}
]
},
@@ -134,20 +122,7 @@
"aliasPath": "/wxtabbar1",
"requireAuth": true,
"style": {
"navigationBarTitleText": "消息",
"app-plus": {
"titleNView": {
"buttons": [{
"text": "\ue657",
"fontSrc": "/static/wx_iconfont.ttf",
"fontSize": "28px"
}, {
"text": "\ue636",
"fontSrc": "/static/wx_iconfont.ttf",
"fontSize": "26px"
}]
}
}
"navigationBarTitleText": "消息"
}
}
, {
@@ -156,20 +131,7 @@
"aliasPath": "/wxtabbar2",
"requireAuth": true,
"style": {
"navigationBarTitleText": "通讯录",
"app-plus": {
"titleNView": {
"buttons": [{
"text": "\ue657",
"fontSrc": "/static/wx_iconfont.ttf",
"fontSize": "28px"
}, {
"text": "\ue636",
"fontSrc": "/static/wx_iconfont.ttf",
"fontSize": "26px"
}]
}
}
"navigationBarTitleText": "通讯录"
}
}, {
"path": "tabbar3/index",

1
im-uniapp/static/js/dayjs.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,350 +0,0 @@
:root,
:host {
--ol-background-color: white;
--ol-accent-background-color: #F5F5F5;
--ol-subtle-background-color: rgba(128, 128, 128, 0.25);
--ol-partial-background-color: rgba(255, 255, 255, 0.75);
--ol-foreground-color: #333333;
--ol-subtle-foreground-color: #666666;
--ol-brand-color: #00AAFF;
}
.ol-box {
box-sizing: border-box;
border-radius: 2px;
border: 1.5px solid var(--ol-background-color);
background-color: var(--ol-partial-background-color);
}
.ol-mouse-position {
top: 8px;
right: 8px;
position: absolute;
}
.ol-scale-line {
background: var(--ol-partial-background-color);
border-radius: 4px;
bottom: 8px;
left: 8px;
padding: 2px;
position: absolute;
}
.ol-scale-line-inner {
border: 1px solid var(--ol-subtle-foreground-color);
border-top: none;
color: var(--ol-foreground-color);
font-size: 10px;
text-align: center;
margin: 1px;
will-change: contents, width;
transition: all 0.25s;
}
.ol-scale-bar {
position: absolute;
bottom: 8px;
left: 8px;
}
.ol-scale-bar-inner {
display: flex;
}
.ol-scale-step-marker {
width: 1px;
height: 15px;
background-color: var(--ol-foreground-color);
float: right;
z-index: 10;
}
.ol-scale-step-text {
position: absolute;
bottom: -5px;
font-size: 10px;
z-index: 11;
color: var(--ol-foreground-color);
text-shadow: -1.5px 0 var(--ol-partial-background-color), 0 1.5px var(--ol-partial-background-color), 1.5px 0 var(--ol-partial-background-color), 0 -1.5px var(--ol-partial-background-color);
}
.ol-scale-text {
position: absolute;
font-size: 12px;
text-align: center;
bottom: 25px;
color: var(--ol-foreground-color);
text-shadow: -1.5px 0 var(--ol-partial-background-color), 0 1.5px var(--ol-partial-background-color), 1.5px 0 var(--ol-partial-background-color), 0 -1.5px var(--ol-partial-background-color);
}
.ol-scale-singlebar {
position: relative;
height: 10px;
z-index: 9;
box-sizing: border-box;
border: 1px solid var(--ol-foreground-color);
}
.ol-scale-singlebar-even {
background-color: var(--ol-subtle-foreground-color);
}
.ol-scale-singlebar-odd {
background-color: var(--ol-background-color);
}
.ol-unsupported {
display: none;
}
.ol-viewport,
.ol-unselectable {
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.ol-viewport canvas {
all: unset;
overflow: hidden;
}
.ol-viewport {
touch-action: none;
}
.ol-selectable {
-webkit-touch-callout: default;
-webkit-user-select: text;
-moz-user-select: text;
user-select: text;
}
.ol-grabbing {
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
cursor: grabbing;
}
.ol-grab {
cursor: move;
cursor: -webkit-grab;
cursor: -moz-grab;
cursor: grab;
}
.ol-control {
position: absolute;
background-color: var(--ol-subtle-background-color);
border-radius: 4px;
}
.ol-zoom {
top: .5em;
left: .5em;
}
.ol-rotate {
top: .5em;
right: .5em;
transition: opacity .25s linear, visibility 0s linear;
}
.ol-rotate.ol-hidden {
opacity: 0;
visibility: hidden;
transition: opacity .25s linear, visibility 0s linear .25s;
}
.ol-zoom-extent {
top: 4.643em;
left: .5em;
}
.ol-full-screen {
right: .5em;
top: .5em;
}
.ol-control button {
display: block;
margin: 1px;
padding: 0;
color: var(--ol-subtle-foreground-color);
font-weight: bold;
text-decoration: none;
font-size: inherit;
text-align: center;
height: 1.375em;
width: 1.375em;
line-height: .4em;
background-color: var(--ol-background-color);
border: none;
border-radius: 2px;
}
.ol-control button::-moz-focus-inner {
border: none;
padding: 0;
}
.ol-zoom-extent button {
line-height: 1.4em;
}
.ol-compass {
display: block;
font-weight: normal;
will-change: transform;
}
.ol-touch .ol-control button {
font-size: 1.5em;
}
.ol-touch .ol-zoom-extent {
top: 5.5em;
}
.ol-control button:hover,
.ol-control button:focus {
text-decoration: none;
outline: 1px solid var(--ol-subtle-foreground-color);
color: var(--ol-foreground-color);
}
.ol-zoom .ol-zoom-in {
border-radius: 2px 2px 0 0;
}
.ol-zoom .ol-zoom-out {
border-radius: 0 0 2px 2px;
}
.ol-attribution {
text-align: right;
bottom: .5em;
right: .5em;
max-width: calc(100% - 1.3em);
display: flex;
flex-flow: row-reverse;
align-items: center;
}
.ol-attribution a {
color: var(--ol-subtle-foreground-color);
text-decoration: none;
}
.ol-attribution ul {
margin: 0;
padding: 1px .5em;
color: var(--ol-foreground-color);
text-shadow: 0 0 2px var(--ol-background-color);
font-size: 12px;
}
.ol-attribution li {
display: inline;
list-style: none;
}
.ol-attribution li:not(:last-child):after {
content: " ";
}
.ol-attribution img {
max-height: 2em;
max-width: inherit;
vertical-align: middle;
}
.ol-attribution button {
flex-shrink: 0;
}
.ol-attribution.ol-collapsed ul {
display: none;
}
.ol-attribution:not(.ol-collapsed) {
background: var(--ol-partial-background-color);
}
.ol-attribution.ol-uncollapsible {
bottom: 0;
right: 0;
border-radius: 4px 0 0;
}
.ol-attribution.ol-uncollapsible img {
margin-top: -.2em;
max-height: 1.6em;
}
.ol-attribution.ol-uncollapsible button {
display: none;
}
.ol-zoomslider {
top: 4.5em;
left: .5em;
height: 200px;
}
.ol-zoomslider button {
position: relative;
height: 10px;
}
.ol-touch .ol-zoomslider {
top: 5.5em;
}
.ol-overviewmap {
left: 0.5em;
bottom: 0.5em;
}
.ol-overviewmap.ol-uncollapsible {
bottom: 0;
left: 0;
border-radius: 0 4px 0 0;
}
.ol-overviewmap .ol-overviewmap-map,
.ol-overviewmap button {
display: block;
}
.ol-overviewmap .ol-overviewmap-map {
border: 1px solid var(--ol-subtle-foreground-color);
height: 150px;
width: 150px;
}
.ol-overviewmap:not(.ol-collapsed) button {
bottom: 0;
left: 0;
position: absolute;
}
.ol-overviewmap.ol-collapsed .ol-overviewmap-map,
.ol-overviewmap.ol-uncollapsible button {
display: none;
}
.ol-overviewmap:not(.ol-collapsed) {
background: var(--ol-subtle-background-color);
}
.ol-overviewmap-box {
border: 1.5px dotted var(--ol-subtle-foreground-color);
}
.ol-overviewmap .ol-overviewmap-box:hover {
cursor: move;
}

View File

@@ -63,18 +63,31 @@ const store = new Vuex.Store({
}
},
actions: {
createRoom(context,room){
_im.createRoom(room).then((res) => {
})
},
joinRoom(context,room){
_im.joinRoom(room).then((res) => {
})
},
getRoomInfo(context,room){
},
onP2PMessage(context, data) {
console.log("========================store 收到信息")
console.log(data)
// console.log("========================store 收到信息")
publicFc.getPush(data)
},
sendMsg(context, data) {
console.log("========================")
// console.log("======================== store:sendMsg")
// console.log(data)
// console.log("========================")
// console.log("========================")
// console.error(data)
_im.sendP2PMessage(_im.createP2PTextMessage(data.userId, data.data.content))
_im.sendP2PMessage(_im.createP2PTextMessage(data.userId, data.data))
},
sendP2PMessageReciveAck(context, data) {
_im.sendP2PMessageReciveAck(data)
@@ -161,10 +174,10 @@ const store = new Vuex.Store({
context.commit('update_ChatList', data)
},
updateChatListInfoById(context, data) { //修改聊天记录
console.log("*********************** 修改聊天记录 2 ********************")
console.log("*********************** 修改聊天记录 2 ********************")
console.log("*********************** 修改聊天记录 2 ********************")
console.log(data)
// console.log("*********************** 修改聊天记录 2 ********************")
// console.log("*********************** 修改聊天记录 2 ********************")
// console.log("*********************** 修改聊天记录 2 ********************")
// console.log(data)
var getKey = data.userId
var retdata = publicFc.getKeyObjectStorage(context.state.userInfo.userId + '_' +
'chatlistData')
@@ -174,7 +187,7 @@ const store = new Vuex.Store({
retdata));
},
createChatObj(context, data) {
console.log("初始化聊天记录")
// console.log("初始化聊天记录")
// console.log("context.state.userInfo.userId:", context.state.userInfo.userId)
// console.log("data.userId:", data.userId)
var userId = data.userId
@@ -187,11 +200,9 @@ const store = new Vuex.Store({
// console.log("===========data2:",JSON.stringify(data2[userId]))
var _num=0
console.error(data2[userId])
if (!data2[userId]) {
data2[userId] = new Object()
}else{
console.warn(data2[userId].num)
// _num=data2[userId].num+1
}
uni.setStorageSync(context.state.userInfo.userId + '_' + 'chatlistData', JSON.stringify(
@@ -201,7 +212,6 @@ const store = new Vuex.Store({
'chatData')
return new Promise((resolve, reject) => {
if (!data1[userId]) {
console.log('初始化聊天')
switch (windowType) {
case 'SINGLE':
@@ -229,7 +239,7 @@ const store = new Vuex.Store({
.userId + '_' + 'chatData', JSON
.stringify(data1));
// 创建记录
console.log("============= 创建记录 ")
// console.log("============= 创建记录 ")

10
im-uniapp/vconsole.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -251,7 +251,12 @@ export default {
});
},
returnParse(txt) {
return JSON.parse(txt);
try{
return JSON.parse(txt);
}catch(e){
return txt;
//TODO handle the exception
}
},
tryagin(e, i) {
this.$emit('tryagin', e, i);

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>

View File

@@ -219,11 +219,11 @@
},
loginDone(data) {
uni.setStorageSync('appId', data.appId);
uni.setStorageSync('im_userId', data.userId);
uni.setStorageSync('userId', data.userId);
uni.setStorageSync('im_userCSign', data.userSign);
uni.setStorageSync('im_imUserSign', data.imUserSign);
uni.setStorageSync('imUserSign', data.imUserSign);
uni.setStorageSync('userCSign', data.userSign);
this.$socketTask.connectSocket()
uni.reLaunch({
url: '../tabbar1/index'

View File

@@ -66,6 +66,12 @@
true
);
},
filters:{
contentFilter(value){
console.warn(value)
return "KKKKK"+value
}
},
watch: {
chatListNum: {
deep: true, //深度监听可见听对象中的元素变化例:obj.id
@@ -136,6 +142,16 @@
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{
console.error(_data)
}
}catch(e){
//TODO handle the exception
}
NOTtoplist.push(obj[k]);
}
}
@@ -158,7 +174,7 @@
this.$store.dispatch('tabBarpull');
},
mounted() {
this.$socketTask.connectSocket()
},
methods: {
longpressItem(e, i, v) {

View File

@@ -2,11 +2,13 @@
<view class="xw-book">
<watermark></watermark>
<uni-indexed-list-wx :options="list" @click="bindClick"></uni-indexed-list-wx>
<top-right-tool-wx ref="trtw"></top-right-tool-wx>
<!-- <top-right-tool-wx ref="trtw"></top-right-tool-wx> -->
</view>
</template>
<script>
import customHttp from "@/common/customHttp.js"
export default {
data() {
return {
@@ -61,7 +63,20 @@
}
]
this.list=this.$fc.sortList({list:list,key:'name'})
// 局部修改配置,局部配置优先级高于全局配置
customHttp.customHttp.post('/api/im/app/addressList', {userName: 'name', password: '123456'}, {
params: {}, /* 会加在url上 */
dataType: 'json',
// 注如果局部custom与全局custom有同名属性则后面的属性会覆盖前面的属性相当于Object.assign(全局,局部)
custom: {target: "znzq"} // 可以加一些自定义参数在拦截器等地方使用。比如这里我加了一个auth可在拦截器里拿到如果true就传token
}).then(res => {
}).catch(err => {
})
this.$http.request({
url: '/friend/friendList',