From 678d4f6436c892164e6a4eedb42d5a1e885365ab Mon Sep 17 00:00:00 2001 From: zhouxueli <2841188632@qq.com> Date: Sat, 15 Mar 2025 16:47:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=89=8B=E8=BD=A6=E4=BA=A4=E6=98=93?= =?UTF-8?q?=EF=BC=8C=E6=89=93=E7=94=B5=E8=AF=9D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/secondHandCar/carSource.vue | 44 ++++++++++++++++++++++++--- src/views/secondHandCar/privacy.vue | 11 +++++++ 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/views/secondHandCar/carSource.vue b/src/views/secondHandCar/carSource.vue index f054fdbd..abb67ce5 100644 --- a/src/views/secondHandCar/carSource.vue +++ b/src/views/secondHandCar/carSource.vue @@ -226,7 +226,9 @@ export default { this.vehicleAnglePhotoList=[{url:res.data?.vehicleAnglePhoto}] console.log("th",this.form) } - console.log("this.$route.params",this.$route.params) + // 监听 message 事件 + window.addEventListener('message', this.handleMessage); + // console.log("this.$route.query==",this.$route.query) if(this.$route.params.form){ this.form={...this.$route.params.form} } @@ -249,7 +251,42 @@ export default { this.otherImgSrc=this.$route.params.otherImgSrc } }, + beforeDestroy() { + // 移除事件监听器 + window.removeEventListener('message', this.handleMessage); + }, methods:{ + // 处理接收到的消息 + handleMessage(event) { + // 解析消息数据 + const data = event.data; + console.log("data",data) + // 检查消息类型(可选) + if (data.type === 'updateCarSourceParams') { + // 更新组件数据 + if (data.form) { + this.form = data.form; + } + if (data.radio) { + this.radio = data.radio; + } + if (data.areaName) { + this.areaName = data.areaName; + } + if (data.vehicleLicensePhotoList) { + this.vehicleLicensePhotoList = data.vehicleLicensePhotoList; + } + if (data.vehicleAnglePhotoList) { + this.vehicleAnglePhotoList = data.vehicleAnglePhotoList; + } + if (data.otherImgSrcList) { + this.otherImgSrcList = data.otherImgSrcList; + } + if (data.otherImgSrc) { + this.otherImgSrc = data.otherImgSrc; + } + } + }, backHandle(){ if(this.$route.query.homePage){//返回列表 this.$router.push({ name: "indexList"}) @@ -269,12 +306,12 @@ export default { url = 'https://crm1.sino-assist.com' // url = 'http://localhost:8080' } - sessionStorage.setItem('formInfo',JSON.stringify(this.form)) + /* sessionStorage.setItem('formInfo',JSON.stringify(this.form)) sessionStorage.setItem('areaName',this.areaName) sessionStorage.setItem('vehicleLicensePhotoList',JSON.stringify(this.vehicleLicensePhotoList)) sessionStorage.setItem('vehicleAnglePhotoList',JSON.stringify(this.vehicleAnglePhotoList)) sessionStorage.setItem('otherImgSrcList',JSON.stringify(this.otherImgSrcList)) - sessionStorage.setItem('otherImgSrc',JSON.stringify(this.otherImgSrc)) + sessionStorage.setItem('otherImgSrc',JSON.stringify(this.otherImgSrc))*/ let urls=url + '/h5/supplier/dispatch/res/privacy.html' this.$router.push({ name: "privacyComponent", query: {url:urls,type:1,homePage:this.homePage},params: { @@ -284,7 +321,6 @@ export default { vehicleAnglePhotoList:this.vehicleAnglePhotoList, otherImgSrcList:this.otherImgSrcList, otherImgSrc:this.otherImgSrc, - }}) }, closeParentDialog() { diff --git a/src/views/secondHandCar/privacy.vue b/src/views/secondHandCar/privacy.vue index c784f19e..cc5417f0 100644 --- a/src/views/secondHandCar/privacy.vue +++ b/src/views/secondHandCar/privacy.vue @@ -30,6 +30,17 @@ export default { }, methods:{ backHandle(){ + const data = { + form: this.$route.params.form, + radio: this.$route.params.radio, + areaName: this.$route.params.areaName, + vehicleLicensePhotoList: this.$route.params.vehicleLicensePhotoList, + vehicleAnglePhotoList: this.$route.params.vehicleAnglePhotoList, + otherImgSrcList: this.$route.params.otherImgSrcList, + otherImgSrc: this.$route.params.otherImgSrc, + }; + // 向父页面(A 项目)发送消息,使用自定义事件名称 + window.parent.postMessage({ type: 'updateCarSourceParams', data }, '*'); if(this.isWebFunc()){ this.h5GoBack() }else{