Commit 9457fb8c authored by weishengfei's avatar weishengfei

feat(analytics): 添加小程序页面埋点统计

- 在各个页面添加了浏览事件和点击事件的埋点统计
- 包括新增产检、修改产检、我的报告单、产检提醒首页等页面
- 埋点数据包括页面名称、按钮名称等信息
- 优化了用户体验,为后续数据分析提供支持
parent 64c9a29c
...@@ -146,6 +146,7 @@ import { ...@@ -146,6 +146,7 @@ import {
// 导入日期选择器组件 // 导入日期选择器组件
import DatePicker from '@/components/DatePicker.vue' import DatePicker from '@/components/DatePicker.vue'
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import md from '../../md';
// 获取用户信息 // 获取用户信息
const userStore = useUserStore(); const userStore = useUserStore();
...@@ -190,6 +191,11 @@ const onPopupClose2 = () => { ...@@ -190,6 +191,11 @@ const onPopupClose2 = () => {
} }
// 修改时间 // 修改时间
const onChangeTime = () => { const onChangeTime = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "新增产检页",
buttonName: "产检时间选择",
});
visible.value = true; visible.value = true;
} }
// 选择日期回调确认 // 选择日期回调确认
...@@ -200,6 +206,11 @@ const handleDateConfirm = (date) => { ...@@ -200,6 +206,11 @@ const handleDateConfirm = (date) => {
} }
// 添加项目 // 添加项目
const onAdd = () => { const onAdd = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "新增产检页",
buttonName: "产检项目添加",
});
wx.setPageStyle({ wx.setPageStyle({
style: { style: {
overflow: 'hidden' overflow: 'hidden'
...@@ -259,6 +270,12 @@ const saveSelection = () => { ...@@ -259,6 +270,12 @@ const saveSelection = () => {
// }; // };
// 删除所选产品项目 // 删除所选产品项目
const onDelete = (id) => { const onDelete = (id) => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "新增产检页",
buttonName: "删除产检项目",
});
listData.value.filter((item, index) => { listData.value.filter((item, index) => {
if (item.id == id) { if (item.id == id) {
listData.value.splice(index, 1) listData.value.splice(index, 1)
...@@ -283,6 +300,12 @@ const onImageDel = (e) => { ...@@ -283,6 +300,12 @@ const onImageDel = (e) => {
} }
// 上传图片 // 上传图片
const onUpload = throttleTap(() => { const onUpload = throttleTap(() => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "新增产检页",
buttonName: "上传报告单",
});
if (bgdImgList.value.length == 15) { if (bgdImgList.value.length == 15) {
uni.showToast({ uni.showToast({
title: "最多上传15张图片", title: "最多上传15张图片",
...@@ -322,6 +345,11 @@ const onUpload = throttleTap(() => { ...@@ -322,6 +345,11 @@ const onUpload = throttleTap(() => {
// 保存 // 保存
const onSave = throttleTap( async () => { const onSave = throttleTap( async () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "新增产检页",
buttonName: "保存",
});
if (listData.value.length == 0) { if (listData.value.length == 0) {
uni.showToast({ uni.showToast({
title: '还没有添加产检项哦', title: '还没有添加产检项哦',
...@@ -363,6 +391,12 @@ const onSave = throttleTap( async () => { ...@@ -363,6 +391,12 @@ const onSave = throttleTap( async () => {
// 查看更多 // 查看更多
const onSeeBtn = () => { const onSeeBtn = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "新增产检页",
buttonName: "查看全部",
});
// 跳转 // 跳转
uni.navigateTo({ uni.navigateTo({
url: '/pages/myReportCard/myReportCard' url: '/pages/myReportCard/myReportCard'
...@@ -378,6 +412,10 @@ const getList = async () => { ...@@ -378,6 +412,10 @@ const getList = async () => {
} }
} }
onLoad((options) => { onLoad((options) => {
md.sensorLogTake({
xcxPage: "小程序页面浏览事件",
pageName: "新增产检页"
});
if (Object.keys(options).length > 0 && options.time) { if (Object.keys(options).length > 0 && options.time) {
time.value = options.time time.value = options.time
} else { } else {
......
...@@ -93,6 +93,7 @@ import { ...@@ -93,6 +93,7 @@ import {
hideLoading hideLoading
} from '@/utils/index.js'; } from '@/utils/index.js';
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import md from '../../md';
import { import {
getUpdate, getUpdate,
...@@ -133,6 +134,12 @@ const onPopupClose2 = () => { ...@@ -133,6 +134,12 @@ const onPopupClose2 = () => {
// 添加项目 // 添加项目
const onAdd = () => { const onAdd = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "修改产检项目页",
buttonName: "添加产检项目",
});
wx.setPageStyle({ wx.setPageStyle({
style: { style: {
overflow: 'hidden' overflow: 'hidden'
...@@ -192,6 +199,12 @@ const saveSelection = () => { ...@@ -192,6 +199,12 @@ const saveSelection = () => {
// }; // };
// 删除所选产品项目 // 删除所选产品项目
const onDelete = (id) => { const onDelete = (id) => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "修改产检项目页",
buttonName: "删除产检项目",
});
listData.value.filter((item, index) => { listData.value.filter((item, index) => {
if (item.id == id) { if (item.id == id) {
listData.value.splice(index, 1) listData.value.splice(index, 1)
...@@ -202,6 +215,12 @@ const onDelete = (id) => { ...@@ -202,6 +215,12 @@ const onDelete = (id) => {
// 保存 // 保存
const onSave = throttleTap(async () => { const onSave = throttleTap(async () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "修改产检项目页",
buttonName: "保存",
});
if (listData.value.length == 0) { if (listData.value.length == 0) {
uni.showToast({ uni.showToast({
title: '还没有添加产检项哦', title: '还没有添加产检项哦',
...@@ -249,6 +268,10 @@ const getList = async () => { ...@@ -249,6 +268,10 @@ const getList = async () => {
} }
} }
onLoad((options) => { onLoad((options) => {
md.sensorLogTake({
xcxPage: "小程序页面浏览事件",
pageName: "修改产检项目页"
});
const { id, examinationItems } = JSON.parse(options.item) const { id, examinationItems } = JSON.parse(options.item)
console.log(id, examinationItems) console.log(id, examinationItems)
editId.value = id editId.value = id
......
...@@ -118,6 +118,11 @@ const listData = ref([]) ...@@ -118,6 +118,11 @@ const listData = ref([])
// 跳转小程序 // 跳转小程序
const onJump = async () => { const onJump = async () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "我的报告单页",
buttonName: '专家在线咨询'
});
const res = await getHealthField(); const res = await getHealthField();
if (!res.success) { if (!res.success) {
...@@ -172,6 +177,11 @@ const getProject = (projects) => { ...@@ -172,6 +177,11 @@ const getProject = (projects) => {
// 删除事件 // 删除事件
const onDelete = throttleTap((id) => { const onDelete = throttleTap((id) => {
console.log(id) console.log(id)
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "我的报告单页",
buttonName: '删除'
});
uni.showModal({ uni.showModal({
// title: '提示', // title: '提示',
content: '确认删除吗?', content: '确认删除吗?',
...@@ -187,6 +197,11 @@ const onDelete = throttleTap((id) => { ...@@ -187,6 +197,11 @@ const onDelete = throttleTap((id) => {
}) })
// 返回上一页面 // 返回上一页面
const backHandler = () => { const backHandler = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "我的报告单页",
buttonName: '返回'
});
uni.navigateBack(); uni.navigateBack();
} }
// 删除报告单 // 删除报告单
...@@ -221,6 +236,10 @@ const getReportListFn = async () => { ...@@ -221,6 +236,10 @@ const getReportListFn = async () => {
} }
onLoad(() => { onLoad(() => {
md.sensorLogTake({
xcxPage: "小程序页面浏览事件",
pageName: "我的报告单页"
});
// 我的报告单 // 我的报告单
getReportListFn() getReportListFn()
}) })
......
...@@ -257,6 +257,26 @@ const backHandler = () => { ...@@ -257,6 +257,26 @@ const backHandler = () => {
// 点击轮播图事件 // 点击轮播图事件
const handleBannerClick = (item, index) => { const handleBannerClick = (item, index) => {
console.log(item) console.log(item)
let buttonName = '';
switch(index){
case 0:
buttonName = '第一张焦点图';
break;
case 1:
buttonName = '第二张焦点图';
break;
case 2:
buttonName = '第三张焦点图';
break;
case 3:
buttonName = '第四张焦点图';
break;
}
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检提醒首页",
buttonName: buttonName,
});
// 跳转 // 跳转
if (item?.url != "") { if (item?.url != "") {
jump({ jump({
...@@ -265,26 +285,15 @@ const handleBannerClick = (item, index) => { ...@@ -265,26 +285,15 @@ const handleBannerClick = (item, index) => {
}) })
} }
// let buttonName = '';
// switch(index){
// case 0:
// buttonName = '第一张焦点图';
// break;
// case 1:
// buttonName = '第二张焦点图';
// break;
// case 2:
// buttonName = '第三张焦点图';
// break;
// }
// md.sensorLogTake({
// xcxClick: "产品提醒页-首屏页面点击",
// pageName: "产品提醒页-首屏",
// buttonName: buttonName,
// });
} }
// 新增体检 // 新增体检
const onAdd = () => { const onAdd = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检提醒首页",
buttonName: '添加'
});
uni.navigateTo({ uni.navigateTo({
url: '/pages/addPostnatal/addPostnatal' url: '/pages/addPostnatal/addPostnatal'
}) })
...@@ -293,24 +302,36 @@ const onAdd = () => { ...@@ -293,24 +302,36 @@ const onAdd = () => {
const onBtn = (type) => { const onBtn = (type) => {
// const items = JSON.stringify(homeInfo.value) // const items = JSON.stringify(homeInfo.value)
// type 0 提醒 1 报告单 2 日历 // type 0 提醒 1 报告单 2 日历
let buttonName = ''
switch (type) { switch (type) {
case 0: case 0:
// 如果授权就不弹出提醒 // 如果授权就不弹出提醒
showPicker.value = isWxNotification.value ? true : false showPicker.value = isWxNotification.value ? true : false
buttonName = '提醒'
break; break;
case 1: case 1:
uni.navigateTo({ uni.navigateTo({
url: '/pages/myReportCard/myReportCard' url: '/pages/myReportCard/myReportCard'
}) })
buttonName = '报告单'
break; break;
case 2: case 2:
uni.navigateTo({ uni.navigateTo({
url: `/pages/productionCalendar/productionCalendar` url: `/pages/productionCalendar/productionCalendar`
}) })
buttonName = '日历'
break; break;
default: default:
break; break;
} }
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检提醒首页",
buttonName: buttonName,
});
} }
// 提醒关闭 // 提醒关闭
const close = () => { const close = () => {
...@@ -341,6 +362,12 @@ const handleConfirm = () => { ...@@ -341,6 +362,12 @@ const handleConfirm = () => {
// 编辑时间 // 编辑时间
const onEdit = (id, newTime) => { const onEdit = (id, newTime) => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检提醒首页",
buttonName: '选择时间',
});
console.log(id, newTime) console.log(id, newTime)
time.value = newTime time.value = newTime
visible.value = true visible.value = true
...@@ -503,6 +530,13 @@ onShow(async () => { ...@@ -503,6 +530,13 @@ onShow(async () => {
console.log('宝宝信息加载完成:', userStore.babyInfo) console.log('宝宝信息加载完成:', userStore.babyInfo)
publicFn() publicFn()
}) })
onMounted(() => {
md.sensorLogTake({
xcxPage: "小程序页面浏览事件",
pageName: "产检提醒首页"
});
})
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -131,7 +131,8 @@ import { ...@@ -131,7 +131,8 @@ import {
import { import {
getInfo getInfo
} from '../../api/obstetric.js'; } from '../../api/obstetric.js';
import { console } from 'inspector';
import md from '../../md';
// 获取用户信息 // 获取用户信息
const userStore = useUserStore(); const userStore = useUserStore();
const babyInfo =ref(userStore?.babyInfo || {}) const babyInfo =ref(userStore?.babyInfo || {})
...@@ -379,10 +380,20 @@ const calendarDates = computed(() => { ...@@ -379,10 +380,20 @@ const calendarDates = computed(() => {
}) })
// 返回 // 返回
const backHandler = () => { const backHandler = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检日历页",
buttonName: '返回'
});
uni.navigateBack() uni.navigateBack()
} }
// 跳转新增产检页面 // 跳转新增产检页面
const onAdd = () => { const onAdd = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检日历页",
buttonName: '新增产检'
});
uni.navigateTo({ uni.navigateTo({
url: `/pages/addPostnatal/addPostnatal?time=${currentSelectedDate.value}` url: `/pages/addPostnatal/addPostnatal?time=${currentSelectedDate.value}`
}) })
...@@ -423,17 +434,12 @@ const getInfoFn = async () => { ...@@ -423,17 +434,12 @@ const getInfoFn = async () => {
}); });
} }
} }
// onLoad((option) => { onLoad((option) => {
// console.log('option:', option) md.sensorLogTake({
// info.value = JSON.parse(option.item) xcxPage: "小程序页面浏览事件",
// // 使用真实的今天日期 pageName: "产检日历页"
// const today = new Date() });
// const todayString = formatDateString(today) })
// currentSelectedDate.value = todayString
// currentDate.value = new Date(today.getFullYear(), today.getMonth(), 1) // 当前月份的第一天
// currentMonthKey.value = `${today.getFullYear()}-${today.getMonth()}` // 设置月份键
// console.log('初始化今日日期:', todayString, '当前月份:', currentDate.value, '月份键:', currentMonthKey.value)
// })
onShow(() => { onShow(() => {
// 使用真实的今天日期 // 使用真实的今天日期
const today = new Date() const today = new Date()
......
...@@ -170,6 +170,7 @@ import { ...@@ -170,6 +170,7 @@ import {
getDeleteReportImg getDeleteReportImg
} from '../../api/obstetric.js'; } from '../../api/obstetric.js';
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import md from '../../md';
// 用户信息 // 用户信息
const userStore = useUserStore(); const userStore = useUserStore();
const babyId = ref(userStore.babyInfo?.content?.id) const babyId = ref(userStore.babyInfo?.content?.id)
...@@ -288,6 +289,27 @@ const updateActiveTab = (scrollTop) => { ...@@ -288,6 +289,27 @@ const updateActiveTab = (scrollTop) => {
// 点击tab滚动到对应区域 // 点击tab滚动到对应区域
const scrollToSection = (index) => { const scrollToSection = (index) => {
let buttonName = ''
switch (index) {
case 0:
buttonName = '产检须知';
break;
case 1:
buttonName = '产检项目';
break;
case 2:
buttonName = '本次报告单';
break;
default:
break;
}
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检详情页",
buttonName: buttonName,
});
activeIndex.value = index; activeIndex.value = index;
scrolling.value = true; scrolling.value = true;
...@@ -354,6 +376,12 @@ const onImageDel = (id) => { ...@@ -354,6 +376,12 @@ const onImageDel = (id) => {
} }
// 上传图片 // 上传图片
const onUpload = throttleTap(() => { const onUpload = throttleTap(() => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检详情页",
buttonName: "上传报告单",
});
if (bgdImgList.value.length == 15) { if (bgdImgList.value.length == 15) {
uni.showToast({ uni.showToast({
title: "最多上传15张图片", title: "最多上传15张图片",
...@@ -401,6 +429,12 @@ const onUpload = throttleTap(() => { ...@@ -401,6 +429,12 @@ const onUpload = throttleTap(() => {
// 查看更多 // 查看更多
const onSeeBtn = () => { const onSeeBtn = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检详情页",
buttonName: "查看全部",
})
uni.navigateTo({ uni.navigateTo({
url: '/pages/myReportCard/myReportCard' url: '/pages/myReportCard/myReportCard'
}) })
...@@ -408,6 +442,12 @@ const onSeeBtn = () => { ...@@ -408,6 +442,12 @@ const onSeeBtn = () => {
// 打开提醒弹窗 // 打开提醒弹窗
const onRemind = () => { const onRemind = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检详情页",
buttonName: "提醒",
})
// 产检时间 // 产检时间
const checkupDate = new Date(infoData.value.checkupDate) const checkupDate = new Date(infoData.value.checkupDate)
...@@ -475,6 +515,12 @@ const getWxNotificationFn = async (notificationDate, wxTemplateId, babyId) => { ...@@ -475,6 +515,12 @@ const getWxNotificationFn = async (notificationDate, wxTemplateId, babyId) => {
} }
// 完成检查 // 完成检查
const onComplete = () => { const onComplete = () => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检详情页",
buttonName: "完成检查",
})
if (infoData.value.checkupDate == '') { if (infoData.value.checkupDate == '') {
uni.showToast({ uni.showToast({
title: '请选择产检日期', title: '请选择产检日期',
...@@ -495,6 +541,12 @@ const onComplete = () => { ...@@ -495,6 +541,12 @@ const onComplete = () => {
// 修改时间 // 修改时间
const onChangeTime = throttleTap((date) => { const onChangeTime = throttleTap((date) => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检详情页",
buttonName: "选择时间",
})
visible.value = true visible.value = true
time.value = date time.value = date
}) })
...@@ -512,6 +564,11 @@ const handleDateConfirm = (date) => { ...@@ -512,6 +564,11 @@ const handleDateConfirm = (date) => {
// 修改项目 // 修改项目
const onModify = (item) => { const onModify = (item) => {
md.sensorLogTake({
xcxClick: "小程序页面点击事件",
pageName: "产检详情页",
buttonName: "修改项目",
})
console.log(item) console.log(item)
const items = JSON.stringify(item) const items = JSON.stringify(item)
uni.navigateTo({ uni.navigateTo({
...@@ -582,6 +639,10 @@ const getSettingFn = () => { ...@@ -582,6 +639,10 @@ const getSettingFn = () => {
} }
// 获取传过来的参数 // 获取传过来的参数
onLoad((options) => { onLoad((options) => {
md.sensorLogTake({
xcxPage: "小程序页面浏览事件",
pageName: "产检详情页"
});
console.log(options) console.log(options)
// 获取传过来的参数:id // 获取传过来的参数:id
editId.value = options.id editId.value = options.id
......
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