Commit 32d64dce by chenwq

优化报告页面埋点逻辑,新增页面显示和隐藏生命周期处理

1 parent 05446aeb
......@@ -6,18 +6,23 @@ import { reportFirstAutoObj } from "./reportFirstAuto";
import fn from "~/components/GLCustForm/ruleFn";
import api from "../../api";
import apiDefault from "~/api/api";
import reportPageTrackMixin from '~/mixins/reportPageTrackMixin'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/'
var allRuleObj = {};
import { setConfigInfo } from "~/store/index";
const app = getApp();
Page({
behaviors: [reportPageTrackMixin],
/**
* 页面的初始数据
* selectWeek 0代表的本周 1代表下一周 -1代表上一周
* timeBean 传递给组件的数据,数据的格式在一开始的工具类中明确
*/
data: {
// 埋点信息
track_event_code: '',
scene: '',
IMG_URL,
imgShow: false,
isDisable: false,
......@@ -88,6 +93,7 @@ Page({
*/
onLoad(options) {
const { titleTxtObj } = this.data;
let userInfo = wx.$util.getUserInfo() || {}
if (options.refresh) {
const { routeParams } = this.data;
this.initData(options);
......@@ -99,7 +105,10 @@ Page({
tmlpCode: routeParams.code || null,
reportType: routeParams.reportType || 1,
title: titleTxtObj[routeParams.reportTypeAttr || "daily"],
track_event_code: routeParams.code.replace(/-/g, '_') + '_browse',
scene: userInfo?.sceneType
});
this.onPageShow();
this.initData(options);
});
},
......@@ -130,7 +139,7 @@ Page({
if (needDefaultCodeList.includes(routeParams.code)) {
reportFirstAutoObj[routeParams.code]?.list.forEach((item) => {
tmlpFormData[item.attrName] =
(data[item[valBaseRole]].totalOrderMoney || 0) + "";
(data[item[valBaseRole]].totalOrderMoney || 0) + "";
});
this.setData(
{
......@@ -196,6 +205,29 @@ Page({
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
if(this.data.track_event_code) {
this.onPageShow();
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
this.onPageHide();
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
this.onPageHide()
},
async initData(options) {
const { routeParams } = this.data;
// 获取配置服务数据
......@@ -495,7 +527,7 @@ Page({
this.data.selectedMonth === currentMonth;
let updates = {};
// If not current month, remove edit capability (hides Modify button)
// If not current month, remove edit capability (hides Modify button)
if (!isCurrentMonth) {
updates.isTodayEdit = false;
}
......@@ -605,18 +637,35 @@ Page({
//改----------------
const hasDailyValue =
timeBean.weekDayList[timeBean.selectDay].hasDailyValue || false;
// 新增:如果是本周最后一天(周日,getDay() === 0)或是当月最后一天,也不可编辑
const selectedDateStr = timeBean.weekDayList[timeBean.selectDay].date;
const selDateObj = new Date(selectedDateStr);
const isSunday = selDateObj.getDay() === 0; // 周日
const lastDayOfMonth = new Date(selDateObj.getFullYear(), selDateObj.getMonth() + 1, 0).getDate();
const isLastOfMonth = selDateObj.getDate() === lastDayOfMonth;
const disableBecauseOfRules = hasDailyValue || isSunday || isLastOfMonth;
this.setData({
isDisable: hasDailyValue,
hasDailyValue: hasDailyValue,
isDisable: disableBecauseOfRules,
hasDailyValue: hasDailyValue
});
if (!hasDailyValue) {
if (!disableBecauseOfRules) {
this.getUserStat();
}
} else if (tmlpEditList.includes(tmlpCode)) {
// 往期编辑
// 往期也需考虑周日或月底不可编辑
const selectedDateStr = timeBean.weekDayList[timeBean.selectDay].date;
const selDateObj = new Date(selectedDateStr);
const isSunday = selDateObj.getDay() === 0;
const lastDayOfMonth = new Date(selDateObj.getFullYear(), selDateObj.getMonth() + 1, 0).getDate();
const isLastOfMonth = selDateObj.getDate() === lastDayOfMonth;
this.setData({
isDisable:
timeBean.weekDayList[timeBean.selectDay].hasDailyValue || false,
timeBean.weekDayList[timeBean.selectDay].hasDailyValue || false || isSunday || isLastOfMonth,
});
}
this.setData({
......@@ -1099,7 +1148,7 @@ Page({
secondConfirm(params) {
let that = this;
const { titleTxtObj, routeParams } = this.data;
const { titleTxtObj, routeParams, scene, hasDailyValue } = this.data;
wx.showModal({
title: "确认提示",
content:
......@@ -1119,6 +1168,10 @@ Page({
that.getRecordDetail();
}
wx.$util.showToast(res.code == "0" ? "提交成功" : res.message);
if(res.code == "0") {
const eventCode = params?.templateCode.replace(/-/g, '_') + (hasDailyValue ? '_edit' : '_add')
wx.$track.setTrackData(0, eventCode, {}, '', scene)
}
})
.finally(() => {
that.setData({
......
......@@ -33,24 +33,21 @@ Page({
url: "packageWorkspace.supervisorDaily",
icon: "warranty-supervisor-daily",
reportTypeAttr: "daily",
reportTypeVal: "1",
trackingCode: "regional-modifications-supervisor-daily",
reportTypeVal: "1"
},
{
name: "工作周报",
url: "packageWorkspace.supervisorDaily",
icon: "modifications-supervisor-week",
reportTypeAttr: "weekly",
reportTypeVal: "2",
trackingCode: "regional-modifications-supervisor-daily",
reportTypeVal: "2"
},
{
name: "工作月报",
url: "packageWorkspace.supervisorDaily",
icon: "modifications-supervisor-month",
reportTypeAttr: "monthly",
reportTypeVal: "3",
trackingCode: "regional-modifications-supervisor-daily",
reportTypeVal: "3"
},
{
name: "服务中心",
......@@ -58,7 +55,7 @@ Page({
icon: "server-center",
reportTypeAttr: "monthly",
reportTypeVal: "3",
trackingCode: "no",
trackingCode: "regional-assistant-server-center",
},
],
staffDevelopmentMenus: [
......@@ -144,6 +141,7 @@ Page({
},
onReportPopupSelect(e) {
const selectedTemplate = e.detail;
let userInfo = wx.$util.getUserInfo()
this.setData({
showReportPopup: false,
});
......@@ -158,6 +156,9 @@ Page({
...(selectedTemplate || {}),
};
const eventCode = params?.code.replace(/-/g, '_') + '_click'
wx.$track.setTrackData(0, eventCode, {}, '', userInfo?.sceneType)
wx.$router.go(item.url, {
params: params,
});
......@@ -339,7 +340,9 @@ Page({
e.currentTarget.dataset.target
let userInfo = wx.$util.getUserInfo()
// 埋点
wx.$track.setTrackData(0, trackingCode, {}, '', userInfo?.sceneType)
if(trackingCode) {
wx.$track.setTrackData(0, trackingCode, {}, '', userInfo?.sceneType)
}
let item = e.currentTarget.dataset.target
if (item.url == 'packageWorkspace.supervisorDaily') {
this.openWorkReportTemp(item)
......
......@@ -118,5 +118,9 @@
]
}
},
"libVersion": "3.12.0"
"libVersion": "3.14.3",
"projectname": "regional-assistant",
"setting": {
"compileHotReLoad": true
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!