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

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

@ -35,7 +35,7 @@
// VConsole 默认会挂载到 `window.VConsole` 上 // VConsole 默认会挂载到 `window.VConsole` 上
let vConsole = new window.VConsole(); let vConsole = new window.VConsole();
(function (doc, win) { (function (doc, win) {
console.log("==window.location.pathname===",window.location.pathname) // console.log("==window.location.pathname===",window.location.pathname)
let docEl = doc.documentElement let docEl = doc.documentElement
let resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize' let resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
recalc = function () { recalc = function () {

View File

@ -2,9 +2,6 @@
export const myMixins = { export const myMixins = {
data() { data() {
return { return {
touchStart: [],
touchEnd: [],
slideShow: true
} }
}, },
methods: { methods: {
@ -96,5 +93,15 @@ export const myMixins = {
} }
return res return res
}, },
closeParentDialog() {
if (window.parent) {
const hasListener = window.parent.dispatchEvent(new Event('checkCloseDialog'));
if (hasListener) {
window.parent.postMessage('closeDialog', '*');
} else {
window.history.back();
}
}
},
} }
} }

View File

@ -175,7 +175,6 @@ export default {
mileage:'', mileage:'',
contactNumber:'', contactNumber:'',
minPrice:'', minPrice:'',
// maxPrice:'',
desc:'', desc:'',
}, },
radio: 0, radio: 0,
@ -195,7 +194,6 @@ export default {
status:'', status:'',
supplierName:'', supplierName:'',
supplierCode:'', supplierCode:'',
homePage:false,
} }
}, },
async mounted() { async mounted() {
@ -203,7 +201,6 @@ export default {
this.type=this.$route.query.type || urlParams.get('type'); this.type=this.$route.query.type || urlParams.get('type');
this.id=this.$route.query.id || urlParams.get('id'); this.id=this.$route.query.id || urlParams.get('id');
this.queryType=this.$route.query.queryType || urlParams.get('queryType'); this.queryType=this.$route.query.queryType || urlParams.get('queryType');
this.homePage=this.$route.query.homePage
if( this.id){ if( this.id){
let res = await carInfoDetail({ let res = await carInfoDetail({
id:this.id, id:this.id,
@ -224,68 +221,23 @@ export default {
} }
this.vehicleLicensePhotoList=[{url:res.data?.vehicleLicensePhoto}] this.vehicleLicensePhotoList=[{url:res.data?.vehicleLicensePhoto}]
this.vehicleAnglePhotoList=[{url:res.data?.vehicleAnglePhoto}] this.vehicleAnglePhotoList=[{url:res.data?.vehicleAnglePhoto}]
console.log("th",this.form)
} }
// 监听 message 事件 let carSourceFormInfo=localStorage.getItem("carSourceFormInfo") ? JSON.parse(localStorage.getItem("carSourceFormInfo")) : ''
window.addEventListener('message', this.handleMessage); // console.log("carSourceFormInfo",carSourceFormInfo)
// console.log("this.$route.query==",this.$route.query) if(!carSourceFormInfo){
if(this.$route.params.form){ return
this.form={...this.$route.params.form}
} }
if(this.$route.params.radio){ this.form={...carSourceFormInfo.form}
this.radio=this.$route.params.radio this.radio=carSourceFormInfo.radio
} this.areaName=carSourceFormInfo.areaName
if(this.$route.params.areaName){ this.vehicleLicensePhotoList=carSourceFormInfo.vehicleLicensePhotoList
this.areaName=this.$route.params.areaName this.vehicleAnglePhotoList=carSourceFormInfo.vehicleAnglePhotoList
} this.otherImgSrcList=carSourceFormInfo.otherImgSrcList
if(this.$route.params.vehicleLicensePhotoList){ this.otherImgSrc=carSourceFormInfo.otherImgSrc
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);
}, },
methods:{ methods:{
// 处理接收到的消息 clearStorageFormInfo(){
handleMessage(event) { localStorage.setItem("carSourceFormInfo",'')
// 解析消息数据
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(){ backHandle(){
if(this.$route.query.homePage){//返回列表 if(this.$route.query.homePage){//返回列表
@ -293,6 +245,7 @@ export default {
}else{//返回我的发布 }else{//返回我的发布
this.$router.push({ name: "mineRelease"}) this.$router.push({ name: "mineRelease"})
} }
this.clearStorageFormInfo()
}, },
viewPrivacy(){ viewPrivacy(){
let url=''; let url='';
@ -303,38 +256,18 @@ export default {
} else if (window.location.href.includes('uat.sino-assist.com')) { } else if (window.location.href.includes('uat.sino-assist.com')) {
url = 'https://api-uat.sino-assist.com' url = 'https://api-uat.sino-assist.com'
} else { } else {
url = 'https://crm1.sino-assist.com' // url = 'https://crm1.sino-assist.com'
// url = 'http://localhost:8080' 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' let urls=url + '/h5/supplier/dispatch/res/privacy.html'
this.$router.push({ name: "privacyComponent", query: {url:urls,type:1,homePage:this.homePage},params: { let data={
form: this.form,radio:this.radio, form:this.form,radio:this.radio,areaName:this.areaName, vehicleLicensePhotoList:this.vehicleLicensePhotoList,
areaName:this.areaName, vehicleAnglePhotoList:this.vehicleAnglePhotoList,
vehicleLicensePhotoList:this.vehicleLicensePhotoList, otherImgSrcList:this.otherImgSrcList,
vehicleAnglePhotoList:this.vehicleAnglePhotoList, otherImgSrc:this.otherImgSrc,
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();
}
} }
localStorage.setItem("carSourceFormInfo",JSON.stringify(data))
this.$router.push({ name: "privacyComponent", query: {url:urls}})
}, },
confirmHandle(val){ confirmHandle(val){
let data=val.length let data=val.length
@ -371,10 +304,8 @@ export default {
this.otherImgSrc.push(data.url) this.otherImgSrc.push(data.url)
}, },
handleDeleteOtherImg(file,index) { handleDeleteOtherImg(file,index) {
// this.otherImgSrc = this.otherImgSrc.filter((item) => item !== file.url);
this.otherImgSrc = this.otherImgSrc.filter((item,i) => index !== i); this.otherImgSrc = this.otherImgSrc.filter((item,i) => index !== i);
this.otherImgSrcList = this.otherImgSrcList.filter((item,i) => index !== i); this.otherImgSrcList = this.otherImgSrcList.filter((item,i) => index !== i);
console.log("删除后的 otherImgSrc", this.otherImgSrc,this.otherImgSrcList);
}, },
// 审核操作 // 审核操作
async auditHandle(type){ async auditHandle(type){
@ -382,30 +313,7 @@ export default {
this.$toast('请填写不通过原因') this.$toast('请填写不通过原因')
return return
} }
if (!this.form.vehicleLicensePhoto) { await this.commonMethods();
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
}
try { try {
await auditCarInfo({ await auditCarInfo({
id: this.id, id: this.id,
@ -414,6 +322,7 @@ export default {
...this.form, ...this.form,
otherPhoto:this.otherImgSrc?.join(',') otherPhoto:this.otherImgSrc?.join(',')
}) })
this.clearStorageFormInfo()
setTimeout(()=>{ setTimeout(()=>{
this.closeParentDialog() this.closeParentDialog()
},1000) },1000)
@ -421,12 +330,7 @@ export default {
console.log(type) console.log(type)
} }
}, },
// 发布车源 commonMethods(){
async submitHandle(){
if (!this.radio) {
this.$toast('请勾选我已阅读并同意')
return
}
if (!this.form.vehicleLicensePhoto) { if (!this.form.vehicleLicensePhoto) {
this.$toast('行驶证不能为空') this.$toast('行驶证不能为空')
return return
@ -451,11 +355,20 @@ export default {
this.$toast(rule.name) this.$toast(rule.name)
return return
} }
},
// 发布车源
async submitHandle(){
if (!this.radio) {
this.$toast('请勾选我已阅读并同意')
return
}
await this.commonMethods();
try { try {
let res = await publishCarInfo({ let res = await publishCarInfo({
...this.form, ...this.form,
otherPhoto:this.otherImgSrc?.join(',') otherPhoto:this.otherImgSrc?.join(',')
}) })
this.clearStorageFormInfo()
if(res.code == 200 && !res.msg){ if(res.code == 200 && !res.msg){
this.$toast('发布成功') this.$toast('发布成功')
if(this.isWebFunc()){ if(this.isWebFunc()){

View File

@ -134,7 +134,7 @@ export default {
this.imgSrcList=res.data.otherPhoto.split(',') || [] this.imgSrcList=res.data.otherPhoto.split(',') || []
} }
this.imgSrcList.unshift(res?.data?.vehicleAnglePhoto) this.imgSrcList.unshift(res?.data?.vehicleAnglePhoto)
console.log("this.imgSrcList",this.imgSrcList) // console.log("this.imgSrcList",this.imgSrcList)
} }
}, },
destroyed() { destroyed() {
@ -154,18 +154,11 @@ export default {
getDuration(){ getDuration(){
// 页面卸载时记录离开时间并计算浏览时长 // 页面卸载时记录离开时间并计算浏览时长
const endTime = new Date(); const endTime = new Date();
const duration = (endTime - this.startTime) / 1000; // 计算时长(秒) const duration = (endTime - this.startTime) / 1000; // 计算时长(秒)\
// console.log('页面卸载时间:', endTime);
console.log('浏览时长:', duration, '秒');
this.saveRecord(duration); this.saveRecord(duration);
}, },
async saveRecord(duration){ async saveRecord(duration){
try { await saveRecord({type: this.recordType, carInfoId: this.id, duration})
let res= await saveRecord({type: this.recordType, carInfoId: this.id, duration})
console.log("saveRecord",res)
} catch (e) {
console.log("e",e)
}
}, },
handle(){ handle(){
this.show=true this.show=true

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="wrap" > <div class="wrap" >
<div class="headerWrap"> <div class="headerWrap">
<img class="back" @click="backHandle" src="@/assets/secondHandCar/back.png" /> <img class="back" @click="h5GoBack" src="@/assets/secondHandCar/back.png" />
<span>免责声明</span> <span>免责声明</span>
<div style="opacity: 0;" class="back"></div> <div style="opacity: 0;" class="back"></div>
</div> </div>
@ -23,45 +23,8 @@ export default {
}, },
async mounted() { async mounted() {
this.url=this.$route.query.url this.url=this.$route.query.url
console.log("1122",this.$route.params.form,this.$route.params.radio)
}, },
beforeUnmount() { methods:{ }
},
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{
if(this.$route.query.type == 1){
this.$router.push({ name: 'carSource',query: {type:1,homePage:this.$route.query.homePage},params: {
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 ,
} })
}else{
this.$router.push({ name: 'wantBuy',query: {type:1,homePage:this.$route.query.homePage},params: { form: this.$route.params.form,radio:this.$route.params.radio } })
}
}
},
}
} }
</script> </script>
@ -93,7 +56,6 @@ export default {
} }
.contentWrap{ .contentWrap{
height: calc(100% - 42px); height: calc(100% - 42px);
//overflow-y: auto;
iframe{ iframe{
overflow-y:hidden; overflow-y:hidden;
width: 100%; width: 100%;

View File

@ -137,7 +137,6 @@ export default {
status:'', status:'',
supplierName:'', supplierName:'',
supplierCode:'', supplierCode:'',
homePage:false,
} }
}, },
async mounted() { async mounted() {
@ -145,7 +144,6 @@ export default {
this.type=this.$route.query.type || urlParams.get('type'); this.type=this.$route.query.type || urlParams.get('type');
this.id=this.$route.query.id || urlParams.get('id'); this.id=this.$route.query.id || urlParams.get('id');
this.queryType=this.$route.query.queryType || urlParams.get('queryType'); this.queryType=this.$route.query.queryType || urlParams.get('queryType');
this.homePage=this.$route.query.homePage
if( this.id){ if( this.id){
let res = await carInfoDetail({ let res = await carInfoDetail({
id:this.id, id:this.id,
@ -164,23 +162,27 @@ export default {
this.ortherReason=res[1] this.ortherReason=res[1]
} }
} }
if(this.$route.params.form){ let wantBuyFormInfo=localStorage.getItem("wantBuyFormInfo") ? JSON.parse(localStorage.getItem("wantBuyFormInfo")) : ''
this.form={...this.$route.params.form} if(!wantBuyFormInfo){
} return
if(this.$route.params.radio){
this.radio=this.$route.params.radio
} }
this.form={...wantBuyFormInfo.form}
this.radio=wantBuyFormInfo.radio
this.ortherReason=wantBuyFormInfo.ortherReason
}, },
methods:{ methods:{
clearStorageFormInfo(){
localStorage.setItem("wantBuyFormInfo",'')
},
backHandle(){ backHandle(){
if(this.$route.query.homePage){//返回列表 if(this.$route.query.homePage){//返回列表
this.$router.push({ name: "indexList"}) this.$router.push({ name: "indexList"})
}else{//返回我的发布 }else{//返回我的发布
this.$router.push({ name: "mineRelease"}) this.$router.push({ name: "mineRelease"})
} }
this.clearStorageFormInfo();
}, },
viewPrivacy(){ viewPrivacy(){
// let host = window.location.host
let url=''; let url='';
if (window.location.href.includes('www.sinoassist.com')) { if (window.location.href.includes('www.sinoassist.com')) {
url = 'https://www.sinoassist.com' url = 'https://www.sinoassist.com'
@ -193,43 +195,18 @@ export default {
// url = 'http://localhost:8080' // url = 'http://localhost:8080'
} }
let urls=url + '/h5/supplier/dispatch/res/privacy.html' let urls=url + '/h5/supplier/dispatch/res/privacy.html'
this.$router.push({ name: "privacyComponent", query: {url:urls,type:2,homePage:this.homePage},params: { form: this.form,radio:this.radio } }) let data={form:this.form,radio:this.radio,ortherReason:this.ortherReason}
}, localStorage.setItem("wantBuyFormInfo",JSON.stringify(data))
closeParentDialog() { this.$router.push({ name: "privacyComponent", query: {url:urls}})
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();
}
}
}, },
// 审核操作 // 审核操作
async auditHandle(type){ async auditHandle(type){
if (!type && !this.auditReason){ if (!type && !this.auditReason){
this.$toast('请填写不通过原因') this.$toast('请填写不通过原因')
return return
} }
let flag=this.validateHandle() await this.commonMethods()
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
}
try { try {
await auditCarInfo({ await auditCarInfo({
id: this.id, id: this.id,
@ -238,6 +215,7 @@ export default {
...this.form, ...this.form,
vehicleType: this.ortherReason ? (this.form.vehicleType+','+this.ortherReason) : this.form.vehicleType vehicleType: this.ortherReason ? (this.form.vehicleType+','+this.ortherReason) : this.form.vehicleType
}) })
this.clearStorageFormInfo()
setTimeout(()=>{ setTimeout(()=>{
this.closeParentDialog() this.closeParentDialog()
},1000) },1000)
@ -249,12 +227,7 @@ export default {
} }
}, },
// 发布求购 commonMethods() {
async submitHandle(){
if (!this.radio) {
this.$toast('请勾选我已阅读并同意')
return
}
let flag=this.validateHandle() let flag=this.validateHandle()
if(flag){ if(flag){
this.$toast(flag) this.$toast(flag)
@ -271,11 +244,20 @@ export default {
this.$toast(rule.name) this.$toast(rule.name)
return return
} }
},
// 发布求购
async submitHandle(){
if (!this.radio) {
this.$toast('请勾选我已阅读并同意')
return
}
await this.commonMethods()
try { try {
let res = await publishCarInfo({ let res = await publishCarInfo({
...this.form, ...this.form,
vehicleType: this.ortherReason ? (this.form.vehicleType+','+this.ortherReason) : this.form.vehicleType vehicleType: this.ortherReason ? (this.form.vehicleType+','+this.ortherReason) : this.form.vehicleType
}) })
this.clearStorageFormInfo()
if(res.code == 200 && !res.msg){ if(res.code == 200 && !res.msg){
this.$toast('发布成功') this.$toast('发布成功')
if(this.isWebFunc()){ if(this.isWebFunc()){

View File

@ -91,7 +91,6 @@ export default {
getDuration(){ getDuration(){
const endTime = new Date(); const endTime = new Date();
const duration = (endTime - this.startTime) / 1000; // 计算时长(秒) const duration = (endTime - this.startTime) / 1000; // 计算时长(秒)
console.log('浏览时长:', duration, '秒');
this.saveRecord(duration); this.saveRecord(duration);
}, },
async saveRecord(duration){ async saveRecord(duration){