Merge branch 'master' of https://git.yuzhankeji.cn/TmOct5/ZhHealth
This commit is contained in:
@@ -3,13 +3,16 @@
|
|||||||
<view class="users">
|
<view class="users">
|
||||||
<view :class="['user', {'active': item.targetId == currentUser.targetId}]" @longpress="showAction(item)"
|
<view :class="['user', {'active': item.targetId == currentUser.targetId}]" @longpress="showAction(item)"
|
||||||
v-for="(item, index) in users" :key="index" @click="toUser(item)">
|
v-for="(item, index) in users" :key="index" @click="toUser(item)">
|
||||||
<u-avatar :size="avatarSize" shape="square" :src="contact(item.targetId).portraitUrl"></u-avatar>
|
<view class="avatar">
|
||||||
|
<u-avatar :size="avatarSize" shape="square" :src="contact(item.targetId).portraitUrl"></u-avatar>
|
||||||
|
<view class="admin" v-if="item.is_admin">管理</view>
|
||||||
|
<view class="owner" v-if="item.targetId === adminUid">群主</view>
|
||||||
|
</view>
|
||||||
<view class="name">{{ item.name }}</view>
|
<view class="name">{{ item.name }}</view>
|
||||||
<view class="admin" v-if="item.is_admin">管理</view>
|
|
||||||
<view class="owner" v-if="item.targetId === adminUid">群主</view>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="user" v-if="isAdmin">
|
<view class="user" v-if="isAdmin">
|
||||||
<u-avatar @click="inviteUser" shape="square" icon="plus" bg-color="#eeeeee" color="#999999">
|
<u-avatar @click="inviteUser" :size="avatarSize" shape="square" icon="plus" bg-color="#eeeeee"
|
||||||
|
color="#999999">
|
||||||
</u-avatar>
|
</u-avatar>
|
||||||
<view class="name">邀请好友</view>
|
<view class="name">邀请好友</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -67,12 +70,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.avatarSize = 126 / 750 * wx.getSystemInfoSync().windowWidth
|
this.avatarSize = 90 / 750 * wx.getSystemInfoSync().windowWidth
|
||||||
console.log(this.avatarSize)
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initGroupInfo()
|
this.initGroupInfo()
|
||||||
this.initUsers()
|
getGroupUsers(this.targetId, this.count).then(res => {
|
||||||
|
this.users = res
|
||||||
|
res.map(item => {
|
||||||
|
this.$store.dispatch('updateContact', item)
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initGroupInfo() {
|
initGroupInfo() {
|
||||||
@@ -86,7 +93,6 @@
|
|||||||
initUsers() {
|
initUsers() {
|
||||||
getGroupUsers(this.targetId, this.count).then(res => {
|
getGroupUsers(this.targetId, this.count).then(res => {
|
||||||
this.users = res
|
this.users = res
|
||||||
console.log('群成员列表', res);
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
hideAction(item) {
|
hideAction(item) {
|
||||||
@@ -237,7 +243,6 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.users {
|
.users {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@@ -246,8 +251,6 @@
|
|||||||
padding: 20rpx 0;
|
padding: 20rpx 0;
|
||||||
|
|
||||||
.user {
|
.user {
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
width: 126rpx;
|
width: 126rpx;
|
||||||
margin-left: 20rpx;
|
margin-left: 20rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
@@ -255,12 +258,46 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-radius: 0 10rpx 0 0;
|
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
background-color: $window-color;
|
background-color: $window-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
border-radius: 0 8rpx 0 0;
|
||||||
|
position: relative;
|
||||||
|
width: 90rpx;
|
||||||
|
height: 90rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.admin {
|
||||||
|
position: absolute;
|
||||||
|
background-color: $main-color;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 12rpx;
|
||||||
|
width: 100rpx;
|
||||||
|
padding-top: 30rpx;
|
||||||
|
text-align: center;
|
||||||
|
right: -45rpx;
|
||||||
|
top: -20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.owner {
|
||||||
|
position: absolute;
|
||||||
|
background-color: $text-price;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 12rpx;
|
||||||
|
width: 100rpx;
|
||||||
|
padding-top: 30rpx;
|
||||||
|
text-align: center;
|
||||||
|
right: -45rpx;
|
||||||
|
top: -20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
color: $text-gray-m;
|
color: $text-gray-m;
|
||||||
width: 126rpx;
|
width: 126rpx;
|
||||||
@@ -272,31 +309,6 @@
|
|||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin {
|
|
||||||
position: absolute;
|
|
||||||
background-color: $main-color;
|
|
||||||
transform: rotate(45deg);
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 12rpx;
|
|
||||||
width: 100rpx;
|
|
||||||
padding-top: 30rpx;
|
|
||||||
text-align: center;
|
|
||||||
right: -45rpx;
|
|
||||||
top: -20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.owner {
|
|
||||||
position: absolute;
|
|
||||||
background-color: $text-price;
|
|
||||||
transform: rotate(45deg);
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 12rpx;
|
|
||||||
width: 100rpx;
|
|
||||||
padding-top: 30rpx;
|
|
||||||
text-align: center;
|
|
||||||
right: -45rpx;
|
|
||||||
top: -20rpx;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,12 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<view class="header">
|
<view class="header">
|
||||||
<view class="name">{{ contact(item.targetId).name }} <text v-if="item.conversationType === 3" class='qun'>[群]</text></view>
|
<view class="name">{{ contact(item.targetId).name }} <text v-if="item.conversationType === 3"
|
||||||
|
class='qun'>[群]</text></view>
|
||||||
<view class="time">{{ item.sentTime|timeCustomCN }}</view>
|
<view class="time">{{ item.sentTime|timeCustomCN }}</view>
|
||||||
</view>
|
</view>
|
||||||
<message-preview class="preview" :msg="item.latestMessage" :conversationType="item.conversationType" :user="item.latestMessage.userInfo" />
|
<message-preview class="preview" :msg="item.latestMessage" :conversationType="item.conversationType"
|
||||||
|
:user="item.latestMessage.userInfo" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -17,10 +19,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import messagePreview from './messagePreview'
|
import messagePreview from './messagePreview'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
item: {
|
item: {
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
<view class="preview" v-if="msg.objectName=='RC:VideoMsg'">
|
<view class="preview" v-if="msg.objectName=='RC:VideoMsg'">
|
||||||
<text v-if="conversationType == 3">{{ user.name }}:</text>[视频通话]
|
<text v-if="conversationType == 3">{{ user.name }}:</text>[视频通话]
|
||||||
</view>
|
</view>
|
||||||
|
<view class="preview" v-if="msg.objectName=='RC:GrpNtf'">
|
||||||
|
[{{ msg.message }}]
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
<view class="group--chat">
|
<view class="group--chat">
|
||||||
<list class="body" :show-scrollbar="false">
|
<list class="body" :show-scrollbar="false">
|
||||||
<cell class="cell" v-for="(item, index) in messages" :key="index">
|
<cell class="cell" v-for="(item, index) in messages" :key="index">
|
||||||
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
<view class="cell-system" v-if="item.senderUserId === '__system__'">
|
||||||
|
<text class="text">{{ item.content.message }}</text>
|
||||||
|
</view>
|
||||||
|
<view v-else :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']">
|
||||||
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
|
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
|
||||||
:src="contact(item.senderUserId).portraitUrl" />
|
:src="contact(item.senderUserId).portraitUrl" />
|
||||||
<view class="msg">
|
<view class="msg">
|
||||||
@@ -25,6 +28,9 @@
|
|||||||
import {
|
import {
|
||||||
timeCustomCN
|
timeCustomCN
|
||||||
} from '@/utils/filters.js'
|
} from '@/utils/filters.js'
|
||||||
|
import {
|
||||||
|
getGroupBase
|
||||||
|
} from '@/apis/interfaces/im.js'
|
||||||
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||||
import im from '@/utils/im/index.js'
|
import im from '@/utils/im/index.js'
|
||||||
import showVoice from '../components/showVoice'
|
import showVoice from '../components/showVoice'
|
||||||
@@ -73,12 +79,21 @@
|
|||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
title: this.groupInfo.name
|
title: this.groupInfo.name
|
||||||
})
|
})
|
||||||
|
// 获取群成员数量
|
||||||
|
getGroupBase(this.targetId).then(res => {
|
||||||
|
uni.setNavigationBarTitle({
|
||||||
|
title: this.groupInfo.name + `(${res.members})`
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// 获取历史消息列表
|
||||||
this.getMessageList()
|
this.getMessageList()
|
||||||
|
// 监听收到本群的消息,追加消息
|
||||||
uni.$on('onReceiveMessage', (msg) => {
|
uni.$on('onReceiveMessage', (msg) => {
|
||||||
if (msg.targetId == this.targetId) {
|
if (msg.targetId == this.targetId) {
|
||||||
this.getNewMessage()
|
this.getNewMessage()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 清理聊天记录
|
||||||
uni.$once('cleanGroupMessage', this.getMessageList)
|
uni.$once('cleanGroupMessage', this.getMessageList)
|
||||||
},
|
},
|
||||||
onNavigationBarButtonTap() {
|
onNavigationBarButtonTap() {
|
||||||
@@ -87,6 +102,7 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 转到好友资料页面
|
||||||
toUser(item) {
|
toUser(item) {
|
||||||
if (item.senderUserId == '__system__') {
|
if (item.senderUserId == '__system__') {
|
||||||
return
|
return
|
||||||
@@ -106,7 +122,7 @@
|
|||||||
this.conversationType,
|
this.conversationType,
|
||||||
this.targetId,
|
this.targetId,
|
||||||
this.latestMessage.sentTime,
|
this.latestMessage.sentTime,
|
||||||
1,
|
10,
|
||||||
false,
|
false,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
this.messages = this.messages.concat(messages)
|
this.messages = this.messages.concat(messages)
|
||||||
@@ -122,6 +138,7 @@
|
|||||||
100,
|
100,
|
||||||
true,
|
true,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
|
console.log(messages);
|
||||||
this.messages = messages.reverse()
|
this.messages = messages.reverse()
|
||||||
this.scrollBottom()
|
this.scrollBottom()
|
||||||
})
|
})
|
||||||
@@ -161,6 +178,15 @@
|
|||||||
.cell {
|
.cell {
|
||||||
padding: 10rpx 30rpx;
|
padding: 10rpx 30rpx;
|
||||||
|
|
||||||
|
.cell-system {
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.text {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: $text-gray-m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.cell-item {
|
.cell-item {
|
||||||
width: 690rpx;
|
width: 690rpx;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
|
|||||||
@@ -64,13 +64,14 @@
|
|||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '创建成功'
|
title: '创建成功'
|
||||||
})
|
})
|
||||||
this.initData()
|
|
||||||
this.onHideModal()
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: err
|
title: err.message
|
||||||
})
|
})
|
||||||
|
}).finally(() => {
|
||||||
|
this.initData()
|
||||||
|
this.onHideModal()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toGroup(targetId) {
|
toGroup(targetId) {
|
||||||
|
|||||||
@@ -273,6 +273,7 @@
|
|||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
dismissGroup(this.targetId).then(res => {
|
dismissGroup(this.targetId).then(res => {
|
||||||
|
console.log('解散群', res);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: '解散成功'
|
title: '解散成功'
|
||||||
|
|||||||
@@ -56,7 +56,6 @@
|
|||||||
this.checkNewFriendPending()
|
this.checkNewFriendPending()
|
||||||
// 监听新的好友申请
|
// 监听新的好友申请
|
||||||
uni.$on('onContactNotification', () => {
|
uni.$on('onContactNotification', () => {
|
||||||
console.log('监听申请');
|
|
||||||
this.checkNewFriendPending()
|
this.checkNewFriendPending()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -77,7 +76,6 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
checkNewFriendPending() {
|
checkNewFriendPending() {
|
||||||
console.log('触发新申请好友事件');
|
|
||||||
im.getPendingList((pendings) => {
|
im.getPendingList((pendings) => {
|
||||||
console.log(pendings);
|
console.log(pendings);
|
||||||
this.hasNewFriends = pendings.length
|
this.hasNewFriends = pendings.length
|
||||||
@@ -96,9 +94,13 @@
|
|||||||
getConversationList() {
|
getConversationList() {
|
||||||
const count = 1000
|
const count = 1000
|
||||||
const timestamp = 0
|
const timestamp = 0
|
||||||
RongIMLib.getConversationList([1, 3], count, timestamp, (res) => {
|
RongIMLib.getConversationList([1, 3], count, timestamp, ({
|
||||||
if (res.code === 0) {
|
code,
|
||||||
this.conversations = res.conversations
|
conversations
|
||||||
|
}) => {
|
||||||
|
console.log(conversations);
|
||||||
|
if (code === 0) {
|
||||||
|
this.conversations = conversations
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<view class="time">
|
<view class="time">
|
||||||
<text class="text">{{ customCN(item.sentTime) }}</text>
|
<text class="text">{{ customCN(item.sentTime) }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
<view :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']">
|
||||||
<u-avatar class="avatar" size="36" shape="square" @click="showUser(targetId, item.messageDirection)"
|
<u-avatar class="avatar" size="36" shape="square" @click="showUser(targetId, item.messageDirection)"
|
||||||
:src="contact(item.senderUserId).portraitUrl" />
|
:src="contact(item.senderUserId).portraitUrl" />
|
||||||
<view class="msg">
|
<view class="msg">
|
||||||
|
|||||||
@@ -160,9 +160,21 @@ const addListeners = () => {
|
|||||||
console.log('消息删除结果', code)
|
console.log('消息删除结果', code)
|
||||||
})
|
})
|
||||||
} else if (message.objectName === RongIMLib.ObjectName.ContactNotification) {
|
} else if (message.objectName === RongIMLib.ObjectName.ContactNotification) {
|
||||||
console.log('onContactNotification');
|
|
||||||
// 触发一个新好友的通知事件
|
// 触发一个新好友的通知事件
|
||||||
uni.$emit('onContactNotification', message.content)
|
uni.$emit('onContactNotification', message)
|
||||||
|
} else if (message.objectName === RongIMLib.ObjectName.GroupNotification) {
|
||||||
|
// 解散群
|
||||||
|
if (message.content.operation === 'Dismiss') {
|
||||||
|
RongIMLib.cleanHistoryMessages(message.conversationType, message.targetId,
|
||||||
|
message.sentTime - 1, false, ({
|
||||||
|
code
|
||||||
|
}) => {
|
||||||
|
if (code == 0) {
|
||||||
|
uni.$emit('onGroupDismiss', message.targetId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
uni.$emit('onReceiveMessage', message)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ const getMessageList = (conversationType, targetId, timeStamp, count, isForward,
|
|||||||
'RC:LBSMsg',
|
'RC:LBSMsg',
|
||||||
'RC:SightMsg',
|
'RC:SightMsg',
|
||||||
'RC:ReferenceMsg',
|
'RC:ReferenceMsg',
|
||||||
'RC:CombineMsg'
|
'RC:CombineMsg',
|
||||||
|
'RC:GrpNtf'
|
||||||
]
|
]
|
||||||
|
|
||||||
RongIMLib.getHistoryMessagesByTimestamp(
|
RongIMLib.getHistoryMessagesByTimestamp(
|
||||||
|
|||||||
Reference in New Issue
Block a user