提交 e6f9ecf0 编写于 作者: M mehaotian

fix(stat) : 修复 uni 统计首次开启统计,24 小时生效的问题。

上级 1129a55c
......@@ -306,27 +306,46 @@ const isReportData = () => {
let start_time = '';
let end_time = new Date().getTime();
let diff_time = DIFF_TIME;
let report_status = 1;
try {
start_time = uni.getStorageSync(Report_Data_Time);
report_status = uni.getStorageSync(Report_Status);
} catch (e) {
start_time = '';
report_status = 1;
}
if (report_status === '') {
requestData(({
enable
}) => {
uni.setStorageSync(Report_Data_Time, end_time);
uni.setStorageSync(Report_Status, enable);
if (enable === 1) {
resolve();
}
});
return
}
if (report_status === 1) {
resolve();
}
if (!start_time) {
uni.setStorageSync(Report_Data_Time, end_time);
start_time = end_time;
}
if ((end_time - start_time) > diff_time) {
requestData(({
enable
}) => {
uni.setStorageSync(Report_Data_Time, end_time);
uni.setStorageSync(Report_Status, enable);
if (enable === 1) {
resolve();
}
});
}
})
};
......@@ -358,6 +377,9 @@ const requestData = (done) => {
} catch (e) {
report_status_code = 1;
}
if (report_status_code === '') {
report_status_code = 1;
}
if (report_status_code === 1) {
typeof done === 'function' && done({
enable: res.enable
......
......@@ -2,7 +2,7 @@ import {
PAGE_PVER_TIME,
APP_PVER_TIME,
STAT_URL,
STAT_VERSION,
STAT_VERSION,
DIFF_TIME
} from './config';
const statConfig = require('uni-stat-config').default || require('uni-stat-config');
......@@ -306,27 +306,46 @@ export const isReportData = () => {
let start_time = ''
let end_time = new Date().getTime()
let diff_time = DIFF_TIME
let report_status = 1
try {
start_time = uni.getStorageSync(Report_Data_Time)
report_status = uni.getStorageSync(Report_Status)
} catch (e) {
start_time = ''
report_status = 1
}
if (report_status === '') {
requestData(({
enable
}) => {
uni.setStorageSync(Report_Data_Time, end_time);
uni.setStorageSync(Report_Status, enable);
if (enable === 1) {
resolve();
}
});
return
}
if (report_status === 1) {
resolve();
}
if (!start_time) {
uni.setStorageSync(Report_Data_Time, end_time)
start_time = end_time
}
if ((end_time - start_time) > diff_time) {
requestData(({
enable
}) => {
uni.setStorageSync(Report_Data_Time, end_time)
uni.setStorageSync(Report_Status, enable)
if (enable === 1) {
resolve();
}
});
}
})
}
......@@ -358,6 +377,9 @@ const requestData = (done) => {
} catch (e) {
report_status_code = 1
}
if (report_status_code === '') {
report_status_code = 1
}
if (report_status_code === 1) {
typeof done === 'function' && done({
enable: res.enable
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册