"use strict";const e=require("../../common/vendor.js"),t=require("../../pages/furniture_customer/utils/dataInit.js"),o=require("../../common/config.js"),i={components:{CustomerList:()=>"./components/CustomerList.js",ServiceList:()=>"./components/ServiceList.js",CustomerProfileModal:()=>"./components/CustomerProfileModal.js",ConversationSummaryFurniture:()=>"./components/ConversationSummaryFurniture.js"},data(){const t=2*(e.index.getSystemInfoSync().statusBarHeight||20)+88;return{navbarTop:t+"rpx",contentTop:t+72+"rpx",activeTab:"customer",activeDetailTab:"summary",isPlaying:!1,currentServiceDetail:{title:"",date:"",duration:"",description:"",customerName:""},currentCustomerProfile:{name:"",intent:"",serviceCount:0,lastService:"",phone:"",serviceStaff:"",wechatStatus:"",address:"",source:"",followStage:"",systemTags:[],customTags:[],intentDescription:""},summaryList:[],furnitureAnalysisList:[],productCategoryList:[],activeProductCategory:"",productRequirementMap:{},summarySentence:"",dealKeyPoints:"",performanceData:{totalScore:81,categories:[]},serviceList:[],serviceListTotal:0,serviceListPage:{current:1,size:10},todoList:[],todoListPage:{current:1,size:10},todoListTotal:0,activeTodoMenuIndex:null,todoMenuStyle:{},currentTodoItem:null,chapterSummaryList:[],audioSegmentsList:[],audioSegmentsLoading:!1,playingAudioId:null,innerAudioContext:null,currentAudioUrl:null,showTextModal:!1,currentRecordingText:"",transcribingIds:[]}},computed:{currentProductRequirement(){return this.activeProductCategory&&this.productRequirementMap[this.activeProductCategory]||null},computedNavbarTop:()=>2*(e.index.getSystemInfoSync().statusBarHeight||20)+88+"rpx",computedContentTop:()=>2*(e.index.getSystemInfoSync().statusBarHeight||20)+88+72+"rpx"},onLoad(e={}){console.log("[FurnitureCustomer][onLoad] 页面加载"),this.applyIncomingTab(null==e?void 0:e.tab),this.updateNavbarPosition(),"service"===this.activeTab&&this.loadServiceList()},onShow(){console.log("[FurnitureCustomer][onShow] 页面显示"),this.$nextTick((()=>{this.updateNavbarPosition(),setTimeout((()=>{this.updateNavbarPosition(),console.log("[FurnitureCustomer][onShow] 延迟更新后的位置:",{navbarTop:this.navbarTop,contentTop:this.contentTop})}),50)}))},onReady(){console.log("[FurnitureCustomer][onReady] 页面渲染完成"),console.log("[FurnitureCustomer][onReady] activeTab:",this.activeTab),console.log("[FurnitureCustomer][onReady] navbarTop:",this.navbarTop),console.log("[FurnitureCustomer][onReady] contentTop:",this.contentTop),this.updateNavbarPosition(),this.initUrlHidingAfterPageLoad();const t=e.index.getSystemInfoSync();console.log("[FurnitureCustomer][onReady] 系统信息:",{statusBarHeight:t.statusBarHeight,windowHeight:t.windowHeight,screenHeight:t.screenHeight}),setTimeout((()=>{e.index.createSelectorQuery().in(this).select(".tabs").boundingClientRect((e=>{console.log("[FurnitureCustomer][onReady] tab栏元素信息:",e),e?(console.log("[FurnitureCustomer][onReady] tab栏位置:",{top:e.top,left:e.left,width:e.width,height:e.height,expectedTop:this.navbarTop,isVisible:e.width>0&&e.height>0,isOnScreen:e.top>=0&&e.top{console.error("[FurnitureCustomer][goBack] 返回失败:",e)}})},switchTab(e){this.activeTab=e,"service"===e&&0===this.serviceList.length&&this.loadServiceList()},refreshServiceList(e={}){this.serviceListPage.current=1,this.loadServiceList(e)},onServiceListReachBottom(){this.serviceList.length>=this.serviceListTotal||(this.serviceListPage.current+=1,this.loadServiceList())},async viewDetail(e){this.currentServiceDetail={...e},this.todoList=[],this.todoListTotal=0,this.chapterSummaryList=[],"todo"===this.activeDetailTab&&this.loadTodoList(),"chapter"===this.activeDetailTab&&this.loadChapterSummary(),"performance"===this.activeDetailTab&&this.loadPerformanceData(),this.$refs.serviceDetailPopup.open()},async handleMenuAction({action:e,item:t}){switch(console.log("父组件收到菜单操作:",e,t),e){case"view":this.viewDetail(t);break;case"analysis":break;case"audio":await this.loadAudioSegments(t);break;case"delete":await this.deleteServiceRecord(t);break;default:console.warn("未知的菜单操作:",e)}},handleUpdateItem({recordId:e,data:t}){const o=this.serviceList.findIndex((t=>{var o;return(t.id||(null==(o=t.rawData)?void 0:o.id))===e}));-1!==o&&this.$set(this.serviceList,o,t)},async deleteServiceRecord(t){var i,n;console.log("删除服务记录,item:",t);if(await new Promise((t=>{e.index.showModal({title:"确认删除",content:"确定要删除这条服务记录吗?删除后无法恢复。",confirmText:"删除",confirmColor:"#FF3B30",cancelText:"取消",success:e=>{t(e.confirm)},fail:()=>{t(!1)}})})))try{const s=t.id||(null==(i=t.rawData)?void 0:i.id);if(!s)return void e.index.showToast({title:"无法获取记录ID",icon:"none"});const r=o.getApiUrl(`/api/audioManagement/delete/${s}`);let c="",d="";try{c=e.index.getStorageSync("backend-tenant-id")||"",d=e.index.getStorageSync("backend-token")||""}catch(a){console.error("获取认证信息失败:",a)}const l={"Content-Type":"application/json"};d&&(l.Authorization=`Bearer ${d}`),c&&(l["X-Tenant-Id"]=c);const u=await e.index.request({url:r,method:"DELETE",header:l,timeout:1e4});200===u.statusCode&&u.data&&u.data.success?(e.index.showToast({title:"删除成功",icon:"success"}),this.serviceListPage.current=1,this.serviceList=[],await this.loadServiceList()):e.index.showToast({title:(null==(n=u.data)?void 0:n.message)||"删除失败",icon:"none"})}catch(s){console.error("删除服务记录失败:",s),e.index.showToast({title:`删除失败: ${s.errMsg||s.message||"未知错误"}`,icon:"none"})}},async loadAudioSegments(t){var i,n;try{const s=(null==(i=t.rawData)?void 0:i.id)||t.id;if(!s)return void e.index.showToast({title:"无法获取录音ID",icon:"none"});this.audioSegmentsLoading=!0,this.audioSegmentsList=[],e.index.showLoading({title:"加载中..."});const r=`${o.getApiUrl("/api/audioManagementSegments/listByParentId")}?parentId=${s}`;let c="",d="";try{c=e.index.getStorageSync("backend-tenant-id")||"",d=e.index.getStorageSync("backend-token")||""}catch(a){console.error("获取认证信息失败:",a)}const l={"Content-Type":"application/json"};d&&(l.Authorization=`Bearer ${d}`),c&&(l["X-Tenant-Id"]=c);const u=await e.index.request({url:r,method:"GET",header:l,timeout:1e4});if(e.index.hideLoading(),200===u.statusCode&&u.data&&u.data.success){const e=u.data.data||[];console.log("录音分段列表:",e),this.audioSegmentsList=e,this.audioSegmentsLoading=!1,this.$refs.audioListPopup.open()}else e.index.showToast({title:(null==(n=u.data)?void 0:n.message)||"获取录音分段失败",icon:"none"})}catch(s){e.index.hideLoading(),this.audioSegmentsLoading=!1,console.error("获取录音分段列表失败:",s),e.index.showToast({title:`获取录音分段失败: ${s.errMsg||s.message||"未知错误"}`,icon:"none"})}},closeAudioList(){this.playingAudioId&&this.stopAudioPlay({id:this.playingAudioId}),this.$refs.audioListPopup.close()},async toggleAudioPlay(t,o){try{const o=t.id||t.segmentId;if(!o)return console.warn("录音项缺少ID:",t),void e.index.showToast({title:"无法获取录音ID",icon:"none"});this.playingAudioId===o?await this.stopAudioPlay(t):(this.playingAudioId&&await this.stopAudioPlay({id:this.playingAudioId}),this.currentRecordingText=t.recordingText||"",this.showTextModal=!0,this.$refs.textModalPopup.open(),await this.startAudioPlay(t))}catch(i){console.error("切换播放状态失败:",i),e.index.showToast({title:"操作失败",icon:"none"})}},closeTextModal(){this.showTextModal=!1,this.currentRecordingText="",this.$refs.textModalPopup.close()},onTextModalChange(e){e.show||(this.showTextModal=!1,this.currentRecordingText="")},async startAudioPlay(t){try{const n=t.id||t.segmentId;if(!n)return console.warn("录音项缺少ID:",t),void e.index.showToast({title:"无法获取录音ID",icon:"none"});this.innerAudioContext&&(this.innerAudioContext.stop(),this.innerAudioContext.destroy(),this.innerAudioContext=null),e.index.showLoading({title:"加载中..."});let a="",s="";try{a=e.index.getStorageSync("backend-tenant-id")||"",s=e.index.getStorageSync("backend-token")||""}catch(i){console.error("获取认证信息失败:",i)}const r=o.getApiUrl(`/api/audioManagementSegments/playSegmentById/${n}`);console.log("请求音频URL:",r),console.log("音频ID:",n);const c={"Content-Type":"application/json"};s&&(c.Authorization=`Bearer ${s}`),a&&(c["X-Tenant-Id"]=a),console.log("请求头:",c);const d=await e.index.request({url:r,method:"POST",header:c,responseType:"arraybuffer",timeout:3e4});if(console.log("响应状态码:",d.statusCode),console.log("响应头:",d.header),200!==d.statusCode){if(console.error("请求失败,状态码:",d.statusCode),console.error("响应数据:",d.data),404===d.statusCode)throw new Error(`接口路径不存在(404),请检查后端接口路径是否正确。当前URL: ${r}`);throw new Error(`请求失败,状态码: ${d.statusCode}`)}let l="audio/mpeg";d.header&&d.header["Content-Type"]?l=d.header["Content-Type"]:d.header&&d.header["content-type"]&&(l=d.header["content-type"]);const u=`data:${l};base64,${e.index.arrayBufferToBase64(d.data)}`;this.currentAudioUrl=u;const m=e.index.createInnerAudioContext();m.src=u,m.onPlay((()=>{console.log("开始播放音频"),e.index.hideLoading(),this.playingAudioId=n,e.index.showToast({title:"开始播放",icon:"success",duration:1e3})})),m.onError((t=>{console.error("音频播放错误:",t),e.index.hideLoading(),this.playingAudioId=null,m.destroy(),this.innerAudioContext=null,this.currentAudioUrl=null,e.index.showToast({title:"播放失败,请检查网络或音频文件",icon:"none",duration:2e3})})),m.onEnded((()=>{console.log("音频播放结束"),this.playingAudioId=null,m.destroy(),this.innerAudioContext=null,this.currentAudioUrl=null})),m.onPause((()=>{console.log("音频播放暂停"),this.playingAudioId=null})),this.innerAudioContext=m,m.play()}catch(n){e.index.hideLoading(),console.error("播放录音失败:",n),this.innerAudioContext&&(this.innerAudioContext.destroy(),this.innerAudioContext=null),this.playingAudioId=null,e.index.showToast({title:`播放失败: ${n.errMsg||n.message||"未知错误"}`,icon:"none",duration:2e3})}},async stopAudioPlay(t){try{this.innerAudioContext&&(this.innerAudioContext.stop(),this.innerAudioContext.destroy(),this.innerAudioContext=null),this.playingAudioId=null,e.index.showToast({title:"已停止",icon:"success",duration:1e3})}catch(o){if(this.innerAudioContext){try{this.innerAudioContext.stop(),this.innerAudioContext.destroy()}catch(i){console.error("销毁音频播放器失败:",i)}this.innerAudioContext=null}this.playingAudioId=null,console.error("停止播放失败:",o),e.index.showToast({title:"已停止",icon:"success",duration:1e3})}},async transcribeAudio(t,i){var n;try{const s=t.id||t.segmentId;if(!s)return void e.index.showToast({title:"无法获取录音ID",icon:"none"});if(this.transcribingIds.includes(s))return;this.transcribingIds.push(s);const r=o.getApiUrl(`/api/audioManagementSegments/transcribe/${s}`);let c="",d="";try{c=e.index.getStorageSync("backend-tenant-id")||"",d=e.index.getStorageSync("backend-token")||""}catch(a){console.error("获取认证信息失败:",a)}const l={"Content-Type":"application/json"};d&&(l.Authorization=`Bearer ${d}`),c&&(l["X-Tenant-Id"]=c);const u=await e.index.request({url:r,method:"POST",header:l,timeout:3e4}),m=this.transcribingIds.indexOf(s);m>-1&&this.transcribingIds.splice(m,1),200===u.statusCode&&u.data&&u.data.success?(e.index.showToast({title:u.data.message||"转文本请求已提交",icon:"success",duration:2e3}),u.data.data&&this.$set(this.audioSegmentsList,i,{...t,...u.data.data})):e.index.showToast({title:(null==(n=u.data)?void 0:n.message)||"转文本请求失败",icon:"none",duration:2e3})}catch(s){const o=t.id||t.segmentId,i=this.transcribingIds.indexOf(o);i>-1&&this.transcribingIds.splice(i,1),console.error("转文本失败:",s),e.index.showToast({title:`转文本失败: ${s.errMsg||s.message||"未知错误"}`,icon:"none",duration:2e3})}},formatDuration(e){if(!e)return"00:00:00";const t=Math.floor(e/3600),o=Math.floor(e%3600/60),i=e%60;return`${String(t).padStart(2,"0")}:${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`},formatDateTime(e){if(!e)return"";const t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")} ${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`},formatAudioFileName(e){if(!e)return"未命名录音";const t=e.indexOf("-");if(-1===t)return e;const o=e.lastIndexOf("-");return t===o?e.substring(t+1):e.substring(t+1,o)},truncateText:(e,t)=>e?e.length<=t?e:e.substring(0,t)+"...":"",closeDetail(){this.$refs.serviceDetailPopup.close()},shareDetail(){e.index.showToast({title:"分享功能",icon:"none"})},togglePlay(){this.isPlaying=!this.isPlaying},switchDetailTab(e){this.activeDetailTab=e,"todo"===e&&this.loadTodoList(),"chapter"===e&&this.loadChapterSummary(),"performance"===e&&this.loadPerformanceData()},getDetailTabName:e=>({todo:"智能待办",chapter:"章节概要",performance:"服务表现"}[e]||""),initSummaryList(e){this.summaryList=t.initSummaryList(e),this.performanceData=t.initPerformanceData()},async loadFurnitureAnalysis(t){var i,n;try{const a=(null==(i=t.rawData)?void 0:i.id)||t.id;if(!a)return console.warn("无法获取parentId"),void(this.furnitureAnalysisList=[]);const s=`${o.getApiUrl("/api/audioTextAnalysisFurniture/byParentId")}?parentId=${a}`,r=await e.index.request({url:s,method:"GET",timeout:1e4});200===r.statusCode&&r.data&&r.data.success?(this.furnitureAnalysisList=r.data.data||[],this.furnitureAnalysisList.length>0&&this.updateSummaryWithFurnitureData()):(console.warn("获取家具意向分析失败:",(null==(n=r.data)?void 0:n.message)||"未知错误"),this.furnitureAnalysisList=[])}catch(a){console.error("获取家具意向分析失败:",a),this.furnitureAnalysisList=[]}},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=[],o=e.summarySentence;(o.includes("优惠")||o.includes("活动"))&&t.push("活动优惠"),o.includes("搭配")&&t.push("整套搭配"),o.includes("环保")&&t.push("环保"),o.includes("安全")&&t.push("安全"),(o.includes("交付")||o.includes("周期"))&&t.push("快速交付"),(o.includes("退换")||o.includes("服务"))&&t.push("无忧退换服务"),t.length>0&&(this.dealKeyPoints=t.join(","))}t.length>0&&(this.summaryList=t),this.buildProductRequirementList(e)},buildProductRequirementList(e){const t={},o=[];[{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((i=>{let n=!1,a=null;if("bed"===i.key||"mattress"===i.key){const t=e.bedAndMattress||e.bed_and_mattress||"";t&&t.trim()&&(n=!0,a=this.parseProductJson(t))}else if("custom"===i.key)n=!1;else{const t=e[i.field]||e[this.toSnakeCase(i.field)]||"";t&&t.trim()&&(n=!0,a=this.parseProductJson(t))}if(n){o.push({key:i.key,name:i.name});const n=this.buildProductDimensionRows(a,e,i.key);t[i.key]={rows:n}}})),this.productRequirementMap=t,this.productCategoryList=o,o.length>0&&(this.activeProductCategory=o[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,o){const i={},n=(t||"").trim();if(!n)return i;const a=e=>{const t=n.match(e);return t?t[0]:""};switch(e){case"sofa":i.type=a(/(L型|L形|一字型|U型|U形|带贵妃榻|贵妃榻|三人位|四人位|转角|组合)/),i.material=a(/(真皮|科技布|布艺|布|皮质|皮革|实木|板式|棉麻|绒布)/),i.size=a(/(\d+\.?\d*)\s*(米|m|平米|平方米)/),i.color=a(/(米白|白色|灰色|黑色|棕色|蓝色|绿色|暖色调|冷色调|灰白色系)/),i.style=a(/(现代简约|简约现代|现代|北欧|中式|美式|欧式|工业风|原木风|简约|极简)/),(n.includes("储物")||n.includes("收纳"))&&(i.feature="储物"),n.includes("好打理")&&(i.remark="要求好打理");break;case"bed":i.size=a(/(\d+\.?\d*)\s*(米|m)/),i.material=a(/(实木|板式|软包|皮质|布艺)/),i.style=o.decorationStyle||"",n.includes("主卧")&&(i.remark="主卧");break;case"mattress":i.size=a(/(\d+\.?\d*)\s*(米|m)/),i.material=a(/(弹簧|记忆棉|乳胶|椰棕|海绵)/),n.includes("分区支撑")?i.softness="分区支撑(兼顾软硬需求)":n.includes("偏软")||n.includes("软")?i.softness="偏软":(n.includes("偏硬")||n.includes("硬"))&&(i.softness="偏硬");break;case"dining_table":n.includes("伸缩")&&(i.type="可伸缩");const e=n.match(/(\d+\.?\d*)\s*[-~到]\s*(\d+\.?\d*)\s*米/);i.size=e?`${e[1]}-${e[2]}米`:a(/(\d+\.?\d*)\s*米/),i.chairCount=a(/(\d+)\s*把/),n.includes("舒适")&&(i.feature="舒适型"),i.style=o.decorationStyle||"";break;case"tea_table":n.includes("抽屉")&&(i.type="带抽屉"),(n.includes("储物")||n.includes("收纳"))&&(i.feature="储物"),i.style=o.decorationStyle||"";break;case"tv_cabinet":n.includes("组合")&&(i.type="组合式"),n.includes("储物")&&(i.feature="储物"),i.style=o.decorationStyle||"";break;case"study_desk":(n.includes("可调节")||n.includes("调节高度"))&&(i.type="可调节高度"),n.includes("成长")&&(i.feature="适应孩子成长");break;case"wine_cabinet":n.includes("恒温")&&(i.feature="恒温");const t=n.match(/(\d+)[-~到](\d+)\s*瓶|(\d+)\s*瓶/);t&&(t[1]&&t[2]?i.capacity=`${t[1]}-${t[2]}瓶`:t[3]&&(i.capacity=`${t[3]}瓶`));break;case"master_bedroom_cabinet":case"secondary_bedroom_cabinet":(n.includes("定制")||n.includes("整墙"))&&(i.type=n.includes("整墙")?"整墙定制":"定制"),i.size=a(/(\d+\.?\d*)\s*(米|m)/),n.includes("衣帽间")&&(i.feature="带衣帽间"),n.includes("主卧")&&(i.remark="主卧"),n.includes("次卧")&&(i.remark="次卧");break;case"shoe_cabinet":(n.includes("窄款")||n.includes("高型"))&&(i.type="窄款高型"),i.size=a(/(\d+\.?\d*)\s*(米|m)/),(n.includes("带座")||n.includes("可坐"))&&(i.feature="带座功能"),n.includes("收纳空间")&&(i.remark="大容量收纳");break;default:i.description=n}if(!i.style&&o&&o.decorationStyle&&(i.style=o.decorationStyle),!i.color&&o&&o.decorationStyle){const e=o.decorationStyle.match(/(米白|白色|灰色|黑色|棕色|蓝色|暖色调|冷色调|灰白色系|原木色)/);e&&(i.color=e[0])}return!i.description&&n&&(i.description=n),i},buildProductDimensionRows(e=null,t={},o=""){const i=e&&"object"==typeof e&&!Array.isArray(e)&&null!==e&&("preferenceStyleAndColor"in e||"materialPreference"in e||"customerConcerns"in e),n=o=>{if(i){const t=e[o];if(null==t||""===t)return"暂无信息";if("string"==typeof t){return t.trim()||"暂无信息"}return String(t)||"暂无信息"}{const i=e||{};switch(o){case"preferenceStyleAndColor":const e=[];return i.style&&e.push(i.style),i.color&&e.push(i.color),0===e.length&&t.decorationStyle&&e.push(t.decorationStyle),e.join(" / ")||"暂无信息";case"materialPreference":return i.material||"暂无信息";case"customerFocusAreas":return i.feature||i.remark||"暂无信息";case"priceSensitivity":return t.priceSensitivity||"暂无信息";case"activityParticipation":return t.campaignPreference||t.activityParticipation||"暂无信息";case"customerConcerns":return i.description||"暂无信息";case"deliveryService":return t.serviceExpectation||"暂无信息";case"competitorFeedback":return t.competitorFeedback||"暂无信息";case"deliveryCycle":return t.deliveryCycle||"暂无信息";case"productAppearance":return t.appearancePreference||i.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:n(e.field)||"暂无信息"})))},toggleCategory(e){this.performanceData.categories[e].expanded=!this.performanceData.categories[e].expanded},toggleItem(e,t){console.log("查看子项详情",e,t)},viewSummaryDetail(e){console.log("查看总结详情",e)},viewCustomer(){this.closeDetail(),this.switchTab("customer")},viewCustomerDetail(e){this.currentCustomerProfile=t.initCustomerProfile(e),this.$refs.customerProfileModal.open()},async loadTodoList(t={}){var i,n,a;try{const s=(null==(i=this.currentServiceDetail.rawData)?void 0:i.id)||this.currentServiceDetail.id;if(!s)return console.warn("无法获取parentId,无法加载待办事项"),this.todoList=[],void(this.todoListTotal=0);const r={current:this.todoListPage.current,size:this.todoListPage.size,parentId:s};t.status&&(r.status=t.status),t.todoTitle&&(r.todoTitle=t.todoTitle),t.ownerName&&(r.ownerName=t.ownerName),t.ownerPhone&&(r.ownerPhone=t.ownerPhone),t.createStartTime&&(r.createStartTime=t.createStartTime),t.createEndTime&&(r.createEndTime=t.createEndTime),t.updateStartTime&&(r.updateStartTime=t.updateStartTime),t.updateEndTime&&(r.updateEndTime=t.updateEndTime);const c=Object.keys(r).filter((e=>null!==r[e]&&void 0!==r[e]&&""!==r[e])).map((e=>`${e}=${encodeURIComponent(r[e])}`)).join("&"),d=o.getApiUrl("/api/todoItem/list"),l=c?`${d}?${c}`:d,u=await e.index.request({url:l,method:"GET",timeout:1e4});200===u.statusCode&&u.data&&u.data.success?(this.todoList=u.data.data||[],this.todoListTotal=u.data.total||0):(console.warn("获取待办事项失败:",(null==(n=u.data)?void 0:n.message)||"未知错误"),this.todoList=[],this.todoListTotal=0,e.index.showToast({title:(null==(a=u.data)?void 0:a.message)||"获取待办事项失败",icon:"none"}))}catch(s){console.error("获取待办事项失败:",s),this.todoList=[],this.todoListTotal=0,e.index.showToast({title:`获取待办事项失败: ${s.errMsg||s.message||"未知错误"}`,icon:"none",duration:3e3})}},getTodoStatusClass:e=>e?e.includes("完成")||"已完成"===e?"status-completed":e.includes("进行")||"进行中"===e?"status-processing":(e.includes("待"),"status-pending"):"status-pending",getTodoStatusTextClass:e=>e?e.includes("完成")||"已完成"===e?"status-text-completed":e.includes("进行")||"进行中"===e?"status-text-processing":(e.includes("待"),"status-text-pending"):"status-text-pending",formatDateTime(e){if(!e)return"";try{const t=new Date(e),o=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0");return`${o}-${i}-${n} ${a}:${String(t.getMinutes()).padStart(2,"0")}`}catch(t){return console.warn("格式化日期时间失败:",t),e}},isTodoPending:e=>!e||(e.includes("待")||"待处理"===e||"待处理"===e),toggleTodoMenu(t,o){this.activeTodoMenuIndex===t?(this.activeTodoMenuIndex=null,this.currentTodoItem=null,this.todoMenuStyle={}):(this.activeTodoMenuIndex=t,this.currentTodoItem=this.todoList[t],this.$nextTick((()=>{e.index.createSelectorQuery().in(this).select(`#todo-status-${t}`).boundingClientRect((t=>{t&&e.index.getSystemInfo({success:e=>{const o=200*(e.windowWidth/750),i=e.windowWidth-t.right,n=t.bottom+4;this.todoMenuStyle={right:`${i}px`,top:`${n}px`,width:`${o}px`}}})})).exec()})))},closeTodoMenu(){this.activeTodoMenuIndex=null,this.currentTodoItem=null,this.todoMenuStyle={}},async handleTodoComplete(t,i){var n;this.closeTodoMenu();const a=t.id;if(a)try{const t=o.getApiUrl("/api/todoItem/updateTodoStatus"),i=await e.index.request({url:t,method:"POST",data:{id:a},timeout:1e4,header:{"Content-Type":"application/json"}});200===i.statusCode&&i.data&&i.data.success?(e.index.showToast({title:"处理完成",icon:"success"}),await this.loadTodoList()):e.index.showToast({title:(null==(n=i.data)?void 0:n.message)||"处理失败",icon:"none"})}catch(s){console.error("处理待办事项失败:",s),e.index.showToast({title:`处理失败: ${s.errMsg||s.message||"未知错误"}`,icon:"none",duration:3e3})}else e.index.showToast({title:"待办事项ID不存在",icon:"none"})},async handleTodoDelay(t,i){var n;this.closeTodoMenu();const a=t.id;if(a)try{const t=o.getApiUrl("/api/todoItem/delayProcessTodo"),i=await e.index.request({url:t,method:"POST",data:{id:a},timeout:1e4,header:{"Content-Type":"application/json"}});200===i.statusCode&&i.data&&i.data.success?(e.index.showToast({title:"已延期3天",icon:"success"}),await this.loadTodoList()):e.index.showToast({title:(null==(n=i.data)?void 0:n.message)||"延期失败",icon:"none"})}catch(s){console.error("延期待办事项失败:",s),e.index.showToast({title:`延期失败: ${s.errMsg||s.message||"未知错误"}`,icon:"none",duration:3e3})}else e.index.showToast({title:"待办事项ID不存在",icon:"none"})},onCustomerProfileClose(){},async loadChapterSummary(){var t,i;try{const a=(null==(t=this.currentServiceDetail.rawData)?void 0:t.id)||this.currentServiceDetail.id;if(!a)return console.warn("无法获取parentId,无法加载章节概要"),void(this.chapterSummaryList=[]);const s=`${o.getApiUrl("/api/audioTextAnalysisFurniture/byParentId")}?parentId=${a}`,r=await e.index.request({url:s,method:"GET",timeout:1e4});if(200===r.statusCode&&r.data&&r.data.success){const e=r.data.data||[],t=[],o=Array.isArray(e)&&e.length>0?e[0]:e;if(o){if(o.summary1)try{const e="string"==typeof o.summary1?JSON.parse(o.summary1):o.summary1;e&&(e.customerConcerns||e.answer)&&t.push({title:"章节1",customerConcerns:e.customerConcerns||"",answer:e.answer||""})}catch(n){console.warn("解析summary1失败:",n)}if(o.summary2)try{const e="string"==typeof o.summary2?JSON.parse(o.summary2):o.summary2;e&&(e.customerConcerns||e.answer)&&t.push({title:"章节2",customerConcerns:e.customerConcerns||"",answer:e.answer||""})}catch(n){console.warn("解析summary2失败:",n)}if(o.summary3)try{const e="string"==typeof o.summary3?JSON.parse(o.summary3):o.summary3;e&&(e.customerConcerns||e.answer)&&t.push({title:"章节3",customerConcerns:e.customerConcerns||"",answer:e.answer||""})}catch(n){console.warn("解析summary3失败:",n)}}this.chapterSummaryList=t}else console.warn("获取章节概要失败:",(null==(i=r.data)?void 0:i.message)||"未知错误"),this.chapterSummaryList=[]}catch(n){console.error("获取章节概要失败:",n),this.chapterSummaryList=[]}},async loadPerformanceData(){var i,n;try{const a=(null==(i=this.currentServiceDetail.rawData)?void 0:i.id)||this.currentServiceDetail.id;if(!a)return console.warn("无法获取parentId,无法加载服务表现数据"),void(this.performanceData=t.initPerformanceData());const s=`${o.getApiUrl("/api/audioTextAnalysisSop/listByParentId")}?parentId=${a}`,r=await e.index.request({url:s,method:"GET",timeout:1e4});if(200===r.statusCode&&r.data&&r.data.success){const e=r.data.data,o=Array.isArray(e)&&e.length>0?e[0]:e;o?this.performanceData=this.convertSopDataToPerformanceData(o):(console.warn("服务表现数据为空"),this.performanceData=t.initPerformanceData())}else console.warn("获取服务表现数据失败:",(null==(n=r.data)?void 0:n.message)||"未知错误"),this.performanceData=t.initPerformanceData()}catch(a){console.error("获取服务表现数据失败:",a),this.performanceData=t.initPerformanceData()}},convertSopDataToPerformanceData(e){const t=e=>null!=e&&e>=60,o=[e.greetingIceBreaking,e.brandIntroduction,e.goldenThreeQuestions,e.needsGuidance,e.serviceProgression,e.reassuranceHandbook,e.threeLevelPricing,e.objectionHandling,e.activityImplantation,e.closingCooperation,e.proactiveWechatAdd,e.politeFarewell].filter((e=>null!=e));let i=e.comprehensiveScore||e.comprehensive_score;if(null==i)if(o.length>0){const e=o.reduce(((e,t)=>e+t),0);i=Math.round(e/o.length)}else i=0;return{totalScore:i,categories:[{name:"迎宾探寻",completed:t(e.greetingIceBreaking)||t(e.brandIntroduction),expanded:!0,showBanner:!1,showAudio:!1,items:[{name:"破冰",completed:t(e.greetingIceBreaking),points:e.greetingIceBreaking||0},{name:"品牌介绍",completed:t(e.brandIntroduction),points:e.brandIntroduction||0}]},{name:"展厅体验",completed:t(e.goldenThreeQuestions)||t(e.needsGuidance),expanded:!0,showBanner:!1,showAudio:!1,items:[{name:"黄金三问",completed:t(e.goldenThreeQuestions),points:e.goldenThreeQuestions||0},{name:"需求引导",completed:t(e.needsGuidance),points:e.needsGuidance||0}]},{name:"落座规划",completed:t(e.serviceProgression)||t(e.reassuranceHandbook),expanded:!0,showBanner:!1,showAudio:!1,items:[{name:"服务递进",completed:t(e.serviceProgression),points:e.serviceProgression||0},{name:"SGS放心手册",completed:t(e.reassuranceHandbook),points:e.reassuranceHandbook||0}]},{name:"方案报价",completed:t(e.threeLevelPricing),expanded:!0,showBanner:!1,showAudio:!1,items:[{name:"三级报价",completed:t(e.threeLevelPricing),points:e.threeLevelPricing||0}]},{name:"促单成交",completed:t(e.objectionHandling),expanded:!0,showBanner:!1,showAudio:!1,items:[{name:"解答异议",completed:t(e.objectionHandling),points:e.objectionHandling||0}]},{name:"送客跟进",completed:t(e.activityImplantation)||t(e.closingCooperation)||t(e.proactiveWechatAdd)||t(e.politeFarewell),expanded:!0,showBanner:!1,showAudio:!1,items:[{name:"活动植入",completed:t(e.activityImplantation),points:e.activityImplantation||0},{name:"压单配合",completed:t(e.closingCooperation),points:e.closingCooperation||0},{name:"主动添加微信",completed:t(e.proactiveWechatAdd),points:e.proactiveWechatAdd||0},{name:"邀约量尺时间",completed:!1,points:0},{name:"礼貌道别",completed:t(e.politeFarewell),points:e.politeFarewell||0}]}]}},async loadServiceList(t={}){var i,n;try{const s={current:this.serviceListPage.current,size:this.serviceListPage.size,serviceStatus:"服务结束"},r=null==(i=t.salesName)?void 0:i.trim(),c=null==(n=t.customerName)?void 0:n.trim();r&&(s.salesName=r),c&&(s.customerName=c);const d=Object.keys(s).filter((e=>null!==s[e]&&void 0!==s[e]&&""!==s[e])).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(s[e])}`)).join("&");console.log("服务记录查询参数:",JSON.stringify(s)),console.log("查询字符串:",d);const l=o.getApiUrl("/api/audioManagement/list"),u=d?`${l}?${d}`:l;let m="",p="";try{m=e.index.getStorageSync("backend-tenant-id")||"",p=e.index.getStorageSync("backend-token")||""}catch(a){console.error("获取认证信息失败:",a)}const h={"Content-Type":"application/json"};p&&(h.Authorization=`Bearer ${p}`),m&&(h["X-Tenant-Id"]=m);const g=await e.index.request({url:u,method:"POST",data:{},header:h,timeout:1e4});if(200===g.statusCode&&g.data&&g.data.success){const e=g.data.data.map((e=>{const t=e.updateTime||e.update_time;let o="";if(t){const e=new Date(t);if(!Number.isNaN(e.getTime())){o=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`}}return{id:e.id,title:`${e.salesName||""}的服务记录`,date:o?`更新时间:${o}`:"",description:e.summary||"",customerName:e.customerName||"",recordingName:e.recordingName||"",duration:e.duration,audioFileExtension:null!=e.audioFileExtension&&""!==e.audioFileExtension?e.audioFileExtension:(()=>{const t=e.audioFileOriginalName;if(t&&"string"==typeof t){const e=t.lastIndexOf(".");if(-1!==e&&e"../../uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.js")+(()=>"../../uni_modules/uni-icons/components/uni-icons/uni-icons.js")+(()=>"../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"))();const n=e._export_sfc(i,[["render",function(t,o,i,n,a,s){var r;return e.e({a:e.o(s.goBack,"4e"),b:e.p({fixed:!0,statusBar:!0,border:!1,title:"AI销冠系统",leftIcon:"left",color:"#333",backgroundColor:"#FFFFFF"}),c:"customer"===a.activeTab?1:"",d:e.o((e=>s.switchTab("customer")),"5e"),e:"service"===a.activeTab?1:"",f:e.o((e=>s.switchTab("service")),"aa"),g:s.computedNavbarTop||a.navbarTop,h:"service"===a.activeTab},"service"===a.activeTab?{i:s.computedContentTop||a.contentTop,j:e.o(s.viewDetail,"9e"),k:e.o(s.refreshServiceList,"b5"),l:e.o(s.onServiceListReachBottom,"78"),m:e.o(s.handleMenuAction,"e8"),n:e.o(s.handleUpdateItem,"31"),o:e.p({list:a.serviceList,total:a.serviceListTotal})}:{},{p:"customer"===a.activeTab},"customer"===a.activeTab?{q:s.computedContentTop||a.contentTop,r:e.o(s.viewCustomerDetail,"19")}:{},{s:e.sr("customerProfileModal","612be0dc-3"),t:e.o(s.onCustomerProfileClose,"08"),v:e.p({profile:a.currentCustomerProfile}),w:e.p({type:"close",size:"24",color:"#333"}),x:e.o(((...e)=>s.closeAudioList&&s.closeAudioList(...e)),"58"),y:e.t(a.audioSegmentsList.length),z:e.f(a.audioSegmentsList,((t,o,i)=>e.e({a:e.t(a.playingAudioId===(t.id||t.segmentId)?"暂停":"播放"),b:e.n(a.playingAudioId===(t.id||t.segmentId)?"audio-play-text--playing":""),c:e.o((e=>s.toggleAudioPlay(t,o)),o),d:e.t(s.formatAudioFileName(t.audioFileOriginalName)),e:t.recordingText},t.recordingText?{f:e.t(s.truncateText(t.recordingText,30))}:e.e({g:!a.transcribingIds.includes(t.id||t.segmentId)},(a.transcribingIds.includes(t.id||t.segmentId),{}),{h:a.transcribingIds.includes(t.id||t.segmentId)?1:"",i:e.o((e=>s.transcribeAudio(t,o)),o)}),{j:t.endTime},t.endTime?{k:e.t(s.formatDateTime(t.endTime))}:{},{l:t.duration},t.duration?{m:e.t(s.formatDuration(t.duration))}:{},{n:t.deviceNo},t.deviceNo?{o:e.t(t.deviceNo)}:{},{p:o}))),A:!a.audioSegmentsLoading&&0===a.audioSegmentsList.length},(a.audioSegmentsLoading||a.audioSegmentsList.length,{}),{B:e.sr("audioListPopup","612be0dc-4"),C:e.p({type:"bottom","mask-click":!1}),D:e.p({type:"close",size:"24",color:"#333"}),E:e.o(((...e)=>s.closeTextModal&&s.closeTextModal(...e)),"cf"),F:e.t(a.currentRecordingText||"暂无录音文本"),G:e.sr("textModalPopup","612be0dc-6"),H:e.o(s.onTextModalChange,"f1"),I:e.p({type:"center","mask-click":!0}),J:e.p({type:"close",size:"24",color:"#333"}),K:e.o(((...e)=>s.closeDetail&&s.closeDetail(...e)),"da"),L:e.t(a.currentServiceDetail.title),M:e.p({type:"forward",size:"20",color:"#333"}),N:e.o(((...e)=>s.shareDetail&&s.shareDetail(...e)),"c6"),O:e.t(a.currentServiceDetail.date),P:e.p({type:"loop",size:"18",color:"#007AFF"}),Q:e.p({type:a.isPlaying?"pause-filled":"play-filled",size:"24",color:"#007AFF"}),R:e.o(((...e)=>s.togglePlay&&s.togglePlay(...e)),"8d"),S:"summary"===a.activeDetailTab?1:"",T:e.o((e=>s.switchDetailTab("summary")),"52"),U:"todo"===a.activeDetailTab?1:"",V:e.o((e=>s.switchDetailTab("todo")),"12"),W:"chapter"===a.activeDetailTab?1:"",X:e.o((e=>s.switchDetailTab("chapter")),"ab"),Y:"performance"===a.activeDetailTab?1:"",Z:e.o((e=>s.switchDetailTab("performance")),"5b"),aa:"summary"===a.activeDetailTab},"summary"===a.activeDetailTab?{ab:`summary-${a.currentServiceDetail.id||(null==(r=a.currentServiceDetail.rawData)?void 0:r.id)||Date.now()}`,ac:e.p({serviceItem:a.currentServiceDetail})}:{},{ad:"performance"===a.activeDetailTab},"performance"===a.activeDetailTab?{ae:e.t(a.performanceData.totalScore),af:e.f(a.performanceData.categories,((t,o,i)=>e.e({a:e.n(t.completed?"bullet-blue":"bullet-gray"),b:e.t(t.name),c:"612be0dc-14-"+i+",612be0dc-8",d:e.p({type:t.expanded?"up":"down",size:"16",color:"#999"}),e:e.o((e=>s.toggleCategory(o)),o),f:t.expanded},t.expanded?e.e({g:t.showBanner},t.showBanner?{h:"612be0dc-15-"+i+",612be0dc-8",i:e.p({type:"loop",size:"18",color:"#007AFF"})}:{},{j:t.showAudio},t.showAudio?{k:"612be0dc-16-"+i+",612be0dc-8",l:e.p({type:a.isPlaying?"pause-filled":"play-filled",size:"24",color:"#007AFF"}),m:e.o(((...e)=>s.togglePlay&&s.togglePlay(...e)),o)}:{},{n:e.f(t.items,((t,n,a)=>e.e({a:e.t(t.name),b:!t.completed},t.completed?{}:{c:e.t(t.completed?"已完成":"未提及"),d:e.n(t.completed?"status-completed":"status-missing")},{e:e.t(t.points),f:"612be0dc-17-"+i+"-"+a+",612be0dc-8",g:e.o((e=>s.toggleItem(o,n)),n),h:n,i:t.completed?1:""}))),o:e.p({type:"down",size:"16",color:"#999"})}):{},{p:o})))}:{},{ag:"todo"===a.activeDetailTab},"todo"===a.activeDetailTab?e.e({ah:a.todoList.length>0},a.todoList.length>0?{ai:e.f(a.todoList,((t,o,i)=>e.e({a:e.n(s.getTodoStatusClass(t.status)),b:e.t(t.todoTitle||t.title||"待办事项"),c:s.isTodoPending(t.status)},s.isTodoPending(t.status)?{d:e.t(t.status||"待处理"),e:"612be0dc-18-"+i+",612be0dc-8",f:e.p({type:"down",size:"14",color:"#FF9800"}),g:e.n(s.getTodoStatusTextClass(t.status)),h:"todo-status-"+o,i:e.o((e=>s.toggleTodoMenu(o,e)),o)}:{j:e.t(t.status||"待处理"),k:e.n(s.getTodoStatusTextClass(t.status))},{l:t.todoContent||t.content||t.description},t.todoContent||t.content||t.description?{m:e.t(t.todoContent||t.content||t.description)}:{},{n:t.ownerName},t.ownerName?{o:e.t(t.ownerName)}:{},{p:t.ownerPhone},t.ownerPhone?{q:e.t(t.ownerPhone)}:{},{r:t.PendingDate||t.pendingDate},t.PendingDate||t.pendingDate?{s:e.t(s.formatDateTime(t.PendingDate||t.pendingDate))}:{},{t:o,v:t.status&&(t.status.includes("完成")||"已完成"===t.status)?1:"",w:s.isTodoPending(t.status)?1:""})))}:{}):{},{aj:null!==a.activeTodoMenuIndex},null!==a.activeTodoMenuIndex?{ak:e.o(((...e)=>s.closeTodoMenu&&s.closeTodoMenu(...e)),"c6")}:{},{al:null!==a.activeTodoMenuIndex},null!==a.activeTodoMenuIndex?{am:e.o((e=>s.handleTodoComplete(a.currentTodoItem,a.activeTodoMenuIndex)),"5c"),an:e.o((e=>s.handleTodoDelay(a.currentTodoItem,a.activeTodoMenuIndex)),"2a"),ao:e.s(a.todoMenuStyle),ap:e.o((()=>{}),"e6")}:{},{aq:"chapter"===a.activeDetailTab},"chapter"===a.activeDetailTab?e.e({ar:a.chapterSummaryList.length>0},a.chapterSummaryList.length>0?{as:e.f(a.chapterSummaryList,((t,o,i)=>e.e({a:e.t(t.title||`章节${o+1}`),b:t.customerConcerns},t.customerConcerns?{c:e.t(t.customerConcerns)}:{},{d:t.answer},t.answer?{e:e.t(t.answer)}:{},{f:o})))}:{}):{},{at:"summary"!==a.activeDetailTab&&"performance"!==a.activeDetailTab&&"todo"!==a.activeDetailTab&&"chapter"!==a.activeDetailTab},"summary"!==a.activeDetailTab&&"performance"!==a.activeDetailTab&&"todo"!==a.activeDetailTab&&"chapter"!==a.activeDetailTab?{av:e.t(s.getDetailTabName(a.activeDetailTab))}:{},{aw:e.p({type:"person",size:"20",color:"#666"}),ax:e.t(a.currentServiceDetail.customerName),ay:e.p({type:"right",size:"16",color:"#999"}),az:e.o(((...e)=>s.viewCustomer&&s.viewCustomer(...e)),"7d"),aA:e.sr("serviceDetailPopup","612be0dc-8"),aB:e.p({type:"bottom","mask-click":!1})})}]]);wx.createPage(n);