525 lines
21 KiB
JavaScript
525 lines
21 KiB
JavaScript
"use strict";
|
||
const common_vendor = require("../../../common/vendor.js");
|
||
const common_config = require("../../../common/config.js");
|
||
const pages_furniture_customer_utils_dataInit = require("../utils/dataInit.js");
|
||
const _sfc_main = {
|
||
name: "ConversationSummaryFurniture",
|
||
props: {
|
||
// 服务记录项
|
||
serviceItem: {
|
||
type: Object,
|
||
default: () => ({})
|
||
}
|
||
},
|
||
data() {
|
||
return {
|
||
summaryList: [],
|
||
furnitureAnalysisList: [],
|
||
// 家具意向分析数据
|
||
productCategoryList: [],
|
||
// 产品类别列表
|
||
activeProductCategory: "",
|
||
// 当前选中的产品类别
|
||
productRequirementMap: {},
|
||
// 产品需求映射 {categoryKey: {rows: [...]}}
|
||
summarySentence: "",
|
||
// 一句话总结
|
||
dealKeyPoints: "",
|
||
// 成交关键点
|
||
loading: false
|
||
// 加载状态
|
||
};
|
||
},
|
||
computed: {
|
||
// 当前选中的产品需求
|
||
currentProductRequirement() {
|
||
if (!this.activeProductCategory)
|
||
return null;
|
||
return this.productRequirementMap[this.activeProductCategory] || null;
|
||
}
|
||
},
|
||
watch: {
|
||
serviceItem: {
|
||
handler(newVal, oldVal) {
|
||
var _a, _b;
|
||
if (newVal === oldVal) {
|
||
return;
|
||
}
|
||
if (newVal && typeof newVal === "object") {
|
||
const newId = newVal.id || ((_a = newVal.rawData) == null ? void 0 : _a.id);
|
||
const oldId = (oldVal == null ? void 0 : oldVal.id) || ((_b = oldVal == null ? void 0 : oldVal.rawData) == null ? void 0 : _b.id);
|
||
if (newId && newId === oldId) {
|
||
return;
|
||
}
|
||
if (newId) {
|
||
this.initData();
|
||
this.loadFurnitureAnalysis(newVal);
|
||
} else {
|
||
this.initData();
|
||
}
|
||
} else {
|
||
this.initData();
|
||
}
|
||
},
|
||
immediate: true,
|
||
deep: true
|
||
}
|
||
},
|
||
mounted() {
|
||
var _a;
|
||
if (this.serviceItem && (this.serviceItem.id || ((_a = this.serviceItem.rawData) == null ? void 0 : _a.id))) {
|
||
this.initData();
|
||
this.loadFurnitureAnalysis(this.serviceItem);
|
||
}
|
||
},
|
||
methods: {
|
||
// 初始化数据
|
||
initData() {
|
||
var _a;
|
||
try {
|
||
if (this.serviceItem && (this.serviceItem.id || ((_a = this.serviceItem.rawData) == null ? void 0 : _a.id))) {
|
||
this.summaryList = pages_furniture_customer_utils_dataInit.initSummaryList(this.serviceItem);
|
||
} else {
|
||
this.summaryList = [];
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/furniture_customer/components/ConversationSummaryFurniture.vue:197", "初始化总结数据失败:", error);
|
||
this.summaryList = [];
|
||
}
|
||
this.productCategoryList = [];
|
||
this.activeProductCategory = "";
|
||
this.productRequirementMap = {};
|
||
this.summarySentence = "";
|
||
this.dealKeyPoints = "";
|
||
this.furnitureAnalysisList = [];
|
||
this.loading = false;
|
||
},
|
||
// 加载家具意向分析数据
|
||
async loadFurnitureAnalysis(item) {
|
||
var _a, _b;
|
||
if (!item) {
|
||
return;
|
||
}
|
||
try {
|
||
this.loading = true;
|
||
const parentId = ((_a = item.rawData) == null ? void 0 : _a.id) || item.id;
|
||
if (!parentId) {
|
||
common_vendor.index.__f__("warn", "at pages/furniture_customer/components/ConversationSummaryFurniture.vue:220", "无法获取parentId");
|
||
this.furnitureAnalysisList = [];
|
||
this.loading = false;
|
||
return;
|
||
}
|
||
const url = `${common_config.getApiUrl("/api/audioTextAnalysisFurniture/byParentId")}?parentId=${parentId}`;
|
||
const res = await common_vendor.index.request({
|
||
url,
|
||
method: "GET",
|
||
timeout: 1e4
|
||
});
|
||
if (res.statusCode === 200 && res.data && res.data.success) {
|
||
this.furnitureAnalysisList = res.data.data || [];
|
||
if (this.furnitureAnalysisList.length > 0) {
|
||
this.updateSummaryWithFurnitureData();
|
||
}
|
||
} else {
|
||
common_vendor.index.__f__("warn", "at pages/furniture_customer/components/ConversationSummaryFurniture.vue:242", "获取家具意向分析失败:", ((_b = res.data) == null ? void 0 : _b.message) || "未知错误");
|
||
this.furnitureAnalysisList = [];
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/furniture_customer/components/ConversationSummaryFurniture.vue:246", "获取家具意向分析失败:", error);
|
||
this.furnitureAnalysisList = [];
|
||
} finally {
|
||
this.loading = false;
|
||
}
|
||
},
|
||
// 用家具意向分析数据更新会话总结
|
||
updateSummaryWithFurnitureData() {
|
||
if (this.furnitureAnalysisList.length === 0)
|
||
return;
|
||
const firstItem = this.furnitureAnalysisList[0];
|
||
const summaryItems = [];
|
||
if (firstItem.customerType) {
|
||
summaryItems.push({
|
||
label: "客户类型",
|
||
value: firstItem.customerType,
|
||
rawData: firstItem
|
||
});
|
||
}
|
||
if (firstItem.familyStructure) {
|
||
summaryItems.push({
|
||
label: "家庭结构",
|
||
value: firstItem.familyStructure,
|
||
rawData: firstItem
|
||
});
|
||
}
|
||
if (firstItem.summarySentence) {
|
||
this.summarySentence = firstItem.summarySentence;
|
||
}
|
||
if (firstItem.dealKeyPoints) {
|
||
this.dealKeyPoints = firstItem.dealKeyPoints;
|
||
} else if (firstItem.summarySentence) {
|
||
const keyWords = [];
|
||
const summary = firstItem.summarySentence;
|
||
if (summary.includes("优惠") || summary.includes("活动")) {
|
||
keyWords.push("活动优惠");
|
||
}
|
||
if (summary.includes("搭配")) {
|
||
keyWords.push("整套搭配");
|
||
}
|
||
if (summary.includes("环保")) {
|
||
keyWords.push("环保");
|
||
}
|
||
if (summary.includes("安全")) {
|
||
keyWords.push("安全");
|
||
}
|
||
if (summary.includes("交付") || summary.includes("周期")) {
|
||
keyWords.push("快速交付");
|
||
}
|
||
if (summary.includes("退换") || summary.includes("服务")) {
|
||
keyWords.push("无忧退换服务");
|
||
}
|
||
if (keyWords.length > 0) {
|
||
this.dealKeyPoints = keyWords.join(",");
|
||
}
|
||
}
|
||
if (summaryItems.length > 0) {
|
||
this.summaryList = summaryItems;
|
||
}
|
||
this.buildProductRequirementList(firstItem);
|
||
},
|
||
// 构建产品需求清单(固定显示所有产品类别)
|
||
buildProductRequirementList(data) {
|
||
const categories = [
|
||
{ key: "sofa", name: "沙发", field: "sofa" },
|
||
{ key: "bed", name: "床", field: "bedAndMattress" },
|
||
{ key: "mattress", name: "床垫", field: "bedAndMattress" },
|
||
{ key: "dining_table", name: "餐桌椅", field: "diningTable" },
|
||
{ key: "tea_table", name: "茶几", field: "teaTable" },
|
||
{ key: "tv_cabinet", name: "电视柜", field: "tvCabinet" },
|
||
{ key: "study_desk", name: "学习桌", field: "studyDesk" },
|
||
{ key: "cabinet", name: "橱柜", field: "cabinet" },
|
||
{ key: "wine_cabinet", name: "酒柜", field: "wineCabinet" },
|
||
{ key: "master_bedroom_cabinet", name: "主卧衣柜", field: "masterBedroomCabinet" },
|
||
{ key: "secondary_bedroom_cabinet", name: "次卧衣柜", field: "secondaryBedroomCabinet" },
|
||
{ key: "shoe_cabinet", name: "鞋柜", field: "shoeCabinet" },
|
||
{ key: "custom", name: "定制家居", field: null }
|
||
];
|
||
const requirementMap = {};
|
||
const categoryList = [];
|
||
categories.forEach((category) => {
|
||
let hasData = false;
|
||
let productData = null;
|
||
if (category.key === "bed" || category.key === "mattress") {
|
||
const fieldValue = data.bedAndMattress || data.bed_and_mattress || "";
|
||
if (fieldValue && fieldValue.trim()) {
|
||
hasData = true;
|
||
productData = this.parseProductJson(fieldValue);
|
||
}
|
||
} else if (category.key === "custom") {
|
||
hasData = false;
|
||
} else {
|
||
const fieldValue = data[category.field] || data[this.toSnakeCase(category.field)] || "";
|
||
if (fieldValue && fieldValue.trim()) {
|
||
hasData = true;
|
||
productData = this.parseProductJson(fieldValue);
|
||
}
|
||
}
|
||
if (hasData) {
|
||
categoryList.push({ key: category.key, name: category.name });
|
||
const rows = this.buildProductDimensionRows(productData, data, category.key);
|
||
requirementMap[category.key] = { rows };
|
||
}
|
||
});
|
||
this.productRequirementMap = requirementMap;
|
||
this.productCategoryList = categoryList;
|
||
if (categoryList.length > 0) {
|
||
this.activeProductCategory = categoryList[0].key;
|
||
}
|
||
},
|
||
// 解析产品JSON字符串
|
||
parseProductJson(jsonString) {
|
||
if (!jsonString || typeof jsonString !== "string") {
|
||
return null;
|
||
}
|
||
try {
|
||
const parsed = JSON.parse(jsonString);
|
||
return parsed;
|
||
} catch (error) {
|
||
common_vendor.index.__f__("warn", "at pages/furniture_customer/components/ConversationSummaryFurniture.vue:397", "解析产品JSON失败:", error, jsonString);
|
||
return null;
|
||
}
|
||
},
|
||
// 驼峰转蛇形命名
|
||
toSnakeCase(str) {
|
||
if (!str)
|
||
return "";
|
||
return str.replace(/([A-Z])/g, "_$1").toLowerCase().replace(/^_/, "");
|
||
},
|
||
// 切换产品类别
|
||
switchProductCategory(categoryKey) {
|
||
this.activeProductCategory = categoryKey;
|
||
},
|
||
// 获取产品类别名称
|
||
getProductCategoryName(categoryKey) {
|
||
const category = this.productCategoryList.find((item) => item.key === categoryKey);
|
||
return category ? category.name : "";
|
||
},
|
||
// 获取所有产品类别名称(用于意向产品清单显示)
|
||
getProductCategoryNames() {
|
||
return this.productCategoryList.map((item) => item.name).join(",");
|
||
},
|
||
parseProductAttributes(productKey, requirementText, data) {
|
||
const attributes = {};
|
||
const text = (requirementText || "").trim();
|
||
if (!text)
|
||
return attributes;
|
||
const matchFirst = (pattern) => {
|
||
const result = text.match(pattern);
|
||
return result ? result[0] : "";
|
||
};
|
||
switch (productKey) {
|
||
case "sofa":
|
||
attributes.type = matchFirst(/(L型|L形|一字型|U型|U形|带贵妃榻|贵妃榻|三人位|四人位|转角|组合)/);
|
||
attributes.material = matchFirst(/(真皮|科技布|布艺|布|皮质|皮革|实木|板式|棉麻|绒布)/);
|
||
attributes.size = matchFirst(/(\d+\.?\d*)\s*(米|m|平米|平方米)/);
|
||
attributes.color = matchFirst(/(米白|白色|灰色|黑色|棕色|蓝色|绿色|暖色调|冷色调|灰白色系)/);
|
||
attributes.style = matchFirst(/(现代简约|简约现代|现代|北欧|中式|美式|欧式|工业风|原木风|简约|极简)/);
|
||
if (text.includes("储物") || text.includes("收纳"))
|
||
attributes.feature = "储物";
|
||
if (text.includes("好打理"))
|
||
attributes.remark = "要求好打理";
|
||
break;
|
||
case "bed":
|
||
attributes.size = matchFirst(/(\d+\.?\d*)\s*(米|m)/);
|
||
attributes.material = matchFirst(/(实木|板式|软包|皮质|布艺)/);
|
||
attributes.style = data.decorationStyle || "";
|
||
if (text.includes("主卧"))
|
||
attributes.remark = "主卧";
|
||
break;
|
||
case "mattress":
|
||
attributes.size = matchFirst(/(\d+\.?\d*)\s*(米|m)/);
|
||
attributes.material = matchFirst(/(弹簧|记忆棉|乳胶|椰棕|海绵)/);
|
||
if (text.includes("分区支撑"))
|
||
attributes.softness = "分区支撑(兼顾软硬需求)";
|
||
else if (text.includes("偏软") || text.includes("软"))
|
||
attributes.softness = "偏软";
|
||
else if (text.includes("偏硬") || text.includes("硬"))
|
||
attributes.softness = "偏硬";
|
||
break;
|
||
case "dining_table":
|
||
if (text.includes("伸缩"))
|
||
attributes.type = "可伸缩";
|
||
const rangeMatch = text.match(/(\d+\.?\d*)\s*[-~到]\s*(\d+\.?\d*)\s*米/);
|
||
if (rangeMatch)
|
||
attributes.size = `${rangeMatch[1]}-${rangeMatch[2]}米`;
|
||
else
|
||
attributes.size = matchFirst(/(\d+\.?\d*)\s*米/);
|
||
attributes.chairCount = matchFirst(/(\d+)\s*把/);
|
||
if (text.includes("舒适"))
|
||
attributes.feature = "舒适型";
|
||
attributes.style = data.decorationStyle || "";
|
||
break;
|
||
case "tea_table":
|
||
if (text.includes("抽屉"))
|
||
attributes.type = "带抽屉";
|
||
if (text.includes("储物") || text.includes("收纳"))
|
||
attributes.feature = "储物";
|
||
attributes.style = data.decorationStyle || "";
|
||
break;
|
||
case "tv_cabinet":
|
||
if (text.includes("组合"))
|
||
attributes.type = "组合式";
|
||
if (text.includes("储物"))
|
||
attributes.feature = "储物";
|
||
attributes.style = data.decorationStyle || "";
|
||
break;
|
||
case "study_desk":
|
||
if (text.includes("可调节") || text.includes("调节高度"))
|
||
attributes.type = "可调节高度";
|
||
if (text.includes("成长"))
|
||
attributes.feature = "适应孩子成长";
|
||
break;
|
||
case "wine_cabinet":
|
||
if (text.includes("恒温"))
|
||
attributes.feature = "恒温";
|
||
const capacity = text.match(/(\d+)[-~到](\d+)\s*瓶|(\d+)\s*瓶/);
|
||
if (capacity) {
|
||
if (capacity[1] && capacity[2])
|
||
attributes.capacity = `${capacity[1]}-${capacity[2]}瓶`;
|
||
else if (capacity[3])
|
||
attributes.capacity = `${capacity[3]}瓶`;
|
||
}
|
||
break;
|
||
case "master_bedroom_cabinet":
|
||
case "secondary_bedroom_cabinet":
|
||
if (text.includes("定制") || text.includes("整墙"))
|
||
attributes.type = text.includes("整墙") ? "整墙定制" : "定制";
|
||
attributes.size = matchFirst(/(\d+\.?\d*)\s*(米|m)/);
|
||
if (text.includes("衣帽间"))
|
||
attributes.feature = "带衣帽间";
|
||
if (text.includes("主卧"))
|
||
attributes.remark = "主卧";
|
||
if (text.includes("次卧"))
|
||
attributes.remark = "次卧";
|
||
break;
|
||
case "shoe_cabinet":
|
||
if (text.includes("窄款") || text.includes("高型"))
|
||
attributes.type = "窄款高型";
|
||
attributes.size = matchFirst(/(\d+\.?\d*)\s*(米|m)/);
|
||
if (text.includes("带座") || text.includes("可坐"))
|
||
attributes.feature = "带座功能";
|
||
if (text.includes("收纳空间"))
|
||
attributes.remark = "大容量收纳";
|
||
break;
|
||
default:
|
||
attributes.description = text;
|
||
break;
|
||
}
|
||
if (!attributes.style && data && data.decorationStyle)
|
||
attributes.style = data.decorationStyle;
|
||
if (!attributes.color && data && data.decorationStyle) {
|
||
const color = data.decorationStyle.match(/(米白|白色|灰色|黑色|棕色|蓝色|暖色调|冷色调|灰白色系|原木色)/);
|
||
if (color)
|
||
attributes.color = color[0];
|
||
}
|
||
if (!attributes.description && text)
|
||
attributes.description = text;
|
||
return attributes;
|
||
},
|
||
buildProductDimensionRows(productData = null, data = {}, categoryKey = "") {
|
||
const dimensionLabels = [
|
||
{ key: "styleColor", label: "偏好风格与颜色", field: "preferenceStyleAndColor" },
|
||
{ key: "material", label: "材质偏好", field: "materialPreference" },
|
||
{ key: "focus", label: "客户重点关注", field: "customerFocusAreas" },
|
||
{ key: "price", label: "价格敏感度", field: "priceSensitivity" },
|
||
{ key: "campaign", label: "活动参与度", field: "activityParticipation" },
|
||
{ key: "ordered", label: "客户疑虑点", field: "customerConcerns" },
|
||
{ key: "service", label: "交付服务", field: "deliveryService" },
|
||
{ key: "competitor", label: "竞品反馈", field: "competitorFeedback" },
|
||
{ key: "delivery", label: "交付周期", field: "deliveryCycle" },
|
||
{ key: "appearance", label: "产品颜值", field: "productAppearance" }
|
||
];
|
||
const isParsedJson = productData && typeof productData === "object" && !Array.isArray(productData) && productData !== null && ("preferenceStyleAndColor" in productData || "materialPreference" in productData || "customerConcerns" in productData);
|
||
const getValue = (field) => {
|
||
if (isParsedJson) {
|
||
const value = productData[field];
|
||
if (value === null || value === void 0 || value === "") {
|
||
return "暂无信息";
|
||
}
|
||
if (typeof value === "string") {
|
||
const trimmed = value.trim();
|
||
return trimmed || "暂无信息";
|
||
}
|
||
return String(value) || "暂无信息";
|
||
} else {
|
||
const attributes = productData || {};
|
||
switch (field) {
|
||
case "preferenceStyleAndColor":
|
||
const parts = [];
|
||
if (attributes.style)
|
||
parts.push(attributes.style);
|
||
if (attributes.color)
|
||
parts.push(attributes.color);
|
||
if (parts.length === 0 && data.decorationStyle)
|
||
parts.push(data.decorationStyle);
|
||
return parts.join(" / ") || "暂无信息";
|
||
case "materialPreference":
|
||
return attributes.material || "暂无信息";
|
||
case "customerFocusAreas":
|
||
return attributes.feature || attributes.remark || "暂无信息";
|
||
case "priceSensitivity":
|
||
return data.priceSensitivity || "暂无信息";
|
||
case "activityParticipation":
|
||
return data.campaignPreference || data.activityParticipation || "暂无信息";
|
||
case "customerConcerns":
|
||
return attributes.description || "暂无信息";
|
||
case "deliveryService":
|
||
return data.serviceExpectation || "暂无信息";
|
||
case "competitorFeedback":
|
||
return data.competitorFeedback || "暂无信息";
|
||
case "deliveryCycle":
|
||
return data.deliveryCycle || "暂无信息";
|
||
case "productAppearance":
|
||
return data.appearancePreference || attributes.style || "暂无信息";
|
||
default:
|
||
return "暂无信息";
|
||
}
|
||
}
|
||
};
|
||
return dimensionLabels.map((item) => ({
|
||
label: item.label,
|
||
content: getValue(item.field) || "暂无信息"
|
||
}));
|
||
},
|
||
viewSummaryDetail(item) {
|
||
common_vendor.index.__f__("log", "at pages/furniture_customer/components/ConversationSummaryFurniture.vue:591", "查看总结详情", item);
|
||
}
|
||
}
|
||
};
|
||
if (!Array) {
|
||
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
||
_easycom_uni_icons2();
|
||
}
|
||
const _easycom_uni_icons = () => "../../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
||
if (!Math) {
|
||
_easycom_uni_icons();
|
||
}
|
||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||
return common_vendor.e({
|
||
a: $data.loading
|
||
}, $data.loading ? {} : !$data.loading && $data.summaryList.length === 0 && !$data.summarySentence && !$data.dealKeyPoints && $data.productCategoryList.length === 0 ? {} : {}, {
|
||
b: !$data.loading && $data.summaryList.length === 0 && !$data.summarySentence && !$data.dealKeyPoints && $data.productCategoryList.length === 0,
|
||
c: common_vendor.f($data.summaryList, (item, index, i0) => {
|
||
return {
|
||
a: common_vendor.t(item.label),
|
||
b: common_vendor.t(item.value),
|
||
c: "5e008aeb-0-" + i0,
|
||
d: index,
|
||
e: common_vendor.o(($event) => $options.viewSummaryDetail(item), index)
|
||
};
|
||
}),
|
||
d: common_vendor.p({
|
||
type: "right",
|
||
size: "16",
|
||
color: "#999"
|
||
}),
|
||
e: $data.productCategoryList.length > 0
|
||
}, $data.productCategoryList.length > 0 ? {
|
||
f: common_vendor.t($options.getProductCategoryNames())
|
||
} : {}, {
|
||
g: $data.summarySentence
|
||
}, $data.summarySentence ? {
|
||
h: common_vendor.t($data.summarySentence)
|
||
} : {}, {
|
||
i: $data.dealKeyPoints
|
||
}, $data.dealKeyPoints ? {
|
||
j: common_vendor.t($data.dealKeyPoints)
|
||
} : {}, {
|
||
k: $data.productCategoryList.length > 0
|
||
}, $data.productCategoryList.length > 0 ? {
|
||
l: common_vendor.f($data.productCategoryList, (category, index, i0) => {
|
||
return {
|
||
a: common_vendor.t(category.name),
|
||
b: $data.activeProductCategory === category.key ? 1 : "",
|
||
c: index,
|
||
d: common_vendor.o(($event) => $options.switchProductCategory(category.key), index)
|
||
};
|
||
})
|
||
} : {}, {
|
||
m: $data.activeProductCategory && $options.currentProductRequirement
|
||
}, $data.activeProductCategory && $options.currentProductRequirement ? {
|
||
n: common_vendor.t($options.getProductCategoryName($data.activeProductCategory)),
|
||
o: common_vendor.f($options.currentProductRequirement.rows, (row, index, i0) => {
|
||
return {
|
||
a: common_vendor.t(row.label),
|
||
b: common_vendor.t(row.content),
|
||
c: index
|
||
};
|
||
})
|
||
} : $data.productCategoryList.length === 0 && $data.furnitureAnalysisList.length > 0 ? {} : {}, {
|
||
p: $data.productCategoryList.length === 0 && $data.furnitureAnalysisList.length > 0
|
||
});
|
||
}
|
||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-5e008aeb"]]);
|
||
wx.createComponent(Component);
|
||
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/furniture_customer/components/ConversationSummaryFurniture.js.map
|