From 54e8581b819a2d3feaabc3b32edefb0ad9b7cacd Mon Sep 17 00:00:00 2001 From: zzc <1761997216@qq.com> Date: Thu, 12 Feb 2026 11:18:53 +0800 Subject: [PATCH] feat: card log --- api/system.js | 8 ++++++++ pages/avatar/index.vue | 2 ++ pages/make/index.vue | 19 +++++++++++++++++-- pages/mine/mine.vue | 2 +- utils/common.js | 14 +++++++++++++- utils/system.js | 8 ++++---- 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/api/system.js b/api/system.js index 261346e..4f0a5ea 100644 --- a/api/system.js +++ b/api/system.js @@ -73,3 +73,11 @@ export const getTipsList = async () => { method: "get", }); }; + +export const createTracking = async (data) => { + return request({ + url: "/api/common/tracking/create", + method: "POST", + data, + }); +}; diff --git a/pages/avatar/index.vue b/pages/avatar/index.vue index 7d3c30a..2299558 100644 --- a/pages/avatar/index.vue +++ b/pages/avatar/index.vue @@ -218,6 +218,7 @@ import { uploadImage, saveViewRequest, } from "@/utils/common.js"; +import { trackRecord } from "@/utils/common.js"; import NavBar from "@/components/NavBar/NavBar.vue"; import LoginPopup from "@/components/LoginPopup/LoginPopup.vue"; @@ -488,6 +489,7 @@ const handleLogind = async () => { }; const onChooseAlbum = () => { + trackRecord({ eventName: "avatar_choose_album", eventType: "click" }); uni.chooseImage({ count: 1, sizeType: ["original", "compressed"], diff --git a/pages/make/index.vue b/pages/make/index.vue index c25fb58..37d3b14 100644 --- a/pages/make/index.vue +++ b/pages/make/index.vue @@ -31,7 +31,7 @@ @tap.stop="openBgmList" :class="{ playing: isBgmPlaying }" > - + {{ isBgmPlaying ? "🎵" : "🔇" }} @@ -513,7 +513,7 @@ import { } from "@dcloudio/uni-app"; import { useUserStore } from "@/stores/user"; import LoginPopup from "@/components/LoginPopup/LoginPopup.vue"; -import { saveRecordRequest, uploadImage } from "@/utils/common.js"; +import { saveRecordRequest, uploadImage, trackRecord } from "@/utils/common.js"; const userStore = useUserStore(); const loginPopupRef = ref(null); @@ -1205,6 +1205,11 @@ onShareTimeline(async () => { }); const selectGreeting = (text) => { + trackRecord({ + eventName: "card_text_choose", + eventType: "click", + elementId: text?.id, + }); blessingText.value = text; }; @@ -1231,11 +1236,21 @@ const templates = ref([]); const currentTemplate = ref(templates.value[0]); const applyTemplate = (tpl) => { + trackRecord({ + eventName: "card_tpl_choose", + eventType: "click", + elementId: tpl?.id, + }); currentTemplate.value = tpl; closePanel(); }; const selectTitle = (title) => { + trackRecord({ + eventName: "card_title_choose", + eventType: "click", + elementId: title?.id, + }); if (currentTitle.value?.id === title?.id) { currentTitle.value = null; } else { diff --git a/pages/mine/mine.vue b/pages/mine/mine.vue index db42fa2..807b0d5 100644 --- a/pages/mine/mine.vue +++ b/pages/mine/mine.vue @@ -159,7 +159,7 @@ const userInfo = computed(() => ({ const isLoggedIn = computed(() => !!userStore.userInfo.nickName); -const isIos = false; +const isIos = computed(() => uni.getSystemInfoSync().osName === "ios"); onMounted(() => { const sysInfo = uni.getSystemInfoSync(); diff --git a/utils/common.js b/utils/common.js index 6dcdb88..27adfc8 100644 --- a/utils/common.js +++ b/utils/common.js @@ -1,5 +1,10 @@ import { getDeviceInfo } from "@/utils/system"; -import { saveRecord, viewRecord, createShareToken } from "@/api/system"; +import { + saveRecord, + viewRecord, + createShareToken, + createTracking, +} from "@/api/system"; export const generateObjectId = ( m = Math, @@ -101,3 +106,10 @@ export const getShareToken = async (scene, targetId = "") => { }); return shareTokenRes?.shareToken || ""; }; + +export const trackRecord = (event) => { + createTracking({ + ...event, + page: getCurrentPages().pop()?.route, + }); +}; diff --git a/utils/system.js b/utils/system.js index c9b9388..cb471d7 100644 --- a/utils/system.js +++ b/utils/system.js @@ -39,6 +39,10 @@ export const getLeftIconLeft = () => { // #endif }; +export function getPlatform() { + return getPlatformProvider().replace("mp-", ""); +} + export function getPlatformProvider() { const platform = process.env.UNI_PLATFORM; return platform || "mp-weixin"; @@ -55,10 +59,6 @@ export function getPlatformProvider() { // return typeof tt !== 'undefined' ? 'toutiao' : 'weixin'; } -export function getPlatform() { - return getPlatformProvider().replace("mp-", ""); -} - export function getDeviceInfo() { const info = uni.getSystemInfoSync(); return {