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

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` 上
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 () {

View File

@ -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();
}
}
},
}
}

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

View File

@ -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

View File

@ -1,7 +1,7 @@
<template>
<div class="wrap" >
<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>
<div style="opacity: 0;" class="back"></div>
</div>
@ -23,45 +23,8 @@ export default {
},
async mounted() {
this.url=this.$route.query.url
console.log("1122",this.$route.params.form,this.$route.params.radio)
},
beforeUnmount() {
},
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 } })
}
}
},
}
methods:{ }
}
</script>
@ -93,7 +56,6 @@ export default {
}
.contentWrap{
height: calc(100% - 42px);
//overflow-y: auto;
iframe{
overflow-y:hidden;
width: 100%;

View File

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

View File

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