首页细节调整

This commit is contained in:
2026-02-06 16:18:04 +08:00
parent d00f0b7412
commit 57846534bc
86 changed files with 2751 additions and 3074 deletions

View File

@@ -1,8 +1,8 @@
<template>
<template>
<view class="page" @click.self="closeMoreMenu">
<!-- 鍥哄畾椤堕儴瀵艰埅鏍?-->
<!-- 固定顶部导航栏 -->
<AnalyticsTopBar
:title="'鐢ㄦ埛鍒嗘瀽'"
:title="'用户分析'"
:lastUpdateTime="lastUpdateTime"
:sidebarVisible="showSidebarMenu"
@menu-click="handleMenu"
@@ -16,21 +16,21 @@
/>
<view class="page-layout">
<!-- 渚ц竟鏍忚彍鍗曠粍浠?-->
<!-- 侧边栏菜单组件 -->
<AnalyticsSidebarMenu
:visible="showSidebarMenu"
:currentPath="currentPath"
@visible-change="handleSidebarUpdate"
/>
<!-- 涓诲唴瀹瑰尯鍩?-->
<!-- 主内容区域 -->
<view class="main-content">
<view class="container">
<!-- 鍏ㄥ眬绛涢€夊尯 -->
<!-- 全局筛选区 -->
<view class="filters">
<view class="filter-block">
<text class="filter-label">鏃堕棿鑼冨洿</text>
<text class="filter-label">时间范围</text>
<view class="tabs">
<view
v-for="p in timePeriods"
@@ -46,7 +46,8 @@
:class="{ active: customRangeEnabled }"
@click="toggleCustomRange"
>
鑷畾涔? </view>
自定义
</view>
</view>
</view>
@@ -59,52 +60,52 @@
/>
<view class="filter-hint">
<text class="filter-hint-text">娓犻亾/缁堢/浼氬憳/鏂拌€侊細寰呮帴鍏ユ暟鎹悗寮€鏀?/text>
<text class="filter-hint-text">渠道/终端/会员/新老:待接入数据后开放</text>
</view>
</view>
<!-- 鏍稿績 KPI锛堢數鍟嗗寲锛?-->
<!-- 核心 KPI(电商化) -->
<view class="kpi-grid kpi-grid-6">
<view class="kpi-card">
<text class="kpi-label">鏂板鐢ㄦ埛</text>
<text class="kpi-label">新增用户</text>
<text class="kpi-value">{{ formatInt(userData.new_users) }}</text>
<text class="kpi-meta">杈冧笂鏈燂細{{ formatPct(userData.new_user_growth) }}</text>
<text class="kpi-meta">较上期:{{ formatPct(userData.new_user_growth) }}</text>
</view>
<view class="kpi-card">
<text class="kpi-label">娲昏穬鐢ㄦ埛锛圖AU锛?/text>
<text class="kpi-label">活跃用户DAU</text>
<text class="kpi-value">{{ formatInt(userData.active_users) }}</text>
<text class="kpi-meta">杈冧笂鏈燂細{{ formatPct(userData.active_growth) }}</text>
<text class="kpi-meta">较上期:{{ formatPct(userData.active_growth) }}</text>
</view>
<view class="kpi-card" v-if="hasOrderingData">
<text class="kpi-label">涓嬪崟鐢ㄦ埛鏁?/text>
<text class="kpi-label">下单用户数</text>
<text class="kpi-value">{{ formatInt(userData.ordering_users) }}</text>
<text class="kpi-meta">杈冧笂鏈燂細{{ formatPct(userData.ordering_growth) }}</text>
<text class="kpi-meta">较上期:{{ formatPct(userData.ordering_growth) }}</text>
</view>
<view class="kpi-card" v-if="hasPaidData">
<text class="kpi-label">鏀粯鐢ㄦ埛鏁?/text>
<text class="kpi-label">支付用户数</text>
<text class="kpi-value">{{ formatInt(userData.paid_users) }}</text>
<text class="kpi-meta">杈冧笂鏈燂細{{ formatPct(userData.paid_growth) }}</text>
<text class="kpi-meta">较上期:{{ formatPct(userData.paid_growth) }}</text>
</view>
<view class="kpi-card" v-if="hasNewConversionData">
<text class="kpi-label">鏂板杞寲鐜?/text>
<text class="kpi-label">新客转化率</text>
<text class="kpi-value">{{ formatPct(userData.new_user_conversion_rate) }}</text>
<text class="kpi-meta">鏂板 鈫?涓嬪崟/鏀粯</text>
<text class="kpi-meta">新客 → 下单/支付</text>
</view>
<view class="kpi-card">
<text class="kpi-label">澶嶈喘鐜?/text>
<text class="kpi-label">复购率</text>
<text class="kpi-value">{{ formatPct(userData.repurchase_rate) }}</text>
<text class="kpi-meta">杈冧笂鏈燂細{{ formatPct(userData.repurchase_growth) }}</text>
<text class="kpi-meta">较上期:{{ formatPct(userData.repurchase_growth) }}</text>
</view>
</view>
<!-- 澧為暱涓庢椿璺冭秼鍔?-->
<!-- 增长与活跃趋势 -->
<view class="card card-full">
<view class="card-head">
<text class="card-title">澧為暱涓庢椿璺冭秼鍔?/text>
<text class="card-desc">{{ selectedPeriodText }} 路 鏂板 vs 娲昏穬锛圖AU锛?/text>
<text class="card-title">增长与活跃趋势</text>
<text class="card-desc">{{ selectedPeriodText }} · 新增 vs 活跃DAU</text>
</view>
<view v-if="loading || !growthChartOption || !growthChartOption.series || growthChartOption.series.length === 0" class="chart-loading">
<text>{{ loading ? '鍔犺浇涓?..' : '鏆傛棤鏁版嵁' }}</text>
<text>{{ loading ? '加载中...' : '暂无数据' }}</text>
</view>
<EChartsView v-else class="chart-box" :option="growthChartOption" />
</view>
@@ -112,30 +113,30 @@
<view class="two-col">
<view class="card two-col-card">
<view class="card-head">
<text class="card-title">鏂板杞寲瓒嬪娍</text>
<text class="card-desc">鏂板 鈫?涓嬪崟/鏀粯锛堝緟鎺ュ叆锛?/text>
<text class="card-title">新客转化趋势</text>
<text class="card-desc">新客 → 下单/支付(待接入)</text>
</view>
<view class="chart-loading chart-loading-sm">
<text>鏆傛棤鏁版嵁 / 寰呮帴鍏?/text>
<text>暂无数据 / 待接入</text>
</view>
</view>
<view class="card two-col-card">
<view class="card-head">
<text class="card-title">鍥炶 / 澶嶈喘瓒嬪娍</text>
<text class="card-desc">澶嶈喘浜烘暟 / 澶嶈喘鐜囷紙寰呮帴鍏ワ級</text>
<text class="card-title">回访 / 复购趋势</text>
<text class="card-desc">复购人数 / 复购率(待接入)</text>
</view>
<view class="chart-loading chart-loading-sm">
<text>鏆傛棤鏁版嵁 / 寰呮帴鍏?/text>
<text>暂无数据 / 待接入</text>
</view>
</view>
</view>
<!-- 杞寲婕忔枟 -->
<!-- 转化漏斗 -->
<view class="card card-full">
<view class="card-head">
<text class="card-title">杞寲婕忔枟</text>
<text class="card-desc">鎷夋柊 鈫?婵€娲?鈫?杞寲锛堝緟鎺ュ叆鍩嬬偣/浜嬩欢锛?/text>
<text class="card-title">转化漏斗</text>
<text class="card-desc">拉新 → 激活 → 转化(待接入埋点/事件)</text>
</view>
<view class="funnel">
<view class="funnel-steps">
@@ -146,49 +147,49 @@
</view>
<view class="funnel-step-metrics">
<text class="funnel-step-value">{{ formatInt(s.value) }}</text>
<text class="funnel-step-rate" v-if="idx > 0">杞寲锛歿{ formatPct(calcFunnelRate(idx)) }}</text>
<text class="funnel-step-rate" v-else>鈥?/text>
<text class="funnel-step-rate" v-if="idx > 0">转化:{{ formatPct(calcFunnelRate(idx)) }}</text>
<text class="funnel-step-rate" v-else>—</text>
</view>
</view>
</view>
<view class="funnel-empty" v-if="!hasFunnelData">
<text class="funnel-empty-text">鏆傛棤婕忔枟鏁版嵁 / 寰呮帴鍏ワ細UV銆丳DP銆佸姞璐€佷笅鍗曘€佹敮浠?/text>
<text class="funnel-empty-text">暂无漏斗数据 / 待接入UV、PDP、加购、下单、支付</text>
</view>
</view>
</view>
<!-- 鐣欏瓨 / 鍥炶 -->
<!-- 留存 / 回访 -->
<view class="card card-full">
<view class="card-head">
<text class="card-title">鐣欏瓨涓庡洖璁?/text>
<text class="card-desc">{{ selectedPeriodText }} 1/3/7/14/30鏃ョ暀瀛橈紙Cohort 鍚庣画琛ワ級</text>
<text class="card-title">留存与回访</text>
<text class="card-desc">{{ selectedPeriodText }} · 1/3/7/14/30日留存(Cohort 后续补)</text>
</view>
<view class="two-col">
<view class="two-col-item">
<view class="sub-head">
<text class="sub-title">鐣欏瓨鏇茬嚎</text>
<text class="sub-desc">鐣欏瓨鐜囪秼鍔匡紙寰呮帴鍏ワ級</text>
<text class="sub-title">留存曲线</text>
<text class="sub-desc">留存率趋势(待接入)</text>
</view>
<EChartsView class="chart-box chart-box-sm" :option="retentionChartOption" />
</view>
<view class="two-col-item">
<view class="sub-head">
<text class="sub-title">娴佸け鐢ㄦ埛鍗犳瘮</text>
<text class="sub-desc">7/14澶╂湭娲昏穬锛堝緟鎺ュ叆锛?/text>
<text class="sub-title">流失用户占比</text>
<text class="sub-desc">7/14天未活跃(待接入)</text>
</view>
<view class="metric-empty">
<text class="metric-empty-text">鏆傛棤鏁版嵁 / 寰呮帴鍏?/text>
<text class="metric-empty-text">暂无数据 / 待接入</text>
</view>
</view>
</view>
</view>
<!-- 鐢ㄦ埛鍒嗙兢锛堣繍钀ュ彲鐢級 -->
<!-- 用户分群(运营可用) -->
<view class="card card-full">
<view class="card-head">
<text class="card-title">鐢ㄦ埛鍒嗙兢锛堣繍钀ュ彲鐢級</text>
<text class="card-desc">RFM / LTV / 鏂板鍒嗗眰锛堝悗缁ˉ锛?路 褰撳墠涓哄熀纭€缁撴瀯鍗犳瘮</text>
<text class="card-title">用户分群(运营可用)</text>
<text class="card-desc">RFM / LTV / 新客分层(后续补) · 当前为基础结构占比</text>
</view>
<view class="two-col">
<view class="two-col-item">
@@ -196,24 +197,24 @@
</view>
<view class="two-col-item">
<view class="sub-head">
<text class="sub-title">鐢ㄦ埛鐢诲儚锛堝熀纭€锛?/text>
<text class="sub-desc">鎬у埆/骞撮緞/鍦板煙锛堝緟鎺ュ叆锛?/text>
<text class="sub-title">用户画像(基础)</text>
<text class="sub-desc">性别/年龄/地域(待接入)</text>
</view>
<EChartsView class="chart-box chart-box-sm" :option="profileChartOption" />
</view>
</view>
</view>
<!-- 娓犻亾鏉ユ簮锛圓cquisition锛?-->
<!-- 渠道来源Acquisition -->
<view class="card card-full">
<view class="card-head">
<text class="card-title">娓犻亾鏉ユ簮</text>
<text class="card-desc">{{ selectedPeriodText }} 路 娓犻亾鍗犳瘮锛堝悗缁彲鎵╁睍娓犻亾璐ㄩ噺琛級</text>
<text class="card-title">渠道来源</text>
<text class="card-desc">{{ selectedPeriodText }} · 渠道占比(后续可扩展渠道质量表)</text>
</view>
<EChartsView class="chart-box" :option="trafficChartOption" />
</view>
<!-- 鐣欑櫧 -->
<!-- 留白 -->
<view style="height: 24px;"></view>
</view>
</view>
@@ -247,10 +248,10 @@ const showSidebarMenu = ref(false)
const currentPath = ref('/pages/mall/analytics/user-analysis')
const timePeriods = ref<Array<TimePeriod>>([
{ value: '7d', label: '7澶? },
{ value: '30d', label: '30澶? },
{ value: '90d', label: '90澶? },
{ value: '1y', label: '1骞? }
{ value: '7d', label: '7天' },
{ value: '30d', label: '30天' },
{ value: '90d', label: '90天' },
{ value: '1y', label: '1年' }
])
const userData = reactive<UserData>({
@@ -278,18 +279,18 @@ const segmentChartOption = ref<any>({})
const trafficChartOption = ref<any>({})
const funnelSteps = reactive<Array<FunnelStep>>([
{ step: '璁块棶鐢ㄦ埛锛圲V锛?, value: 0 },
{ step: '鍟嗗搧璇︽儏椤碉紙PDP UV锛?, value: 0 },
{ step: '鍔犺喘鐢ㄦ埛', value: 0 },
{ step: '涓嬪崟鐢ㄦ埛', value: 0 },
{ step: '鏀粯鐢ㄦ埛', value: 0 }
{ step: '访问用户UV', value: 0 },
{ step: '商品详情页(PDP UV', value: 0 },
{ step: '加购用户', value: 0 },
{ step: '下单用户', value: 0 },
{ step: '支付用户', value: 0 }
])
const loading = ref(false)
const selectedPeriodText = computed((): string => {
const p = timePeriods.value.find((t) => t.value === selectedPeriod.value)
return p ? p.label : '7澶?
return p ? p.label : '7天'
})
const hasOrderingData = computed((): boolean => {
@@ -387,12 +388,12 @@ async function loadUserData() {
growthChartOption.value = {
grid: { left: 40, right: 18, top: 20, bottom: 40 },
tooltip: { trigger: 'axis' },
legend: { data: ['鏂板鐢ㄦ埛', '娲昏穬鐢ㄦ埛锛圖AU锛?], bottom: 0 },
legend: { data: ['新增用户', '活跃用户DAU'], bottom: 0 },
xAxis: { type: 'category', data: x, axisLabel: { color: 'rgba(0,0,0,0.55)' } },
yAxis: { type: 'value', axisLabel: { color: 'rgba(0,0,0,0.55)' }, splitLine: { lineStyle: { color: 'rgba(0,0,0,0.06)' } } },
series: [
{ name: '鏂板鐢ㄦ埛', type: 'line', data: newArr, smooth: true, symbolSize: 6, areaStyle: { opacity: 0.08 } },
{ name: '娲昏穬鐢ㄦ埛锛圖AU锛?, type: 'line', data: activeArr, smooth: true, symbolSize: 6 }
{ name: '新增用户', type: 'line', data: newArr, smooth: true, symbolSize: 6, areaStyle: { opacity: 0.08 } },
{ name: '活跃用户DAU', type: 'line', data: activeArr, smooth: true, symbolSize: 6 }
]
}
@@ -410,7 +411,7 @@ async function loadUserData() {
legend: { top: 10, left: 'center', padding: [12, 0, 24, 0] },
series: [
{
name: '鐢ㄦ埛鍒嗙兢',
name: '用户分群',
type: 'pie',
center: ['48%', '60%'],
radius: ['42%', '66%'],
@@ -442,20 +443,20 @@ async function loadUserData() {
}
funnelSteps.splice(0, funnelSteps.length,
{ step: '璁块棶鐢ㄦ埛锛圲V锛?, value: 0 },
{ step: '鍟嗗搧璇︽儏椤碉紙PDP UV锛?, value: 0 },
{ step: '鍔犺喘鐢ㄦ埛', value: 0 },
{ step: '涓嬪崟鐢ㄦ埛', value: 0 },
{ step: '鏀粯鐢ㄦ埛', value: 0 }
{ step: '访问用户UV', value: 0 },
{ step: '商品详情页(PDP UV', value: 0 },
{ step: '加购用户', value: 0 },
{ step: '下单用户', value: 0 },
{ step: '支付用户', value: 0 }
)
retentionChartOption.value = { title: { text: '鐣欏瓨鐜囷紙寰呮帴鍏ワ級', left: 'center', top: 10, textStyle: { fontSize: 12, color: 'rgba(0,0,0,0.55)' } }, series: [] }
activityChartOption.value = { title: { text: '娲昏穬搴︼紙寰呮帴鍏ワ級', left: 'center', top: 10, textStyle: { fontSize: 12, color: 'rgba(0,0,0,0.55)' } }, series: [] }
comparisonChartOption.value = { title: { text: '鏂拌€佺敤鎴峰姣旓紙寰呮帴鍏ワ級', left: 'center', top: 10, textStyle: { fontSize: 12, color: 'rgba(0,0,0,0.55)' } }, series: [] }
profileChartOption.value = { title: { text: '鐢ㄦ埛鐢诲儚锛堝緟鎺ュ叆锛氶渶瑕佹€у埆/骞撮緞/鍦板煙瀛楁锛?, left: 'center', top: 10, textStyle: { fontSize: 12, color: 'rgba(0,0,0,0.55)' } }, series: [] }
retentionChartOption.value = { title: { text: '留存率(待接入)', left: 'center', top: 10, textStyle: { fontSize: 12, color: 'rgba(0,0,0,0.55)' } }, series: [] }
activityChartOption.value = { title: { text: '活跃度(待接入)', left: 'center', top: 10, textStyle: { fontSize: 12, color: 'rgba(0,0,0,0.55)' } }, series: [] }
comparisonChartOption.value = { title: { text: '新老用户对比(待接入)', left: 'center', top: 10, textStyle: { fontSize: 12, color: 'rgba(0,0,0,0.55)' } }, series: [] }
profileChartOption.value = { title: { text: '用户画像(待接入:需要性别/年龄/地域字段)', left: 'center', top: 10, textStyle: { fontSize: 12, color: 'rgba(0,0,0,0.55)' } }, series: [] }
} catch (e) {
console.error('loadUserData failed', e)
uni.showToast({ title: mapAnalyticsError(e, { fallbackMessage: '鏁版嵁鍔犺浇澶辫触' }), icon: 'none', duration: 2000 })
uni.showToast({ title: mapAnalyticsError(e, { fallbackMessage: '数据加载失败' }), icon: 'none', duration: 2000 })
} finally {
loading.value = false
updateTime()
@@ -490,19 +491,19 @@ function onDateRangeClear() {
function refreshData() {
loadUserData()
uni.showToast({ title: '宸插埛鏂?, icon: 'success' })
uni.showToast({ title: '已刷新', icon: 'success' })
}
function exportReport() {
uni.showActionSheet({
itemList: ['瀵煎嚭Excel', '瀵煎嚭PDF', '瀵煎嚭鍥剧墖'],
success: () => uni.showToast({ title: '瀵煎嚭鎴愬姛', icon: 'success' })
itemList: ['导出Excel', '导出PDF', '导出图片'],
success: () => uni.showToast({ title: '导出成功', icon: 'success' })
})
}
function formatInt(n: number): string {
const v = isFinite(n) ? Math.round(n) : 0
if (v >= 10000) return (v / 10000).toFixed(1) + '涓?
if (v >= 10000) return (v / 10000).toFixed(1) + '万'
return v.toString()
}
@@ -537,27 +538,27 @@ function closeMoreMenu() {
}
function handleSearch() {
uni.showToast({ title: '鎼滅储', icon: 'none' })
uni.showToast({ title: '搜索', icon: 'none' })
}
function handleNotification() {
uni.showToast({ title: '閫氱煡', icon: 'none' })
uni.showToast({ title: '通知', icon: 'none' })
}
function handleFullscreen() {
uni.showToast({ title: '鍏ㄥ睆', icon: 'none' })
uni.showToast({ title: '全屏', icon: 'none' })
}
function handleMobile() {
uni.showToast({ title: '绉诲姩绔?, icon: 'none' })
uni.showToast({ title: '移动端', icon: 'none' })
}
function handleDropdown() {
uni.showToast({ title: '涓嬫媺鑿滃崟', icon: 'none' })
uni.showToast({ title: '下拉菜单', icon: 'none' })
}
function handleSettings() {
uni.showToast({ title: '璁剧疆', icon: 'none' })
uni.showToast({ title: '设置', icon: 'none' })
}
</script>
@@ -568,7 +569,7 @@ function handleSettings() {
background: #f6f7fb;
}
/* 椤甸潰甯冨眬锛氬灞忔椂渚ц竟鏍?鍐呭锛岀獎灞忔椂鍏ㄥ睆鍐呭 */
/* 页面布局:宽屏时侧边栏+内容,窄屏时全屏内容 */
.page-layout {
display: flex;
flex-direction: row !important;
@@ -580,10 +581,10 @@ function handleSettings() {
min-width: 0;
display: flex;
flex-direction: column;
padding-top: 64px; /* 涓哄浐瀹氶《閮ㄥ鑸爮鐣欏嚭绌洪棿 */
padding-top: 64px; /* 为固定顶部导航栏留出空间 */
}
/* 鍝嶅簲寮忥細绐勫睆鏃跺叏灞忔樉绀?*/
/* 响应式:窄屏时全屏显示 */
@media screen and (max-width: 959px) {
.page-layout {
flex-direction: column !important;
@@ -598,11 +599,11 @@ function handleSettings() {
width: 100%;
max-width: 1280px;
margin: 0 auto;
/* padding removed */ 16px 28px;
padding: 16px 16px 28px;
box-sizing: border-box;
}
/* 鍏ㄥ眬绛涢€夊尯 */
/* 全局筛选区 */
.filters {
margin-top: 12px;
background: #fff;
@@ -639,7 +640,7 @@ function handleSettings() {
color: #6c757d;
}
/* 鏃堕棿缁村害 tabs */
/* 时间维度 tabs */
.tabs {
display: flex;
flex-direction: row !important;
@@ -670,7 +671,7 @@ function handleSettings() {
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
/* KPI 缃戞牸 */
/* KPI 网格 */
.kpi-grid {
margin-top: 12px;
display: grid;
@@ -740,7 +741,7 @@ function handleSettings() {
color: rgba(0,0,0,0.55);
}
/* 鍗$墖 */
/* 卡片 */
.card {
margin-top: 12px;
background: #fff;
@@ -855,7 +856,7 @@ function handleSettings() {
}
}
/* 婕忔枟 */
/* 漏斗 */
.funnel {
width: 100%;
}
@@ -949,4 +950,3 @@ function handleSettings() {
}
}
</style>