Files
Friendship-and-chat-uniapp/src/pages/components/user-more.vue
T
2026-01-06 11:41:57 +08:00

78 lines
2.0 KiB
Vue

<template>
<wd-action-sheet v-model="actionShow" :actions="actions" @select="actionSelect" cancel-text="取消" :z-index="5000" />
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
import RecentApi from '@/sheep/api/member/recent';
const props = defineProps({
user: {
type: Object,
default: () => ({})
},
hides: {
/**
* user - 查看资料
* report - 举报
* shield - 拉黑
*/
type: Array,
default: () => []
}
})
const actions = computed(() => {
const { hides } = props;
let actions = [{ name: '查看资料', key: "user" }, { name: '拉黑', key: "shield" }, { name: '举报', key: "report" }];
if (hides.includes('user')) {
actions = actions.filter(item => item.key !== 'user');
}
if (hides.includes('report')) {
actions = actions.filter(item => item.key !== 'report');
}
if (hides.includes('shield')) {
actions = actions.filter(item => item.key !== 'shield');
}
return actions;
})
const actionShow = ref(false);
const openActionSheet = () => {
actionShow.value = true;
}
const closeActionSheet = () => {
actionShow.value = false;
}
// 拉黑 举报
async function actionSelect({ item, index }) {
console.log(item, "item");
const key = item.key
switch (key) {
case "user":
uni.navigateTo({ url: '/pages/home/detail?memberId=' + props.user.member.memberId });
break;
case "shield":
const { code } = await RecentApi.recentOperate({
memberId: props.user.member.memberId,
action: 'MEMBER_SHIELD',
});
if (code === 0) {
uni.showToast({ title: '拉黑成功', icon: 'none' });
}
break;
case "report":
uni.navigateTo({ url: '/pages/home/report?memberId=' + props.user.member.memberId });
}
}
defineExpose({
open: openActionSheet,
close: closeActionSheet
})
</script>