【更新】IM页面逻辑完善

This commit is contained in:
2022-01-21 12:15:45 +08:00
parent 92c6b37229
commit 21bee49729
8 changed files with 430 additions and 295 deletions

View File

@@ -4,12 +4,17 @@ export default {
state: {
newMsg: {},
friends: {},
sender: {}
sender: {},
// IM连接状态0是正常
connection: 0
},
getters: {
newMessage(state) {
return state.newMsg
},
connection(state) {
return state.connection
},
friends(state) {
return state.friends
},
@@ -17,8 +22,8 @@ export default {
if (state.friends[targetId]) {
return state.friends[targetId]
} else {
console.log('没找到, 死循环了,得处理 todo', targetId);
im.syncUserInfo(targetId)
console.log('没找到,死循环了,得处理 todo', targetId);
// im.syncUserInfo(targetId)
return {
name: '',
address: '',
@@ -43,9 +48,15 @@ export default {
},
SET_state_sender(state, userInfo) {
state.sender = userInfo
},
SET_connection_status(state, status) {
state.connection = status
}
},
actions: {
actions: {
updateConnectionStatus({commit}, status) {
commit('SET_connection_status', status)
},
newMessage({
commit
}, msg) {
@@ -63,7 +74,6 @@ export default {
const model = uni.model.friendModel
model.find('userId=' + userInfo.userId, (err, user) => {
if (!err && user.length == 0) {
console.log('哪里更新的 ', 1);
saveAvatar(userInfo, (savedFilePath) => {
model.insert({
userId: userInfo.userId,
@@ -76,7 +86,6 @@ export default {
commit('updateFriends', userInfo)
})
} else if (!err && user[0].hash != userInfo.hash) {
console.log('哪里更新的 ', 2);
saveAvatar(userInfo, (savedFilePath) => {
model.update('userId=' + userInfo.userId, {
name: userInfo.name,
@@ -98,7 +107,7 @@ export default {
commit('updateFriends', userInfo)
})
} else {
console.log('不需要有动作', user[0]);
console.log('不用操作', user[0]);
}
})
}