import { get, post } from "@js/request";

let timer = 0;
let counter = 0;

export function startTime(scid){
    counter = 0;
    get('/kjy/mp/content/read', {
        scid: scid
    }).then(res => {
        if (res.success) {
            let visitId = res.data.visitId;
            timer = setInterval(() => {
                get('/kjy/mp/content/updateDuration', {visitId: visitId});
                if(counter++ > 360){
                    counter = 0;
                    clearInterval(timer);
                }
            }, 5000);
        }
    })
}

export function endTime(){
    clearInterval(timer);
}

export default {
    startTime,
    endTime
}