|
|
@ -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,17 +725,17 @@ 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); |
|
|
@ -742,7 +743,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: { |
|
|
@ -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(); |
|
|
} |
|
|
} |
|
|
|