diff --git a/common/baseStyle.scss b/common/baseStyle.scss
index 4dfbda40875255523262dd7eac90db1f444cdee6..4b770549e135530540cf1d8572b496d687395838 100644
--- a/common/baseStyle.scss
+++ b/common/baseStyle.scss
@@ -1,6 +1,7 @@
/* #ifdef H5 */
::v-deep {
/* #endif */
+ #app,
page,
view,
label
@@ -34,7 +35,6 @@
text,
textarea,
video {
- position: relative;
box-sizing: border-box;
}
diff --git a/common/config.js b/common/config.js
index 0650fabec0167cab703c923f379c71b3c7c323c9..39243b12518b8dc87043fb596f688fe5d9600d18 100644
--- a/common/config.js
+++ b/common/config.js
@@ -1,4 +1,9 @@
export default {
+ // 云存储服务商
+ cloudFile:{
+ // 云存储服务商,支持:aliyun、tencent、qiniu
+ provider: 'qiniu',
+ },
uniPush: {
// 消息渠道设置,避免被限量推送、静默推送(静音且需下拉系统通知栏才可见通知内容)详情文档:https://doc.dcloud.net.cn/uniCloud/uni-cloud-push/api.html#channel
channel:{
@@ -7,5 +12,7 @@ export default {
// 消息渠道描述,会显示在手机系统关于当前应用的通知设置中
desc: "客服消息"
}
- }
+ },
+ // web端绑定的域名,用于生成二维码等
+ domain: 'https://im.dcloud.net.cn',
}
\ No newline at end of file
diff --git a/components/uni-im-chat-input/uni-im-chat-input.vue b/components/uni-im-chat-input/uni-im-chat-input.vue
index 3d4b5df044d1e9efeeed5c1e6c9b97b03f1cefee..a6dd13e102f5f6e818ee08180c41bb755fda1aa0 100644
--- a/components/uni-im-chat-input/uni-im-chat-input.vue
+++ b/components/uni-im-chat-input/uni-im-chat-input.vue
@@ -1,4 +1,4 @@
-
+
@@ -26,7 +28,7 @@
-
+
@@ -61,17 +63,17 @@
↵ 发送 / shift + ↵ 换行
-
-
-
-
-
+ }
+ }
+
+
\ No newline at end of file
diff --git a/components/uni-im-choose-user/uni-im-choose-user.vue b/components/uni-im-choose-user/uni-im-choose-user.vue
new file mode 100644
index 0000000000000000000000000000000000000000..17eea34cd930c3207406a8cb1215d7c3d6be6f18
--- /dev/null
+++ b/components/uni-im-choose-user/uni-im-choose-user.vue
@@ -0,0 +1,126 @@
+
+
+ {{title}}:
+
+
+ {{user.nickname}}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/uni-im-conversation-list/changeMute.js b/components/uni-im-conversation-list/changeMute.js
deleted file mode 100644
index a9164894e544f295d1d5d91af4b04b2b5c6cebcc..0000000000000000000000000000000000000000
--- a/components/uni-im-conversation-list/changeMute.js
+++ /dev/null
@@ -1,19 +0,0 @@
-export default function changeMute(conversation) {
- conversation.mute = !conversation.mute
- const db = uniCloud.database();
- db.collection('uni-im-conversation')
- .doc(conversation._id)
- .update({
- "mute": conversation.mute
- })
- .then((e) => {
- console.log('updated 消息免打扰设置', e.result.updated, conversation._id)
- })
- .catch(() => {
- uni.showToast({
- title: '服务端错误,消息免打扰设置失败,请稍后重试',
- icon: 'none'
- });
- conversation.mute = !conversation.mute
- })
-}
diff --git a/components/uni-im-conversation-list/uni-im-conversation-list.vue b/components/uni-im-conversation-list/uni-im-conversation-list.vue
index a551dd45d78ea3f608cde3c0ba075f9433f5018c..15c31d5f03da83a742536430e1dea5e780645145 100644
--- a/components/uni-im-conversation-list/uni-im-conversation-list.vue
+++ b/components/uni-im-conversation-list/uni-im-conversation-list.vue
@@ -1,39 +1,45 @@
+
+
+ {{item.title}}
+
+
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
uniIm.conversation,
loadMoreContentText() {
return {
contentrefresh: "正在加载...",
@@ -88,11 +93,31 @@ export default {
}
},
conversationList() {
- return uniIm.conversation.dataList
+ const conversationList = uniIm.conversation.dataList
// #ifdef H5
.filter(i => i.title.toLowerCase().includes(this.keyword.toLowerCase()))
// #endif
.filter(i => !i.hidden)
+ .filter(conversation=>{
+ if(typeof this.activeTypeId === 'object' && Object.keys(this.activeTypeId)[0] === 'group_type'){
+ return conversation.group?.type === this.activeTypeId.group_type
+ }else{
+ const action = {
+ all:()=>true,
+ unread:()=>conversation.unread_count > 0 || this.oldUnreadCid?.includes(conversation.id),
+ group:()=>conversation.group_id,
+ single:()=>!conversation.group_id,
+ is_star:()=>conversation.is_star
+ }
+ return action[this.activeTypeId]?.()
+ }
+ })
+ if(this.activeTypeId === 'unread'){
+ this.oldUnreadCid = conversationList?.map(i=>i.id)
+ }else{
+ this.oldUnreadCid = []
+ }
+ return conversationList
}
},
watch: {
@@ -108,7 +133,7 @@ export default {
// 重试次数
let tryIndex = 0
const scrollToCurrentConversation = () => {
- if (tryIndex > 5) {
+ if (!activeConversationId || tryIndex > 5) {
return
}
const query = uni.createSelectorQuery().in(this);
@@ -132,12 +157,38 @@ export default {
})
}).exec()
}
- scrollToCurrentConversation()
+ setTimeout(() => {
+ scrollToCurrentConversation()
+ },300)
// #endif
}
},
- mounted() {},
+ async mounted() {
+ // 监听鼠标移入conversation-type 后滚动事件,并设置滚动条位置
+ // #ifdef H5
+ const tagBox = this.$el.querySelector('.conversation-type')
+ function scrollFunc(e) {
+ tagBox.scrollLeft += e.deltaY/5
+ }
+ tagBox.addEventListener('mouseover', (e) => {
+ tagBox.addEventListener('wheel', scrollFunc)
+ })
+ tagBox.addEventListener('mouseout', (e) => {
+ tagBox.removeEventListener('wheel', scrollFunc)
+ })
+ // #endif
+ },
methods: {
+ changeType(tagId){
+ this.activeTypeId = tagId
+ uniIm.conversation.hasMore = true
+ uniIm.conversation.loadMore.type = tagId
+ this.listScrollTop = ''
+ this.$nextTick(()=>{
+ this.listScrollTop = 0
+ })
+ this.loadMore()
+ },
onScroll(e) {
currentScrollTop = e.detail.scrollTop
this.$emit('onScroll', e)
@@ -204,6 +255,12 @@ export default {
conversation.setUnreadCount(conversation.unread_count ? 0 : 1)
}
},
+ {
+ "title": (conversation.is_star ? "取消" : "设为") + "星标",
+ "action": () => {
+ conversation.changeIsStar()
+ }
+ },
{
"title": conversation.mute ? "允许消息通知" : "消息免打扰",
"action": () => {
@@ -245,8 +302,35 @@ export default {
diff --git a/components/uni-im-group-notification/uni-im-group-notification.vue b/components/uni-im-group-notification/uni-im-group-notification.vue
index fbbb90127850df9bec12115041a2bf9c8410fd53..874a8938c51f1ce1fb305b02713231b8f68c28d3 100644
--- a/components/uni-im-group-notification/uni-im-group-notification.vue
+++ b/components/uni-im-group-notification/uni-im-group-notification.vue
@@ -50,7 +50,7 @@
diff --git a/components/uni-im-msg-list/components/filter-contorl/filter-contorl.vue b/components/uni-im-msg-list/components/filter-contorl/filter-contorl.vue
new file mode 100644
index 0000000000000000000000000000000000000000..51cdabb57733be21d94b68680067e776c5fbdd18
--- /dev/null
+++ b/components/uni-im-msg-list/components/filter-contorl/filter-contorl.vue
@@ -0,0 +1,65 @@
+
+
+ 已进入话题
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/uni-im-msg-list/components/uni-im-list-item/uni-im-list-item.vue b/components/uni-im-msg-list/components/uni-im-list-item/uni-im-list-item.vue
deleted file mode 100644
index 9e78568c5fcebc2cb9482e86374841410f1bc425..0000000000000000000000000000000000000000
--- a/components/uni-im-msg-list/components/uni-im-list-item/uni-im-list-item.vue
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
diff --git a/components/uni-im-msg-list/uni-im-msg-list.vue b/components/uni-im-msg-list/uni-im-msg-list.vue
index a3bc9dacb2bdc856071cf585493b09c8abd60e6c..6fa0b3961e5c208b28761774ba693166d482c666 100644
--- a/components/uni-im-msg-list/uni-im-msg-list.vue
+++ b/components/uni-im-msg-list/uni-im-msg-list.vue
@@ -1,34 +1,35 @@
-
+
+
-
-
+
-
+
-
-
+
@@ -65,14 +66,9 @@
* @see module:uni-im-list
*/
import uniIm from '@/uni_modules/uni-im/sdk/index.js';
- import {
- store as uniIdStore
- } from '@/uni_modules/uni-id-pages/common/store';
-
import uniImList from './components/uni-im-list/uni-im-list';
+ import filterContorl from './components/filter-contorl/filter-contorl';
- // 一页多少条数据
- let pageLimit = 30
// 当前页面滚动条高度
let currentScrollTop = 0
@@ -80,33 +76,40 @@
export default {
components: {
- uniImList
+ uniImList,
+ filterContorl
},
- emits:['checkedMsgList','update:checkedMsgList','longpressMsgAvatar','showControl','clickItem','retriesSendMsg','putChatInputContent'],
+ emits:['checkedMsgList','update:checkedMsgList','longpressMsgAvatar','showControl','clickItem','retriesSendMsg','putChatInputContent','showMenberList'],
computed: {
...uniIm.mapState(['systemInfo', 'isWidescreen']),
- loadState() {
- return this.hasMore ? '正在加载历史消息' : '没有更多历史消息'
- },
- hasMore() {
- return this.conversation.hasMore
+ loadStatus() {
+ return this.conversation.msg.hasMore ? 'loading' : 'noMore'
},
visibleMsgList() {
- const msgList = this.conversation.msgList || []
- // 过滤掉,撤回消息的指令型消息 、 群头像更新(指令型)消息
- const visibleMsgList = uniIm.utils.filterMsgList(msgList)
- // 返回倒数 laterRenderIndex 条消息,实现懒渲染
- .slice(-this.laterRenderIndex)
+ const visibleMsgList = this.conversation.msg.visibleDataList()
+ // console.log('visibleMsgList',visibleMsgList);
this.$nextTick(() => {
- uniIm.utils.throttle(this.setIntersectionObserver, 3000);
+ uniIm.utils.throttle(this.setIntersectionObserver, 1000);
})
+
+ if(this.filterAsUid.length > 0){
+ return visibleMsgList.filter(i=>this.filterAsUid.includes(i.from_uid))
+ }
+ // console.log('visibleMsgList.l',visibleMsgList.length);
return visibleMsgList
+ },
+ //当前用户自己的uid
+ currentUid() {
+ return uniIm.currentUser._id;
}
},
data() {
return {
conversation: {
- hasMore: true,
+ msg: {
+ hasMore: true,
+ visibleDataList: () => []
+ },
has_unread_group_notification: false,
group_info: {
notification: false
@@ -117,9 +120,7 @@
hasNewMsg: false,
call_list: [],
activeMsgId: "",
- loadMoreIng: false,
- // 延迟渲染,避免页面卡顿
- laterRenderIndex: pageLimit
+ filterAsUid:[]
}
},
watch: {
@@ -128,7 +129,7 @@
},
'conversation.has_unread_group_notification': {
async handler(hasUnreadGroupNotification) {
- const group_notification = this.conversation?.group_info?.notification
+ const group_notification = this.conversation?.group?.notification
const conversation_id = this.conversationId
// 弹出群公告
if (hasUnreadGroupNotification && group_notification && group_notification.content) {
@@ -147,13 +148,19 @@
this.closeGroupNotification()
} else {
this.$refs["group-notification-popup"].open()
- this.$nextTick(() => {
+ setTimeout(() => {
this.$refs["group-notification"].notification = group_notification
- })
+ },0)
}
}
},
immediate: true
+ },
+ filterAsUid(filterAsUid,old){
+ this.$refs['filter-contorl'].userIdList = filterAsUid
+ if(filterAsUid.length === 0 || old.length === 0){
+ setTimeout(this.showLast,0)
+ }
}
},
props: {
@@ -172,12 +179,6 @@
}
},
async mounted() {
- // for (var i = 0; i < 10; i++) {
- // this.msgList.unshift({
- // t:i
- // })
- // }
- //
},
destroyed() {
// console.log('destroyed')
@@ -190,53 +191,52 @@
if (this.intersectionObserver){
this.intersectionObserver.disconnect()
}
- this.conversation = await uniIm.conversation.get(this.conversationId)
+ this.conversation = uniIm.conversation.find(this.conversationId)
+
// init data --start
this.scrollIntoView = ''
this.scrollTop = 0
currentScrollTop = 0
- this.laterRenderIndex = pageLimit
- if (!this.conversation.isInit) {
- this.conversation.hasMore = true
- await this.loadMore()
- this.conversation.isInit = true
- if (this.conversation.hasMore && this.visibleMsgList.length < pageLimit) {
- console.log('不满一屏时,再loadMore一次');
- await this.loadMore()
+ const showLast = ()=>{
+ // #ifdef H5
+ // 非web-pc端,list是颠倒的,所以默认显示最后一条。而web-pc端是正常的,所以需要滚动到底部
+ if(this.isWidescreen){
+ this.showLast()
}
+ // #endif
}
-
- if(this.isWidescreen){
- this.$nextTick(()=>{
- this.showLast()
- // TODO:未知原因,部分情况下 $nextTick时机执行不能定位到最后一条,需要用setTimeout 500再次定位
- setTimeout(() => {
- this.showLast()
- },500)
- })
+
+ if(this.visibleMsgList.length === 0){
+ await this.loadMore(showLast)
+ } else {
+ showLast()
+ setTimeout(async()=>{
+ const msgIsOverFlow = await this.msgIsOverFlow()
+ if(this.visibleMsgList.length === 0 || !msgIsOverFlow){
+ await this.loadMore(showLast)
+ }
+ },0)
+ }
+ },
+ async msgIsOverFlow(){
+ if(this.visibleMsgList.length > 0){
+ // 计时
+ // console.time('getElInfo')
+ let firstMsgTop = (await this.getElInfo('#item-0')).top
+ let lastMsgBottom = (await this.getElInfo('#item-' + (this.visibleMsgList.length - 1) )).bottom
+ const listElInfo = await this.getElInfo('.uni-im-list')
+ // console.timeEnd('getElInfo')
+ return firstMsgTop < listElInfo.top || lastMsgBottom > listElInfo.bottom
+ }else{
+ return true
}
},
async loadMore(callback) {
let datas = []
- if(this.laterRenderIndex < this.conversation.msgList.length){
- let oldVisibleMsgList = JSON.parse(JSON.stringify(this.visibleMsgList))
- await this.canHoldScrollDo(()=>{
- this.laterRenderIndex += pageLimit
- })
- await this.$nextTick()
- // 新加载到的数据为:oldVisibleMsgList和this.visibleMsgList的差集
- datas = this.visibleMsgList.filter(i => !oldVisibleMsgList.some(j => j._id == i._id))
- // console.log('beforeLoadMore 懒渲染=>',this.laterRenderIndex,this.conversation.msgList.length);
- }else{
- datas = await this.conversation.msgManager.getHistory()
- // console.error(`加载到${datas.length}条,历史聊天数据`);
- // console.log('加载到历史聊天数据:', datas);
- if (datas.length === 0) {
- this.conversation.hasMore = false
- } else {
- await this.insertMsg(datas)
- }
+ datas = await this.conversation.msg.getMore()
+ if(datas.length){
+ await this.insertMsg(datas)
}
if (typeof callback === 'function') {
// 为兼容 web pc端特殊场景 不能使用$nextTick
@@ -246,13 +246,6 @@
}
return datas
},
- async beforeLoadMore() {
- if (!this.loadMoreIng && this.hasMore) {
- this.loadMoreIng = true
- await this.loadMore()
- this.loadMoreIng = false
- }
- },
msgOnAppear(msgId){
uniIm.utils.throttle(()=>{
let index = this.visibleMsgList.findIndex(i => i._id == msgId)
@@ -267,10 +260,9 @@
if (this.intersectionObserver) {
// console.log('this.intersectionObserver存在','执行销毁');
this.intersectionObserver.disconnect()
+ await uniIm.utils.sleep(1000)
}
- await uniIm.utils.sleep(1000)
-
this.intersectionObserver = uni.createIntersectionObserver(this, { observeAll: true })
.relativeTo('.uni-im-list', {})
.observe('.uni-im-msg', (res) => {
@@ -306,22 +298,16 @@
// 是否为第一个消息
if (isFirstMsg) {
// console.log('第一个消息出现在视窗内,加载更多',this.visibleMsgList[0]?._id , msgId);
- this.beforeLoadMore()
+ this.loadMore()
}
// 调用扩展点,通知消息列表某条消息进入显示区。
- uniIm.extensions.invokeExts('msg-appear', msgRef.msg, {
- user_id: uniCloud.getCurrentUserInfo().uid,
- isInternalUser: this.uniIDHasRole('staff'),
- })
+ uniIm.extensions.invokeExts('msg-appear', msgRef.msg)
} else if (!res.intersectionRatio > 0 && hasBeenDisplayed) {
appearObj[msgId] = false;
msgRef.onDisappear()
// console.error('消失了',msgRef.msg.body)
// 调用扩展点,通知消息列表某条消息离开显示区。
- uniIm.extensions.invokeExts('msg-disappear', msgRef.msg, {
- user_id: uniCloud.getCurrentUserInfo().uid,
- isInternalUser: this.uniIDHasRole('staff'),
- })
+ uniIm.extensions.invokeExts('msg-disappear', msgRef.msg)
}
})
},
@@ -350,24 +336,26 @@
*/
// #ifdef H5
if(this.isWidescreen){
- if(this.systemInfo.browserName === "chrome"){
+ if(window.chrome){
// console.error('currentScrollTop',currentScrollTop)
- if(currentScrollTop === 0 && this.visibleMsgList.length != 0){
+ // console.error('this.visibleMsgList.length',this.visibleMsgList.length)
+ const msgIsOverFlow = await this.msgIsOverFlow()
+ if(msgIsOverFlow && currentScrollTop === 0 && this.visibleMsgList.length != 0){
this.scrollTop = currentScrollTop
- currentScrollTop += 1
- await this.$nextTick(()=>this.scrollTop = currentScrollTop)
-
+ await this.$nextTick(()=> this.scrollTop = (currentScrollTop + 1) )
if(!this.canHoldScrollDo.tryIndex){
this.canHoldScrollDo.tryIndex = 1
}else{
this.canHoldScrollDo.tryIndex ++
}
-
- if(this.canHoldScrollDo.tryIndex > 100){
- console.error('canHoldScrollDo tryIndex > 100')
+ if(this.canHoldScrollDo.tryIndex > 10){
+ console.warn('canHoldScrollDo tryIndex > 10',this.canHoldScrollDo.tryIndex,currentScrollTop,this.visibleMsgList.length)
+ this.canHoldScrollDo.tryIndex = 0
fn()
}else{
- this.$nextTick(()=>this.canHoldScrollDo(fn))
+ setTimeout(()=>{
+ this.canHoldScrollDo(fn)
+ },300)
}
}else{
fn()
@@ -376,13 +364,13 @@
const getScrollContentHeight = ()=>document.querySelector('.scroll-content').offsetHeight
let scrollContent = getScrollContentHeight()
fn()
- this.$nextTick(()=>{
+ // 下一个事件循环中,重新计算滚动条的高度
+ setTimeout(()=>{
const diff = getScrollContentHeight() - scrollContent
- console.error( diff, diff)
+ // console.error( 'diff', diff)
this.scrollTop = currentScrollTop
- currentScrollTop += diff
- this.$nextTick(()=> this.scrollTop = currentScrollTop)
- })
+ this.$nextTick(()=> this.scrollTop = currentScrollTop + diff)
+ },0)
}
return
}
@@ -390,12 +378,13 @@
fn()
},
async insertMsg(data) {
- // 重新获取会话对象,防止web pc端 切换太快引起的会话对象指向错误
- const conversation = await uniIm.conversation.get(data[0].conversation_id)
- this.canHoldScrollDo(()=>{
- conversation.msgList.unshift(...data)
- // 有新消息插入laterRenderIndex的值重新设置
- this.laterRenderIndex += data.length
+ return await new Promise((resolve) => {
+ this.canHoldScrollDo(async ()=>{
+ // 重新获取会话对象,防止web pc端 切换太快引起的会话对象指向错误
+ const conversation = await uniIm.conversation.get(data[0].conversation_id)
+ conversation.msg.add(data,{unshift:true})
+ resolve()
+ })
})
},
equalPrevTime(index) {
@@ -432,7 +421,7 @@
const query = uni.createSelectorQuery().in(this);
query.select(select).boundingClientRect(data => {
if (!data) {
- console.log('找不到 showMsgByIndex' + select);
+ console.log('找不到 showMsgByIndex:' + select);
return rejece(false)
}
resolve(data)
@@ -465,32 +454,55 @@
// 设置一个新值触发视图更新 -> 滚动
this.$nextTick(async () => {
this.scrollTop = val
- currentScrollTop = val
// console.error('currentScrollTop',currentScrollTop)
})
},
+ // 进入话题
+ intoTopic(msgId) {
+ let currentMsg = this.conversation.msg.find(msgId)
+ const getAboutUser = msg => {
+ const aboutUid = [msg.from_uid];
+ const about_msg_id = msg.about_msg_id
+ if(!about_msg_id){
+ return aboutUid
+ }
+ const aboutMsg = this.conversation.msg.find(about_msg_id)
+ if(aboutMsg){
+ aboutUid.push(...getAboutUser(aboutMsg))
+ }
+ // 去重
+ return [...new Set(aboutUid)]
+ }
+
+ this.filterAsUid = getAboutUser(currentMsg)
+ },
+ showMenberList(){
+ this.$emit('showMenberList',arguments[0])
+ },
async showMsgById(msgId) {
// 找到消息的索引
let index = this.visibleMsgList.findIndex(i => i._id == msgId)
+ // 如果找不到,先加载更多,再找
if (index === -1) {
- // 如果找不到,先加载更多,再找
- uni.showLoading();
const {_findIndex} = this.showMsgById
if (!_findIndex) {
+ uni.showLoading();
this.showMsgById._findIndex = 0
- } else if (_findIndex > 30) {
+ } else if (_findIndex > 9) {
uni.hideLoading()
this.showMsgById._findIndex = false
- return console.error('防止特殊情况下死循环,不加载30屏以外的引用数据');
+ console.error('防止特殊情况下死循环,不加载10屏以外的引用数据');
+ return uni.showToast({
+ title: '暂不支持,定向10屏以外的引用消息',
+ icon: 'none'
+ });
}
this.showMsgById._findIndex++
+ console.log('this.showMsgById._findIndex', this.showMsgById._findIndex);
await this.loadMore()
- this.showMsgById._findIndex = false
- await uniIm.utils.sleep(300)
- uni.hideLoading()
return await this.showMsgById(msgId)
}
-
+ uni.hideLoading()
this.activeMsgId = msgId
if(this.showMsgActiveColorActionT){
clearTimeout(this.showMsgActiveColorActionT)
@@ -514,7 +526,7 @@
db.collection('uni-im-conversation')
.where({
id:this.conversationId,
- user_id: uniCloud.getCurrentUserInfo().uid
+ user_id: this.currentUid
})
.update({
has_unread_group_notification: false
@@ -540,12 +552,12 @@
}
this.$emit('update:checkedMsgList', checkedMsgList)
},
- //当前用户自己的uid
- current_uid() {
- return uniCloud.getCurrentUserInfo().uid;
- },
showControl(e) {
- this.$emit('showControl', e)
+ if (this.isWidescreen || this.onScroll.end !== false){
+ this.$emit('showControl', e)
+ }else{
+ // console.log('滚动中,不响应长按弹出菜单')
+ }
},
longpressMsgAvatar(e) {
this.$emit('longpressMsgAvatar', e)
@@ -558,6 +570,9 @@
},
putChatInputContent(msgBody) {
this.$emit('putChatInputContent', msgBody)
+ },
+ updateFilterUids(uids){
+ this.filterAsUid = uids
}
}
}
@@ -566,11 +581,14 @@
\ No newline at end of file
diff --git a/components/uni-im-msg/types/file.vue b/components/uni-im-msg/types/file.vue
index 37fa8307a93dbfd1465300a83289d36484ea85fd..abd2c724a844024fa8a4dc04a39158dda0fef7cd 100644
--- a/components/uni-im-msg/types/file.vue
+++ b/components/uni-im-msg/types/file.vue
@@ -1,14 +1,10 @@
-
- {{ fileName }}
-
-
- {{ fileSize }}
-
+ {{fileName}}
+ {{fileSize}}
-
+
@@ -90,29 +86,27 @@
}
-
\ No newline at end of file
diff --git a/components/uni-im-msg/types/history.vue b/components/uni-im-msg/types/history.vue
index 38f52bba0f551d547b9659788300486e07acb13f..0e4b6af15f8d5c9f3cacf42c75990c0a185721ca 100644
--- a/components/uni-im-msg/types/history.vue
+++ b/components/uni-im-msg/types/history.vue
@@ -36,9 +36,8 @@
msg.content = typeof(msg.body) === 'string' ? msg.body.replace(/<[^>]+>/g, "") : '[多媒体类型]'
}
if(!this.msgList[0].group_id){
- let currentUid = uniCloud.getCurrentUserInfo().uid;
- let currentUidInfo = uniIm.users[currentUid];
- let currentNickname = currentUidInfo?currentUidInfo.nickname:'';
+ let currentUid = uniIm.currentUser._id;
+ let currentNickname = uniIm.users.getNickname(currentUid);
// 找到不是自己的nickname去重
let nickname = this.msgList.map(item=>item.nickname).filter(nickname=>nickname!==currentNickname)[0]
this.title = currentNickname + (nickname?'与'+nickname:'')+'的聊天记录';
@@ -66,7 +65,7 @@
}
-
\ No newline at end of file
diff --git a/components/uni-im-msg/types/order.vue b/components/uni-im-msg/types/order.vue
new file mode 100644
index 0000000000000000000000000000000000000000..eaba2d5f2295fda5ca3e0489866acf6451f69324
--- /dev/null
+++ b/components/uni-im-msg/types/order.vue
@@ -0,0 +1,159 @@
+
+
+ 订单信息
+
+ 订单编号:
+ {{orderInfo.order_id}}
+
+
+ 产品/服务名称:
+ {{orderInfo.product.name}}
+
+
+ 订单价格:
+ {{orderInfo.product.price}}元
+
+
+ 所属用户:
+ {{nickName}}
+
+
+
+ 订单状态:
+ {{status}}
+
+
+
+ 支付时间:
+ {{new Date(orderInfo.pay_time).toLocaleString()}}
+
+
+ 支付渠道:
+ {{orderInfo.pay_channel}}
+
+
+
+
+ 请在 {{new Date(orderInfo.expire_time).toLocaleString()}} 前完成支付
+
+
+
+
+
+
+
diff --git a/components/uni-im-msg/types/pay-notify.vue b/components/uni-im-msg/types/pay-notify.vue
new file mode 100644
index 0000000000000000000000000000000000000000..09a6ac9c3287014d4a663ecbfb24deaf88419fd9
--- /dev/null
+++ b/components/uni-im-msg/types/pay-notify.vue
@@ -0,0 +1,84 @@
+
+
+ 支付成功通知
+
+ 订单编号:
+ {{msg.body.order_id}}
+
+
+ 支付时间:
+ {{new Date(msg.create_time).toLocaleString()}}
+
+
+ 支付金额:
+ {{msg.body.price / 100}}元
+
+
+ 支付渠道:
+ {{msg.body.pay_channel}}
+
+
+
+
+
+
+
+
diff --git a/components/uni-im-msg/types/rich-text.vue b/components/uni-im-msg/types/rich-text.vue
index 861390594fd1b4ec9029c4e5bc612afc2ec16b23..db804f84866a7065d65f429e627b4f20d2a6f102 100644
--- a/components/uni-im-msg/types/rich-text.vue
+++ b/components/uni-im-msg/types/rich-text.vue
@@ -1,163 +1,179 @@
-
-
+
{{item.children[0].text}}
{{item.children[0].text}}
-
-
+
+
- {{item.text}}
- {{trText(item.text)}}
+
-
-
-
-
-
-
-
-
-
-
+ }
+ }
+ }
+
+
\ No newline at end of file
diff --git a/components/uni-im-msg/types/system.vue b/components/uni-im-msg/types/system.vue
index 780ca90f1762482f2b19f167a1241ff5b494c15a..25967cffae645f21d7a10293fb07a35538a1e911 100644
--- a/components/uni-im-msg/types/system.vue
+++ b/components/uni-im-msg/types/system.vue
@@ -12,8 +12,7 @@
export default {
data() {
return {
- content: false,
- create_time:false
+ create_time:0
}
},
props: {
@@ -27,49 +26,50 @@
computed: {
friendlyTime() {
return uniIm.utils.toFriendlyTime(this.create_time || this.msg.create_time || this.msg.client_create_time)
- }
- },
- watch: {
- msg: {
- handler: async function (msg, oldMsg) {
- if(msg.action.indexOf("update-group-info-") === 0){
- const key = Object.keys(msg.body.updateData)[0]
- const value = msg.body.updateData[key];
- if (key == "notification"){
- this.content = value.content
- this.create_time = value.create_time
- }else if(key == "avatar_file"){
- this.content = "群聊头像已更新"// 已在 msg-list 组件隐藏此类型消息
- }
- // mute_all_members
- else if(key == "mute_all_members"){
- this.content = value ? "已开启“全员禁言”" : "已关闭“全员禁言”"
- } else{
- this.content = {
- "name":" 群聊名称",
- "introduction":"群简介"
- }[key] + "已更新为:" + value
- }
- }else if( ["join-group","group-exit","group-expel"].includes(msg.action) ){
- let nicknameList = (await uniIm.users.get(msg.body.user_id_list)).map(item => item.nickname)
- let actionName = {
- "join-group":"加入群聊",
- "group-exit":"退出群聊",
- "group-expel":"被踢出群聊"
- }[msg.action];
- this.content = nicknameList.join(' , ') + actionName
- }else if(msg.action === "group-dissolved"){
- this.content = '此群聊已被解散'
- }else if(msg.action === "set-group-admin"){
- const {user_id,addRole,delRole} = msg.body
- const nickname = (await uniIm.users.get(user_id)).nickname
- this.content = `已将"${nickname}"${addRole.includes("admin") ? "添加为群管理员" : "从群管理员中移除"}`
- }else{
- this.content = msg.body
+ },
+ content(){
+ const msg = this.msg
+ if(msg.action.indexOf("update-group-info-") === 0){
+ const key = Object.keys(msg.body.updateData)[0]
+ const value = msg.body.updateData[key];
+ if (key == "notification"){
+ this.create_time = value.create_time
+ return value.content
+ }else if(key == "avatar_file"){
+ return "群聊头像已更新"// 已在 msg-list 组件隐藏此类型消息
+ }
+ // mute_all_members
+ else if(key == "mute_all_members"){
+ return value ? "已开启“全员禁言”" : "已关闭“全员禁言”"
+ } else{
+ return {
+ "name":" 群聊名称",
+ "introduction":"群简介"
+ }[key] + "已更新为:" + value
}
- },
- deep: true,
- immediate: true
+ }else if( ["join-group","group-exit","group-expel"].includes(msg.action) ){
+ const nicknameList = []
+ msg.body.user_id_list.forEach(async (user_id) => {
+ const nickname = uniIm.users.getNickname(user_id)
+ // console.log(nickname)
+ nicknameList.push(nickname)
+ })
+ let actionName = {
+ "join-group":"加入群聊",
+ "group-exit":"退出群聊",
+ "group-expel":"被踢出群聊"
+ }[msg.action];
+ return nicknameList.join(' , ') + actionName
+ }else if(msg.action === "group-dissolved"){
+ return '此群聊已被解散'
+ }else if(msg.action === "set-group-admin"){
+ const {user_id,addRole,delRole} = msg.body
+ const nickname = uniIm.users.getNickname(user_id)
+ // console.log(nickname)
+ return `已将"${nickname}"${addRole.includes("admin") ? "添加为群管理员" : "从群管理员中移除"}`
+ }else{
+ return msg.body
+ }
}
},
async mounted() {}
diff --git a/components/uni-im-msg/types/text.vue b/components/uni-im-msg/types/text.vue
index 8be6ba4d9ac67383e9d979bbe957ad7ed8581b6d..2705606d7755547cad87c689c8d6bef98b1ccad2 100644
--- a/components/uni-im-msg/types/text.vue
+++ b/components/uni-im-msg/types/text.vue
@@ -1,54 +1,60 @@
-
- {{ msg.body }}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/components/uni-im-msg/types/userinfo-card.vue b/components/uni-im-msg/types/userinfo-card.vue
index bdbbdc8b6b5bd033cd83161669afc00ab3434257..38ea285c7abb15fe0fd6b1d1dfc7d5e8984053cf 100644
--- a/components/uni-im-msg/types/userinfo-card.vue
+++ b/components/uni-im-msg/types/userinfo-card.vue
@@ -1,11 +1,11 @@
-
import uniIm from '@/uni_modules/uni-im/sdk/index.js';
+ import config from '@/uni_modules/uni-im/common/config.js';
export default {
props: {
msg: {
@@ -58,8 +59,20 @@
// #endif
}else{
// 文件存储的服务商
- let storageProvider = this.msg.body.url.substring(0, 8) == "cloud://" ? 'tencent' : 'aliyun'
- this.videoPoster = this.videoUrl + (storageProvider == 'aliyun' ? '?x-oss-process=video/snapshot,t_1000,f_jpg,w_200,m_fast,ar_auto':'?imageView2/0/w/200')
+ const {provider} = config.cloudFile
+ switch (provider){
+ case 'aliyun':
+ this.videoPoster = this.videoUrl + '?x-oss-process=video/snapshot,t_1000,f_jpg,w_200,m_fast,ar_auto'
+ break;
+ case 'tencent':
+ this.videoPoster = this.videoUrl + '?imageView2/0/w/200'
+ break;
+ case 'qiniu':
+ this.videoPoster = this.videoUrl + '?vframe/jpg/offset/1/w/200'
+ break;
+ default:
+ break;
+ }
}
},
deep: true,
@@ -85,39 +98,37 @@
}
-
\ No newline at end of file
diff --git a/components/uni-im-msg/uni-im-msg.vue b/components/uni-im-msg/uni-im-msg.vue
index cf7de00d464793434a7060c2a7b023712878a3bf..a448bdc90c02694b3b805d14ee5344b1f9a7cf0e 100644
--- a/components/uni-im-msg/uni-im-msg.vue
+++ b/components/uni-im-msg/uni-im-msg.vue
@@ -2,10 +2,8 @@
-
-
- {{ friendlyTime }}
-
+
+
@@ -22,30 +20,34 @@
-
- {{ msg.nickname || users.nickname }}
- 管理员
+ {{nickname}}
+ {{real_name}}
+ 管理员
+
+
+
-
+
回复的消息已被撤回
- {{ getNicknameByUid(aboutMsg.from_uid) }}:{{ aboutMsg.body }}
+ {{ getNickname(aboutMsg.from_uid) }}:{{aboutMsgNote}}
[加载中]
-
+
@@ -394,10 +422,6 @@
&,& > * {
cursor: default;
}
- .file-msg-box,
- .cloud-image {
- cursor: pointer;
- }
/* #endif */
.msg-main {
margin: 0 8px;
@@ -448,35 +472,65 @@
.nickname-box {
flex-direction: row;
align-items: center;
- }
-
- .nickname {
- font-size: 13px;
- color: #666666;
- padding-left: 2px;
+ width: 100%;
+ .nickname {
+ font-size: 14px;
+ color: #666666;
+ padding-left: 2px;
+ }
+ .real_name {
+ font-size: 12px;
+ color: #999;
+ padding:0 4px;
+ background-color: #FFF;
+ border-radius: 2px;
+ box-shadow: 0 0 2px #ddd;
+ margin-left: 3px;
+ position: relative;
+ bottom: 2px;
+ // 溢出隐藏,且显示省略号
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ &::before {
+ content: "\eab8";
+ color: #fd7e08;
+ font-size: 10px;
+ margin-right: 2px;
+ font-family: uni-im-icons;
+ }
+ }
+ .badge {
+ position: relative;
+ bottom: 2px;
+ font-size: 12px;
+ color: #FFFFFF;
+ background-color: #1ab94d;
+ padding: 1px 3px;
+ border-radius: 2px;
+ // 缩小字体
+ transform: scale(0.8);
+ &.grey {
+ background-color: #bbb;
+ }
+ }
}
/* #ifdef H5 */
- .nickname-box .nickname:hover {
- color: #0b65ff;
- cursor: pointer;
- }
- .nickname-box .nickname:hover::after {
- content: '@';
- margin-left: 3px;
+ .nickname-box {
+ .nickname.noPreview{
+ &:hover {
+ color: #0b65ff;
+ cursor: pointer;
+ &::after {
+ content: '@';
+ margin-left: 3px;
+ }
+ }
+ }
}
/* #endif */
- .isFromAdmin {
- font-size: 14px;
- color: #FFFFFF;
- background-color: #1ab94d;
- padding: 2px 3px;
- border-radius: 2px;
- transform: scale(0.7);
- margin-left: -4px;
- }
-
.rich-text {
background-color: transparent;
width: 500rpx;
@@ -518,20 +572,14 @@
height: 22px;
}
- .format-time-text {
- font-size: 12px;
- text-align: center;
- color: #999999;
- line-height: 22px;
- }
-
/* #ifdef H5 */
- .dup-format-time-text {
+ .hide .format-time-text {
display: none;
}
- &:hover .dup-format-time-text {
- display: unset;
+ &:hover .hide .format-time-text {
+ display: flex;
}
+
.pointer {
cursor: pointer;
}
diff --git a/components/uni-im-share-msg/uni-im-share-msg.vue b/components/uni-im-share-msg/uni-im-share-msg.vue
index 534ac9c64bb0e4cfa90ea7974bb6a1990a9aeb38..f82c246410b2e363b276c34a7d01bf311950c460 100644
--- a/components/uni-im-share-msg/uni-im-share-msg.vue
+++ b/components/uni-im-share-msg/uni-im-share-msg.vue
@@ -125,8 +125,8 @@ export default {
this.merge = merge;
this.msgList = msgList.map(msg => {
- let {body,from_uid,type,conversation_id,create_time,group_id} = msg;
- let data = {body,from_uid,type,conversation_id,create_time,group_id};
+ let data = Object.assign({},msg);
+ delete data._id
if (!merge) {
// 如果不是合并转发,则删除会话id和群id
data.conversation_id = '';
@@ -170,7 +170,7 @@ export default {
"to_uid": friend_uid,
conversation_id,
group_id,
- "from_uid": uniCloud.getCurrentUserInfo().uid,
+ "from_uid": uniIm.currentUser._id,
"state": 0,
"client_create_time": Date.now(),
"is_read": false,
@@ -207,9 +207,9 @@ export default {
this.close();
async function sendMsgToConversation(conversation, msg) {
// 插到消息列表
- conversation.msgList.push(msg);
+ msg = conversation.msg.add(msg);
// 保存到本地数据库
- await conversation.msgManager.localMsg.add(msg);
+ // await conversation.msgManager.localMsg.add(msg);
const uniImCo = uniCloud.importObject("uni-im-co");
await uniImCo.sendMsg(msg)
.then(async e => {
@@ -217,7 +217,6 @@ export default {
msg.state = e.errCode === 0 ? 100 : -100;
msg.create_time = e.data.create_time;
msg._id = e.data._id;
- await updateMsg(msg)
})
.catch(async e => {
uni.showModal({
@@ -229,19 +228,8 @@ export default {
// 必须要有create_time的值,否则indexDB通过创建时间索引找不到数据
msg.create_time = Date.now();
msg.state = -200;
- await updateMsg(msg)
});
}
- async function updateMsg(msg) {
- const conversation = await uniIm.conversation.get(msg.conversation_id);
- // console.log('conversation', conversation);
- let index = conversation.msgList.findIndex(_msg => _msg.unique_id == msg.unique_id)
- if (index === -1) {
- throw 'updateMsg msg 不存在'
- }
- conversation.msgList.splice(index, 1, Object.assign({}, msg))
- conversation.msgManager.localMsg.update(msg.unique_id, msg)
- }
}
}
}
@@ -288,11 +276,6 @@ export default {
border-right: 1px solid #eee;
}
- .conversation-list-box ::v-deep .conversation-list {
- max-height: calc(70vh - 60px) !important;
- height: calc(70vh - 60px) !important;
- }
-
.conversation-list-box ::v-deep .conversation-list .refresh-box {
background-color: #fff;
}
diff --git a/components/uni-im-sound/uni-im-sound.vue b/components/uni-im-sound/uni-im-sound.vue
index 90fb7337487eab6a70c9bce3bc251aaef4709b33..5a5b9f282f39a1f5d8f2dd0400405308043ba04d 100644
--- a/components/uni-im-sound/uni-im-sound.vue
+++ b/components/uni-im-sound/uni-im-sound.vue
@@ -61,7 +61,7 @@
});
uniCloud.uploadFile({
filePath:res.tempFilePath,
- cloudPath:'uni-im/' + uniCloud.getCurrentUserInfo().uid + '/sound/' + Date.now() + '.mp3',
+ cloudPath:'uni-im/' + uniIm.currentUser._id + '/sound/' + Date.now() + '.mp3',
// fileType:"audio",
success: (e) => {
// console.log('uniCloud.uploadFile-sendSoundMsg',e,'sendSoundMsg',{"url":e.fileID,time:this.time});
diff --git a/components/uni-im-view-msg/uni-im-view-msg.vue b/components/uni-im-view-msg/uni-im-view-msg.vue
index 7172cf52ad0c9fd3362a34585adb5629bb35c1c2..e9cc72a9f34b871f17d2421ce5e41e8d6f343101 100644
--- a/components/uni-im-view-msg/uni-im-view-msg.vue
+++ b/components/uni-im-view-msg/uni-im-view-msg.vue
@@ -12,17 +12,20 @@
-
-
+
+
+
+
@@ -41,11 +44,9 @@ export default {
open(msgList) {
this.showMsgList = true;
this.msgList = msgList;
- // document.getElementById('dialog').showModal();
},
close() {
this.showMsgList = false;
- // document.getElementById('dialog').close();
this.msgList = [];
}
}
@@ -54,68 +55,50 @@ export default {
\ No newline at end of file
diff --git a/pages/group/members.vue b/pages/group/members.vue
index f871b4763e7f506b5f3fb0262cb774a95053a3cb..3d14881914d2732a064d2828fbdd6a24ba14497a 100644
--- a/pages/group/members.vue
+++ b/pages/group/members.vue
@@ -2,7 +2,7 @@
-
+
@@ -16,8 +16,7 @@
@contextmenu.prevent="openConversationMenu($event,index)"
@mousemove="hoverUserId = member.users._id"
>
-
{{member.users.nickname||'匿名用户'}}
管
@@ -25,45 +24,71 @@
- {{showAllMember ? '收起' : '查看更多'}}
+
+ 收起
+
+ 加载中...
+ 查看更多
+
+
+
+ 加载中...
+ 没有更多了
+
+
+
+
+
+