2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
"use strict";const e=require("../../../common/vendor.js"),t=require("../../../common/config.js"),i=require("../../../pages/furniture_customer/utils/dataInit.js"),r={name:"ConversationSummaryFurniture",props:{serviceItem:{type:Object,default:()=>({})}},data:()=>({summaryList:[],furnitureAnalysisList:[],productCategoryList:[],activeProductCategory:"",productRequirementMap:{},summarySentence:"",dealKeyPoints:"",loading:!1}),computed:{currentProductRequirement(){return this.activeProductCategory&&this.productRequirementMap[this.activeProductCategory]||null}},watch:{serviceItem:{handler(e,t){var i,r;if(e!==t)if(e&&"object"==typeof e){const a=e.id||(null==(i=e.rawData)?void 0:i.id),s=(null==t?void 0:t.id)||(null==(r=null==t?void 0:t.rawData)?void 0:r.id);if(a&&a===s)return;a?(this.initData(),this.loadFurnitureAnalysis(e)):this.initData()}else this.initData()},immediate:!0,deep:!0}},mounted(){var e;this.serviceItem&&(this.serviceItem.id||(null==(e=this.serviceItem.rawData)?void 0:e.id))&&(this.initData(),this.loadFurnitureAnalysis(this.serviceItem))},methods:{initData(){var e;try{this.serviceItem&&(this.serviceItem.id||(null==(e=this.serviceItem.rawData)?void 0:e.id))?this.summaryList=i.initSummaryList(this.serviceItem):this.summaryList=[]}catch(t){console.error("初始化总结数据失败:",t),this.summaryList=[]}this.productCategoryList=[],this.activeProductCategory="",this.productRequirementMap={},this.summarySentence="",this.dealKeyPoints="",this.furnitureAnalysisList=[],this.loading=!1},async loadFurnitureAnalysis(i){var r,a;if(i)try{this.loading=!0;const s=(null==(r=i.rawData)?void 0:r.id)||i.id;if(!s)return console.warn("无法获取parentId"),this.furnitureAnalysisList=[],void(this.loading=!1);const n=`${t.getApiUrl("/api/audioTextAnalysisFurniture/byParentId")}?parentId=${s}`,c=await e.index.request({url:n,method:"GET",timeout:1e4});200===c.statusCode&&c.data&&c.data.success?(this.furnitureAnalysisList=c.data.data||[],this.furnitureAnalysisList.length>0&&this.updateSummaryWithFurnitureData()):(console.warn("获取家具意向分析失败:",(null==(a=c.data)?void 0:a.message)||"未知错误"),this.furnitureAnalysisList=[])}catch(s){console.error("获取家具意向分析失败:",s),this.furnitureAnalysisList=[]}finally{this.loading=!1}},updateSummaryWithFurnitureData(){if(0===this.furnitureAnalysisList.length)return;const e=this.furnitureAnalysisList[0],t=[];if(e.customerType&&t.push({label:"客户类型",value:e.customerType,rawData:e}),e.familyStructure&&t.push({label:"家庭结构",value:e.familyStructure,rawData:e}),e.summarySentence&&(this.summarySentence=e.summarySentence),e.dealKeyPoints)this.dealKeyPoints=e.dealKeyPoints;else if(e.summarySentence){const t=[],i=e.summarySentence;(i.includes("优惠")||i.includes("活动"))&&t.push("活动优惠"),i.includes("搭配")&&t.push("整套搭配"),i.includes("环保")&&t.push("环保"),i.includes("安全")&&t.push("安全"),(i.includes("交付")||i.includes("周期"))&&t.push("快速交付"),(i.includes("退换")||i.includes("服务"))&&t.push("无忧退换服务"),t.length>0&&(this.dealKeyPoints=t.join(","))}t.length>0&&(this.summaryList=t),this.buildProductRequirementList(e)},buildProductRequirementList(e){const t={},i=[];[{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}].forEach((r=>{let a=!1,s=null;if("bed"===r.key||"mattress"===r.key){const t=e.bedAndMattress||e.bed_and_mattress||"";t&&t.trim()&&(a=!0,s=this.parseProductJson(t))}else if("custom"===r.key)a=!1;else{const t=e[r.field]||e[this.toSnakeCase(r.field)]||"";t&&t.trim()&&(a=!0,s=this.parseProductJson(t))}if(a){i.push({key:r.key,name:r.name});const a=this.buildProductDimensionRows(s,e,r.key);t[r.key]={rows:a}}})),this.productRequirementMap=t,this.productCategoryList=i,i.length>0&&(this.activeProductCategory=i[0].key)},parseProductJson(e){if(!e||"string"!=typeof e)return null;try{return JSON.parse(e)}catch(t){return console.warn("解析产品JSON失败:",t,e),null}},toSnakeCase:e=>e?e.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,""):"",switchProductCategory(e){this.activeProductCategory=e},getProductCategoryName(e){const t=this.productCategoryList.find((t=>t.key===e));return t?t.name:""},getProductCategoryNames(){return this.productCategoryList.map((e=>e.name)).join(",")},parseProductAttributes(e,t,i){const r={},a=(t||"").trim();if(!a)return r;const s=e=>{const t=a.match(e);return t?t[0]:""};switch(e){case"sofa":r.type=s(/(L型|L形|一字型|U型|U形|带贵妃榻|贵妃榻|三人位|四人位|转角|组合)/),r.material=s(/(真皮|科技布|布艺|布|皮质|皮革|实木|板式|棉麻|绒布)/),r.size=s(/(\d+\.?\d*)\s*(米|m|平米|平方米)/),r.color=s(/(米白|白色|灰色|黑色|棕色|蓝色|绿色|暖色调|冷色调|灰白色系)/),r.style=s(/(现代简约|简约现代|现代|北欧|中式|美式|欧式|工业风|原木风|简约|极简)/),(a.includes("储物")||a.includes("收纳"))&&(r.feature="储物"),a.includes("好打理")&&(r.remark="要求好打理");break;case"bed":r.size=s(/(\d+\.?\d*)\s*(米|m)/),r.material=s(/(实木|板式|软包|皮质|布艺)/),r.style=i.decorationStyle||"",a.includes("主卧")&&(r.remark="主卧");break;case"mattress":r.size=s(/(\d+\.?\d*)\s*(米|m)/),r.material=s(/(弹簧|记忆棉|乳胶|椰棕|海绵)/),a.includes("分区支撑")?r.softness="分区支撑(兼顾软硬需求)":a.includes("偏软")||a.includes("软")?r.softness="偏软":(a.includes("偏硬")||a.includes("硬"))&&(r.softness="偏硬");break;case"dining_table":a.includes("伸缩")&&(r.type="可伸缩");const e=a.match(/(\d+\.?\d*)\s*[-~到]\s*(\d+\.?\d*)\s*米/);r.size=e?`${e[1]}-${e[2]}米`:s(/(\d+\.?\d*)\s*米/),r.chairCount=s(/(\d+)\s*把/),a.includes("舒适")&&(r.feature="舒适型"),r.style=i.decorationStyle||"";break;case"tea_table":a.includes("抽屉")&&(r.type="带抽屉"),(a.includes("储物")||a.includes("收纳"))&&(r.feature="储物"),r.style=i.decorationStyle||"";break;case"tv_cabinet":a.includes("组合")&&(r.type="组合式"),a.includes("储物")&&(r.feature="储物"),r.style=i.decorationStyle||"";break;case"study_desk":(a.includes("可调节")||a.includes("调节高度"))&&(r.type="可调节高度"),a.includes("成长")&&(r.feature="适应孩子成长");break;case"wine_cabinet":a.includes("恒温")&&(r.feature="恒温");const t=a.match(/(\d+)[-~到](\d+)\s*瓶|(\d+)\s*瓶/);t&&(t[1]&&t[2]?r.capacity=`${t[1]}-${t[2]}瓶`:t[3]&&(r.capacity=`${t[3]}瓶`));break;case"master_bedroom_cabinet":case"secondary_bedroom_cabinet":(a.includes("定制")||a.includes("整墙"))&&(r.type=a.includes("整墙")?"整墙定制":"定制"),r.size=s(/(\d+\.?\d*)\s*(米|m)/),a.includes("衣帽间")&&(r.feature="带衣帽间"),a.includes("主卧")&&(r.remark="主卧"),a.includes("次卧")&&(r.remark="次卧");break;case"shoe_cabinet":(a.includes("窄款")||a.includes("高型"))&&(r.type="窄款高型"),r.size=s(/(\d+\.?\d*)\s*(米|m)/),(a.includes("带座")||a.includes("可坐"))&&(r.feature="带座功能"),a.includes("收纳空间")&&(r.remark="大容量收纳");break;default:r.description=a}if(!r.style&&i&&i.decorationStyle&&(r.style=i.decorationStyle),!r.color&&i&&i.decorationStyle){const e=i.decorationStyle.match(/(米白|白色|灰色|黑色|棕色|蓝色|暖色调|冷色调|灰白色系|原木色)/);e&&(r.color=e[0])}return!r.description&&a&&(r.description=a),r},buildProductDimensionRows(e=null,t={},i=""){const r=e&&"object"==typeof e&&!Array.isArray(e)&&null!==e&&("preferenceStyleAndColor"in e||"materialPreference"in e||"customerConcerns"in e),a=i=>{if(r){const t=e[i];if(null==t||""===t)return"暂无信息";if("string"==typeof t){return t.trim()||"暂无信息"}return String(t)||"暂无信息"}{const r=e||{};switch(i){case"preferenceStyleAndColor":const e=[];return r.style&&e.push(r.style),r.color&&e.push(r.color),0===e.length&&t.decorationStyle&&e.push(t.decorationStyle),e.join(" / ")||"暂无信息";case"materialPreference":return r.material||"暂无信息";case"customerFocusAreas":return r.feature||r.remark||"暂无信息";case"priceSensitivity":return t.priceSensitivity||"暂无信息";case"activityParticipation":return t.campaignPreference||t.activityParticipation||"暂无信息";case"customerConcerns":return r.description||"暂无信息";case"deliveryService":return t.serviceExpectation||"暂无信息";case"competitorFeedback":return t.competitorFeedback||"暂无信息";case"deliveryCycle":return t.deliveryCycle||"暂无信息";case"productAppearance":return t.appearancePreference||r.style||"暂无信息";default:return"暂无信息"}}};return[{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"}].map((e=>({label:e.label,content:a(e.field)||"暂无信息"})))},viewSummaryDetail(e){console.log("查看总结详情",e)}}};if(!Array){e.resolveComponent("uni-icons")()}Math;const a=e._export_sfc(r,[["render",function(t,i,r,a,s,n){return e.e({a:s.loading},(s.loading||s.loading||0!==s.summaryList.length||s.summarySentence||s.dealKeyPoints||s.productCategoryList.length,{}),{b:!s.loading&&0===s.summaryList.length&&!s.summarySentence&&!s.dealKeyPoints&&0===s.productCategoryList.length,c:e.f(s.summaryList,((t,i,r)=>({a:e.t(t.label),b:e.t(t.value),c:"f91a70d9-0-"+r,d:i,e:e.o((e=>n.viewSummaryDetail(t)),i)}))),d:e.p({type:"right",size:"16",color:"#999"}),e:s.productCategoryList.length>0},s.productCategoryList.length>0?{f:e.t(n.getProductCategoryNames())}:{},{g:s.summarySentence},s.summarySentence?{h:e.t(s.summarySentence)}:{},{i:s.dealKeyPoints},s.dealKeyPoints?{j:e.t(s.dealKeyPoints)}:{},{k:s.productCategoryList.length>0},s.productCategoryList.length>0?{l:e.f(s.productCategoryList,((t,i,r)=>({a:e.t(t.name),b:s.activeProductCategory===t.key?1:"",c:i,d:e.o((e=>n.switchProductCategory(t.key)),i)})))}:{},{m:s.activeProductCategory&&n.currentProductRequirement},s.activeProductCategory&&n.currentProductRequirement?{n:e.t(n.getProductCategoryName(s.activeProductCategory)),o:e.f(n.currentProductRequirement.rows,((t,i,r)=>({a:e.t(t.label),b:e.t(t.content),c:i})))}:(0===s.productCategoryList.length&&s.furnitureAnalysisList.length,{}),{p:0===s.productCategoryList.length&&s.furnitureAnalysisList.length>0})}],["__scopeId","data-v-f91a70d9"]]);wx.createComponent(a);
|