Commit 5bec8fd5 authored by 李增强's avatar 李增强

m

parent 61a3e5b9
......@@ -10,26 +10,16 @@ class QMTJ {
static DB _db;
static String _appStartUpId;
static bool isDebug = false;
static void debug() {
isDebug = true;
}
static void init() async {
_appStartUpId = _md5(_getDateNow().toString());
_db = new DB();
await _db.init();
var app_tj = await _db.db.query("app_tj");
print('=============================================================app_tj');
print(app_tj);
print('=============================================================app_tj');
var page_tj = await _db.db.query("page_tj");
print('=============================================================page_tj');
print(page_tj);
print('=============================================================page_tj');
var a = await _db.db.query("tap_tj");
print('=============================================================tap_tj');
print(a);
print('=============================================================tap_tj');
var exposure = await _db.db.query("exposure_tj");
print('=============================================================exposure');
print(exposure);
print('=============================================================exposure');
}
/// APP 启动
......@@ -38,14 +28,16 @@ class QMTJ {
int disappearTime = 0;
int appearTime = _getDateNow();
String id = _appStartUpId;
await _db.db.insert("app_tj", {
Map<String, dynamic> map = {
"id": id,
"type": type,
"source": source,
"disappear_time": disappearTime,
"appear_time": appearTime,
"extras": json.encode(extras),
});
};
log("appStart", map);
await _db.db.insert("app_tj", map);
}
/// APP 可见
......@@ -57,20 +49,28 @@ class QMTJ {
int disappearTime = 0;
int appearTime = _getDateNow();
String id = _appStartUpId;
await _db.db.insert("app_tj", {
Map<String, dynamic> map = {
"id": id,
"type": type,
"source": source,
"disappear_time": disappearTime,
"appear_time": appearTime,
"extras": json.encode(extras),
});
};
log("appAppear", map);
await _db.db.insert("app_tj", map);
}
/// APP 不可见
static void appDisappear() {
_db.db.update("app_tj", {"disappear_time": _getDateNow()},
int disappearTime = _getDateNow();
_db.db.update("app_tj", {"disappear_time": disappearTime},
where: "id = ? and disappear_time = 0", whereArgs: [_appStartUpId]);
Map<String, dynamic> map = {
"id": _appStartUpId,
"disappear_time": disappearTime,
};
log("appDisappear", map);
}
/// PAGE 可见
......@@ -83,7 +83,7 @@ class QMTJ {
String id = _md5("${pageId}_${lastPageId}_$extrasStr");
int disappearTime = 0;
int appearTime = _getDateNow();
await _db.db.insert("page_tj", {
Map<String, dynamic> map = {
"id": id,
"source": source,
"page_id": pageId,
......@@ -91,7 +91,9 @@ class QMTJ {
"appear_time": appearTime,
"disappear_time": disappearTime,
"extras": extrasStr,
});
};
log("pageAppear", map);
await _db.db.insert("page_tj", map);
}
/// PAGE 不可见
......@@ -99,13 +101,22 @@ class QMTJ {
{String pageId, String lastPageId, Map<String, dynamic> extras}) async {
String extrasStr = json.encode(extras);
String id = _md5("${pageId}_${lastPageId}_$extrasStr");
int disappearTime = _getDateNow();
await _db.db.update(
"page_tj",
{
"disappear_time": _getDateNow(),
"disappear_time": disappearTime,
},
where: "id = ? and disappear_time = 0",
whereArgs: [id]);
Map<String, dynamic> map = {
"id": id,
"page_id": pageId,
"last_page_id": lastPageId,
"disappear_time": disappearTime,
"extras": extrasStr,
};
log("pageDisappear", map);
}
/// 点击
......@@ -120,14 +131,16 @@ class QMTJ {
int clickTime = _getDateNow();
String extrasStr = json.encode(extras);
String id = _md5("${pageId}_${clickId}_${extrasStr}_${clickTime}");
await _db.db.insert("tap_tj", {
Map<String, dynamic> map = {
"id": id,
"source": source,
"page_id": pageId,
"click_id": clickId,
"click_time": clickTime,
"extras": extrasStr,
});
};
log("tap", map);
await _db.db.insert("tap_tj", map);
}
/// 曝光
......@@ -142,14 +155,16 @@ class QMTJ {
int exposureTime = _getDateNow();
String extrasStr = json.encode(extras);
String id = _md5("${pageId}_${exposureId}_${extrasStr}_${exposureTime}");
await _db.db.insert("exposure_tj", {
Map<String, dynamic> map = {
"id": id,
"source": source,
"page_id": pageId,
"exposure_id": exposureId,
"exposure_time": exposureTime,
"extras": extrasStr,
});
};
log("exposure", map);
await _db.db.insert("exposure_tj", map);
}
/// 获取当前时间戳,单位:秒
......@@ -164,4 +179,13 @@ class QMTJ {
var digest = crypto.md5.convert(bytes);
return digest.toString();
}
static void log(String type, Map<String, dynamic> map) {
if (!isDebug) {
return;
}
print("$type=======================s===========================$type");
print(map);
print("$type=======================e===========================$type");
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment