feat: card log

This commit is contained in:
zzc
2026-02-12 11:18:53 +08:00
parent b6d4a8074e
commit 54e8581b81
6 changed files with 45 additions and 8 deletions

View File

@@ -73,3 +73,11 @@ export const getTipsList = async () => {
method: "get", method: "get",
}); });
}; };
export const createTracking = async (data) => {
return request({
url: "/api/common/tracking/create",
method: "POST",
data,
});
};

View File

@@ -218,6 +218,7 @@ import {
uploadImage, uploadImage,
saveViewRequest, saveViewRequest,
} from "@/utils/common.js"; } from "@/utils/common.js";
import { trackRecord } from "@/utils/common.js";
import NavBar from "@/components/NavBar/NavBar.vue"; import NavBar from "@/components/NavBar/NavBar.vue";
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue"; import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
@@ -488,6 +489,7 @@ const handleLogind = async () => {
}; };
const onChooseAlbum = () => { const onChooseAlbum = () => {
trackRecord({ eventName: "avatar_choose_album", eventType: "click" });
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ["original", "compressed"], sizeType: ["original", "compressed"],

View File

@@ -31,7 +31,7 @@
@tap.stop="openBgmList" @tap.stop="openBgmList"
:class="{ playing: isBgmPlaying }" :class="{ playing: isBgmPlaying }"
> >
<uni-icons type="headphones" size="20" color="#fff"></uni-icons> <text class="music-icon">{{ isBgmPlaying ? "🎵" : "🔇" }}</text>
</view> </view>
<view class="premium-tag"> <view class="premium-tag">
<uni-icons type="info" size="12" color="#fff"></uni-icons> <uni-icons type="info" size="12" color="#fff"></uni-icons>
@@ -513,7 +513,7 @@ import {
} from "@dcloudio/uni-app"; } from "@dcloudio/uni-app";
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue"; 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 userStore = useUserStore();
const loginPopupRef = ref(null); const loginPopupRef = ref(null);
@@ -1205,6 +1205,11 @@ onShareTimeline(async () => {
}); });
const selectGreeting = (text) => { const selectGreeting = (text) => {
trackRecord({
eventName: "card_text_choose",
eventType: "click",
elementId: text?.id,
});
blessingText.value = text; blessingText.value = text;
}; };
@@ -1231,11 +1236,21 @@ const templates = ref([]);
const currentTemplate = ref(templates.value[0]); const currentTemplate = ref(templates.value[0]);
const applyTemplate = (tpl) => { const applyTemplate = (tpl) => {
trackRecord({
eventName: "card_tpl_choose",
eventType: "click",
elementId: tpl?.id,
});
currentTemplate.value = tpl; currentTemplate.value = tpl;
closePanel(); closePanel();
}; };
const selectTitle = (title) => { const selectTitle = (title) => {
trackRecord({
eventName: "card_title_choose",
eventType: "click",
elementId: title?.id,
});
if (currentTitle.value?.id === title?.id) { if (currentTitle.value?.id === title?.id) {
currentTitle.value = null; currentTitle.value = null;
} else { } else {

View File

@@ -159,7 +159,7 @@ const userInfo = computed(() => ({
const isLoggedIn = computed(() => !!userStore.userInfo.nickName); const isLoggedIn = computed(() => !!userStore.userInfo.nickName);
const isIos = false; const isIos = computed(() => uni.getSystemInfoSync().osName === "ios");
onMounted(() => { onMounted(() => {
const sysInfo = uni.getSystemInfoSync(); const sysInfo = uni.getSystemInfoSync();

View File

@@ -1,5 +1,10 @@
import { getDeviceInfo } from "@/utils/system"; import { getDeviceInfo } from "@/utils/system";
import { saveRecord, viewRecord, createShareToken } from "@/api/system"; import {
saveRecord,
viewRecord,
createShareToken,
createTracking,
} from "@/api/system";
export const generateObjectId = ( export const generateObjectId = (
m = Math, m = Math,
@@ -101,3 +106,10 @@ export const getShareToken = async (scene, targetId = "") => {
}); });
return shareTokenRes?.shareToken || ""; return shareTokenRes?.shareToken || "";
}; };
export const trackRecord = (event) => {
createTracking({
...event,
page: getCurrentPages().pop()?.route,
});
};

View File

@@ -39,6 +39,10 @@ export const getLeftIconLeft = () => {
// #endif // #endif
}; };
export function getPlatform() {
return getPlatformProvider().replace("mp-", "");
}
export function getPlatformProvider() { export function getPlatformProvider() {
const platform = process.env.UNI_PLATFORM; const platform = process.env.UNI_PLATFORM;
return platform || "mp-weixin"; return platform || "mp-weixin";
@@ -55,10 +59,6 @@ export function getPlatformProvider() {
// return typeof tt !== 'undefined' ? 'toutiao' : 'weixin'; // return typeof tt !== 'undefined' ? 'toutiao' : 'weixin';
} }
export function getPlatform() {
return getPlatformProvider().replace("mp-", "");
}
export function getDeviceInfo() { export function getDeviceInfo() {
const info = uni.getSystemInfoSync(); const info = uni.getSystemInfoSync();
return { return {