diff --git a/Server/application/superadmin/controller/TrafficPool.php b/Server/application/superadmin/controller/TrafficPool.php index 27ccd022..f81edaaf 100644 --- a/Server/application/superadmin/controller/TrafficPool.php +++ b/Server/application/superadmin/controller/TrafficPool.php @@ -35,7 +35,7 @@ class TrafficPool extends Controller ->field([ 'ts.id', 'tp.wechatId', - 'tp.createTime as addTime', + 'ts.createTime as addTime', 'ts.fromd as source', 'c.name as projectName', 'wa.avatar', @@ -65,7 +65,9 @@ class TrafficPool extends Controller default: $item['gender'] = '保密'; } - + + $item['addTime'] = $item['addTime'] ? date('Y-m-d H:i:s', $item['addTime']) : null; + // 处理标签显示 if (is_string($item['tags'])) { $item['tags'] = json_decode($item['tags'], true); @@ -123,7 +125,7 @@ class TrafficPool extends Controller $result = [ 'source' => $sourceInfo['source'], - 'addTime' => $sourceInfo['addTime'], + 'addTime' => $sourceInfo['addTime'] ? date('Y-m-d H:i:s', $sourceInfo['addTime']) : null, 'projectName' => $sourceInfo['projectName'] ]; diff --git a/SuperAdmin/app/dashboard/customers/[id]/page.tsx b/SuperAdmin/app/dashboard/customers/[id]/page.tsx index ff6243f5..5fb1fd4c 100644 --- a/SuperAdmin/app/dashboard/customers/[id]/page.tsx +++ b/SuperAdmin/app/dashboard/customers/[id]/page.tsx @@ -1,5 +1,6 @@ "use client" +import { useEffect, useState } from "react" import Link from "next/link" import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" @@ -7,19 +8,10 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Badge } from "@/components/ui/badge" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { ArrowLeft, MessageSquare, Phone, UserPlus } from "lucide-react" +import { getCustomerDetail, CustomerDetail } from "@/lib/traffic-pool-api" -// Sample customer data -const customerData = { - id: "1", - name: "张三", - avatar: "/placeholder.svg?height=100&width=100", - wechatId: "zhangsan123", - gender: "男", - region: "北京", - source: "微信搜索", - tags: ["潜在客户", "高消费"], - projectName: "电商平台项目", - addedDate: "2023-06-10", +// 示例数据(用于详细信息部分) +const detailData = { devices: [ { id: "d1", name: "iPhone 13 Pro", addedDate: "2023-06-10" }, { id: "d2", name: "MacBook Pro", addedDate: "2023-06-12" }, @@ -63,6 +55,43 @@ const customerData = { } export default function CustomerDetailPage({ params }: { params: { id: string } }) { + const [customer, setCustomer] = useState(null) + const [isLoading, setIsLoading] = useState(true) + const [error, setError] = useState(null) + + useEffect(() => { + const fetchCustomerDetail = async () => { + try { + setIsLoading(true) + const response = await getCustomerDetail(params.id) + if (response.code === 200) { + setCustomer(response.data) + setError(null) + } else { + setError(response.msg || "获取客户详情失败") + } + } catch (err: any) { + setError(err.message || "获取客户详情失败") + } finally { + setIsLoading(false) + } + } + + fetchCustomerDetail() + }, [params.id]) + + if (isLoading) { + return
加载中...
+ } + + if (error) { + return
{error}
+ } + + if (!customer) { + return
未找到客户信息
+ } + return (
@@ -86,15 +115,14 @@ export default function CustomerDetailPage({ params }: { params: { id: string } - - {customerData.name.slice(0, 2)} + + {customer.nickname.slice(0, 2)} -

{customerData.name}

-

{customerData.wechatId}

+

{customer.nickname}

- {customerData.tags.map((tag) => ( - + {customer.tags.map((tag, index) => ( + {tag} ))} @@ -103,23 +131,23 @@ export default function CustomerDetailPage({ params }: { params: { id: string }
性别 - {customerData.gender} + {customer.gender}
地区 - {customerData.region} + {customer.region}
来源 - {customerData.source} + {customer.source}
所属项目 - {customerData.projectName} + {customer.projectName}
添加时间 - {customerData.addedDate} + {customer.addTime || '暂无'}
@@ -138,7 +166,7 @@ export default function CustomerDetailPage({ params }: { params: { id: string } - {customerData.interactions.map((interaction) => ( + {detailData.interactions.map((interaction) => (
{interaction.type === "消息" ? ( @@ -162,7 +190,7 @@ export default function CustomerDetailPage({ params }: { params: { id: string } - {customerData.devices.map((device) => ( + {detailData.devices.map((device) => (

{device.name}

@@ -173,8 +201,8 @@ export default function CustomerDetailPage({ params }: { params: { id: string } - {customerData.transactions.length > 0 ? ( - customerData.transactions.map((transaction) => ( + {detailData.transactions.length > 0 ? ( + detailData.transactions.map((transaction) => (

{transaction.product}

diff --git a/SuperAdmin/app/dashboard/customers/page.tsx b/SuperAdmin/app/dashboard/customers/page.tsx index e966abc7..a7c4c067 100644 --- a/SuperAdmin/app/dashboard/customers/page.tsx +++ b/SuperAdmin/app/dashboard/customers/page.tsx @@ -294,9 +294,9 @@ export default function CustomersPage() { - 客户信息 + 客户昵称 微信ID - 标签 + 性别 地区 来源 公司名称 @@ -341,19 +341,11 @@ export default function CustomersPage() { {customer.wechatId} - -
- {customer.tags.map((tag, index) => ( - - {tag} - - ))} -
-
+ {customer.gender} {customer.region} {customer.source} - {customer.companyName} - {customer.createTime} + {customer.projectName} + {customer.addTime || '暂无'} diff --git a/SuperAdmin/lib/traffic-pool-api.ts b/SuperAdmin/lib/traffic-pool-api.ts index 39f77dfa..bb21c59f 100644 --- a/SuperAdmin/lib/traffic-pool-api.ts +++ b/SuperAdmin/lib/traffic-pool-api.ts @@ -12,11 +12,25 @@ export interface Customer { region: string; tags: string[]; source: string; - companyName: string; - createTime: string; + projectName: string; + addTime: string | null; mobile: number; } +/** + * 客户详情接口 + */ +export interface CustomerDetail { + source: string; + addTime: string | null; + projectName: string; + avatar: string; + nickname: string; + region: string; + gender: string; + tags: string[]; +} + /** * 分页响应数据类型 */ @@ -48,4 +62,11 @@ export async function getTrafficPoolList( } return apiRequest(`/trafficPool/list?${params.toString()}`); +} + +/** + * 获取客户详情 + */ +export async function getCustomerDetail(id: string): Promise> { + return apiRequest(`/trafficPool/detail?id=${id}`); } \ No newline at end of file