聊天
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
export default class config{
|
||||
static getBaseApiUrl(){
|
||||
return process.env.NODE_ENV === 'development' ? 'http://192.168.1.117:8989' :'http://www.shudong.xyz/shudong_api/';
|
||||
return process.env.NODE_ENV === 'development' ? 'http://192.168.1.117:8989' :'http://192.168.1.117:8989';
|
||||
}
|
||||
static getImApiUrl(){
|
||||
return process.env.NODE_ENV === 'development' ? 'http://192.168.1.117:28000/v1' :'http://www.shudong.xyz/shudong_api/';
|
||||
return process.env.NODE_ENV === 'development' ? 'http://192.168.1.117:28000/v1' :'http://192.168.1.117:28000/v1';
|
||||
}
|
||||
static getImAppId(){
|
||||
return 10000;
|
||||
|
||||
@@ -186,7 +186,7 @@ export default {
|
||||
browser.show(url)
|
||||
},
|
||||
//获取时间format
|
||||
getNewDate(format, add0,datetime) {
|
||||
getNewDate(format, add0, datetime) {
|
||||
//获取当前时间
|
||||
function addZero(val) {
|
||||
//补零
|
||||
@@ -197,10 +197,10 @@ export default {
|
||||
}
|
||||
}
|
||||
var date = new Date()
|
||||
if(datetime){
|
||||
date=Date.parse(new Date(datetime))
|
||||
if (datetime) {
|
||||
date = Date.parse(new Date(datetime))
|
||||
}
|
||||
|
||||
|
||||
var year = date.getFullYear(),
|
||||
month = addZero(date.getMonth() + 1),
|
||||
strDate = addZero(date.getDate()),
|
||||
@@ -254,37 +254,39 @@ export default {
|
||||
}
|
||||
},
|
||||
loadMore({
|
||||
url='xxx/list/',
|
||||
queryParams={
|
||||
refreshing:false,
|
||||
pageNum:1,
|
||||
status: 'more',//more loading前 loading loading中 noMore 没有更多了
|
||||
pageSize:10
|
||||
url = 'xxx/list/',
|
||||
queryParams = {
|
||||
refreshing: false,
|
||||
pageNum: 1,
|
||||
status: 'more', //more loading前 loading loading中 noMore 没有更多了
|
||||
pageSize: 10
|
||||
},
|
||||
status='0'//0无更多数据 1持续加载 2重新加载 3无数据+清空数据
|
||||
}){
|
||||
status = '0' //0无更多数据 1持续加载 2重新加载 3无数据+清空数据
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.request({
|
||||
url:url+'&pageNum='+(queryParams.refreshing ? 1 : queryParams.pageNum) +'&pageSize=' +queryParams.pageSize,
|
||||
url: url + '&pageNum=' + (queryParams.refreshing ? 1 : queryParams.pageNum) +
|
||||
'&pageSize=' + queryParams.pageSize,
|
||||
success: res => {
|
||||
if (res.data.code == 200) {
|
||||
let list = [];
|
||||
let data = res.data.rows;
|
||||
if (queryParams.refreshing&&res.data.rows == ''||queryParams.refreshing&&res.data.rows.length==0) {
|
||||
queryParams.status='noMore'
|
||||
if (queryParams.refreshing && res.data.rows == '' || queryParams
|
||||
.refreshing && res.data.rows.length == 0) {
|
||||
queryParams.status = 'noMore'
|
||||
resolve({
|
||||
queryParams:queryParams,
|
||||
list:list,
|
||||
status:'3'
|
||||
queryParams: queryParams,
|
||||
list: list,
|
||||
status: '3'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (res.data.rows == ''||res.data.rows.length==0) {
|
||||
queryParams.status='noMore'
|
||||
if (res.data.rows == '' || res.data.rows.length == 0) {
|
||||
queryParams.status = 'noMore'
|
||||
resolve({
|
||||
queryParams:queryParams,
|
||||
list:list,
|
||||
status:'0'
|
||||
queryParams: queryParams,
|
||||
list: list,
|
||||
status: '0'
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -295,19 +297,19 @@ export default {
|
||||
if (queryParams.refreshing) {
|
||||
queryParams.refreshing = false;
|
||||
queryParams.pageNum = 2;
|
||||
queryParams.status='more'
|
||||
queryParams.status = 'more'
|
||||
resolve({
|
||||
queryParams:queryParams,
|
||||
list:list,
|
||||
status:'2'
|
||||
queryParams: queryParams,
|
||||
list: list,
|
||||
status: '2'
|
||||
})
|
||||
} else {
|
||||
queryParams.pageNum += 1;
|
||||
queryParams.status='more'
|
||||
queryParams.status = 'more'
|
||||
resolve({
|
||||
queryParams:queryParams,
|
||||
list:list,
|
||||
status:'1'
|
||||
queryParams: queryParams,
|
||||
list: list,
|
||||
status: '1'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
@@ -325,55 +327,64 @@ export default {
|
||||
console.log(resbody)
|
||||
var pushType = resbody.pushType //推送类型
|
||||
if (pushType == 'MSG') {
|
||||
/*
|
||||
if(resbody.msgContent.msgType=='TRTC_VOICE_START'||resbody.msgContent.msgType=='TRTC_VIDEO_START'){
|
||||
//音视频开始拦截
|
||||
return
|
||||
}
|
||||
var userId=resbody.fromInfo.userId
|
||||
var windowType='SINGLE'
|
||||
}
|
||||
*/
|
||||
var userId = resbody.userId
|
||||
var windowType = 'SINGLE'
|
||||
/*
|
||||
if(resbody.groupInfo.userId){
|
||||
userId=resbody.groupInfo.userId
|
||||
windowType='GROUP'
|
||||
}
|
||||
}
|
||||
*/
|
||||
const _userId = uni.getStorageSync("userId")
|
||||
|
||||
debugger
|
||||
|
||||
this.pushInMsg({
|
||||
type: resbody.msgContent.msgType == 'ALERT' ? 3 : 1, //显示类型 1左侧 2右侧 3中间
|
||||
msgContent: resbody.msgContent.content, //msg内容
|
||||
msgType: resbody.msgContent.msgType, //msgType信息类型
|
||||
windowType: windowType, //聊天室类型 SINGLE GROUP
|
||||
time: resbody.createTime, //时间
|
||||
fromInfo:resbody.fromInfo,//来源信息
|
||||
groupInfo:resbody.groupInfo,//群信息
|
||||
userId: userId,//talktoId
|
||||
personId:resbody.fromInfo.userId,
|
||||
msgId:resbody.msgId,//消息Id
|
||||
disturb:resbody.msgContent.disturb,//是否静默消息
|
||||
top:resbody.msgContent.top//是否置顶
|
||||
fromInfo: resbody.fromInfo, //来源信息
|
||||
groupInfo: resbody.groupInfo, //群信息
|
||||
userId: _userId, //talktoId
|
||||
personId: resbody.fromInfo.userId,
|
||||
msgId: resbody.msgId, //消息Id
|
||||
disturb: resbody.msgContent.disturb, //是否静默消息
|
||||
top: resbody.msgContent.top //是否置顶
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
if (pushType == 'NOTICE') {//红点通知等
|
||||
if(resbody.msgContent.topicReply.count){
|
||||
store.commit('update_topicReply',resbody.msgContent.topicReply)
|
||||
if (pushType == 'NOTICE') { //红点通知等
|
||||
if (resbody.msgContent.topicReply.count) {
|
||||
store.commit('update_topicReply', resbody.msgContent.topicReply)
|
||||
}
|
||||
if(resbody.msgContent.topicRed.portrait){
|
||||
store.commit('update_topicRed',resbody.msgContent.topicRed)
|
||||
if (resbody.msgContent.topicRed.portrait) {
|
||||
store.commit('update_topicRed', resbody.msgContent.topicRed)
|
||||
}
|
||||
if(resbody.msgContent.friendApply.count){
|
||||
store.commit('update_friendApply',resbody.msgContent.friendApply)
|
||||
if (resbody.msgContent.friendApply.count) {
|
||||
store.commit('update_friendApply', resbody.msgContent.friendApply)
|
||||
}
|
||||
}
|
||||
if (pushType == 'BIG') {//大消息
|
||||
var bigId=resbody.msgContent.content
|
||||
if (pushType == 'BIG') { //大消息
|
||||
var bigId = resbody.msgContent.content
|
||||
http.request({
|
||||
url: '/chat/getBigMsg/'+bigId,
|
||||
url: '/chat/getBigMsg/' + bigId,
|
||||
success: (res) => {
|
||||
if (res.data.code == 200) {
|
||||
var resbody=res.data.data
|
||||
var userId=resbody.fromInfo.userId
|
||||
var windowType='SINGLE'
|
||||
if(resbody.groupInfo.userId){
|
||||
userId=resbody.groupInfo.userId
|
||||
windowType='GROUP'
|
||||
var resbody = res.data.data
|
||||
var userId = resbody.fromInfo.userId
|
||||
var windowType = 'SINGLE'
|
||||
if (resbody.groupInfo.userId) {
|
||||
userId = resbody.groupInfo.userId
|
||||
windowType = 'GROUP'
|
||||
}
|
||||
this.pushInMsg({
|
||||
type: resbody.msgContent.msgType == 'ALERT' ? 3 : 1, //显示类型 1左侧 2右侧 3中间
|
||||
@@ -381,13 +392,13 @@ export default {
|
||||
msgType: resbody.msgContent.msgType, //msgType信息类型
|
||||
windowType: windowType, //聊天室类型 SINGLE GROUP
|
||||
time: resbody.createTime, //时间
|
||||
fromInfo:resbody.fromInfo,//来源信息
|
||||
groupInfo:resbody.groupInfo,//群信息
|
||||
userId: userId,//talktoId
|
||||
personId:resbody.fromInfo.userId,
|
||||
msgId:resbody.msgId,//消息Id
|
||||
disturb:resbody.msgContent.disturb,//是否静默消息
|
||||
top:resbody.msgContent.top//是否置顶
|
||||
fromInfo: resbody.fromInfo, //来源信息
|
||||
groupInfo: resbody.groupInfo, //群信息
|
||||
userId: userId, //talktoId
|
||||
personId: resbody.fromInfo.userId,
|
||||
msgId: resbody.msgId, //消息Id
|
||||
disturb: resbody.msgContent.disturb, //是否静默消息
|
||||
top: resbody.msgContent.top //是否置顶
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -397,18 +408,18 @@ export default {
|
||||
},
|
||||
// 接收到的聊天推送
|
||||
pushInMsg({
|
||||
msgId,//消息Id
|
||||
msgContent,//内容
|
||||
msgType,//消息类型
|
||||
windowType,//聊天室类型 SINGLE GROUP
|
||||
userId,//聊天对象ID
|
||||
personId,//发送人ID
|
||||
time,//时间
|
||||
type,//显示类型 1左侧 2右侧 3中间
|
||||
fromInfo,//来源
|
||||
groupInfo,//群信息
|
||||
disturb,//是否静默消息
|
||||
top//是否置顶
|
||||
msgId, //消息Id
|
||||
msgContent, //内容
|
||||
msgType, //消息类型
|
||||
windowType, //聊天室类型 SINGLE GROUP
|
||||
userId, //聊天对象ID
|
||||
personId, //发送人ID
|
||||
time, //时间
|
||||
type, //显示类型 1左侧 2右侧 3中间
|
||||
fromInfo, //来源
|
||||
groupInfo, //群信息
|
||||
disturb, //是否静默消息
|
||||
top //是否置顶
|
||||
}) {
|
||||
var msgTypeLabel = ''; //消息类型
|
||||
if (msgType == 'TEXT') {
|
||||
@@ -444,26 +455,37 @@ export default {
|
||||
if (msgType == 'TRTC_VIDEO_END') {
|
||||
msgTypeLabel = '[视频通话]'
|
||||
}
|
||||
store.dispatch('createChatObj',{
|
||||
userId:userId,
|
||||
windowType:windowType,
|
||||
}).then(res=>{
|
||||
var localData=res.data
|
||||
console.log(userId)
|
||||
debugger
|
||||
store.dispatch('createChatObj', {
|
||||
userId: userId,
|
||||
windowType: windowType,
|
||||
}).then(res => {
|
||||
debugger
|
||||
var localData = res.data
|
||||
store.dispatch('getchatDatalist');
|
||||
store.dispatch('getChatList');
|
||||
var chatWindowData = store.state.chatDatalist[userId].list
|
||||
var chatListInfo = store.state.chatlist[userId]
|
||||
// 找到数组中对象属性值一样的对象并返回
|
||||
function arrfindobject({arr,object,key}){
|
||||
var result=arr.find(item =>{
|
||||
return item[key] == object[key]
|
||||
function arrfindobject({
|
||||
arr,
|
||||
object,
|
||||
key
|
||||
}) {
|
||||
var result = arr.find(item => {
|
||||
return item[key] == object[key]
|
||||
});
|
||||
return result
|
||||
}
|
||||
var same=arrfindobject({arr:chatWindowData,object:{
|
||||
msgId:msgId
|
||||
},key:'msgId'})
|
||||
if(same){
|
||||
var same = arrfindobject({
|
||||
arr: chatWindowData,
|
||||
object: {
|
||||
msgId: msgId
|
||||
},
|
||||
key: 'msgId'
|
||||
})
|
||||
if (same) {
|
||||
return
|
||||
}
|
||||
//离线消息体
|
||||
@@ -476,13 +498,13 @@ export default {
|
||||
content: msgContent,
|
||||
time: time,
|
||||
type: type,
|
||||
msgId:msgId,
|
||||
msgId: msgId,
|
||||
windowType: windowType
|
||||
}
|
||||
|
||||
|
||||
// 聊天记录体
|
||||
var msgList = {}
|
||||
if(windowType=='SINGLE'){
|
||||
if (windowType == 'SINGLE') {
|
||||
msgList = {
|
||||
userId: userId,
|
||||
personId: personId,
|
||||
@@ -490,14 +512,14 @@ export default {
|
||||
portrait: fromInfo.portrait,
|
||||
content: msgTypeLabel,
|
||||
time: time,
|
||||
num: disturb=='Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1),
|
||||
num: disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1),
|
||||
windowType: windowType,
|
||||
disturb:disturb,//是否静默消息
|
||||
top:top,//是否置顶
|
||||
userType:fromInfo.userType
|
||||
disturb: disturb, //是否静默消息
|
||||
top: top, //是否置顶
|
||||
userType: fromInfo.userType
|
||||
}
|
||||
}
|
||||
if(windowType=='GROUP'){
|
||||
if (windowType == 'GROUP') {
|
||||
msgList = {
|
||||
userId: userId,
|
||||
personId: personId,
|
||||
@@ -505,11 +527,11 @@ export default {
|
||||
portrait: groupInfo.portrait,
|
||||
content: msgTypeLabel,
|
||||
time: time,
|
||||
num: disturb=='Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1),
|
||||
num: disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num + 1 : 1),
|
||||
windowType: windowType,
|
||||
disturb:disturb,//是否静默消息
|
||||
top:top,//是否置顶
|
||||
userType:'GROUP'
|
||||
disturb: disturb, //是否静默消息
|
||||
top: top, //是否置顶
|
||||
userType: 'GROUP'
|
||||
}
|
||||
}
|
||||
chatWindowData.push(msgOffline)
|
||||
@@ -522,7 +544,7 @@ export default {
|
||||
data: msgList
|
||||
})
|
||||
store.dispatch('tabBarpull')
|
||||
store.dispatch('updateChatDataState',userId);
|
||||
store.dispatch('updateChatDataState', userId);
|
||||
});
|
||||
},
|
||||
//发送消息
|
||||
@@ -567,28 +589,28 @@ export default {
|
||||
msgTypeLabel = '[视频通话]'
|
||||
}
|
||||
var userInfo = store.state.userInfo;
|
||||
store.dispatch('createChatObj',{
|
||||
userId:userId,
|
||||
windowType:windowType,
|
||||
}).then(res=>{
|
||||
var localData=res.data
|
||||
store.dispatch('createChatObj', {
|
||||
userId: userId,
|
||||
windowType: windowType,
|
||||
}).then(res => {
|
||||
var localData = res.data
|
||||
store.dispatch('getchatDatalist');
|
||||
store.dispatch('getChatList');
|
||||
var chatWindowData = store.state.chatDatalist[userId].list
|
||||
var chatListInfo = store.state.chatlist[userId]
|
||||
var time = this.getNewDate('format',true)
|
||||
var time = this.getNewDate('format', true)
|
||||
//在线消息体
|
||||
var msgOnlie={}
|
||||
var msgOnlie = {}
|
||||
//聊天记录
|
||||
var msgList={}
|
||||
var url=''
|
||||
if(windowType=='SINGLE'){
|
||||
var msgList = {}
|
||||
var url = ''
|
||||
if (windowType == 'SINGLE') {
|
||||
msgOnlie = {
|
||||
userId: userId,
|
||||
msgType: msgType,
|
||||
content: msgContent
|
||||
}
|
||||
url='/chat/sendMsg'
|
||||
url = '/chat/sendMsg'
|
||||
msgList = {
|
||||
userId: userId,
|
||||
personId: userInfo.userId,
|
||||
@@ -596,20 +618,20 @@ export default {
|
||||
portrait: localData.fromInfo.portrait,
|
||||
content: msgTypeLabel,
|
||||
time: time,
|
||||
num: chatListInfo.disturb=='Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num : 0),
|
||||
num: chatListInfo.disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num : 0),
|
||||
windowType: windowType,
|
||||
disturb:chatListInfo.disturb ? chatListInfo.disturb : 'N',//是否静默消息
|
||||
top:chatListInfo.top ? chatListInfo.top : 'N',//是否置顶
|
||||
userType:localData.fromInfo.userType
|
||||
disturb: chatListInfo.disturb ? chatListInfo.disturb : 'N', //是否静默消息
|
||||
top: chatListInfo.top ? chatListInfo.top : 'N', //是否置顶
|
||||
userType: localData.fromInfo.userType
|
||||
}
|
||||
}
|
||||
if(windowType=='GROUP'){
|
||||
if (windowType == 'GROUP') {
|
||||
msgOnlie = {
|
||||
groupId: userId,
|
||||
msgType: msgType,
|
||||
content: msgContent
|
||||
}
|
||||
url='/group/sendMsg'
|
||||
url = '/group/sendMsg'
|
||||
msgList = {
|
||||
userId: userId,
|
||||
personId: userInfo.userId,
|
||||
@@ -617,11 +639,11 @@ export default {
|
||||
portrait: localData.groupInfo.portrait,
|
||||
content: msgTypeLabel,
|
||||
time: time,
|
||||
num: chatListInfo.disturb=='Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num : 0),
|
||||
num: chatListInfo.disturb == 'Y' ? 'dot' : (chatListInfo.num ? chatListInfo.num : 0),
|
||||
windowType: windowType,
|
||||
disturb:chatListInfo.disturb ? chatListInfo.disturb : 'N',//是否静默消息
|
||||
top:chatListInfo.top ? chatListInfo.top : 'N',//是否置顶
|
||||
userType:'GROUP'
|
||||
disturb: chatListInfo.disturb ? chatListInfo.disturb : 'N', //是否静默消息
|
||||
top: chatListInfo.top ? chatListInfo.top : 'N', //是否置顶
|
||||
userType: 'GROUP'
|
||||
}
|
||||
}
|
||||
//离线消息体 自己的消息
|
||||
@@ -634,7 +656,7 @@ export default {
|
||||
content: msgContent,
|
||||
time: time,
|
||||
type: 2,
|
||||
msgId:'local',
|
||||
msgId: 'local',
|
||||
windowType: windowType
|
||||
};
|
||||
//离线/发送失败错误消息体
|
||||
@@ -646,6 +668,40 @@ export default {
|
||||
type: 3
|
||||
};
|
||||
var msgSendType = 'wating';
|
||||
|
||||
//开始发送消息
|
||||
store.dispatch('sendMsg', {
|
||||
userId: userId,
|
||||
data: msgOnlie
|
||||
});
|
||||
|
||||
// TODO
|
||||
// 发送完成之后设置消息状态
|
||||
|
||||
// msgSendType = 'error';
|
||||
msgOffline.sendtype = msgSendType;
|
||||
msgOffline.msgId = "1231"
|
||||
msgNotSend.content = msgOnlie.content;
|
||||
msgList.content = msgOnlie.content;
|
||||
|
||||
chatWindowData.push(msgOffline);
|
||||
if (msgSendType == 'error') {
|
||||
chatWindowData.push(msgNotSend);
|
||||
}
|
||||
store.dispatch('updateChatById', {
|
||||
userId: userId,
|
||||
data: chatWindowData
|
||||
});
|
||||
store.dispatch('updateChatListInfoById', {
|
||||
userId: userId,
|
||||
data: msgList
|
||||
});
|
||||
store.dispatch('tabBarpull');
|
||||
store.dispatch('updateChatDataState', userId);
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
http.request({
|
||||
url: url,
|
||||
method: 'POST',
|
||||
@@ -655,7 +711,7 @@ export default {
|
||||
if (res.data.data.status !== '0') {
|
||||
msgSendType = 'error';
|
||||
msgOffline.sendtype = msgSendType;
|
||||
msgOffline.msgId=res.data.data.msgId
|
||||
msgOffline.msgId = res.data.data.msgId
|
||||
msgNotSend.content = res.data.data.statusLabel;
|
||||
msgList.content = res.data.data.statusLabel;
|
||||
} else {
|
||||
@@ -679,7 +735,7 @@ export default {
|
||||
data: msgList
|
||||
});
|
||||
store.dispatch('tabBarpull');
|
||||
store.dispatch('updateChatDataState',userId);
|
||||
store.dispatch('updateChatDataState', userId);
|
||||
},
|
||||
fail: res => {
|
||||
msgSendType = 'error';
|
||||
@@ -696,7 +752,7 @@ export default {
|
||||
data: msgList
|
||||
});
|
||||
store.dispatch('tabBarpull');
|
||||
store.dispatch('updateChatDataState',userId);
|
||||
store.dispatch('updateChatDataState', userId);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -890,24 +946,24 @@ export default {
|
||||
}
|
||||
return sortlist
|
||||
},
|
||||
saoyisao(){//扫一扫
|
||||
saoyisao() { //扫一扫
|
||||
// #ifdef APP-PLUS
|
||||
uni.scanCode({
|
||||
success: (res)=> {
|
||||
var result=res.result
|
||||
var data=res.result.split(':')
|
||||
var type=data[0]
|
||||
var value=data[1]
|
||||
switch (type){
|
||||
success: (res) => {
|
||||
var result = res.result
|
||||
var data = res.result.split(':')
|
||||
var type = data[0]
|
||||
var value = data[1]
|
||||
switch (type) {
|
||||
case 'group':
|
||||
uni.navigateTo({
|
||||
url:'../../wx/groupInfo/scanCodeDetail?param='+result
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: '../../wx/groupInfo/scanCodeDetail?param=' + result
|
||||
})
|
||||
break;
|
||||
case 'user':
|
||||
uni.navigateTo({
|
||||
url:'../../wx/personInfo/detail?param='+value+'&source=1'
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: '../../wx/personInfo/detail?param=' + value + '&source=1'
|
||||
})
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -917,13 +973,13 @@ export default {
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
uni.showToast({
|
||||
title:'扫一扫',
|
||||
icon:'none'
|
||||
title: '扫一扫',
|
||||
icon: 'none'
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
// 设置原生titleNView导航文字
|
||||
setTitleNViewBtns(index,text){
|
||||
setTitleNViewBtns(index, text) {
|
||||
let pages = getCurrentPages();
|
||||
let page = pages[pages.length - 1];
|
||||
// #ifdef APP-PLUS
|
||||
@@ -938,7 +994,7 @@ export default {
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
debounce(func, wait = 1000, immediate = true){
|
||||
debounce(func, wait = 1000, immediate = true) {
|
||||
/**
|
||||
* @desc 函数防抖
|
||||
* @param func 目标函数
|
||||
@@ -957,7 +1013,7 @@ export default {
|
||||
timer = setTimeout(() => {
|
||||
timer = null;
|
||||
}, wait);
|
||||
if (callNow){
|
||||
if (callNow) {
|
||||
func.apply(this, args);
|
||||
}
|
||||
} else {
|
||||
@@ -967,7 +1023,7 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
throttle (func, wait = 1000, type = 1) {
|
||||
throttle(func, wait = 1000, type = 1) {
|
||||
/**
|
||||
* @desc 函数节流
|
||||
* @param func 函数
|
||||
@@ -981,7 +1037,7 @@ export default {
|
||||
let args = arguments;
|
||||
if (type === 1) {
|
||||
let now = Date.now();
|
||||
|
||||
|
||||
if (now - previous > wait) {
|
||||
func.apply(context, args);
|
||||
previous = now;
|
||||
@@ -996,4 +1052,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import config from "@/common/config.js"
|
||||
let timer = null
|
||||
let retimer = null
|
||||
|
||||
import store from '../store'
|
||||
|
||||
import * as sdk from "@/common/imSdk/lim-sdk.js";
|
||||
|
||||
@@ -30,15 +30,35 @@ export default {
|
||||
},
|
||||
onTestMessage: (e) => {
|
||||
console.log("onTestMessage :" + e);
|
||||
store.dispatch('onP2PMessage',e)
|
||||
},
|
||||
onP2PMessage: (e) => {
|
||||
console.log("onP2PMessage :" + e);
|
||||
e = JSON.parse(e)
|
||||
e.pushType="TEXT"
|
||||
e.data.pushType="MSG"
|
||||
e.data.msgContent={
|
||||
msgType:"UNKOWN",
|
||||
content:e.data.messageBody,
|
||||
disturb:false,
|
||||
top:false,
|
||||
}
|
||||
|
||||
e.data.windowType="SINGLE"
|
||||
e.data.createTime=e.data.messageTime;
|
||||
e.data.fromInfo={
|
||||
userId:e.data.fromId
|
||||
};
|
||||
e.data.groupInfo={};
|
||||
e.data.msgId=e.data.messageId;
|
||||
|
||||
debugger
|
||||
uni.$emit('onP2PMessage', e.data);
|
||||
store.dispatch('onP2PMessage',e.data)
|
||||
},
|
||||
onLogin: (uid) => {
|
||||
console.log("用户" + uid + "登陆sdk成功");
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
@@ -54,6 +74,7 @@ export default {
|
||||
|
||||
console.log(lim)
|
||||
|
||||
// 防止多次建立ws链接,貌似还没有生效,需要检查
|
||||
if (this.socketTask != null) {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user