Browse Source

fix: 同时上传文件失败的bug

master
xsx 5 months ago
parent
commit
0457e706ee
  1. 13
      im-uniapp/pages/chat/chat-box.vue
  2. 27
      im-web/src/components/chat/ChatBox.vue

13
im-uniapp/pages/chat/chat-box.vue

@ -152,7 +152,8 @@ export default {
isInBottom: true, // isInBottom: true, //
newMessageSize: 0, // newMessageSize: 0, //
scrollTop: 0, // ios h5 scrollTop: 0, // ios h5
scrollViewHeight: 0 // scrollViewHeight: 0, //
maxTmpId: 0 // id
} }
}, },
methods: { methods: {
@ -983,7 +984,13 @@ export default {
}, },
generateId() { generateId() {
// id // id
return String(new Date().getTime()) + String(Math.floor(Math.random() * 1000)); const id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1000));
// id
if (this.maxTmpId > id) {
return this.generateId();
}
this.maxTmpId = id;
return id;
} }
}, },
computed: { computed: {
@ -1108,6 +1115,8 @@ export default {
// //
this.isInBottom = true; this.isInBottom = true;
this.newMessageSize = 0; this.newMessageSize = 0;
// id
this.maxTmpId = 0;
// //
this.listenKeyBoard(); this.listenKeyBoard();
// //

27
im-web/src/components/chat/ChatBox.vue

@ -132,7 +132,8 @@ export default {
reqQueue: [], // reqQueue: [], //
isSending: false, // isSending: false, //
isInBottom: false, // isInBottom: false, //
newMessageSize: 0 // newMessageSize: 0, //
maxTmpId: 0 // ID
} }
}, },
methods: { methods: {
@ -573,7 +574,7 @@ export default {
this.$http({ this.$http({
url: url, url: url,
method: 'put' method: 'put'
}).then(() => { }) }).then(() => {})
this.chatStore.resetUnreadCount(this.chat) this.chatStore.resetUnreadCount(this.chat)
} }
}, },
@ -724,25 +725,31 @@ export default {
getImageSize(file) { getImageSize(file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader(); const reader = new FileReader();
reader.onload = function (event) { reader.onload = function(event) {
const img = new Image(); const img = new Image();
img.onload = function () { img.onload = function() {
resolve({ width: img.width, height: img.height }); resolve({ width: img.width, height: img.height });
}; };
img.onerror = function () { img.onerror = function() {
reject(new Error('无法加载图片')); reject(new Error('无法加载图片'));
}; };
img.src = event.target.result; img.src = event.target.result;
}; };
reader.onerror = function () { reader.onerror = function() {
reject(new Error('无法读取文件')); reject(new Error('无法读取文件'));
}; };
reader.readAsDataURL(file); reader.readAsDataURL(file);
}); });
}, },
generateId() { generateId() {
// id // id
return String(new Date().getTime()) + String(Math.floor(Math.random() * 1000)); const id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1000));
// id
if (this.maxTmpId > id) {
return this.generateId();
}
this.maxTmpId = id;
return id;
} }
}, },
computed: { computed: {
@ -799,7 +806,7 @@ export default {
chat: { chat: {
handler(newChat, oldChat) { handler(newChat, oldChat) {
if (newChat.targetId > 0 && (!oldChat || newChat.type != oldChat.type || if (newChat.targetId > 0 && (!oldChat || newChat.type != oldChat.type ||
newChat.targetId != oldChat.targetId)) { newChat.targetId != oldChat.targetId)) {
this.userInfo = {} this.userInfo = {}
this.group = {}; this.group = {};
this.groupMembers = []; this.groupMembers = [];
@ -822,6 +829,8 @@ export default {
this.resetEditor(); this.resetEditor();
// //
this.isReceipt = false; this.isReceipt = false;
// id
this.maxTmpId = 0;
// placeholder // placeholder
this.refreshPlaceHolder(); this.refreshPlaceHolder();
} }

Loading…
Cancel
Save