二手车交易,缓存问题解决

This commit is contained in:
2025-03-15 17:49:25 +08:00
parent 678d4f6436
commit 22e6c58e65
7 changed files with 77 additions and 221 deletions

View File

@ -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()){