From 69a81a927adcc2a4aed75841ed02da9dd211df13 Mon Sep 17 00:00:00 2001 From: liangzai <2440983361@qq.com> Date: Mon, 2 Mar 2026 12:58:07 +0800 Subject: [PATCH] f --- src/api/agent.js | 63 +++++++++ src/components/BaseReport.vue | 258 +++++++++++++++++++++++++++++++++- src/components/Payment.vue | 18 +-- src/views/PaymentResult.vue | 43 +++++- src/views/Report.vue | 8 +- 5 files changed, 371 insertions(+), 19 deletions(-) diff --git a/src/api/agent.js b/src/api/agent.js index 14391a4..8fcf90c 100644 --- a/src/api/agent.js +++ b/src/api/agent.js @@ -278,3 +278,66 @@ export function getInviteLink(params) { const queryString = buildQueryString(params || {}); return useApiFetch(`/agent/invite_link${queryString}`).get().json(); } + +// ==================== 白名单相关接口 ==================== + +/** + * 获取可屏蔽的 feature 列表(带价格) + */ +export function getWhitelistFeatures() { + return useApiFetch("/agent/whitelist/features").get().json(); +} + +/** + * 创建白名单订单 + * @param {object} params - 创建参数 + * @param {string} params.id_card - 身份证号 + * @param {string[]} params.feature_ids - 要屏蔽的 feature ID 列表 + */ +export function createWhitelistOrder(params) { + return useApiFetch("/agent/whitelist/order/create").post(params).json(); +} + +/** + * 查询白名单列表 + * @param {object} params - 查询参数 + * @param {number} params.page - 页码 + * @param {number} params.page_size - 每页数量 + * @param {string} params.id_card - 身份证号(可选) + */ +export function getWhitelistList(params) { + const queryString = buildQueryString(params || {}); + return useApiFetch(`/agent/whitelist/list${queryString}`).get().json(); +} + +/** + * 检查模块是否已下架 + * @param {object} params - 查询参数 + * @param {string} params.id_card - 身份证号 + * @param {string} params.feature_api_id - Feature 的 API 标识 + * @param {string} params.query_id - 查询记录 ID(可选) + */ +export function checkFeatureWhitelistStatus(params) { + const queryString = buildQueryString(params || {}); + return useApiFetch(`/agent/whitelist/check${queryString}`).get().json(); +} + +/** + * 下架单个模块(免费或需支付) + * @param {object} params - 下架参数 + * @param {string} params.feature_api_id - Feature 的 API 标识 + * @param {string} params.query_id - 查询记录 ID(必填) + */ +export function offlineFeature(params) { + return useApiFetch("/agent/whitelist/offline").post(params).json(); +} + +/** + * 检查订单是否属于当前代理推广 + * @param {object} params - 查询参数 + * @param {string} params.order_id - 订单 ID + */ +export function checkOrderAgent(params) { + const queryString = buildQueryString(params || {}); + return useApiFetch(`/agent/order/agent${queryString}`).get().json(); +} diff --git a/src/components/BaseReport.vue b/src/components/BaseReport.vue index b7214c9..4af8529 100644 --- a/src/components/BaseReport.vue +++ b/src/components/BaseReport.vue @@ -3,12 +3,17 @@ import ShareReportButton from "./ShareReportButton.vue"; import TitleBanner from "./TitleBanner.vue"; import VerificationCard from "./VerificationCard.vue"; import StyledTabs from "./StyledTabs.vue"; +import Payment from "./Payment.vue"; import { splitDWBG8B4DForTabs } from '@/ui/CDWBG8B4D/utils/simpleSplitter.js'; import { splitDWBG6A2CForTabs } from '@/ui/DWBG6A2C/utils/simpleSplitter.js'; import { splitJRZQ7F1AForTabs } from '@/ui/JRZQ7F1A/utils/simpleSplitter.js'; import { splitCJRZQ5E9FForTabs } from '@/ui/CJRZQ5E9F/utils/simpleSplitter.js'; import { splitCQYGL3F8EForTabs } from '@/ui/CQYGL3F8E/utils/simpleSplitter.js'; import { useAppStore } from "@/stores/appStore"; +import { useAgentStore } from "@/stores/agentStore"; +import { storeToRefs } from "pinia"; +import { showFailToast } from "vant"; +import { checkFeatureWhitelistStatus, offlineFeature, checkOrderAgent } from "@/api/agent"; // 动态导入产品背景图片的函数 const loadProductBackground = async (productType) => { @@ -53,6 +58,11 @@ const props = defineProps({ type: String, default: "", }, + queryId: { + type: String, + required: false, + default: "", + }, feature: { type: String, required: true, @@ -98,8 +108,20 @@ const { isEmpty, isDone, isExample, + orderId, + orderNo, + queryId, } = toRefs(props); +const agentStore = useAgentStore(); +const { isDiamond } = storeToRefs(agentStore); + +// 订单是否属于当前代理推广 +const isAgentOrder = ref(false); + +// 获取身份证号(从 reportParams 中) +const idCard = computed(() => reportParams.value?.id_card || ""); + const active = ref(null); const backgroundContainerRef = ref(null); // 背景容器的引用 @@ -153,6 +175,21 @@ onMounted(async () => { // 监听窗口大小变化,重新计算高度 window.addEventListener('resize', handleResize); + + // 检查订单是否属于当前代理推广 + if (!isExample.value && orderId.value) { + try { + const { data, error } = await checkOrderAgent({ order_id: orderId.value }); + if (data.value && !error.value && data.value.code === 200) { + isAgentOrder.value = data.value.data.is_agent_order; + } + } catch (err) { + console.error("检查订单代理状态失败:", err); + } + } + if (isAgentOrder.value && idCard.value && !isExample.value) { + checkAllFeaturesStatus(); + } }); // 处理窗口大小变化(带防抖) @@ -242,6 +279,200 @@ const trapezoidBgStyle = computed(() => { return {}; }); +// 模块下架状态映射:主模块ID -> { isOfflined, whitelistPrice, isSubmitting } +const featureOfflineStatus = ref(new Map()); + +const getMainApiId = (apiId) => { + if (!apiId) return ""; + const index = apiId.indexOf("_"); + return index > 0 ? apiId.substring(0, index) : apiId; +}; + +const checkFeatureStatus = async (featureApiId, forceRefresh = false) => { + if (!idCard.value || !featureApiId) return; + const mainApiId = getMainApiId(featureApiId); + if (!mainApiId) return; + if (!forceRefresh && featureOfflineStatus.value.has(mainApiId)) return; + try { + const { data, error } = await checkFeatureWhitelistStatus({ + id_card: idCard.value, + feature_api_id: mainApiId, + query_id: queryId.value || "", + }); + if (data.value && !error.value && data.value.code === 200) { + const isWhitelisted = data.value.data.is_whitelisted || false; + const dataDeleted = data.value.data.data_deleted !== undefined ? data.value.data.data_deleted : true; + featureOfflineStatus.value.set(mainApiId, { + isOfflined: isWhitelisted && dataDeleted, + whitelistPrice: data.value.data.whitelist_price || 0, + isSubmitting: false, + }); + } + } catch (err) { + console.error("检查模块状态失败:", err); + } +}; + +const checkAllFeaturesStatus = async () => { + if (!idCard.value || !isAgentOrder.value || isExample.value) return; + const featureApiIds = processedReportData.value.map((item) => item.data.apiID); + const mainApiIds = [...new Set(featureApiIds.map((id) => getMainApiId(id)))]; + for (const mainApiId of mainApiIds) { + if (mainApiId) await checkFeatureStatus(mainApiId); + } +}; + +const getFeatureStatus = (featureApiId) => { + const mainApiId = getMainApiId(featureApiId); + return featureOfflineStatus.value.get(mainApiId) || { + isOfflined: false, + whitelistPrice: 0, + isSubmitting: false, + }; +}; + +const currentOfflineFeature = ref(null); +const showOfflineConfirmDialog = ref(false); + +const handleOfflineClick = async (featureApiId, featureName) => { + const mainApiId = getMainApiId(featureApiId); + const status = getFeatureStatus(mainApiId); + if (status.isOfflined) { + showFailToast("该模块已下架"); + return; + } + if (status.whitelistPrice <= 0) { + await confirmOfflineDirectly(mainApiId, featureName); + return; + } + currentOfflineFeature.value = { + featureApiId: mainApiId, + featureName, + whitelistPrice: status.whitelistPrice, + }; + showOfflineConfirmDialog.value = true; +}; + +const showWhitelistPayment = ref(false); +const whitelistPaymentData = ref({ product_name: "", sell_price: 0 }); +const whitelistPaymentId = ref(""); +const whitelistPaymentType = ref("whitelist"); + +const getCurrentReportUrl = () => { + if (orderNo.value) return `/report?orderNo=${orderNo.value}`; + if (orderId.value) return `/report?orderId=${orderId.value}`; + return ""; +}; + +const confirmOfflineDirectly = async (mainApiId, featureName) => { + if (!idCard.value || !mainApiId) return; + const status = getFeatureStatus(mainApiId); + status.isSubmitting = true; + featureOfflineStatus.value.set(mainApiId, { ...status }); + try { + if (!queryId.value) { + showFailToast("缺少查询记录ID,无法下架"); + const cur = getFeatureStatus(mainApiId); + cur.isSubmitting = false; + featureOfflineStatus.value.set(mainApiId, { ...cur }); + return; + } + const { data, error } = await offlineFeature({ + query_id: queryId.value, + feature_api_id: mainApiId, + }); + if (!data.value || error.value || data.value.code !== 200) { + showFailToast(data.value?.msg || "下架失败"); + const cur = getFeatureStatus(mainApiId); + cur.isSubmitting = false; + featureOfflineStatus.value.set(mainApiId, { ...cur }); + return; + } + const resp = data.value.data || {}; + if (resp.need_pay) { + const cur = getFeatureStatus(mainApiId); + cur.isSubmitting = false; + cur.whitelistPrice = resp.amount || 0; + featureOfflineStatus.value.set(mainApiId, { ...cur }); + whitelistPaymentData.value = { + product_name: `${featureName || "模块"} 下架`, + sell_price: resp.amount || 0, + }; + whitelistPaymentId.value = `${idCard.value}|${mainApiId}`; + whitelistPaymentType.value = "whitelist"; + showWhitelistPayment.value = true; + return; + } + showFailToast("下架成功"); + const updated = getFeatureStatus(mainApiId); + updated.isSubmitting = false; + updated.isOfflined = true; + featureOfflineStatus.value.set(mainApiId, { ...updated }); + if (queryId.value || orderId.value) window.location.reload(); + } catch (err) { + console.error("下架模块失败:", err); + showFailToast("下架模块失败"); + const cur = getFeatureStatus(mainApiId); + cur.isSubmitting = false; + featureOfflineStatus.value.set(mainApiId, { ...cur }); + } +}; + +const confirmOffline = async () => { + if (!currentOfflineFeature.value) return; + const { featureApiId } = currentOfflineFeature.value; + const mainApiId = featureApiId; + if (!queryId.value) { + showFailToast("缺少查询记录ID,无法下架"); + return; + } + const status = getFeatureStatus(mainApiId); + status.isSubmitting = true; + featureOfflineStatus.value.set(mainApiId, { ...status }); + try { + const { data, error } = await offlineFeature({ + query_id: queryId.value, + feature_api_id: mainApiId, + }); + if (!data.value || error.value || data.value.code !== 200) { + showFailToast(data.value?.msg || "下架失败"); + const cur = getFeatureStatus(mainApiId); + cur.isSubmitting = false; + featureOfflineStatus.value.set(mainApiId, { ...cur }); + return; + } + const resp = data.value.data || {}; + if (resp.need_pay) { + showOfflineConfirmDialog.value = false; + whitelistPaymentData.value = { + product_name: `${currentOfflineFeature.value?.featureName || "模块"} 下架`, + sell_price: resp.amount || 0, + }; + whitelistPaymentId.value = `${idCard.value}|${mainApiId}`; + whitelistPaymentType.value = "whitelist"; + showWhitelistPayment.value = true; + const cur = getFeatureStatus(mainApiId); + cur.isSubmitting = false; + featureOfflineStatus.value.set(mainApiId, { ...cur }); + return; + } + showFailToast("下架成功"); + showOfflineConfirmDialog.value = false; + currentOfflineFeature.value = null; + const updated = getFeatureStatus(mainApiId); + updated.isSubmitting = false; + updated.isOfflined = true; + featureOfflineStatus.value.set(mainApiId, { ...updated }); + if (queryId.value || orderId.value) window.location.reload(); + } catch (err) { + console.error("下架模块失败:", err); + showFailToast("下架模块失败"); + const cur = getFeatureStatus(mainApiId); + cur.isSubmitting = false; + featureOfflineStatus.value.set(mainApiId, { ...cur }); + } +}; + const featureMap = { IVYZ5733: { name: "婚姻状态", @@ -691,7 +922,7 @@ const featureRiskLevels = { 'IVYZ5733': 4, // 婚姻状态 'IVYZ9A2B': 4, // 学历信息 'IVYZ3P9M': 4, // 学历信息查询(实时版) - 'IVYZ0S0D': 20, // 劳动仲裁信息 + 'IVYZ0S0D': 10, // 劳动仲裁信息 // 📊 复合报告类 - 按子模块动态计算 @@ -894,9 +1125,16 @@ const showPublicSecurityRecord = import.meta.env.VITE_SHOW_PUBLIC_SECURITY_RECOR - - {{ featureMap[item.data.apiID]?.name }} - +
+ + {{ featureMap[item.data.apiID]?.name }} + + + 下架 + +
+
+ 确定要下架「{{ currentOfflineFeature?.featureName || '该模块' }}」吗?需支付 ¥{{ currentOfflineFeature?.whitelistPrice?.toFixed(2) || '0.00' }}。 +
+ + + + +