【更新】IM页面逻辑完善
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user