|
|
@@ -33,9 +33,11 @@
|
|
|
<div class="chat-list" ref="chatRef">
|
|
|
<chat-info
|
|
|
v-for="(item, index) in list"
|
|
|
- :key="index"
|
|
|
+ :key="item.time"
|
|
|
:info="item"
|
|
|
:beforeTime="index > 0 ? list[index - 1].time : ''"
|
|
|
+ @setImage="setImage"
|
|
|
+ @preview="onPreview"
|
|
|
></chat-info>
|
|
|
</div>
|
|
|
</van-pull-refresh>
|
|
|
@@ -375,15 +377,20 @@ function onFocus(e) {
|
|
|
|
|
|
const imgList = ref([]);
|
|
|
function setImage(img) {
|
|
|
- imgList.value.push(img);
|
|
|
+ console.log(img);
|
|
|
+ imgList.value = [...imgList.value, img].sort((a, b) => {
|
|
|
+ return a.time - b.time;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-function onPreview(url) {
|
|
|
+function onPreview(info) {
|
|
|
let index = imgList.value.findIndex(item => {
|
|
|
- return item === url;
|
|
|
+ return item.time === info.time;
|
|
|
});
|
|
|
ImagePreview({
|
|
|
- images: imgList.value,
|
|
|
+ images: imgList.value.map(item => {
|
|
|
+ return item.body.msg;
|
|
|
+ }),
|
|
|
startPosition: index
|
|
|
});
|
|
|
}
|