二手车交易,记录浏览量
This commit is contained in:
@ -67,7 +67,6 @@ export default {
|
||||
detailInfo:'',
|
||||
duration:'',
|
||||
startTime: null, // 记录进入时间
|
||||
recordType:1,
|
||||
isList:false,
|
||||
}
|
||||
},
|
||||
@ -88,31 +87,31 @@ export default {
|
||||
document.addEventListener('visibilitychange', async ( ) => {
|
||||
let state = document.visibilityState
|
||||
if (state == 'hidden') { // 用户离开了
|
||||
console.log("用户离开了")
|
||||
await this.getDuration()
|
||||
console.log("用户离开了1")
|
||||
await this.getDuration(1);
|
||||
console.log("用户离开了2")
|
||||
}
|
||||
});
|
||||
},
|
||||
destroyed() {
|
||||
this.getDuration()
|
||||
},
|
||||
/*destroyed() {
|
||||
this.getDuration(1)
|
||||
},*/
|
||||
methods:{
|
||||
getDuration(){
|
||||
getDuration(type){
|
||||
const endTime = new Date();
|
||||
const duration = (endTime - this.startTime) / 1000; // 计算时长(秒)
|
||||
this.saveRecord(duration);
|
||||
this.saveRecord(duration,type);
|
||||
},
|
||||
async saveRecord(duration){
|
||||
await saveRecord({type:this.recordType,carInfoId:this.id,duration})
|
||||
async saveRecord(duration,type){
|
||||
await saveRecord({type:type,carInfoId:this.id,duration})
|
||||
},
|
||||
handle(){
|
||||
this.getDuration(2)
|
||||
Dialog.alert({
|
||||
message:this.detailInfo.contactNumber ,
|
||||
confirmButtonText:'拨打电话',
|
||||
showCancelButton:true,
|
||||
}).then(() => {
|
||||
this.recordType=2
|
||||
this.getDuration()
|
||||
window.location.href = `tel:${this.detailInfo.contactNumber}`;
|
||||
}).catch(() => {
|
||||
// on cancel
|
||||
|
Reference in New Issue
Block a user