适配微信小程序

This commit is contained in:
zhonghua.li
2026-04-17 09:41:37 +08:00
parent 18455a311d
commit 36b8784bc1
59 changed files with 650 additions and 586 deletions

View File

@@ -16,145 +16,11 @@
</uni-nav-bar>
<view class="content">
<!-- 功能分类展示 -->
<scroll-view class="content-scroll" scroll-y="true" :style="{ top: computedContentTop || contentTop, bottom: contentBottom || '96rpx' }">
<!-- 接待 -->
<view class="category-section quick-links-section">
<view class="category-header">
<text class="category-icon">🚀</text>
<text class="category-title">接待</text>
</view>
<view class="function-grid">
<view class="function-item" @click="quickJumpReceptionTab('reception')">
<view class="function-icon">🤝</view>
<text class="function-name">开始接待</text>
<text class="function-desc"></text>
</view>
<view class="function-item" @click="quickJumpReceptionTab('status')">
<view class="function-icon">📋</view>
<text class="function-name">服务中</text>
<text class="function-desc"></text>
</view>
<view class="function-item" @click="quickJumpReceptionTab('tag')">
<view class="function-icon">🏷</view>
<text class="function-name">标签管理</text>
<text class="function-desc"></text>
</view>
</view>
</view>
<!-- AI分析 -->
<view class="category-section two-column">
<view class="category-header">
<text class="category-icon">👤</text>
<text class="category-title">AI分析</text>
</view>
<view class="function-grid">
<view class="function-item" @click="quickJumpCustomerTab('customer')">
<view class="function-icon">👥</view>
<text class="function-name">客户列表</text>
<text class="function-desc"></text>
</view>
<view class="function-item" @click="quickJumpCustomerTab('service')">
<view class="function-icon">📝</view>
<text class="function-name">服务记录</text>
<text class="function-desc"></text>
</view>
</view>
</view>
<!-- 录音和接待统计 -->
<view class="category-section two-column">
<view class="category-header">
<text class="category-icon">📊</text>
<text class="category-title">录音和接待统计</text>
</view>
<view class="function-grid">
<view class="function-item" @click="navigateToPage('recording_duration')">
<view class="function-icon"></view>
<text class="function-name">录音时长</text>
<text class="function-desc"></text>
</view>
<view class="function-item" @click="navigateToPage('customer_count')">
<view class="function-icon">👥</view>
<text class="function-name">接待客户数</text>
<text class="function-desc"></text>
</view>
</view>
</view>
<!-- 质量管控 -->
<view class="category-section two-column">
<view class="category-header">
<text class="category-icon"></text>
<text class="category-title">质量管控</text>
</view>
<view class="function-grid">
<view class="function-item" @click="showQualityCoveragePopup">
<view class="function-icon">📊</view>
<text class="function-name">质检覆盖率</text>
<text class="function-desc"></text>
</view>
<view class="function-item" @click="navigateToPage('speech_rating')">
<view class="function-icon">🗣</view>
<text class="function-name">员工话术评分</text>
<text class="function-desc"></text>
</view>
</view>
</view>
<!-- 销售分析 -->
<view class="category-section sales-analysis">
<view class="category-header">
<text class="category-icon">📈</text>
<text class="category-title">销售分析</text>
</view>
<view class="function-grid">
<view class="function-item full-row-item" @click="navigateToPage('intent_level')">
<view class="function-icon">🎯</view>
<text class="function-name">客户意向分级</text>
<text class="function-desc"></text>
</view>
<view class="function-item full-row-item" @click="navigateToPage('deal_attribution')">
<view class="function-icon">💰</view>
<text class="function-name">成交归因</text>
<text class="function-desc"></text>
</view>
<view class="function-item full-row-item new-line-item" @click="navigateToPage('opening_rate')">
<view class="function-icon">🚪</view>
<text class="function-name">开口率</text>
<text class="function-desc"></text>
</view>
</view>
</view>
<!-- 风险监控 -->
<view class="category-section two-column">
<view class="category-header">
<text class="category-icon"></text>
<text class="category-title">风险监控</text>
</view>
<view class="function-grid">
<view class="function-item" @click="navigateToPage('over_commitment')">
<view class="function-icon">🚨</view>
<text class="function-name">过度承诺统计</text>
<text class="function-desc"></text>
</view>
<view class="function-item" @click="navigateToPage('red_line_touch')">
<view class="function-icon">🔴</view>
<text class="function-name">触及红线统计</text>
<text class="function-desc"></text>
</view>
</view>
</view>
</scroll-view>
<ai-analysis-dashboard-body
:content-top="computedContentTop || contentTop"
:content-bottom="contentBottom"
/>
</view>
<!-- 质检覆盖率弹出框 -->
<QualityCoveragePopup
v-if="showQualityCoverage"
:open-trigger="openQualityCoverageTrigger"
@close="onQualityCoveragePopupClose" />
</view>
</template>
@@ -162,6 +28,7 @@
// #ifdef APP
import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
// #endif
import AiAnalysisDashboardBody from '@/components/ai-analysis-dashboard-body.vue';
// 注意:子包组件不使用 import 导入,而是通过 componentPlaceholder 配置
// 这样可以确保子包异步加载时组件能正确找到
@@ -206,14 +73,14 @@ function getSystemInfo() {
export default {
// #ifdef APP
components: {
statusBar
// 注意:子包组件不在这里注册,通过 componentPlaceholder 自动处理
// RecordingDurationPopup, CustomerCountPopup, QualityCoveragePopup 通过 componentPlaceholder 配置自动注册
statusBar,
AiAnalysisDashboardBody,
},
// #endif
// #ifndef APP
// 注意:子包组件不在这里注册,通过 componentPlaceholder 自动处理
// CustomerCountPopup, QualityCoveragePopup 通过 componentPlaceholder 配置自动注册
components: {
AiAnalysisDashboardBody,
},
// #endif
data() {
// 动态计算导航栏高度
@@ -228,10 +95,7 @@ export default {
return {
contentTop: totalNavbarHeight + 'rpx', // 内容区域距离顶部的距离
contentBottom: '96rpx', // 内容区域距离底部的距离(默认值,会在 onReady 中更新)
showQualityCoverage: false, // 是否显示质检覆盖率弹出框
subpackageLoaded: false, // 子包是否已加载
popupsInitialized: false, // 弹出框组件是否已初始化
openQualityCoverageTrigger: 0, // 打开质检覆盖率弹出框的触发器
}
},
computed: {
@@ -257,17 +121,6 @@ export default {
this.preloadSubpackage();
}, 100);
// #endif
// 预先创建弹出框组件(使用 v-show组件会被创建但隐藏
// 这样可以避免在访问 $refs 时出现组件未初始化的问题
// 由于使用 v-show组件会在页面加载时就被创建只是通过 CSS 隐藏
this.$nextTick(() => {
// 等待一个渲染周期,确保组件已创建
setTimeout(() => {
this.popupsInitialized = true;
console.log('[AIAnalysis] Popup components ready (using v-show)');
}, 500);
});
},
onShow() {
// 每次页面显示时都重新计算导航栏位置
@@ -377,20 +230,6 @@ export default {
}
},
// #endif
// 显示质检覆盖率弹出框
showQualityCoveragePopup() {
// 显示组件(使用 v-show组件已存在只是显示
this.showQualityCoverage = true;
// 使用触发器来通知子组件打开弹窗,避免直接访问 refs
this.$nextTick(() => {
this.openQualityCoverageTrigger++;
});
},
// 质检覆盖率弹出框关闭事件
onQualityCoveragePopupClose() {
// 弹出框关闭时隐藏组件
this.showQualityCoverage = false;
},
// 计算并更新导航栏和内容区域的位置
updateNavbarPosition() {
const systemInfo = getSystemInfo();
@@ -421,56 +260,6 @@ export default {
console.error('[AIAnalysis][goBack] 返回失败:', err);
}
});
},
navigateToPage(pageName) {
const pagePath = `pages-subpackage/ai_features/${pageName}/${pageName}`
uni.navigateTo({
url: `/${pagePath}`,
fail: (err) => {
console.error('导航失败:', err)
uni.showToast({
title: '页面跳转失败',
icon: 'none'
})
}
})
},
quickJumpReceptionTab(tabKey) {
const allowedTabs = ['status', 'reception', 'tag'];
if (!allowedTabs.includes(tabKey)) {
return;
}
try {
uni.setStorageSync('workbench-reception-tab', tabKey);
} catch (e) {
console.warn('[AIAnalysis] 写入接待tab快捷跳转参数失败:', e);
}
uni.navigateTo({
url: '/pages/furniture_reception/furniture_reception',
fail: (err) => {
console.error('[AIAnalysis] 快捷跳转接待页失败:', err);
uni.showToast({
title: '跳转失败,请稍后重试',
icon: 'none'
});
}
});
},
quickJumpCustomerTab(tabKey) {
const allowedTabs = ['service', 'customer'];
if (!allowedTabs.includes(tabKey)) {
return;
}
uni.navigateTo({
url: `/pages-subpackage/furniture_customer/furniture_customer?tab=${tabKey}`,
fail: (err) => {
console.error('[AIAnalysis] 快捷跳转客户页失败:', err);
uni.showToast({
title: '跳转失败,请稍后重试',
icon: 'none'
});
}
});
}
}
}
@@ -483,15 +272,15 @@ page {
.page {
min-height: 100vh;
background-color: #F5F5F5;
background-color: #f5f5f5;
}
.content {
padding-top: 0 !important;
margin-top: 0 !important;
position: relative;
min-height: 100vh;
/* 确保内容从顶部开始,不受占位符影响 */
width: 100%;
min-height: calc(100vh - 200rpx);
top: 0;
}
@@ -519,151 +308,4 @@ page {
display: none !important;
height: 0 !important;
}
.content-scroll {
position: absolute;
left: 0;
right: 0;
top: 0; /* 先从顶部开始 */
bottom: 0; /* 先设为0通过查询实际高度动态设置 */
/* top值通过内联样式动态设置覆盖上面的 top: 0 */
padding: 0 !important;
padding-bottom: 0 !important;
margin: 0 !important;
box-sizing: border-box;
}
/* 确保scroll-view内部没有默认间距 */
.content-scroll > view {
margin-top: 0;
padding-top: 0;
margin-bottom: 0;
padding-bottom: 0;
}
.category-section {
margin: 20rpx 30rpx;
background: #FFFFFF;
border-radius: 16rpx;
overflow: hidden;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}
.category-section:first-child {
margin-top: 0;
}
.category-section:last-child {
margin-bottom: 0;
}
.category-header {
display: flex;
align-items: center;
padding: 30rpx;
background: #FFFFFF;
border-bottom: 1rpx solid #F0F0F0;
}
.category-icon {
font-size: 32rpx;
margin-right: 20rpx;
}
.category-title {
font-size: 32rpx;
font-weight: 500;
color: #333;
}
.function-grid {
display: flex;
flex-wrap: wrap;
padding: 10rpx;
}
.quick-links-section .function-item {
width: calc(33.333% - 10rpx);
background: #FFFFFF;
border-radius: 12rpx;
padding: 24rpx 12rpx;
margin: 5rpx;
text-align: center;
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.04);
transition: all 0.3s ease;
border: 1rpx solid #F0F0F0;
box-sizing: border-box;
}
/* 两列布局的分类 */
.two-column .function-item {
flex: 1;
background: #FFFFFF;
border-radius: 12rpx;
padding: 24rpx 16rpx;
margin: 0 5rpx;
text-align: center;
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.04);
transition: all 0.3s ease;
border: 1rpx solid #F0F0F0;
}
/* 三列布局的分类 */
.three-column .function-item {
width: 31%;
background: #FFFFFF;
border-radius: 12rpx;
padding: 24rpx 12rpx;
margin: 1%;
text-align: center;
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.04);
transition: all 0.3s ease;
border: 1rpx solid #F0F0F0;
}
/* 销售分析所有项目统一宽度50% */
.sales-analysis .function-item.full-row-item {
flex: 1;
width: calc(50% - 10rpx);
background: #FFFFFF;
border-radius: 12rpx;
padding: 24rpx 16rpx;
margin: 0 5rpx;
text-align: center;
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.04);
transition: all 0.3s ease;
border: 1rpx solid #F0F0F0;
}
/* 销售分析开口率单独一行但保持50%宽度 */
.sales-analysis .function-item.new-line-item {
flex-basis: 100%;
width: calc(50% - 10rpx);
margin-top: 10rpx;
}
.function-item:active {
transform: scale(0.95);
box-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.1);
}
.function-icon {
font-size: 48rpx;
margin-bottom: 12rpx;
}
.function-name {
display: block;
font-size: 28rpx;
font-weight: 500;
color: #333;
margin-bottom: 8rpx;
}
.function-desc {
display: block;
font-size: 24rpx;
color: #666;
line-height: 1.4;
}
</style>

View File

@@ -13,16 +13,12 @@
</template>
<script>
// 微信小程序pages.json 的 componentPlaceholder 注册分包组件requiredComponents / 分包异步化)
// #ifndef MP-WEIXIN
// 全端显式注册:微信小程序下仅用 componentPlaceholder 时,子组件实例不会出现在 this.$refs 上,导致无法 refresh。
import FurnitureReceptionImpl from '@/pages-subpackage/furniture_reception/furniture_reception-impl.vue';
// #endif
export default {
components: {
// #ifndef MP-WEIXIN
FurnitureReceptionImpl
// #endif
},
data() {
return {
@@ -31,7 +27,14 @@ export default {
error: ''
};
},
onLoad() {
onLoad(options) {
// 与 storage 双通道:避免分包异步晚于 onShow 时漏掉目标 tab
const tab = options && options.tab;
if (tab && ['status', 'reception', 'tag'].includes(String(tab))) {
try {
uni.setStorageSync('workbench-reception-tab', String(tab));
} catch (e) {}
}
this.loadImpl();
},
onShow() {
@@ -40,16 +43,20 @@ export default {
const allowed = ['status', 'reception', 'tag'];
const tab = (uni.getStorageSync('workbench-reception-tab') || '').toString();
if (allowed.includes(tab)) {
// 先清空再赋值,确保同一个 tabKey 也能触发子组件 watcher
this.incomingTab = '';
this.$nextTick(() => {
this.incomingTab = tab;
});
uni.removeStorageSync('workbench-reception-tab');
// 首次进入loadImpl 往往在 onShow 的 $nextTick 之前就 implReady若先 incomingTab='' 再 nextTick 赋回,
// 子组件首次挂载会拿到空 tab且与宿主 refresh 竞态。
if (!this.implReady) {
this.incomingTab = tab;
} else {
// 页面已缓存再次显示:脉冲触发子组件 watcher
this.incomingTab = '';
this.$nextTick(() => {
this.incomingTab = tab;
});
}
}
} catch (e) {
// ignore
}
} catch (e) {}
// 底部 tab 等场景下页面会被缓存,子组件 mounted 不会再次执行,需每次显示时拉取最新数据
this.refreshImplDataIfReady();
},
@@ -79,6 +86,7 @@ export default {
await this.loadSubPackagePagesSubpackage();
this.implReady = true;
await this.$nextTick();
await this.$nextTick();
this.refreshImplDataIfReady();
} catch (e) {
console.error('[FurnitureReceptionHost] loadImpl failed:', e);
@@ -89,12 +97,19 @@ export default {
if (!this.implReady) {
return;
}
this.$nextTick(() => {
const impl = this.$refs.furnitureReceptionImpl;
if (impl && typeof impl.refreshPageData === 'function') {
impl.refreshPageData();
}
});
const tryRefresh = (attempt) => {
this.$nextTick(() => {
const impl = this.$refs.furnitureReceptionImpl;
if (impl && typeof impl.refreshPageData === 'function') {
impl.refreshPageData();
return;
}
if (attempt < 3) {
setTimeout(() => tryRefresh(attempt + 1), 50);
}
});
};
tryRefresh(0);
}
}
};

View File

@@ -392,7 +392,7 @@
this[item.event]();
} else if (item.to) {
// 如果是 tabBar 页面,使用 switchTab
const tabBarPages = ['/pages-subpackage/furniture_customer/furniture_customer', '/pages/ai_analysis/ai_analysis', '/pages/xixi/xixi', '/pages/ucenter/ucenter']
const tabBarPages = ['/pages-subpackage/furniture_customer/furniture_customer', '/pages/workbench/workbench', '/pages/xixi/xixi', '/pages/ucenter/ucenter']
if (item.to === '/pages/furniture_reception/furniture_reception') {
uni.navigateTo({
url: item.to

View File

@@ -4,24 +4,24 @@
<view class="category-section two-column">
<view class="category-header">
<text class="category-icon">🏷</text>
<text class="category-title">接待页面标签</text>
<text class="category-title">接待</text>
</view>
<view class="function-grid">
<view class="function-item" @click="openReceptionTab('reception')">
<view class="function-icon">🛎</view>
<text class="function-name">开始接待</text>
<text class="function-desc">进入接待页并切到开始接待</text>
<text class="function-desc"></text>
</view>
<view class="function-item" @click="openReceptionTab('status')">
<view class="function-icon">📌</view>
<text class="function-name">服务中</text>
<text class="function-desc">进入接待页并切到服务中</text>
<text class="function-desc"></text>
</view>
<view class="function-item" @click="openReceptionTab('tag')">
<view class="function-icon">🗂</view>
<text class="function-name">标签管理</text>
<text class="function-desc">进入接待页并切到标签管理</text>
<text class="function-desc"></text>
</view>
</view>
</view>
@@ -29,18 +29,18 @@
<view class="category-section two-column">
<view class="category-header">
<text class="category-icon">👤</text>
<text class="category-title">客户页面标签</text>
<text class="category-title">客户</text>
</view>
<view class="function-grid">
<view class="function-item" @click="openCustomerTab('service')">
<view class="function-icon">📝</view>
<text class="function-name">服务记录</text>
<text class="function-desc">进入客户页并切到服务记录</text>
<text class="function-desc"></text>
</view>
<view class="function-item" @click="openCustomerTab('customer')">
<view class="function-icon">👥</view>
<text class="function-name">客户</text>
<text class="function-desc">进入客户页并切到客户列表</text>
<text class="function-desc"></text>
</view>
</view>
</view>
@@ -62,32 +62,24 @@ export default {
},
},
methods: {
/** 与「服务记录」一致:直跳分包页 + query避免主包宿主页在微信上的 ref/占位问题 */
openReceptionTab(tab) {
this.switchTabWithQuery('/pages/furniture_reception/furniture_reception', tab);
const allowed = ['status', 'reception', 'tag'];
if (!allowed.includes(tab)) {
return;
}
const url = `/pages-subpackage/furniture_reception/furniture_reception_entry?tab=${encodeURIComponent(tab)}`;
uni.navigateTo({
url,
fail: () => {
uni.showToast({ title: '跳转接待页失败', icon: 'none' });
},
});
},
openCustomerTab(tab) {
const url = `/pages-subpackage/furniture_customer/furniture_customer?tab=${tab}`;
uni.navigateTo({ url });
},
switchTabWithQuery(basePath, tab) {
if (basePath === '/pages/furniture_reception/furniture_reception') {
uni.setStorageSync('workbench-reception-tab', tab);
uni.navigateTo({
url: basePath,
fail: () => {
uni.showToast({ title: '跳转接待页失败', icon: 'none' });
},
});
return;
}
uni.switchTab({
url: basePath,
fail: () => {
const fallbackUrl = `${basePath}?tab=${tab}`;
uni.navigateTo({ url: fallbackUrl });
},
});
},
},
};
</script>

View File

@@ -19,7 +19,14 @@
:contentTop="contentTop"
:contentBottom="contentBottom"
/>
<view v-else class="redirecting-text">正在跳转到 AI 分析...</view>
<ai-analysis-dashboard-body
v-else-if="isSoftSalesScenario"
:content-top="contentTop"
:content-bottom="contentBottom"
/>
<view v-else class="redirecting-text">
<text>当前未配置为销售或轻销场景backend-scenario 不是 sales / soft_sales工作台入口已隐藏</text>
</view>
</view>
</view>
</template>
@@ -29,6 +36,7 @@
import statusBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar';
// #endif
import SalesScenarioNew from './components/sales_scenario_new.vue';
import AiAnalysisDashboardBody from '@/components/ai-analysis-dashboard-body.vue';
function getSystemInfo() {
try {
@@ -49,6 +57,7 @@ export default {
statusBar,
// #endif
SalesScenarioNew,
AiAnalysisDashboardBody,
},
data() {
const systemInfo = getSystemInfo();
@@ -57,6 +66,7 @@ export default {
contentTop: totalNavbarHeight + 'rpx',
contentBottom: '96rpx',
isSalesScenario: false,
isSoftSalesScenario: false,
};
},
onShow() {
@@ -64,13 +74,9 @@ export default {
},
methods: {
refreshScenario() {
const scenario = (uni.getStorageSync('backend-scenario') || '').toString().toLowerCase();
const scenario = (uni.getStorageSync('backend-scenario') || '').toString().trim().toLowerCase();
this.isSalesScenario = scenario === 'sales';
if (!this.isSalesScenario) {
uni.switchTab({
url: '/pages/ai_analysis/ai_analysis',
});
}
this.isSoftSalesScenario = scenario === 'soft_sales';
},
},
};
@@ -86,9 +92,13 @@ page {
background-color: #f5f5f5;
}
/* 子组件(销售工作台 / AI 分析主体)使用 position:absolute + top/bottom不占文档流
若此处无明确高度,父级会被压成 0导致整块空白。 */
.content {
position: relative;
width: 100%;
min-height: 100vh;
box-sizing: border-box;
}
.redirecting-text {