群头像修改时不同步的问题
This commit is contained in:
@@ -3,13 +3,14 @@
|
|||||||
<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="44" shape="square" :src="item.portraitUrl"></u-avatar>
|
<u-avatar :size="avatarSize" shape="square" :src="item.portraitUrl"></u-avatar>
|
||||||
<view class="name">{{ item.name }}</view>
|
<view class="name">{{ item.name }}</view>
|
||||||
<view class="admin" v-if="item.is_admin">管理</view>
|
<view class="admin" v-if="item.is_admin">管理</view>
|
||||||
<view class="owner" v-if="item.targetId === adminUid">群主</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" size="44" shape="square" icon="plus" bg-color="#eeeeee" color="#999999">
|
<u-avatar @click="inviteUser" size="126rpx" shape="square" icon="plus" bg-color="#eeeeee"
|
||||||
|
color="#999999">
|
||||||
</u-avatar>
|
</u-avatar>
|
||||||
<view class="name">邀请好友</view>
|
<view class="name">邀请好友</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -49,15 +50,20 @@
|
|||||||
return {
|
return {
|
||||||
users: [],
|
users: [],
|
||||||
isOwner: false,
|
isOwner: false,
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
adminUid: 0,
|
adminUid: 0,
|
||||||
members: 0,
|
members: 0,
|
||||||
actionShow: false,
|
actionShow: false,
|
||||||
actionMap: [],
|
actionMap: [],
|
||||||
actionTitle: '',
|
actionTitle: '',
|
||||||
currentUser: {}
|
currentUser: {},
|
||||||
|
avatarSize: 40
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.avatarSize = 126 / 750 * wx.getSystemInfoSync().windowWidth
|
||||||
|
console.log(this.avatarSize)
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initGroupInfo()
|
this.initGroupInfo()
|
||||||
this.initUsers()
|
this.initUsers()
|
||||||
@@ -66,7 +72,7 @@
|
|||||||
initGroupInfo() {
|
initGroupInfo() {
|
||||||
getGroupBase(this.targetId).then(res => {
|
getGroupBase(this.targetId).then(res => {
|
||||||
this.isOwner = res.is_owner
|
this.isOwner = res.is_owner
|
||||||
this.isAdmin = res.is_admin
|
this.isAdmin = res.is_admin
|
||||||
this.adminUid = res.user_id
|
this.adminUid = res.user_id
|
||||||
this.members = res.members
|
this.members = res.members
|
||||||
})
|
})
|
||||||
@@ -79,8 +85,6 @@
|
|||||||
},
|
},
|
||||||
hideAction(item) {
|
hideAction(item) {
|
||||||
this.actionShow = false
|
this.actionShow = false
|
||||||
this.actionTitle = ''
|
|
||||||
this.currentUser = {}
|
|
||||||
},
|
},
|
||||||
showAction(item) {
|
showAction(item) {
|
||||||
this.currentUser = item
|
this.currentUser = item
|
||||||
@@ -180,6 +184,7 @@
|
|||||||
content: '这个操作不可逆转,确定要转让群主身份么?',
|
content: '这个操作不可逆转,确定要转让群主身份么?',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
|
console.log(this.targetId, this.currentUser.targetId);
|
||||||
transferGroupOwner(this.targetId, this.currentUser.targetId).then(
|
transferGroupOwner(this.targetId, this.currentUser.targetId).then(
|
||||||
res => {
|
res => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -245,7 +250,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-radius: 0 10rpx 0 0;
|
border-radius: 0 10rpx 0 0;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
@@ -274,19 +279,19 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
right: -45rpx;
|
right: -45rpx;
|
||||||
top: -20rpx;
|
top: -20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.owner {
|
.owner {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: $text-price;
|
background-color: $text-price;
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-size: 12rpx;
|
font-size: 12rpx;
|
||||||
width: 100rpx;
|
width: 100rpx;
|
||||||
padding-top: 30rpx;
|
padding-top: 30rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
right: -45rpx;
|
right: -45rpx;
|
||||||
top: -20rpx;
|
top: -20rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
<view class="cell-item" :class="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" />
|
||||||
<!-- item.content.userInfo.portraitUrl -->
|
|
||||||
<view class="msg">
|
<view class="msg">
|
||||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
||||||
:msg="item.content" :name="contact(item.senderUserId).name" />
|
:msg="item.content" :name="contact(item.senderUserId).name" />
|
||||||
@@ -54,7 +53,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
latestMessage() {
|
latestMessage() {
|
||||||
if (this.messages.length > 1) {
|
if (this.messages.length) {
|
||||||
return this.messages[this.messages.length - 1]
|
return this.messages[this.messages.length - 1]
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
<u-cell-group class="cells" v-if="group.is_admin">
|
<u-cell-group class="cells" v-if="group.is_admin">
|
||||||
<u-cell isLink title="修改群聊名称" :value="groupName" @click="onGroupName"></u-cell>
|
<u-cell isLink title="修改群聊名称" :value="groupName" @click="onGroupName"></u-cell>
|
||||||
<u-cell isLink title="修改群头像">
|
<u-cell isLink title="修改群头像" @click="onGroupAvatar">
|
||||||
<u-avatar slot="value" size="25" shape="square" @click="onGroupAvatar" :src="group.cover"></u-avatar>
|
<u-avatar slot="value" size="25" shape="square" :src="group.cover"></u-avatar>
|
||||||
</u-cell>
|
</u-cell>
|
||||||
<u-cell isLink v-if="group.is_owner" title="准入方式" :value="joinType" @click="onChangeJoinType"></u-cell>
|
<u-cell isLink v-if="group.is_owner" title="准入方式" :value="joinType" @click="onChangeJoinType"></u-cell>
|
||||||
</u-cell-group>
|
</u-cell-group>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
latestMessage() {
|
latestMessage() {
|
||||||
if (this.messages.length > 1) {
|
if (this.messages.length) {
|
||||||
return this.messages[this.messages.length - 1]
|
return this.messages[this.messages.length - 1]
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
updateContactInfo(state, contactInfo) {
|
updateContactInfo(state, contactInfo) {
|
||||||
Vue.set(state.contacts, contactInfo.targetId, contactInfo)
|
Vue.set(state.contacts, contactInfo.targetId, contactInfo)
|
||||||
},
|
},
|
||||||
setSenderInfo(state, contactInfo) {
|
setSenderInfo(state, contactInfo) {
|
||||||
@@ -68,7 +68,6 @@ export default {
|
|||||||
// 没有数据,直接新增一条
|
// 没有数据,直接新增一条
|
||||||
dispatch('initContact', contactInfo)
|
dispatch('initContact', contactInfo)
|
||||||
} else if (contactInfo.hash != result[0].hash) {
|
} else if (contactInfo.hash != result[0].hash) {
|
||||||
commit('updateContactInfo', contactInfo)
|
|
||||||
if (contactInfo.portraitUrl && contactInfo.portraitUrl != result[0].portraitUrl) {
|
if (contactInfo.portraitUrl && contactInfo.portraitUrl != result[0].portraitUrl) {
|
||||||
saveAvatar(contactInfo, (savedFilePath) => {
|
saveAvatar(contactInfo, (savedFilePath) => {
|
||||||
const info = {
|
const info = {
|
||||||
@@ -79,8 +78,8 @@ export default {
|
|||||||
localAvatar: savedFilePath
|
localAvatar: savedFilePath
|
||||||
}
|
}
|
||||||
model.update('targetId="' + contactInfo.targetId + '"', info, (err,
|
model.update('targetId="' + contactInfo.targetId + '"', info, (err,
|
||||||
res) => {
|
res) => {
|
||||||
console.log('UPDATE AVATAR, ERR', err);
|
console.log('UPDATE AVATAR, ERR', err, info);
|
||||||
})
|
})
|
||||||
commit('updateContactInfo', info)
|
commit('updateContactInfo', info)
|
||||||
})
|
})
|
||||||
@@ -93,8 +92,9 @@ export default {
|
|||||||
localAvatar: result[0].localAvatar
|
localAvatar: result[0].localAvatar
|
||||||
}
|
}
|
||||||
model.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => {
|
model.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => {
|
||||||
console.log('UPDATE NAME, ERR', err);
|
console.log('UPDATE NAME, ERR', err, info);
|
||||||
})
|
})
|
||||||
|
commit('updateContactInfo', info)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('updateContact, 无操作');
|
console.log('updateContact, 无操作');
|
||||||
|
|||||||
@@ -150,7 +150,8 @@ const addListeners = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
newMessage(message)
|
newMessage(message)
|
||||||
} else if (message.objectName === RongIMLib.ObjectName.ProfileNotification) {
|
} else if (message.objectName === RongIMLib.ObjectName.ProfileNotification) {
|
||||||
|
// 更新会话信息
|
||||||
store.dispatch('updateContact', JSON.parse(message.content.data))
|
store.dispatch('updateContact', JSON.parse(message.content.data))
|
||||||
// 调用完更新之后,删除这条消息
|
// 调用完更新之后,删除这条消息
|
||||||
RongIMLib.deleteMessagesByIds([message.messageId], ({
|
RongIMLib.deleteMessagesByIds([message.messageId], ({
|
||||||
|
|||||||
Reference in New Issue
Block a user