增加页面统计代码

This commit is contained in:
lcc
2025-08-01 17:20:09 +08:00
parent 2773275257
commit 09ec673ab1
4 changed files with 74 additions and 17 deletions
+39 -9
View File
@@ -1,15 +1,45 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<head>
<meta charset="UTF-8"/>
<!-- 移动端适配:禁止缩放并固定初始比例 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=yes" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
<meta name="format-detection" content="telephone=yes"/>
<title>好车补</title>
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
<script>
(function (w, d, s, q, i) {
w[q] = w[q] || [];
var f = d.getElementsByTagName(s)[0], j = d.createElement(s);
j.async = true;
j.id = 'beacon-aplus';
j.src = 'https://d.alicdn.com/alilog/mlog/aplus/' + i + '.js';
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'aplus_queue', '203467608');
//集成应用的appKey
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['appKey', '688c73a86c255c7728144a87']
});
/* 如果使用的是单页面应用,例如:React、Vue、Angular等,则需要添加下面的代码 */
/* 关闭自动PV发送,如果不是单页面应用,请删掉下方代码 */
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['aplus-waiting', 'MAN']
});
//是否开启调试模式
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['DEBUG', true]
});
</script>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
+11 -8
View File
@@ -1,6 +1,7 @@
<script setup>
// 路由转发页面无需额外组件引入
import api from './utils/api.js';
import { onMounted } from 'vue'
// 获取当前URL参数
const urlParams = new URLSearchParams(window.location.search);
@@ -24,14 +25,16 @@ try {
} catch (error) {
console.error('授权初始化异常:', error);
}
//统计代码
var _czc = _czc || [];
(function () {
var um = document.createElement("script");
um.src = "https://s4.cnzz.com/z.js?id=1281428623&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
onMounted(() => {
// 首屏加载时发送一次PV
if (window.aplus_queue && Array.isArray(window.aplus_queue)) {
window.aplus_queue.push({
action: 'aplus.sendPV',
arguments: [{ is_auto: false }]
})
}
})
</script>
<template>
+12
View File
@@ -530,6 +530,18 @@ const getCityBrands = async () => {
}
}
//统计代码
// const test = () => {
// const {aplus_queue} = window;
// aplus_queue.push({
// action: 'aplus.record',
// arguments: ['event_id_0', 'CLK', {
// param1: '111',
// param2: '222',
// param3: 333
// }]
// });
// }
</script>
<style lang="scss" scoped>
+12
View File
@@ -22,4 +22,16 @@ const routes = [
]
const router = createRouter({ history: createWebHistory(), routes })
// 路由跳转后发送PV统计
router.afterEach(() => {
// 检查全局的aplus_queue是否存在
if (window.aplus_queue && Array.isArray(window.aplus_queue)) {
// 使用提供的PV发送事件,按要求传递参数
window.aplus_queue.push({
action: 'aplus.sendPV',
arguments: [{ is_auto: false }] // 按文档要求传递固定格式参数
})
}
})
export default router