This commit is contained in:
2026-03-02 12:58:07 +08:00
parent 4bbdde51f6
commit 69a81a927a
5 changed files with 371 additions and 19 deletions

View File

@@ -278,3 +278,66 @@ export function getInviteLink(params) {
const queryString = buildQueryString(params || {}); const queryString = buildQueryString(params || {});
return useApiFetch(`/agent/invite_link${queryString}`).get().json(); 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();
}

View File

@@ -3,12 +3,17 @@ import ShareReportButton from "./ShareReportButton.vue";
import TitleBanner from "./TitleBanner.vue"; import TitleBanner from "./TitleBanner.vue";
import VerificationCard from "./VerificationCard.vue"; import VerificationCard from "./VerificationCard.vue";
import StyledTabs from "./StyledTabs.vue"; import StyledTabs from "./StyledTabs.vue";
import Payment from "./Payment.vue";
import { splitDWBG8B4DForTabs } from '@/ui/CDWBG8B4D/utils/simpleSplitter.js'; import { splitDWBG8B4DForTabs } from '@/ui/CDWBG8B4D/utils/simpleSplitter.js';
import { splitDWBG6A2CForTabs } from '@/ui/DWBG6A2C/utils/simpleSplitter.js'; import { splitDWBG6A2CForTabs } from '@/ui/DWBG6A2C/utils/simpleSplitter.js';
import { splitJRZQ7F1AForTabs } from '@/ui/JRZQ7F1A/utils/simpleSplitter.js'; import { splitJRZQ7F1AForTabs } from '@/ui/JRZQ7F1A/utils/simpleSplitter.js';
import { splitCJRZQ5E9FForTabs } from '@/ui/CJRZQ5E9F/utils/simpleSplitter.js'; import { splitCJRZQ5E9FForTabs } from '@/ui/CJRZQ5E9F/utils/simpleSplitter.js';
import { splitCQYGL3F8EForTabs } from '@/ui/CQYGL3F8E/utils/simpleSplitter.js'; import { splitCQYGL3F8EForTabs } from '@/ui/CQYGL3F8E/utils/simpleSplitter.js';
import { useAppStore } from "@/stores/appStore"; 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) => { const loadProductBackground = async (productType) => {
@@ -53,6 +58,11 @@ const props = defineProps({
type: String, type: String,
default: "", default: "",
}, },
queryId: {
type: String,
required: false,
default: "",
},
feature: { feature: {
type: String, type: String,
required: true, required: true,
@@ -98,8 +108,20 @@ const {
isEmpty, isEmpty,
isDone, isDone,
isExample, isExample,
orderId,
orderNo,
queryId,
} = toRefs(props); } = 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 active = ref(null);
const backgroundContainerRef = ref(null); // 背景容器的引用 const backgroundContainerRef = ref(null); // 背景容器的引用
@@ -153,6 +175,21 @@ onMounted(async () => {
// 监听窗口大小变化,重新计算高度 // 监听窗口大小变化,重新计算高度
window.addEventListener('resize', handleResize); 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 {}; 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 = { const featureMap = {
IVYZ5733: { IVYZ5733: {
name: "婚姻状态", name: "婚姻状态",
@@ -691,7 +922,7 @@ const featureRiskLevels = {
'IVYZ5733': 4, // 婚姻状态 'IVYZ5733': 4, // 婚姻状态
'IVYZ9A2B': 4, // 学历信息 'IVYZ9A2B': 4, // 学历信息
'IVYZ3P9M': 4, // 学历信息查询(实时版) 'IVYZ3P9M': 4, // 学历信息查询(实时版)
'IVYZ0S0D': 20, // 劳动仲裁信息 'IVYZ0S0D': 10, // 劳动仲裁信息
// 📊 复合报告类 - 按子模块动态计算 // 📊 复合报告类 - 按子模块动态计算
@@ -894,9 +1125,16 @@ const showPublicSecurityRecord = import.meta.env.VITE_SHOW_PUBLIC_SECURITY_RECOR
</van-tab> </van-tab>
<van-tab v-for="(item, index) in processedReportData" :key="`${item.data.apiID}_${index}`" <van-tab v-for="(item, index) in processedReportData" :key="`${item.data.apiID}_${index}`"
:title="featureMap[item.data.apiID]?.name"> :title="featureMap[item.data.apiID]?.name">
<TitleBanner :id="item.data.apiID" class="mb-4"> <div class="flex items-center justify-between gap-2 mb-4">
<TitleBanner :id="item.data.apiID" class="mb-0 flex-1">
{{ featureMap[item.data.apiID]?.name }} {{ featureMap[item.data.apiID]?.name }}
</TitleBanner> </TitleBanner>
<van-button v-if="!isShare && !isExample && isAgentOrder && !getFeatureStatus(item.data.apiID).isOfflined"
size="small" type="default" :loading="getFeatureStatus(item.data.apiID).isSubmitting"
@click="handleOfflineClick(item.data.apiID, featureMap[item.data.apiID]?.name)">
下架
</van-button>
</div>
<component :is="featureMap[item.data.apiID]?.component" :ref="el => { <component :is="featureMap[item.data.apiID]?.component" :ref="el => {
if (el) { if (el) {
const refKey = `${item.data.apiID}_${index}`; const refKey = `${item.data.apiID}_${index}`;
@@ -949,6 +1187,18 @@ const showPublicSecurityRecord = import.meta.env.VITE_SHOW_PUBLIC_SECURITY_RECOR
<div>{{ companyName }}版权所有</div> <div>{{ companyName }}版权所有</div>
</div> </div>
<!-- 下架确认弹窗付费场景 -->
<van-dialog v-model:show="showOfflineConfirmDialog" title="确认下架"
show-cancel-button @confirm="confirmOffline">
<div class="p-4 text-gray-600">
确定要下架{{ currentOfflineFeature?.featureName || '该模块' }}需支付 ¥{{ currentOfflineFeature?.whitelistPrice?.toFixed(2) || '0.00' }}
</div>
</van-dialog>
<!-- 白名单下架支付弹窗 -->
<Payment v-model="showWhitelistPayment" :data="whitelistPaymentData"
:id="whitelistPaymentId" :type="whitelistPaymentType" :return-url="getCurrentReportUrl()" />
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -85,6 +85,10 @@ const props = defineProps({
type: String, type: String,
required: true, required: true,
}, },
returnUrl: {
type: String,
default: "",
},
}); });
const show = defineModel(); const show = defineModel();
@@ -132,10 +136,9 @@ async function getPayment() {
// 测试支付模式:直接跳转到结果页面 // 测试支付模式:直接跳转到结果页面
if (selectedPaymentMethod.value === "test" || selectedPaymentMethod.value === "test_empty") { if (selectedPaymentMethod.value === "test" || selectedPaymentMethod.value === "test_empty") {
orderNo.value = data.value.data.order_no; orderNo.value = data.value.data.order_no;
router.push({ const query = { orderNo: data.value.data.order_no };
path: "/payment/result", if (props.returnUrl) query.returnUrl = props.returnUrl;
query: { orderNo: data.value.data.order_no }, router.push({ path: "/payment/result", query });
});
} else if (selectedPaymentMethod.value === "alipay") { } else if (selectedPaymentMethod.value === "alipay") {
orderNo.value = data.value.data.order_no; orderNo.value = data.value.data.order_no;
// 存储订单ID以便支付宝返回时获取 // 存储订单ID以便支付宝返回时获取
@@ -156,10 +159,9 @@ async function getPayment() {
// 支付成功:短延迟再跳转,给后端回调与异步任务留出时间,避免结果页查报告报错 // 支付成功:短延迟再跳转,给后端回调与异步任务留出时间,避免结果页查报告报错
showToast({ message: "支付成功,正在跳转...", type: "success" }); showToast({ message: "支付成功,正在跳转...", type: "success" });
setTimeout(() => { setTimeout(() => {
router.push({ const query = { orderNo: data.value.data.order_no };
path: "/payment/result", if (props.returnUrl) query.returnUrl = props.returnUrl;
query: { orderNo: data.value.data.order_no }, router.push({ path: "/payment/result", query });
});
}, 1500); }, 1500);
} }
} }

View File

@@ -31,18 +31,25 @@
<span class="text-gray-800">{{ <span class="text-gray-800">{{
paymentType === "agent_upgrade" paymentType === "agent_upgrade"
? "代理升级" ? "代理升级"
: paymentType === "whitelist"
? "模块下架"
: "查询服务" : "查询服务"
}}</span> }}</span>
</div> </div>
</div> </div>
<div v-if="paymentType === 'agent_upgrade'" class="text-center text-gray-600 mb-4">恭喜你升级代理等级成功享受更多权益 <div v-if="paymentType === 'agent_upgrade'" class="text-center text-gray-600 mb-4">恭喜你升级代理等级成功享受更多权益
</div> </div>
<div v-else-if="paymentType === 'whitelist'" class="text-center text-gray-600 mb-4">
模块下架成功该身份证号查询时将不显示此模块的数据
</div>
<div class="action-buttons grid grid-cols-1 gap-4"> <div class="action-buttons grid grid-cols-1 gap-4">
<van-button block type="primary" class="rounded-lg" @click="handleNavigation"> <van-button block type="primary" class="rounded-lg" @click="handleNavigation">
{{ {{
paymentType === "agent_upgrade" paymentType === "agent_upgrade"
? "查看代理信息" ? "查看代理信息"
: paymentType === "whitelist"
? "返回报告"
: "查看查询结果" : "查看查询结果"
}} }}
</van-button> </van-button>
@@ -74,6 +81,8 @@
<span class="text-gray-800">{{ <span class="text-gray-800">{{
paymentType === "agent_upgrade" paymentType === "agent_upgrade"
? "代理升级" ? "代理升级"
: paymentType === "whitelist"
? "模块下架"
: "查询服务" : "查询服务"
}}</span> }}</span>
</div> </div>
@@ -137,6 +146,8 @@
<span class="text-gray-800">{{ <span class="text-gray-800">{{
paymentType === "agent_upgrade" paymentType === "agent_upgrade"
? "代理升级" ? "代理升级"
: paymentType === "whitelist"
? "模块下架"
: "查询服务" : "查询服务"
}}</span> }}</span>
</div> </div>
@@ -329,6 +340,20 @@ const checkPaymentStatus = async () => {
return; return;
} }
// 对于白名单类型,如果状态是已支付,跳转回报告页
if (paymentType.value === "whitelist" && newStatus === "paid") {
stopPolling();
const returnUrl = route.query.returnUrl;
if (returnUrl) {
router.replace(returnUrl);
} else if (window.history.length > 1) {
router.go(-1);
} else {
router.replace("/");
}
return;
}
// 如果状态不是 pending停止轮询 // 如果状态不是 pending停止轮询
if (newStatus !== "pending") { if (newStatus !== "pending") {
stopPolling(); stopPolling();
@@ -414,6 +439,16 @@ function handleNavigation() {
router.replace("/agent"); router.replace("/agent");
agentStore.fetchAgentStatus(); agentStore.fetchAgentStatus();
userStore.fetchUserInfo(); userStore.fetchUserInfo();
} else if (paymentType.value === "whitelist") {
// 白名单支付:优先使用 returnUrl否则返回上一页
const returnUrl = route.query.returnUrl;
if (returnUrl) {
router.replace(returnUrl);
} else if (window.history.length > 1) {
router.go(-1);
} else {
router.replace("/");
}
} else { } else {
// 跳转到查询结果页面 // 跳转到查询结果页面
router.replace({ router.replace({

View File

@@ -1,7 +1,7 @@
<template> <template>
<BaseReport v-if="queryState === 'success'" :order-id="orderId" :order-no="orderNo" :feature="feature" <BaseReport v-if="queryState === 'success'" :order-id="orderId" :order-no="orderNo" :query-id="queryId"
:reportData="reportData" :reportParams="reportParams" :reportName="reportName" :reportDateTime="reportDateTime" :feature="feature" :reportData="reportData" :reportParams="reportParams" :reportName="reportName"
:isEmpty="isEmpty" :isDone="isDone" :isExample="false" /> :reportDateTime="reportDateTime" :isEmpty="isEmpty" :isDone="isDone" :isExample="false" />
<div v-else-if="queryState === 'pending'" class="loading-container"> <div v-else-if="queryState === 'pending'" class="loading-container">
<div class="loading-spinner"></div> <div class="loading-spinner"></div>
<p>报告生成中请稍候...</p> <p>报告生成中请稍候...</p>
@@ -27,6 +27,7 @@ const isEmpty = ref(false);
const isDone = ref(false); const isDone = ref(false);
const orderId = ref(null); const orderId = ref(null);
const orderNo = ref(""); const orderNo = ref("");
const queryId = ref("");
const queryState = ref(""); const queryState = ref("");
const pollingInterval = ref(null); const pollingInterval = ref(null);
@@ -98,6 +99,7 @@ const getReport = async () => {
queryState.value = decryptedData.query_state; queryState.value = decryptedData.query_state;
if (queryState.value === "success") { if (queryState.value === "success") {
feature.value = decryptedData.product || ""; feature.value = decryptedData.product || "";
queryId.value = decryptedData.id || decryptedData.query_id || "";
const sortedQueryData = Array.isArray(decryptedData.query_data) const sortedQueryData = Array.isArray(decryptedData.query_data)
? [...decryptedData.query_data].sort((a, b) => { ? [...decryptedData.query_data].sort((a, b) => {