This commit is contained in:
王一嘉
2025-07-22 18:38:39 +08:00
parent d4b90b09f8
commit 8d4c585e53
7 changed files with 55 additions and 14 deletions

View File

@@ -25,20 +25,21 @@ const {contextRow, type, data} = defineProps({
});
const itemList = computed(() => {
const tp = SystemStore.message.find(v => v.id === data.id);
const list = type === 0 ? [
{text: '置顶', type: 1, hide: data.is_top === 1},
{text: '取消置顶', type: 0, hide: data.is_top === 0},
{text: '标记已读', type: 0, hide: data.is_read === 0},
{text: '标记未读', type: 1, hide: data.is_read === 1},
{text: '标记已读', type: 1, hide: data.is_read === 0},
{text: '标记未读', type: 0, hide: data.is_read > 0},
] : [
{text: '标记已读', type: 0, hide: data.is_read === 0},
{text: '标记未读', type: 1, hide: data.is_read === 1},
{text: '标记已读', type: 0, hide: tp.is_read},
{text: '标记未读', type: 1, hide: !tp.is_read},
]
return list.filter(v => !v.hide);
})
const selectActionsheet = async (e) => {
if (type === 0) {
if (e.text === '置顶' || e.text === '取消置顶') {
const {msg} = await Api.system.setExchangeTop({
id: data.id,
type: e.type,
@@ -46,8 +47,17 @@ const selectActionsheet = async (e) => {
showToast(msg);
emits('success');
} else {
const index = SystemStore.message.findIndex(v => v.id === data.id);
SystemStore.message[index].is_read = true;
if (type === 0) {
const {msg} = await Api.system.setChildrenRead({
id: data.id,
type: e.type,
});
showToast(msg);
emits('success');
} else {
const index = SystemStore.message.findIndex(v => v.id === data.id);
SystemStore.message[index].is_read = !SystemStore.message[index].is_read;
}
}
}
@@ -75,7 +85,7 @@ onMounted(() => {
class="!py-[30rpx] !px-[24rpx] bg-[#fff] rounded-[8rpx] !flex items-center gap-[20rpx] overflow-hidden relative !mb-[20rpx]">
<view class="relative">
<image class="!size-[72rpx] flex-shrink-0" mode="aspectFill" :src="messageIcon"></image>
<view v-if="type === 0 ? data.is_read===0 : !SystemStore.message.find(v => v.id===data.id).is_read"
<view v-if="type === 0 ? data.is_read>0 : !SystemStore.message.find(v => v.id===data.id).is_read"
class="size-[20rpx] bg-[#f00] absolute right-0 top-0 rounded-[50%]"></view>
</view>

View File

@@ -5,6 +5,7 @@ const emits = defineEmits(['success']);
const show = ref(false);
const success = (e) => {
show.value = false;
emits('success', e);
}
</script>
@@ -19,7 +20,6 @@ const success = (e) => {
:show="show"
@click="success"
@cancel="show=false">
</tui-actionsheet>
</template>

View File

@@ -1,23 +1,40 @@
<script setup>
const visible = defineModel('visible');
const model = defineModel('model');
const emits = defineEmits(['success']);
const emits = defineEmits(['success', 'init']);
import {watch, ref} from "vue";
const XFilterRef = ref();
const init = () => {
Object.keys(model.value).forEach(key => {
model.value[key] = null;
});
success();
emits('init');
}
const success = () => {
visible.value = false;
emits('success');
}
watch(
() => visible.value,
(val) => {
const node = XFilterRef.value.$el.nextElementSibling.childNodes[2];
if (val) {
node.style.transform = 'none';
} else {
node.style.transform = 'translate3d(0, -100%, 0)';
}
},
{deep: true}
)
</script>
<template>
<tui-drawer
ref="XFilterRef"
mode="top"
maskZIndex="999"
zIndex="999"