录音时长统调整后端接口
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../common/vendor.js");
|
||||
const common_request = require("../../../common/request.js");
|
||||
const common_config = require("../../../common/config.js");
|
||||
function getSystemInfo() {
|
||||
if (typeof common_vendor.wx$1 !== "undefined" && common_vendor.wx$1.getWindowInfo) {
|
||||
try {
|
||||
@@ -10,7 +12,7 @@ function getSystemInfo() {
|
||||
windowHeight: windowInfo.windowHeight
|
||||
};
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("warn", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:95", "[RecordingDuration] Failed to use wx.getWindowInfo, fallback to getSystemInfoSync:", e);
|
||||
common_vendor.index.__f__("warn", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:98", "[RecordingDuration] Failed to use wx.getWindowInfo, fallback to getSystemInfoSync:", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
@@ -21,7 +23,7 @@ function getSystemInfo() {
|
||||
windowHeight: systemInfo.windowHeight
|
||||
};
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:109", "[RecordingDuration] Failed to get system info:", e);
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:112", "[RecordingDuration] Failed to get system info:", e);
|
||||
return {
|
||||
statusBarHeight: 20,
|
||||
windowWidth: 375,
|
||||
@@ -49,17 +51,15 @@ const _sfc_main = {
|
||||
// 默认选择1个月
|
||||
showTimeRangeDropdown: false,
|
||||
// 控制下拉菜单显示
|
||||
totalDuration: "125.5 小时",
|
||||
todayDuration: "8.2 小时",
|
||||
dataList: [
|
||||
{ date: "2024-02-07", description: "客户咨询录音", duration: "2.5 小时" },
|
||||
{ date: "2024-02-06", description: "销售洽谈录音", duration: "3.2 小时" },
|
||||
{ date: "2024-02-05", description: "培训录音", duration: "1.8 小时" },
|
||||
{ date: "2024-02-04", description: "会议录音", duration: "4.1 小时" },
|
||||
{ date: "2024-02-03", description: "客户反馈录音", duration: "2.9 小时" }
|
||||
]
|
||||
totalDuration: "0 小时",
|
||||
todayDuration: "0 小时",
|
||||
dataList: [],
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.loadData();
|
||||
},
|
||||
onReady() {
|
||||
this.$nextTick(() => {
|
||||
const query = common_vendor.index.createSelectorQuery().in(this);
|
||||
@@ -71,7 +71,7 @@ const _sfc_main = {
|
||||
const totalHeight = statusBarHeightRpx + actualHeightRpx;
|
||||
const adjustedHeight = Math.max(totalHeight - 4, 0);
|
||||
this.$set(this, "contentTop", adjustedHeight + "rpx");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:163", "[RecordingDuration] 使用实际导航栏高度:", actualHeight, "px =", actualHeightRpx, "rpx, 总高度:", totalHeight, "rpx, 调整后:", adjustedHeight, "rpx");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:165", "[RecordingDuration] 使用实际导航栏高度:", actualHeight, "px =", actualHeightRpx, "rpx, 总高度:", totalHeight, "rpx, 调整后:", adjustedHeight, "rpx");
|
||||
} else {
|
||||
const systemInfo = getSystemInfo();
|
||||
const statusBarHeight = systemInfo.statusBarHeight;
|
||||
@@ -90,7 +90,7 @@ const _sfc_main = {
|
||||
const tabbarHeightRpx = tabbarHeight * 2;
|
||||
const adjustedBottom = Math.max(tabbarHeightRpx - 4, 0);
|
||||
this.$set(this, "contentBottom", adjustedBottom + "rpx");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:187", "[RecordingDuration] 使用实际tabbar高度:", tabbarHeight, "px =", tabbarHeightRpx, "rpx, 调整后:", adjustedBottom, "rpx");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:189", "[RecordingDuration] 使用实际tabbar高度:", tabbarHeight, "px =", tabbarHeightRpx, "rpx, 调整后:", adjustedBottom, "rpx");
|
||||
} else {
|
||||
this.$set(this, "contentBottom", "0rpx");
|
||||
}
|
||||
@@ -105,7 +105,7 @@ const _sfc_main = {
|
||||
const totalHeight = statusBarHeightRpx + actualHeightRpx;
|
||||
const adjustedHeight = Math.max(totalHeight - 4, 0);
|
||||
this.$set(this, "contentTop", adjustedHeight + "rpx");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:206", "[RecordingDuration] 延迟更新导航栏高度:", actualHeight, "px =", actualHeightRpx, "rpx, 总高度:", totalHeight, "rpx, 调整后:", adjustedHeight, "rpx");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:208", "[RecordingDuration] 延迟更新导航栏高度:", actualHeight, "px =", actualHeightRpx, "rpx, 总高度:", totalHeight, "rpx, 调整后:", adjustedHeight, "rpx");
|
||||
}
|
||||
}).exec();
|
||||
const queryTabbar2 = common_vendor.index.createSelectorQuery().in(this);
|
||||
@@ -115,7 +115,7 @@ const _sfc_main = {
|
||||
const tabbarHeightRpx = tabbarHeight * 2;
|
||||
const adjustedBottom = Math.max(tabbarHeightRpx - 4, 0);
|
||||
this.$set(this, "contentBottom", adjustedBottom + "rpx");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:218", "[RecordingDuration] 延迟更新tabbar高度:", tabbarHeight, "px =", tabbarHeightRpx, "rpx, 调整后:", adjustedBottom, "rpx");
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:220", "[RecordingDuration] 延迟更新tabbar高度:", tabbarHeight, "px =", tabbarHeightRpx, "rpx, 调整后:", adjustedBottom, "rpx");
|
||||
}
|
||||
}).exec();
|
||||
}, 200);
|
||||
@@ -138,15 +138,181 @@ const _sfc_main = {
|
||||
},
|
||||
onRefresh() {
|
||||
this.loadData();
|
||||
common_vendor.index.showToast({
|
||||
title: "刷新成功",
|
||||
icon: "success",
|
||||
duration: 1500
|
||||
});
|
||||
},
|
||||
loadData() {
|
||||
const months = this.timeRangeIndex === 0 ? 1 : this.timeRangeIndex === 1 ? 3 : 6;
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:253", `加载最近${months}个月的数据`);
|
||||
/**
|
||||
* 获取当前登录用户信息
|
||||
*/
|
||||
getCurrentUserInfo() {
|
||||
try {
|
||||
const loginResponse = common_vendor.index.getStorageSync("backend-login-response") || {};
|
||||
return {
|
||||
salesId: loginResponse.userId ? String(loginResponse.userId) : null,
|
||||
salesPhone: loginResponse.phone || null
|
||||
};
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:257", "获取用户信息失败:", e);
|
||||
return { salesId: null, salesPhone: null };
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 格式化时长(分钟转小时)
|
||||
*/
|
||||
formatDuration(minutes) {
|
||||
if (!minutes || minutes === 0)
|
||||
return "0 小时";
|
||||
const hours = (minutes / 60).toFixed(1);
|
||||
return `${hours} 小时`;
|
||||
},
|
||||
/**
|
||||
* 格式化日期
|
||||
*/
|
||||
formatDate(dateStr) {
|
||||
if (!dateStr)
|
||||
return "";
|
||||
try {
|
||||
const date = new Date(dateStr);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
return `${year}-${month}-${day}`;
|
||||
} catch (e) {
|
||||
return dateStr;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 加载统计数据
|
||||
*/
|
||||
async loadData() {
|
||||
if (this.loading) {
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
try {
|
||||
const userInfo = this.getCurrentUserInfo();
|
||||
const { salesId, salesPhone } = userInfo;
|
||||
if (!salesId && !salesPhone) {
|
||||
common_vendor.index.showToast({
|
||||
title: "无法获取用户信息",
|
||||
icon: "none",
|
||||
duration: 2e3
|
||||
});
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
const dateRangeType = this.timeRangeIndex + 1;
|
||||
const queryParams = {
|
||||
dateRangeType
|
||||
};
|
||||
if (salesId) {
|
||||
queryParams.salesId = salesId;
|
||||
}
|
||||
if (salesPhone) {
|
||||
queryParams.salesPhone = salesPhone;
|
||||
}
|
||||
const queryString = Object.keys(queryParams).filter((key) => queryParams[key] !== null && queryParams[key] !== void 0 && queryParams[key] !== "").map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(queryParams[key])}`).join("&");
|
||||
const baseUrl = common_config.getApiUrl("/api/audio-statistics/sales");
|
||||
const url = queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:338", "[RecordingDuration] 请求参数:", queryParams);
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:339", "[RecordingDuration] 请求URL:", url);
|
||||
common_vendor.index.showLoading({
|
||||
title: "加载中...",
|
||||
mask: true
|
||||
});
|
||||
const res = await common_request.post(url, {});
|
||||
common_vendor.index.hideLoading();
|
||||
if (res.statusCode === 200 && res.data) {
|
||||
const result = res.data;
|
||||
if (!result.success) {
|
||||
const errorMsg = result.msg || result.message || "查询失败";
|
||||
common_vendor.index.showToast({
|
||||
title: errorMsg,
|
||||
icon: "none",
|
||||
duration: 2e3
|
||||
});
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
const statisticsList = result.data || [];
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:371", "[RecordingDuration] 返回数据:", statisticsList);
|
||||
this.processStatisticsData(statisticsList);
|
||||
common_vendor.index.showToast({
|
||||
title: "刷新成功",
|
||||
icon: "success",
|
||||
duration: 1500
|
||||
});
|
||||
} else {
|
||||
throw new Error("请求失败,状态码: " + res.statusCode);
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.__f__("error", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:389", "[RecordingDuration] 加载数据失败:", error);
|
||||
common_vendor.index.showToast({
|
||||
title: error.message || "加载失败,请重试",
|
||||
icon: "none",
|
||||
duration: 2e3
|
||||
});
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 处理统计数据
|
||||
*/
|
||||
processStatisticsData(statisticsList) {
|
||||
if (!statisticsList || statisticsList.length === 0) {
|
||||
this.totalDuration = "0 小时";
|
||||
this.todayDuration = "0 小时";
|
||||
this.dataList = [];
|
||||
return;
|
||||
}
|
||||
let totalDurationMinutes = 0;
|
||||
let totalRecordingCount = 0;
|
||||
const formattedList = statisticsList.map((item) => {
|
||||
const salesDuration = item.salesTotalDuration || 0;
|
||||
totalDurationMinutes += salesDuration;
|
||||
totalRecordingCount += item.salesRecordingCount || 0;
|
||||
const date = this.formatDate(item.statisticsDate);
|
||||
let description = "";
|
||||
if (item.salesName) {
|
||||
description = `${item.salesName}的录音`;
|
||||
} else if (item.dealershipName) {
|
||||
description = `${item.dealershipName}的录音`;
|
||||
} else {
|
||||
description = "录音统计";
|
||||
}
|
||||
return {
|
||||
date,
|
||||
description,
|
||||
duration: this.formatDuration(salesDuration),
|
||||
// 保存原始数据,方便后续使用
|
||||
rawData: item
|
||||
};
|
||||
});
|
||||
formattedList.sort((a, b) => {
|
||||
if (a.date > b.date)
|
||||
return -1;
|
||||
if (a.date < b.date)
|
||||
return 1;
|
||||
return 0;
|
||||
});
|
||||
this.totalDuration = this.formatDuration(totalDurationMinutes);
|
||||
this.dataList = formattedList;
|
||||
const today = /* @__PURE__ */ new Date();
|
||||
const todayStr = this.formatDate(today.toISOString());
|
||||
const todayItem = statisticsList.find((item) => {
|
||||
const itemDate = this.formatDate(item.statisticsDate);
|
||||
return itemDate === todayStr;
|
||||
});
|
||||
if (todayItem) {
|
||||
this.todayDuration = this.formatDuration(todayItem.salesTotalDuration || 0);
|
||||
} else {
|
||||
this.todayDuration = "0 小时";
|
||||
}
|
||||
common_vendor.index.__f__("log", "at pages-subpackage/ai_features/recording_duration/recording_duration.vue:469", "[RecordingDuration] 数据处理完成:", {
|
||||
totalDuration: this.totalDuration,
|
||||
todayDuration: this.todayDuration,
|
||||
dataListCount: this.dataList.length
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user