diff --git a/public/index.html b/public/index.html index 53f32f1e..ae07a190 100644 --- a/public/index.html +++ b/public/index.html @@ -35,7 +35,7 @@ // VConsole 默认会挂载到 `window.VConsole` 上 let vConsole = new window.VConsole(); (function (doc, win) { - console.log("==window.location.pathname===",window.location.pathname) + // console.log("==window.location.pathname===",window.location.pathname) let docEl = doc.documentElement let resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize' recalc = function () { diff --git a/src/utils/myMixins.js b/src/utils/myMixins.js index ae2efdcd..07d99874 100644 --- a/src/utils/myMixins.js +++ b/src/utils/myMixins.js @@ -2,9 +2,6 @@ export const myMixins = { data() { return { - touchStart: [], - touchEnd: [], - slideShow: true } }, methods: { @@ -96,5 +93,15 @@ export const myMixins = { } return res }, + closeParentDialog() { + if (window.parent) { + const hasListener = window.parent.dispatchEvent(new Event('checkCloseDialog')); + if (hasListener) { + window.parent.postMessage('closeDialog', '*'); + } else { + window.history.back(); + } + } + }, } } diff --git a/src/views/secondHandCar/carSource.vue b/src/views/secondHandCar/carSource.vue index abb67ce5..14e7c989 100644 --- a/src/views/secondHandCar/carSource.vue +++ b/src/views/secondHandCar/carSource.vue @@ -175,7 +175,6 @@ export default { mileage:'', contactNumber:'', minPrice:'', - // maxPrice:'', desc:'', }, radio: 0, @@ -195,7 +194,6 @@ export default { status:'', supplierName:'', supplierCode:'', - homePage:false, } }, async mounted() { @@ -203,7 +201,6 @@ export default { this.type=this.$route.query.type || urlParams.get('type'); this.id=this.$route.query.id || urlParams.get('id'); this.queryType=this.$route.query.queryType || urlParams.get('queryType'); - this.homePage=this.$route.query.homePage if( this.id){ let res = await carInfoDetail({ id:this.id, @@ -224,68 +221,23 @@ export default { } this.vehicleLicensePhotoList=[{url:res.data?.vehicleLicensePhoto}] this.vehicleAnglePhotoList=[{url:res.data?.vehicleAnglePhoto}] - console.log("th",this.form) } - // 监听 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} + let carSourceFormInfo=localStorage.getItem("carSourceFormInfo") ? JSON.parse(localStorage.getItem("carSourceFormInfo")) : '' + // console.log("carSourceFormInfo",carSourceFormInfo) + if(!carSourceFormInfo){ + return } - if(this.$route.params.radio){ - this.radio=this.$route.params.radio - } - if(this.$route.params.areaName){ - this.areaName=this.$route.params.areaName - } - if(this.$route.params.vehicleLicensePhotoList){ - this.vehicleLicensePhotoList=this.$route.params.vehicleLicensePhotoList - } - if(this.$route.params.vehicleAnglePhotoList){ - this.vehicleAnglePhotoList=this.$route.params.vehicleAnglePhotoList - } - if(this.$route.params.otherImgSrcList){ - this.otherImgSrcList=this.$route.params.otherImgSrcList - } - if(this.$route.params.otherImgSrc){ - this.otherImgSrc=this.$route.params.otherImgSrc - } - }, - beforeDestroy() { - // 移除事件监听器 - window.removeEventListener('message', this.handleMessage); + this.form={...carSourceFormInfo.form} + this.radio=carSourceFormInfo.radio + this.areaName=carSourceFormInfo.areaName + this.vehicleLicensePhotoList=carSourceFormInfo.vehicleLicensePhotoList + this.vehicleAnglePhotoList=carSourceFormInfo.vehicleAnglePhotoList + this.otherImgSrcList=carSourceFormInfo.otherImgSrcList + this.otherImgSrc=carSourceFormInfo.otherImgSrc }, 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; - } - } + clearStorageFormInfo(){ + localStorage.setItem("carSourceFormInfo",'') }, backHandle(){ if(this.$route.query.homePage){//返回列表 @@ -293,6 +245,7 @@ export default { }else{//返回我的发布 this.$router.push({ name: "mineRelease"}) } + this.clearStorageFormInfo() }, viewPrivacy(){ let url=''; @@ -303,38 +256,18 @@ export default { } else if (window.location.href.includes('uat.sino-assist.com')) { url = 'https://api-uat.sino-assist.com' } else { - url = 'https://crm1.sino-assist.com' - // url = 'http://localhost:8080' + // url = 'https://crm1.sino-assist.com' + url = 'http://localhost:8080' } - /* 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))*/ - let urls=url + '/h5/supplier/dispatch/res/privacy.html' - this.$router.push({ name: "privacyComponent", query: {url:urls,type:1,homePage:this.homePage},params: { - form: this.form,radio:this.radio, - areaName:this.areaName, - vehicleLicensePhotoList:this.vehicleLicensePhotoList, - vehicleAnglePhotoList:this.vehicleAnglePhotoList, - otherImgSrcList:this.otherImgSrcList, - otherImgSrc:this.otherImgSrc, - }}) - }, - closeParentDialog() { - if (window.parent) { - // 检查是否有父组件监听 'closeDialog' 事件 - const hasListener = window.parent.dispatchEvent(new Event('checkCloseDialog')); - if (hasListener) { - // 如果有监听器,向父组件发送消息以请求关闭 dialog - window.parent.postMessage('closeDialog', '*'); - } else { - // 如果没有监听器,则执行 history.back() - window.history.back(); - } + let data={ + form:this.form,radio:this.radio,areaName:this.areaName, vehicleLicensePhotoList:this.vehicleLicensePhotoList, + vehicleAnglePhotoList:this.vehicleAnglePhotoList, + otherImgSrcList:this.otherImgSrcList, + otherImgSrc:this.otherImgSrc, } + localStorage.setItem("carSourceFormInfo",JSON.stringify(data)) + this.$router.push({ name: "privacyComponent", query: {url:urls}}) }, confirmHandle(val){ let data=val.length @@ -371,10 +304,8 @@ export default { this.otherImgSrc.push(data.url) }, handleDeleteOtherImg(file,index) { - // this.otherImgSrc = this.otherImgSrc.filter((item) => item !== file.url); this.otherImgSrc = this.otherImgSrc.filter((item,i) => index !== i); this.otherImgSrcList = this.otherImgSrcList.filter((item,i) => index !== i); - console.log("删除后的 otherImgSrc", this.otherImgSrc,this.otherImgSrcList); }, // 审核操作 async auditHandle(type){ @@ -382,30 +313,7 @@ export default { this.$toast('请填写不通过原因') return } - if (!this.form.vehicleLicensePhoto) { - this.$toast('行驶证不能为空') - return - } - if (!this.form.vehicleAnglePhoto) { - this.$toast('车辆45度不能为空') - return - } - let flag=this.validateHandle() - if(flag){ - this.$toast(flag) - return - } - if (this.form.vehicleType=='拖车' && !this.form.boardType) { - this.$toast('落板方式不能为空') - return - }else if(this.form.vehicleType !=='拖车'){ - this.form.boardType='' - } - let rule=this.validationRules.find(item=>!item.value) - if(rule){ - this.$toast(rule.name) - return - } + await this.commonMethods(); try { await auditCarInfo({ id: this.id, @@ -414,6 +322,7 @@ export default { ...this.form, otherPhoto:this.otherImgSrc?.join(',') }) + this.clearStorageFormInfo() setTimeout(()=>{ this.closeParentDialog() },1000) @@ -421,12 +330,7 @@ export default { console.log(type) } }, - // 发布车源 - async submitHandle(){ - if (!this.radio) { - this.$toast('请勾选我已阅读并同意') - return - } + commonMethods(){ if (!this.form.vehicleLicensePhoto) { this.$toast('行驶证不能为空') return @@ -451,11 +355,20 @@ export default { this.$toast(rule.name) return } + }, + // 发布车源 + async submitHandle(){ + if (!this.radio) { + this.$toast('请勾选我已阅读并同意') + return + } + await this.commonMethods(); try { let res = await publishCarInfo({ ...this.form, otherPhoto:this.otherImgSrc?.join(',') }) + this.clearStorageFormInfo() if(res.code == 200 && !res.msg){ this.$toast('发布成功') if(this.isWebFunc()){ diff --git a/src/views/secondHandCar/forSale.vue b/src/views/secondHandCar/forSale.vue index 72222ede..b2ba705f 100644 --- a/src/views/secondHandCar/forSale.vue +++ b/src/views/secondHandCar/forSale.vue @@ -134,7 +134,7 @@ export default { this.imgSrcList=res.data.otherPhoto.split(',') || [] } this.imgSrcList.unshift(res?.data?.vehicleAnglePhoto) - console.log("this.imgSrcList",this.imgSrcList) + // console.log("this.imgSrcList",this.imgSrcList) } }, destroyed() { @@ -154,18 +154,11 @@ export default { getDuration(){ // 页面卸载时记录离开时间并计算浏览时长 const endTime = new Date(); - const duration = (endTime - this.startTime) / 1000; // 计算时长(秒) - // console.log('页面卸载时间:', endTime); - console.log('浏览时长:', duration, '秒'); + const duration = (endTime - this.startTime) / 1000; // 计算时长(秒)\ this.saveRecord(duration); }, async saveRecord(duration){ - try { - let res= await saveRecord({type: this.recordType, carInfoId: this.id, duration}) - console.log("saveRecord",res) - } catch (e) { - console.log("e",e) - } + await saveRecord({type: this.recordType, carInfoId: this.id, duration}) }, handle(){ this.show=true diff --git a/src/views/secondHandCar/privacy.vue b/src/views/secondHandCar/privacy.vue index cc5417f0..3dbaa898 100644 --- a/src/views/secondHandCar/privacy.vue +++ b/src/views/secondHandCar/privacy.vue @@ -1,7 +1,7 @@