Skip to content

Commit

Permalink
init: profileSetOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
co2color committed Nov 28, 2022
1 parent 9da5951 commit 794408c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/turbo.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion minigame-demo/js/utils/turbo.min.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
logger,
extend2Lev,
isObject,
dateFormate,
setQuery,
} from "./utils/tools";
import { eventProperty } from "./lib/eventProperty";
Expand Down Expand Up @@ -91,12 +92,12 @@ turbo._store = {
if (!info) {
turbo._is_first_launch = true;
wx.setStorageSync(turbo._para.storage_store_key, true);
const commonProps = eventProperty.getProperties();
turbo.profileSetOnce({
$first_visit_time: new Date()
.toLocaleString("cn", {
hour12: false,
})
.replaceAll("/", "-"),
$first_visit_time: dateFormate(new Date(), true),
$os: commonProps.$os,
$brand: commonProps.$brand,
$model: commonProps.$model,
});
}
},
Expand Down
22 changes: 22 additions & 0 deletions src/utils/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,25 @@ export function getCurrentPage() {

return obj;
}

export function dateFormate(dateTime, timeflag) {
const date = new Date(Date.parse(dateTime));
const y = date.getFullYear();
let m = date.getMonth() + 1;
m = m < 10 ? `0${m}` : m;
let d = date.getDate();
d = d < 10 ? `0${d}` : d;
let h = date.getHours();
h = h < 10 ? `0${h}` : h;
let minute = date.getMinutes();
minute = minute < 10 ? `0${minute}` : minute;
let seconds = date.getSeconds();
seconds = seconds < 10 ? `0${seconds}` : seconds;
let result = "";
if (timeflag) {
result = `${y}-${m}-${d} ${h}:${minute}:${seconds}`;
} else {
result = `${y}-${m}-${d}`;
}
return result;
}

0 comments on commit 794408c

Please sign in to comment.