二手车交易,记录浏览量
This commit is contained in:
@ -106,7 +106,6 @@ export default {
|
|||||||
mixins:[myMixins],
|
mixins:[myMixins],
|
||||||
data(){
|
data(){
|
||||||
return{
|
return{
|
||||||
show:false,
|
|
||||||
current: 0,
|
current: 0,
|
||||||
noClick:true,
|
noClick:true,
|
||||||
id:'',
|
id:'',
|
||||||
@ -144,14 +143,15 @@ export default {
|
|||||||
document.addEventListener('visibilitychange', async ( ) => {
|
document.addEventListener('visibilitychange', async ( ) => {
|
||||||
let state = document.visibilityState
|
let state = document.visibilityState
|
||||||
if (state == 'hidden') { // 用户离开了
|
if (state == 'hidden') { // 用户离开了
|
||||||
console.log("用户离开了")
|
console.log("用户离开了1")
|
||||||
await this.getDuration()
|
await this.getDuration(1);
|
||||||
|
console.log("用户离开了2")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
destroyed() {
|
/* destroyed() {
|
||||||
this.getDuration()
|
this.getDuration(1)
|
||||||
},
|
},*/
|
||||||
methods:{
|
methods:{
|
||||||
formatToWan(num) {
|
formatToWan(num) {
|
||||||
let result = (num / 10000).toString();
|
let result = (num / 10000).toString();
|
||||||
@ -163,25 +163,23 @@ export default {
|
|||||||
}
|
}
|
||||||
return result + '万';
|
return result + '万';
|
||||||
},
|
},
|
||||||
getDuration(){
|
getDuration(type){
|
||||||
// 页面卸载时记录离开时间并计算浏览时长
|
// 页面卸载时记录离开时间并计算浏览时长
|
||||||
const endTime = new Date();
|
const endTime = new Date();
|
||||||
const duration = (endTime - this.startTime) / 1000; // 计算时长(秒)\
|
const duration = (endTime - this.startTime) / 1000; // 计算时长(秒)\
|
||||||
this.saveRecord(duration);
|
this.saveRecord(duration,type);
|
||||||
},
|
},
|
||||||
async saveRecord(duration){
|
async saveRecord(duration,type){
|
||||||
await saveRecord({type: this.recordType, carInfoId: this.id, duration})
|
await saveRecord({type: type, carInfoId: this.id, duration})
|
||||||
},
|
},
|
||||||
handle(){
|
handle(){
|
||||||
this.show=true
|
this.getDuration(2)
|
||||||
Dialog.alert({
|
Dialog.alert({
|
||||||
message:this.detailInfo.contactNumber ,
|
message:this.detailInfo.contactNumber ,
|
||||||
confirmButtonText:'拨打电话',
|
confirmButtonText:'拨打电话',
|
||||||
showCancelButton:true,
|
showCancelButton:true,
|
||||||
}).then(async() => {
|
}).then(async() => {
|
||||||
this.recordType=2
|
|
||||||
window.location.href = `tel:${this.detailInfo.contactNumber}`;
|
window.location.href = `tel:${this.detailInfo.contactNumber}`;
|
||||||
await this.getDuration()
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// on cancel
|
// on cancel
|
||||||
});
|
});
|
||||||
|
@ -67,7 +67,6 @@ export default {
|
|||||||
detailInfo:'',
|
detailInfo:'',
|
||||||
duration:'',
|
duration:'',
|
||||||
startTime: null, // 记录进入时间
|
startTime: null, // 记录进入时间
|
||||||
recordType:1,
|
|
||||||
isList:false,
|
isList:false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -88,31 +87,31 @@ export default {
|
|||||||
document.addEventListener('visibilitychange', async ( ) => {
|
document.addEventListener('visibilitychange', async ( ) => {
|
||||||
let state = document.visibilityState
|
let state = document.visibilityState
|
||||||
if (state == 'hidden') { // 用户离开了
|
if (state == 'hidden') { // 用户离开了
|
||||||
console.log("用户离开了")
|
console.log("用户离开了1")
|
||||||
await this.getDuration()
|
await this.getDuration(1);
|
||||||
|
console.log("用户离开了2")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
destroyed() {
|
/*destroyed() {
|
||||||
this.getDuration()
|
this.getDuration(1)
|
||||||
},
|
},*/
|
||||||
methods:{
|
methods:{
|
||||||
getDuration(){
|
getDuration(type){
|
||||||
const endTime = new Date();
|
const endTime = new Date();
|
||||||
const duration = (endTime - this.startTime) / 1000; // 计算时长(秒)
|
const duration = (endTime - this.startTime) / 1000; // 计算时长(秒)
|
||||||
this.saveRecord(duration);
|
this.saveRecord(duration,type);
|
||||||
},
|
},
|
||||||
async saveRecord(duration){
|
async saveRecord(duration,type){
|
||||||
await saveRecord({type:this.recordType,carInfoId:this.id,duration})
|
await saveRecord({type:type,carInfoId:this.id,duration})
|
||||||
},
|
},
|
||||||
handle(){
|
handle(){
|
||||||
|
this.getDuration(2)
|
||||||
Dialog.alert({
|
Dialog.alert({
|
||||||
message:this.detailInfo.contactNumber ,
|
message:this.detailInfo.contactNumber ,
|
||||||
confirmButtonText:'拨打电话',
|
confirmButtonText:'拨打电话',
|
||||||
showCancelButton:true,
|
showCancelButton:true,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.recordType=2
|
|
||||||
this.getDuration()
|
|
||||||
window.location.href = `tel:${this.detailInfo.contactNumber}`;
|
window.location.href = `tel:${this.detailInfo.contactNumber}`;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// on cancel
|
// on cancel
|
||||||
|
Reference in New Issue
Block a user