no message

cyl/job_im
jscyl13849007907 2 days ago
parent 365d67904a
commit 365f81a423

@ -1,8 +1,31 @@
<template>
<view class="g_pb_24">
<div style="width: calc(100vw - 20px);margin: 10px auto;border-radius: 8px;">
<div v-for="(item, index) in machineList" :key="index" class="customitem imitems g_bg_f">
<Tooltip ref="tooltipRef" color="white" :isSelf="true" :top="150">
<div style="width: calc(100vw - 20px);margin: 10px auto;border-radius: 8px;overflow: hidden;">
<div
v-for="(item, index) in machineList"
:key="index"
class="slide-container"
@touchstart="touchStart($event, index)"
@touchmove="touchMove($event, index)"
@touchend="touchEnd($event, index)"
>
<!-- 操作按钮区域 -->
<view class="slide-actions">
<view
class="action-btn top-btn"
@click="topMessage(item, index)"
>
{{ item.stickTop ? "取消置顶" : "置顶消息" }}
</view>
<view
class="action-btn delete-btn"
@click="deleteMessage(item, index)"
>
不显示
</view>
</view>
<!-- 内容区域 -->
<div class="customitem imitems g_bg_f slide-content" :style="{ transform: `translateX(${slideOffsets[index] || 0}px)` }">
<div class="g_flex_row_start" hover-class="thover" style="padding: 12px 16px" @click="goChatPage(item)" :style="{ backgroundColor: item.stickTop ? '#f5f5f5' : '#fff' }">
<div
class="g_flex_none"
@ -92,17 +115,7 @@
<div class="g_fs_14 g_ell_1" style="color: #999; font-size: 12px" v-if="!item.lastMessage"></div>
</div>
</div>
<template #content>
<view class="g_fs_16" style="">
<view class="g_flex_column_center g_h_32" @click="topMessage(item, index)">
<view>{{ item.stickTop ? "取消置顶" : "置顶消息" }} </view>
</view>
<view class="g_flex_column_center g_h_32" @click="deleteMessage(item, index)">
<view>不显示</view>
</view>
</view>
</template>
</Tooltip>
</div>
</div>
</div>
</view>
@ -134,10 +147,13 @@
import { ref, onMounted, onUnmounted, getCurrentInstance, watch, defineEmits, defineProps } from "vue";
const props = defineProps({});
const G = getCurrentInstance().appContext.app.config.globalProperties.G;
import Tooltip from "./Tooltip.vue";
const tooltipRef = ref(null);
let firstLoad = ref(false);
const machineList = ref([]);
//
const slideOffsets = ref({}); // item
const touchStartX = ref({}); // X
const touchStartY = ref({}); // Y
const actionWidth = 160; //
onMounted(async () => {
uni.$on("updateConversationList", () => {
console.log("监听到事件");
@ -303,6 +319,45 @@ const goChatPage = async (_item) => {
url: "/root/NEUIKit/index?item=" + _item.conversationId,
});
};
//
const touchStart = (e, index) => {
touchStartX.value[index] = e.touches[0].clientX;
touchStartY.value[index] = e.touches[0].clientY;
};
//
const touchMove = (e, index) => {
const currentX = e.touches[0].clientX;
const currentY = e.touches[0].clientY;
const diffX = currentX - touchStartX.value[index];
const diffY = currentY - touchStartY.value[index];
//
if (Math.abs(diffX) > Math.abs(diffY)) {
e.preventDefault();
let offset = diffX + (slideOffsets.value[index] || 0);
//
offset = Math.max(-actionWidth, Math.min(0, offset));
slideOffsets.value[index] = offset;
}
};
//
const touchEnd = (e, index) => {
const offset = slideOffsets.value[index] || 0;
//
if (offset < -actionWidth / 2) {
slideOffsets.value[index] = -actionWidth;
} else {
slideOffsets.value[index] = 0;
}
};
//
const resetSlide = (index) => {
slideOffsets.value[index] = 0;
};
/**
* 置顶或取消置顶会话
*/
@ -314,7 +369,6 @@ const topMessage = async (_item, _index) => {
} else {
G.nim.V2NIMConversationService.stickTopConversation(_item.conversationId, true);
}
console.log("tooltipRef.value", tooltipRef.value);
} catch (error) {
uni.showToast({
title: error,
@ -322,10 +376,7 @@ const topMessage = async (_item, _index) => {
});
console.log("errorerror", error);
}
tooltipRef.value[_index].close();
// let res1 = await G.nim.V2NIMConversationService.getStickTopConversationList();
// console.log("res1res1", res1);
resetSlide(_index);
};
/**
* 删除会话
@ -350,7 +401,7 @@ const deleteMessage = async (_item, _index) => {
}
},
});
tooltipRef.value[_index].close();
resetSlide(_index);
};
onUnmounted(() => {
uni.$off("updateConversationList");
@ -379,4 +430,47 @@ onUnmounted(() => {
}
}
}
.slide-container {
position: relative;
// overflow: hidden;
// border-radius: 8px;
// margin-bottom: 8px;
}
.slide-actions {
position: absolute;
right: 0;
top: 0;
bottom: 0;
display: flex;
align-items: center;
z-index: 1;
}
.action-btn {
width: 80px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 14px;
flex-shrink: 0;
}
.top-btn {
background-color: #999;
}
.delete-btn {
background-color: #f5222d;
}
.slide-content {
position: relative;
z-index: 2;
background: #fff;
transition: transform 0.3s ease;
width: 100%;
}
</style>

@ -125,7 +125,7 @@
let that = this;
that.G.Get(that.api.bind_recordList + '/' + that.type,{
pageNum: 1,
pageSize: 50,
pageSize: 200,
type:that.type,
keys:that.keys
},(res)=>{

@ -159,7 +159,7 @@ export default {
speed: -1,
query: {
page: 1,
size: 50,
size: 30,
list: [],
isFinish: -1,
},

Loading…
Cancel
Save