剥离im,剥离钱包
This commit is contained in:
BIN
utils/im/.DS_Store
vendored
BIN
utils/im/.DS_Store
vendored
Binary file not shown.
@@ -1,16 +0,0 @@
|
||||
// 获取新好友申请数量
|
||||
const getPendingCount = (callback) => {
|
||||
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 100, 0, (res) => {
|
||||
if (res.code === 0) {
|
||||
const pendingCount = res.conversations.filter((item) => {
|
||||
return item.objectName == RongIMLib.ObjectName.ContactNotification
|
||||
}).length
|
||||
|
||||
callback(pendingCount)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
getPendingCount
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
|
||||
import store from '@/store/index.js'
|
||||
import message from './message.js'
|
||||
import listeners from './listeners.js'
|
||||
import {
|
||||
getFriends,
|
||||
getUserInfo,
|
||||
getImToken,
|
||||
getMyGroups
|
||||
} from '@/apis/interfaces/im.js'
|
||||
import {
|
||||
contactModel
|
||||
} from './models.js'
|
||||
|
||||
const initIm = (KEY) => {
|
||||
RongIMLib.init(KEY)
|
||||
CallLib.init()
|
||||
listeners.imLibListeners()
|
||||
listeners.callLibListeners()
|
||||
// 初始化的时候 自动链接
|
||||
if (store.getters.getToken !== '') {
|
||||
getImToken().then(res => {
|
||||
connect(res.token, res.userInfo, (res) => {
|
||||
console.log('IM.CONNECT', res);
|
||||
// 发布全局事件,有新消息,刷新会话列表
|
||||
uni.$emit('onReceiveMessage')
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const setNotifyBadge = () => {
|
||||
// 获取未读消息数量
|
||||
RongIMLib.getTotalUnreadCount(({
|
||||
code,
|
||||
count
|
||||
}) => {
|
||||
if (code === 0) {
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.setBadgeNumber(count)
|
||||
// #endif
|
||||
if (count > 0) {
|
||||
uni.setTabBarBadge({
|
||||
index: 3,
|
||||
text: String(count > 99 ? '99+' : count)
|
||||
})
|
||||
} else {
|
||||
uni.removeTabBarBadge({
|
||||
index: 3
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接IM服务
|
||||
* @param {string} token token
|
||||
* @param {object} userInfo {targetId: string, name: string, portraitUrl: string}
|
||||
*/
|
||||
const connect = (token, userInfo, callback) => {
|
||||
RongIMLib.connect(token, res => {
|
||||
callback(res)
|
||||
// 更新个人信息
|
||||
store.dispatch('setSenderInfo', userInfo)
|
||||
// 设置未读消息数量
|
||||
setNotifyBadge()
|
||||
// 首次运行获取好友列表
|
||||
const FK = 'ZH_CONTACT_' + userInfo.targetId
|
||||
|
||||
uni.getStorage({
|
||||
key: FK,
|
||||
success: () => {
|
||||
contactModel.find((err, results) => {
|
||||
console.log('初始化联系人信息', results);
|
||||
results.map(item => {
|
||||
store.dispatch('launchContact', item)
|
||||
})
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
// 程序是首次运行,初始化加载好友和群组信息
|
||||
Promise.all([getFriends(), getMyGroups()]).then(result => {
|
||||
result.map(contacts => {
|
||||
contacts.map(item => {
|
||||
store.dispatch('initContact', item)
|
||||
})
|
||||
})
|
||||
uni.setStorageSync(FK, userInfo.targetId)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 断开链接
|
||||
*/
|
||||
const disconnect = () => {
|
||||
RongIMLib.disconnect()
|
||||
// 移除提醒数量
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.setBadgeNumber(0)
|
||||
// #endif
|
||||
uni.removeTabBarBadge({
|
||||
index: 3
|
||||
})
|
||||
}
|
||||
|
||||
// 播放状态
|
||||
let tipState = false
|
||||
|
||||
const triTone = () => {
|
||||
if (tipState == false) {
|
||||
const innerAudioContext = uni.createInnerAudioContext()
|
||||
innerAudioContext.autoplay = true
|
||||
innerAudioContext.src = '/utils/im/sounds/new-msg.mp3'
|
||||
innerAudioContext.onPlay(() => {
|
||||
tipState = true
|
||||
})
|
||||
innerAudioContext.onEnded(() => {
|
||||
tipState = false
|
||||
innerAudioContext.destroy()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
initIm,
|
||||
connect,
|
||||
disconnect,
|
||||
setNotifyBadge,
|
||||
...message
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
|
||||
import * as IMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||
import store from '@/store/index.js'
|
||||
import im from "@/utils/im/index.js"
|
||||
import utils from '../index.js'
|
||||
import {
|
||||
getUserInfo
|
||||
} from '@/apis/interfaces/im.js'
|
||||
|
||||
// 维护消息列表,检查是否需要通知声音,设置新消息提醒的数量
|
||||
const onReceiveMessage = (message) => {
|
||||
IMLib.getConversationNotificationStatus(message.conversationType, message.targetId, ({
|
||||
code,
|
||||
status
|
||||
}) => {
|
||||
if (code === 0) {
|
||||
if (status) {
|
||||
// triTone()
|
||||
}
|
||||
}
|
||||
})
|
||||
im.setNotifyBadge()
|
||||
// 发布全局事件,有新消息,刷新会话列表
|
||||
uni.$emit('onReceiveMessage', message)
|
||||
// 这个是为了更新消息列表页的
|
||||
uni.$emit('onReceiveMessage_' + message.targetId, message)
|
||||
}
|
||||
|
||||
// 检测联系人信息,不存在的时候,从服务端获取
|
||||
const checkContactExists = (message) => {
|
||||
if (!store.getters.contactIsExist(message.targetId)) {
|
||||
getUserInfo(message.targetId).then(res => {
|
||||
console.log('targetId', res);
|
||||
store.dispatch('initContact', res)
|
||||
}).catch(err => {
|
||||
console.error('getUserInfo ERR', err)
|
||||
})
|
||||
}
|
||||
if (!store.getters.contactIsExist(message.senderUserId)) {
|
||||
getUserInfo(message.senderUserId).then(res => {
|
||||
console.log('senderUserId', message.senderUserId, res);
|
||||
store.dispatch('initContact', res)
|
||||
}).catch(err => {
|
||||
console.error('getUserInfo ERR', err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 允许通知的消息类型,触发更新消息列表操作,提示音
|
||||
const notifyMsgTypes = [
|
||||
IMLib.ObjectName.Text,
|
||||
IMLib.ObjectName.File,
|
||||
IMLib.ObjectName.Image,
|
||||
IMLib.ObjectName.GIF,
|
||||
IMLib.ObjectName.Location,
|
||||
IMLib.ObjectName.Voice,
|
||||
IMLib.ObjectName.HQVoice,
|
||||
IMLib.ObjectName.Sight,
|
||||
'RC:IWNormalMsg'
|
||||
]
|
||||
|
||||
const imLibListeners = () => {
|
||||
// 添加连接状态监听函数
|
||||
IMLib.addConnectionStatusListener((res) => {
|
||||
console.error('连接状态监听', res.data.status)
|
||||
uni.$emit('onConnectionStatusChange', res.data.status)
|
||||
})
|
||||
// 添加消息监听函数
|
||||
IMLib.addReceiveMessageListener((res) => {
|
||||
const message = res.data.message
|
||||
console.error('[收到消息]', message)
|
||||
checkContactExists(message)
|
||||
if (utils.inArray(message.objectName, notifyMsgTypes)) {
|
||||
onReceiveMessage(message)
|
||||
} else if (message.objectName === IMLib.ObjectName.ProfileNotification) {
|
||||
uni.$emit('onUpdateProfile_' + message.targetId)
|
||||
// 更新联系人信息
|
||||
store.dispatch('updateContact', JSON.parse(message.content.data))
|
||||
// 调用完更新之后,删除这条消息
|
||||
IMLib.deleteMessagesByIds([message.messageId])
|
||||
} else if (message.objectName === IMLib.ObjectName.ContactNotification) {
|
||||
if (message.content.operation === 'Request') {
|
||||
// 触发一个新好友的通知事件,【会话列表,通讯录,新朋友】页面
|
||||
uni.$emit('onNewContactConversation', message)
|
||||
uni.$emit('onNewContactFriends', message)
|
||||
uni.$emit('onNewContactPendings', message)
|
||||
} else if (message.content.operation === 'Delete') {
|
||||
IMLib.cleanHistoryMessages(1, message.targetId, message.sentTime, false)
|
||||
// 解散了就删了吧
|
||||
IMLib.removeConversation(1, message.targetId)
|
||||
// 刷新会话列表
|
||||
uni.$emit('onUserDelete_' + message.targetId)
|
||||
uni.$emit('onReceiveMessage', message)
|
||||
}
|
||||
} else if (message.objectName === IMLib.ObjectName.GroupNotification) {
|
||||
// 这个是为了更新消息列表页的
|
||||
uni.$emit('onReceiveMessage_' + message.targetId, message)
|
||||
// 解散群
|
||||
if (message.content.operation === 'Dismiss') {
|
||||
IMLib.cleanHistoryMessages(3, message.targetId, message.sentTime,
|
||||
false)
|
||||
// 解散了就删了吧
|
||||
IMLib.removeConversation(3, message.targetId)
|
||||
// 发布群解散的消息
|
||||
uni.$emit('onGroupDismiss')
|
||||
uni.$emit('onGroupDismiss_' + message.targetId)
|
||||
} else if (message.content.operation === 'REMOVE') {
|
||||
// 要判断是否当前用户,然后把当前用户踢出到主页去, 删除聊天记录,会话列表
|
||||
if (message.content.extra == store.getters.sender.userId) {
|
||||
IMLib.cleanHistoryMessages(3, message.targetId, message.sentTime,
|
||||
false)
|
||||
// 解散了就删了吧
|
||||
IMLib.removeConversation(3, message.targetId)
|
||||
// 为了更新群列表
|
||||
uni.$emit('onGroupDismiss')
|
||||
uni.$emit('onGroupRemoveYou_' + message.targetId)
|
||||
}
|
||||
uni.$emit('onReceiveMessage_' + message.targetId, message)
|
||||
// 这个是为了更新消息列表页的
|
||||
}
|
||||
// 触发刷新会话列表
|
||||
uni.$emit('onReceiveMessage', message)
|
||||
}
|
||||
})
|
||||
// 监听私聊消息已读回执
|
||||
IMLib.addReadReceiptReceivedListener(({
|
||||
data
|
||||
}) => {
|
||||
console.error("监听私聊消息已读回执: ", data);
|
||||
uni.$emit('onReadReceiptReceived', data)
|
||||
})
|
||||
// 监听消息撤回操作
|
||||
IMLib.addRecallMessageListener(({
|
||||
data
|
||||
}) => {
|
||||
IMLib.getMessage(data.messageId, ({
|
||||
message
|
||||
}) => {
|
||||
console.error("消息撤回: ", message);
|
||||
im.setNotifyBadge()
|
||||
uni.$emit('onReceiveMessage', message)
|
||||
uni.$emit('onRecallMessage_' + message.targetId, message)
|
||||
})
|
||||
})
|
||||
// 监听需要群聊消息回执
|
||||
IMLib.addReceiptRequestListener(({
|
||||
data
|
||||
}) => {
|
||||
uni.$emit('onReceiptRequest', data)
|
||||
})
|
||||
// 群消息已读的回执
|
||||
IMLib.addReceiptResponseListener(({
|
||||
data
|
||||
}) => {
|
||||
// 获取本地消息
|
||||
IMLib.getMessageByUId(data.messageUId, ({
|
||||
message
|
||||
}) => {
|
||||
const readers = Object.keys(data.users).length
|
||||
const extra = JSON.stringify({
|
||||
readers
|
||||
})
|
||||
// 在消息的扩展数据中,设置已读数量
|
||||
IMLib.setMessageExtra(message.messageId, extra, (result) => {
|
||||
message.extra = extra
|
||||
uni.$emit('onReceiptResponse', message)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const callLibListeners = () => {
|
||||
// 音视频通话相关的
|
||||
// 监听通话呼入
|
||||
CallLib.onCallReceived(({
|
||||
data
|
||||
}) => {
|
||||
console.error('onCallReceived');
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/private/call?targetId=' + data.targetId + '&mediaType=' +
|
||||
data.mediaType
|
||||
})
|
||||
})
|
||||
// 通话建立成功
|
||||
CallLib.onCallConnected(() => {
|
||||
uni.$emit('onCallConnected')
|
||||
})
|
||||
// 外呼
|
||||
CallLib.onCallOutgoing((res) => {
|
||||
console.error('onCallOutgoing', res);
|
||||
uni.$emit('onCallOutgoing')
|
||||
})
|
||||
// 远端响铃
|
||||
CallLib.onRemoteUserRinging((res) => {
|
||||
console.error('onRemoteUserRinging', res);
|
||||
uni.$emit('onRemoteUserRinging')
|
||||
})
|
||||
// 远端加入
|
||||
CallLib.onRemoteUserJoined((res) => {
|
||||
console.error('远端接听');
|
||||
uni.$emit('onRemoteUserJoined')
|
||||
})
|
||||
// 断开链接
|
||||
CallLib.onCallDisconnected((res) => {
|
||||
console.error('断开链接', res)
|
||||
uni.$emit('onCallDisconnected')
|
||||
})
|
||||
// 远端挂断
|
||||
CallLib.onRemoteUserLeft((res) => {
|
||||
console.error('远端离开', res)
|
||||
uni.$emit('onRemoteUserLeft')
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
imLibListeners,
|
||||
callLibListeners
|
||||
}
|
||||
@@ -1,318 +0,0 @@
|
||||
import store from '@/store/index.js'
|
||||
|
||||
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||
|
||||
const getMessageList = (conversationType, targetId, timeStamp, count, isForward, callback) => {
|
||||
// 获取消息列表 https://doc.rongcloud.cn/imserver/server/v1/message/objectname#objectName
|
||||
const objectNames = [
|
||||
'RC:TxtMsg',
|
||||
'RC:VcMsg',
|
||||
'RC:HQVCMsg',
|
||||
'RC:ImgMsg',
|
||||
'RC:GIFMsg',
|
||||
'RC:ImgTextMsg',
|
||||
'RC:FileMsg',
|
||||
'RC:LBSMsg',
|
||||
'RC:SightMsg',
|
||||
'RC:ReferenceMsg',
|
||||
'RC:CombineMsg',
|
||||
'RC:GrpNtf',
|
||||
'RC:InfoNtf',
|
||||
'RC:RcNtf',
|
||||
'RC:IWNormalMsg'
|
||||
]
|
||||
|
||||
RongIMLib.getHistoryMessagesByTimestamp(
|
||||
conversationType,
|
||||
targetId,
|
||||
objectNames,
|
||||
timeStamp,
|
||||
count,
|
||||
isForward,
|
||||
({
|
||||
code,
|
||||
messages
|
||||
}) => {
|
||||
if (code === 0) {
|
||||
callback(messages)
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: code
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// 获取好友申请列表
|
||||
const getPendingList = (callback, total) => {
|
||||
total = total || 100
|
||||
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], total, 0, (res) => {
|
||||
if (res.code === 0) {
|
||||
const pendings = res.conversations.filter((item) => {
|
||||
return item.objectName == RongIMLib.ObjectName.ContactNotification &&
|
||||
item.latestMessage.operation === 'Request'
|
||||
})
|
||||
|
||||
callback(pendings)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 群组申请列表,邀请列表
|
||||
const getGroupPendinglist = (targetId, callback) => {
|
||||
const conversationType = RongIMLib.ConversationType.SYSTEM
|
||||
const objectNames = ['RC:ContactNtf']
|
||||
|
||||
RongIMLib.getHistoryMessagesByTimestamp(conversationType, targetId, objectNames, 0, 1000, true,
|
||||
({
|
||||
messages
|
||||
}) => {
|
||||
callback(messages)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送文本消息
|
||||
* @param {number} conversationType 消息类型
|
||||
* @param {string} targetId 会话id
|
||||
* @param {string} content 消息内容
|
||||
* @param {function} callback 回调函数
|
||||
*/
|
||||
const sentText = (conversationType, targetId, content) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const message = {
|
||||
conversationType: conversationType,
|
||||
targetId: String(targetId),
|
||||
content: {
|
||||
objectName: 'RC:TxtMsg',
|
||||
content: content,
|
||||
userInfo: store.getters.sender
|
||||
}
|
||||
}
|
||||
|
||||
sendCommonMessage(message, (messageId) => {
|
||||
resolve(messageId)
|
||||
}, (errCode) => {
|
||||
reject(errCode)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* @param {number} conversationType 消息类型
|
||||
* @param {string} targetId 会话id
|
||||
* @param {string} voiceUrl 录音的本地路径
|
||||
* @param {integer} time 录音时长
|
||||
* @param {function} user 本人信息
|
||||
*/
|
||||
const sentVoice = (conversationType, targetId, voiceUrl, time) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const msg = {
|
||||
conversationType: conversationType,
|
||||
targetId: String(targetId),
|
||||
content: {
|
||||
objectName: 'RC:HQVCMsg',
|
||||
local: 'file://' + plus.io.convertLocalFileSystemURL(voiceUrl),
|
||||
duration: time == 0 ? 1 : time,
|
||||
userInfo: store.getters.sender
|
||||
}
|
||||
}
|
||||
RongIMLib.sendMediaMessage(msg, {
|
||||
success: (messageId) => {
|
||||
if (conversationType == 3) {
|
||||
RongIMLib.sendReadReceiptRequest(messageId)
|
||||
}
|
||||
resolve(messageId)
|
||||
},
|
||||
progress: (progress, messageId) => {},
|
||||
cancel: (messageId) => {},
|
||||
error: (errorCode, messageId) => {
|
||||
reject(errorCode)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 发送的图片,可能会涉及到一次多张,用Promise来确保前端一次性清算
|
||||
const sentImage = (conversationType, targetId, imageUrl) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getImageInfo({
|
||||
src: imageUrl,
|
||||
success: (imgInfo) => {
|
||||
const msg = {
|
||||
conversationType: conversationType,
|
||||
targetId: String(targetId),
|
||||
content: {
|
||||
objectName: 'RC:ImgMsg',
|
||||
local: imgInfo.path,
|
||||
userInfo: store.getters.sender
|
||||
}
|
||||
}
|
||||
RongIMLib.sendMediaMessage(msg, {
|
||||
success: (messageId) => {
|
||||
if (conversationType == 3) {
|
||||
RongIMLib.sendReadReceiptRequest(messageId)
|
||||
}
|
||||
resolve(messageId)
|
||||
},
|
||||
progress: (progress, messageId) => {},
|
||||
cancel: (messageId) => {},
|
||||
error: (errorCode, messageId) => {
|
||||
reject(errorCode)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const sentFile = (conversationType, targetId, fileUrl) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const msg = {
|
||||
conversationType: conversationType,
|
||||
targetId: String(targetId),
|
||||
content: {
|
||||
objectName: 'RC:FileMsg',
|
||||
local: plus.io.convertLocalFileSystemURL(fileUrl),
|
||||
userInfo: store.getters.sender
|
||||
}
|
||||
}
|
||||
|
||||
RongIMLib.sendMediaMessage(msg, {
|
||||
success: (messageId) => {
|
||||
if (conversationType == 3) {
|
||||
RongIMLib.sendReadReceiptRequest(messageId)
|
||||
}
|
||||
resolve(messageId)
|
||||
},
|
||||
progress: (progress, messageId) => {},
|
||||
cancel: (messageId) => {},
|
||||
error: (errorCode, messageId) => {
|
||||
reject(errorCode)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 发送地理位置
|
||||
const sentLocation = (conversationType, targetId, location, thumbnail) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const message = {
|
||||
conversationType: conversationType,
|
||||
targetId: String(targetId),
|
||||
content: {
|
||||
customType: 2,
|
||||
objectName: 'RC:LBSMsg',
|
||||
customFields: {
|
||||
name: location.name,
|
||||
address: location.address,
|
||||
latitude: Number(location.latitude),
|
||||
longitude: Number(location.longitude),
|
||||
thumbnail: thumbnail
|
||||
},
|
||||
userInfo: store.getters.sender,
|
||||
}
|
||||
}
|
||||
|
||||
sendCommonMessage(message, (messageId) => {
|
||||
resolve(messageId)
|
||||
}, (errCode) => {
|
||||
reject(errCode)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送视频通话结果
|
||||
*/
|
||||
const sentVideo = (conversationType, targetId, status, time) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const message = {
|
||||
conversationType: conversationType,
|
||||
targetId: String(targetId),
|
||||
content: {
|
||||
customType: 2,
|
||||
objectName: 'RC:VideoMsg',
|
||||
customFields: {
|
||||
status: status,
|
||||
duration: time
|
||||
},
|
||||
userInfo: store.getters.sender,
|
||||
}
|
||||
}
|
||||
|
||||
sendCommonMessage(message, (messageId) => {
|
||||
resolve(messageId)
|
||||
}, (errCode) => {
|
||||
reject(errCode)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送语音通话结果
|
||||
*/
|
||||
const sentAudio = (conversationType, targetId, status, time) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const message = {
|
||||
conversationType: conversationType,
|
||||
targetId: String(targetId),
|
||||
content: {
|
||||
customType: 2,
|
||||
objectName: 'RC:AudioMsg',
|
||||
customFields: {
|
||||
status: status,
|
||||
duration: time
|
||||
},
|
||||
userInfo: store.getters.sender,
|
||||
}
|
||||
}
|
||||
|
||||
sendCommonMessage(message, (messageId) => {
|
||||
resolve(messageId)
|
||||
}, (errCode) => {
|
||||
reject(errCode)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送普通消息
|
||||
*/
|
||||
const sendCommonMessage = (message, success, fail) => {
|
||||
RongIMLib.sendMessage(message, ({
|
||||
code,
|
||||
messageId
|
||||
}) => {
|
||||
if (code === 0) {
|
||||
if (message.conversationType == 3) {
|
||||
RongIMLib.sendReadReceiptRequest(messageId)
|
||||
}
|
||||
|
||||
success(messageId)
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '发送失败' + code
|
||||
})
|
||||
fail(code)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
getMessageList,
|
||||
getPendingList,
|
||||
getGroupPendinglist,
|
||||
sentText,
|
||||
sentVoice,
|
||||
sentImage,
|
||||
sentFile,
|
||||
sentLocation,
|
||||
sentVideo,
|
||||
sentAudio
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import {
|
||||
usqlite
|
||||
} from '@/uni_modules/onemue-USQLite/js_sdk/usqlite.js'
|
||||
|
||||
const contactModel = usqlite.model('contacts', {
|
||||
targetId: {
|
||||
type: String,
|
||||
primaryKey: true,
|
||||
unique: true
|
||||
},
|
||||
name: String,
|
||||
remark: String,
|
||||
hash: {
|
||||
type: String,
|
||||
unique: true
|
||||
},
|
||||
type: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
portraitUrl: String,
|
||||
localAvatar: String
|
||||
})
|
||||
|
||||
export {
|
||||
contactModel
|
||||
}
|
||||
Reference in New Issue
Block a user