完善录音时长功能
This commit is contained in:
@@ -25,12 +25,12 @@
|
||||
<text class="category-title">录音和接待统计</text>
|
||||
</view>
|
||||
<view class="function-grid">
|
||||
<view class="function-item" @click="showRecordingDurationPopup">
|
||||
<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-item" @click="showCustomerCountPopup">
|
||||
<view class="function-icon">👥</view>
|
||||
<text class="function-name">接待客户数</text>
|
||||
<text class="function-desc">统计接待客户数量</text>
|
||||
@@ -105,16 +105,16 @@
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 录音时长弹出框 -->
|
||||
<RecordingDurationPopup
|
||||
v-if="popupReady"
|
||||
ref="recordingDurationPopup"
|
||||
@close="onPopupClose" />
|
||||
<!-- 接待客户数弹出框 -->
|
||||
<CustomerCountPopup
|
||||
v-if="showCustomerCount"
|
||||
:open-trigger="openCustomerCountTrigger"
|
||||
@close="onCustomerCountPopupClose" />
|
||||
|
||||
<!-- 质检覆盖率弹出框 -->
|
||||
<QualityCoveragePopup
|
||||
v-if="popupReady"
|
||||
ref="qualityCoveragePopup"
|
||||
v-if="showQualityCoverage"
|
||||
:open-trigger="openQualityCoverageTrigger"
|
||||
@close="onQualityCoveragePopupClose" />
|
||||
</view>
|
||||
</template>
|
||||
@@ -123,27 +123,63 @@
|
||||
// #ifdef APP
|
||||
import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
|
||||
// #endif
|
||||
import RecordingDurationPopup from "@/pages-subpackage/ai_features/recording_duration/recording-duration-popup.vue";
|
||||
import QualityCoveragePopup from "@/pages-subpackage/ai_features/quality_coverage/quality-coverage-popup.vue";
|
||||
|
||||
// 注意:子包组件不使用 import 导入,而是通过 componentPlaceholder 配置
|
||||
// 这样可以确保子包异步加载时组件能正确找到
|
||||
// CustomerCountPopup, QualityCoveragePopup 通过 componentPlaceholder 自动注册
|
||||
|
||||
// 获取系统信息的辅助函数,优先使用新 API
|
||||
function getSystemInfo() {
|
||||
// #ifdef MP-WEIXIN
|
||||
// 微信小程序:优先使用新的 API
|
||||
if (typeof wx !== 'undefined' && wx.getWindowInfo) {
|
||||
try {
|
||||
const windowInfo = wx.getWindowInfo();
|
||||
return {
|
||||
statusBarHeight: windowInfo.statusBarHeight || 20,
|
||||
windowWidth: windowInfo.windowWidth,
|
||||
windowHeight: windowInfo.windowHeight
|
||||
};
|
||||
} catch (e) {
|
||||
console.warn('[AIAnalysis] Failed to use wx.getWindowInfo, fallback to getSystemInfoSync:', e);
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
|
||||
// 回退到旧的 API 或使用 uni-app 的 API
|
||||
try {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
return {
|
||||
statusBarHeight: systemInfo.statusBarHeight || 20,
|
||||
windowWidth: systemInfo.windowWidth,
|
||||
windowHeight: systemInfo.windowHeight
|
||||
};
|
||||
} catch (e) {
|
||||
console.error('[AIAnalysis] Failed to get system info:', e);
|
||||
return {
|
||||
statusBarHeight: 20,
|
||||
windowWidth: 375,
|
||||
windowHeight: 667
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
// #ifdef APP
|
||||
components: {
|
||||
statusBar,
|
||||
RecordingDurationPopup,
|
||||
QualityCoveragePopup
|
||||
statusBar
|
||||
// 注意:子包组件不在这里注册,通过 componentPlaceholder 自动处理
|
||||
// RecordingDurationPopup, CustomerCountPopup, QualityCoveragePopup 通过 componentPlaceholder 配置自动注册
|
||||
},
|
||||
// #endif
|
||||
// #ifndef APP
|
||||
components: {
|
||||
RecordingDurationPopup,
|
||||
QualityCoveragePopup
|
||||
},
|
||||
// 注意:子包组件不在这里注册,通过 componentPlaceholder 自动处理
|
||||
// CustomerCountPopup, QualityCoveragePopup 通过 componentPlaceholder 配置自动注册
|
||||
// #endif
|
||||
data() {
|
||||
// 动态计算导航栏高度
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const statusBarHeight = systemInfo.statusBarHeight || 20; // 默认20px
|
||||
const systemInfo = getSystemInfo();
|
||||
const statusBarHeight = systemInfo.statusBarHeight; // 默认20px
|
||||
const navbarHeight = 44; // navbar高度44px
|
||||
// 转换为rpx:1px = 2rpx(在375px设计稿下)
|
||||
const statusBarHeightRpx = statusBarHeight * 2;
|
||||
@@ -153,14 +189,19 @@ export default {
|
||||
return {
|
||||
contentTop: totalNavbarHeight + 'rpx', // 内容区域距离顶部的距离
|
||||
contentBottom: '96rpx', // 内容区域距离底部的距离(默认值,会在 onReady 中更新)
|
||||
popupReady: false, // 弹出框组件是否准备就绪
|
||||
showCustomerCount: false, // 是否显示接待客户数弹出框
|
||||
showQualityCoverage: false, // 是否显示质检覆盖率弹出框
|
||||
subpackageLoaded: false, // 子包是否已加载
|
||||
popupsInitialized: false, // 弹出框组件是否已初始化
|
||||
openCustomerCountTrigger: 0, // 打开接待客户数弹出框的触发器
|
||||
openQualityCoverageTrigger: 0, // 打开质检覆盖率弹出框的触发器
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 计算内容区域的位置(使用计算属性确保响应式)
|
||||
computedContentTop() {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const statusBarHeight = systemInfo.statusBarHeight || 20;
|
||||
const systemInfo = getSystemInfo();
|
||||
const statusBarHeight = systemInfo.statusBarHeight;
|
||||
const navbarHeight = 44;
|
||||
const statusBarHeightRpx = statusBarHeight * 2;
|
||||
const navbarHeightRpx = navbarHeight * 2;
|
||||
@@ -171,11 +212,24 @@ export default {
|
||||
onLoad() {
|
||||
// 更新导航栏位置
|
||||
this.updateNavbarPosition();
|
||||
// 延迟设置弹出框就绪状态,确保组件已加载
|
||||
// 在微信小程序中,子包会在组件使用时自动加载
|
||||
// 但我们可以尝试预加载以提高响应速度
|
||||
// #ifdef MP-WEIXIN
|
||||
// 延迟预加载,避免阻塞页面初始化
|
||||
setTimeout(() => {
|
||||
this.preloadSubpackage();
|
||||
}, 100);
|
||||
// #endif
|
||||
|
||||
// 预先创建弹出框组件(使用 v-show,组件会被创建但隐藏)
|
||||
// 这样可以避免在访问 $refs 时出现组件未初始化的问题
|
||||
// 由于使用 v-show,组件会在页面加载时就被创建,只是通过 CSS 隐藏
|
||||
this.$nextTick(() => {
|
||||
// 等待一个渲染周期,确保组件已创建
|
||||
setTimeout(() => {
|
||||
this.popupReady = true;
|
||||
}, 100);
|
||||
this.popupsInitialized = true;
|
||||
console.log('[AIAnalysis] Popup components ready (using v-show)');
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
onShow() {
|
||||
@@ -204,8 +258,8 @@ export default {
|
||||
console.log('[AIAnalysis] 使用实际导航栏高度:', actualHeight, 'px =', actualHeightRpx, 'rpx, 调整后:', adjustedHeight, 'rpx');
|
||||
} else {
|
||||
// 如果查询失败,使用默认计算并减小一点
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const statusBarHeight = systemInfo.statusBarHeight || 20;
|
||||
const systemInfo = getSystemInfo();
|
||||
const statusBarHeight = systemInfo.statusBarHeight;
|
||||
const navbarHeight = 44;
|
||||
const statusBarHeightRpx = statusBarHeight * 2;
|
||||
const navbarHeightRpx = navbarHeight * 2;
|
||||
@@ -262,52 +316,62 @@ export default {
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
// 显示录音时长弹出框
|
||||
showRecordingDurationPopup() {
|
||||
// 确保组件已准备就绪
|
||||
if (!this.popupReady) {
|
||||
console.warn('[AIAnalysis] Popup component not ready yet');
|
||||
return;
|
||||
// 预加载子包
|
||||
// #ifdef MP-WEIXIN
|
||||
preloadSubpackage() {
|
||||
// 使用微信原生 API 预加载子包
|
||||
if (typeof wx !== 'undefined' && wx.loadSubpackage) {
|
||||
wx.loadSubpackage({
|
||||
name: 'pages-subpackage',
|
||||
success: () => {
|
||||
console.log('[AIAnalysis] Subpackage loaded successfully');
|
||||
this.subpackageLoaded = true;
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('[AIAnalysis] Failed to load subpackage:', err);
|
||||
// 即使加载失败,也尝试继续(可能已经加载过了)
|
||||
this.subpackageLoaded = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 如果 API 不可用,标记为已加载(可能已经自动加载)
|
||||
console.log('[AIAnalysis] loadSubpackage API not available, assuming subpackage will load automatically');
|
||||
this.subpackageLoaded = true;
|
||||
}
|
||||
|
||||
},
|
||||
// #endif
|
||||
// 显示接待客户数弹出框
|
||||
showCustomerCountPopup() {
|
||||
// 显示组件(使用 v-show,组件已存在,只是显示)
|
||||
this.showCustomerCount = true;
|
||||
// 使用触发器来通知子组件打开弹窗,避免直接访问 refs
|
||||
this.$nextTick(() => {
|
||||
const popup = this.$refs.recordingDurationPopup;
|
||||
if (popup && typeof popup.open === 'function') {
|
||||
popup.open();
|
||||
} else {
|
||||
console.error('[AIAnalysis] recordingDurationPopup ref not found or open method not available');
|
||||
}
|
||||
this.openCustomerCountTrigger++;
|
||||
});
|
||||
},
|
||||
// 弹出框关闭事件
|
||||
onPopupClose() {
|
||||
// 弹出框关闭时的处理
|
||||
// 接待客户数弹出框关闭事件
|
||||
onCustomerCountPopupClose() {
|
||||
// 弹出框关闭时隐藏组件
|
||||
this.showCustomerCount = false;
|
||||
},
|
||||
// 显示质检覆盖率弹出框
|
||||
showQualityCoveragePopup() {
|
||||
// 确保组件已准备就绪
|
||||
if (!this.popupReady) {
|
||||
console.warn('[AIAnalysis] Popup component not ready yet');
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示组件(使用 v-show,组件已存在,只是显示)
|
||||
this.showQualityCoverage = true;
|
||||
// 使用触发器来通知子组件打开弹窗,避免直接访问 refs
|
||||
this.$nextTick(() => {
|
||||
const popup = this.$refs.qualityCoveragePopup;
|
||||
if (popup && typeof popup.open === 'function') {
|
||||
popup.open();
|
||||
} else {
|
||||
console.error('[AIAnalysis] qualityCoveragePopup ref not found or open method not available');
|
||||
}
|
||||
this.openQualityCoverageTrigger++;
|
||||
});
|
||||
},
|
||||
// 质检覆盖率弹出框关闭事件
|
||||
onQualityCoveragePopupClose() {
|
||||
// 弹出框关闭时的处理
|
||||
// 弹出框关闭时隐藏组件
|
||||
this.showQualityCoverage = false;
|
||||
},
|
||||
// 计算并更新导航栏和内容区域的位置
|
||||
updateNavbarPosition() {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const statusBarHeight = systemInfo.statusBarHeight || 20;
|
||||
const systemInfo = getSystemInfo();
|
||||
const statusBarHeight = systemInfo.statusBarHeight;
|
||||
const navbarHeight = 44;
|
||||
// 转换为rpx:1px = 2rpx(在375px设计稿下)
|
||||
const statusBarHeightRpx = statusBarHeight * 2;
|
||||
|
||||
Reference in New Issue
Block a user