diff --git a/public/index.html b/public/index.html index 988e6ac..a9bb8ca 100644 --- a/public/index.html +++ b/public/index.html @@ -2,70 +2,25 @@ - - - - - - - - - + + + + + + + + - -
- - - - - + +
+ + \ No newline at end of file diff --git a/public/zwlogJS接入.html b/public/zwlogJS接入.html index ed41807..15bfb06 100644 --- a/public/zwlogJS接入.html +++ b/public/zwlogJS接入.html @@ -17,9 +17,11 @@ _user_id: "用户ID", _user_nick: "用户昵称" }) + console.log(2222) //onReady表示zwlog加载完成后的函数,它接收一个匿名函数,而sendPV与record方法均要在匿名函数内调用。eg: zwlog.onReady(function () { + console.log(1111) //PV日志 zwlog.sendPV({ miniAppId: 'IRS服务侧应用appid', diff --git a/src/App.vue b/src/App.vue index 85211f5..3f88438 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,8 +11,17 @@ export default { isElder: false, } }, + watch: { + $route(to, from) { + console.log('zheliban 》》》 ', to, from) + this.$zwlogPvGlobal({ url: to.meta.pagePath, enterPageTime: new Date() }) + this.$zwlogPvGlobal({ + url: from.meta.pagePath, + leavePageTime: new Date(), + }) + }, + }, mounted() { - // new vConsole() ZWJSBridge.onReady(() => { console.log('初始化完成后,执行bridge方法') }) diff --git a/src/common/zwUtil.js b/src/common/zwUtil.js new file mode 100644 index 0000000..30114ed --- /dev/null +++ b/src/common/zwUtil.js @@ -0,0 +1,134 @@ + +// 埋点对象 +var zwlog; + +// 页面埋点数据 +var pageLogMap = {}; + +/* + * *******用户信息采集,同时声明 Zwlog 对象实例 + * uerId 用户 ID 没登录就非必填,登录了必填 + */ +export function initZwlog () { + zwlog = new ZwLog({ + _user_id: localStorage.getItem('centerNo'), + _user_nick: localStorage.getItem('_user_nick') + }); +} + +/* + * *******PV 日志参数- global_args + * url 页面路径 【选填】(未传参默认获取当前路由地址) + * enterPageTime 【必填】(默认在路由改变的时候自动获取时间) 进入页面的时间 new Date() + * leavePageTime 【必填】(默认在路由改变的时候自动获取时间) 离开页面的时间 new Date() + * loadTime【必填】(页面onShow中获取当前时间) 加载完的时间 new Date() + * responseTime 【必填】(页面onShow的nextTick中获取当前时间) 响应完的时间 new Date() + */ +export function zwlogPvGlobal ({ + url = null, + enterPageTime = null, + leavePageTime = null, + loadTime = null, + responseTime = null +} = {}) { + console.log('调用zwlogPvGlobal') + if (!zwlog) initZwlog(); + let path = url || getCurRoute(); + if (!pageLogMap.hasOwnProperty(path)) + pageLogMap[path] = { + enterPageTime: null, + leavePageTime: null, + loadTime: null, + responseTime: null, + }; + + if (enterPageTime) pageLogMap[path].enterPageTime = enterPageTime; + if (leavePageTime) pageLogMap[path].leavePageTime = leavePageTime; + if (loadTime) pageLogMap[path].loadTime = loadTime; + if (responseTime) pageLogMap[path].responseTime = responseTime; + + console.log("zheliban === " + path, pageLogMap[path]); + + if ( + pageLogMap[path].enterPageTime && + pageLogMap[path].leavePageTime && + pageLogMap[path].loadTime && + pageLogMap[path].responseTime + ) { + /* + * miniAppId 应用开发管理 平台 appId + * miniAppName 应用开发管理 平台应用名称 + * log_status 用户登录状态 (01:未登录/ 02:单点登录) + * Page_duration 浏览时长 用户从进入到离开当 前页面的时长 + * t2 页面加载时间 页面启动到加载完成 的时间 + * t0 页面响应时间 页面启动到页面响应 完成的时间 + * pageId 应用页面 ID + * pageName 应用页面名称 + */ + let Page_duration = + pageLogMap[path].leavePageTime.getTime() - + pageLogMap[path].enterPageTime.getTime(); + let t2 = + pageLogMap[path].loadTime.getTime() - + pageLogMap[path].enterPageTime.getTime(); + let t0 = + pageLogMap[path].responseTime.getTime() - + pageLogMap[path].enterPageTime.getTime(); + setTimeout(() => { + let pvParams = { + miniAppId: "2001895516", + miniAppName: "红色网上游", + log_status: "2001895516", + Page_duration: Page_duration / 1000 + "秒", + t2: t2 / 1000 + "秒", + t0: t0 / 1000 + "秒", + pageId: path, + pageName: getNavigationBarTitleText(), + }; + zwlog.onReady(function () { + console.log('zwlog onReady') + zwlog.sendPV(pvParams); + delete pageLogMap[path]; + }); + }, 500); + } else { + let result = ""; + for (let k in pageLogMap[path]) { + if (!pageLogMap[path][k]) result += k + ","; + } + console.log("zheliban === 浙里办页面" + path + "埋点缺少参数=>>", result); + } +} +// 获取页面的导航title +function getNavigationBarTitleText () { + // let pages = getCurrentPages(); + // let page = pages[pages.length - 1]; + // let title = page.$holder.navigationBarTitleText; + // console.log("zheliban === getNavigationBarTitleText title=", title); + return document.title; +} + +// 点击事件的埋点 +export function zwlogRecord ({ code = "" } = {}) { + if (!zwlog) initZwlog(); + let path = getCurRoute(); + zwlog.onReady(function () { + zwlog.record({ + trackerEventCode: `${code}`, + eventType: "OTHER", + eventParams: { + pageId: path, //采用页面路径,也可以自己给每个页面设置一个pageId + pageName: getNavigationBarTitleText(), + }, + }); + }); +} + + +let getCurRoute = () => { + // let routes = getCurrentPages(); // 获取当前打开过的页面路由数组 + // let curRoute = routes[routes.length - 1].route; // 获取当前页面路由,也就是最后一个打开的页面路由 + // console.log("curRoute", curRoute); + + return '/'; +}; \ No newline at end of file diff --git a/src/main.js b/src/main.js index 1b3ae2c..ab91b61 100644 --- a/src/main.js +++ b/src/main.js @@ -18,8 +18,8 @@ import yxAxios from '@/https/yxAxios' Vue.prototype.yxAxios = yxAxios; Vue.prototype.dialog = Dialog; -import { mgop } from '@aligov/jssdk-mgop'; -Vue.prototype.mgop = mgop; +import {zwlogPvGlobal} from './common/zwUtil.js' +Vue.prototype.$zwlogPvGlobal = zwlogPvGlobal; import common from './common/index' Vue.prototype.common = common; diff --git a/src/views/Home/Home.vue b/src/views/Home/Home.vue index 379d319..4614d5b 100644 --- a/src/views/Home/Home.vue +++ b/src/views/Home/Home.vue @@ -96,6 +96,10 @@ export default { }, mounted() { + this.$zwlogPvGlobal({ loadTime: new Date() }) + this.$nextTick(() => { + this.$zwlogPvGlobal({ responseTime: new Date() }) + }) const isElder = localStorage.getItem('isElder') if (isElder) { this.isElder = true @@ -193,8 +197,8 @@ export default { localStorage.removeItem('centerNo') setTimeout(() => { const sUserAgent = window.navigator.userAgent.toLowerCase() - const dtdreamweb = sUserAgent.indexOf('dtdreamweb') > -1 - const miniprogram = sUserAgent.indexOf('miniprogram') > -1 && sUserAgent.indexOf('alipay') > -1 + const dtdreamweb = sUserAgent.indexOf('dtdreamweb') > -1 + const miniprogram = sUserAgent.indexOf('miniprogram') > -1 && sUserAgent.indexOf('alipay') > -1 if (miniprogram) { // alert('支付宝') window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` diff --git a/src/views/Service/ServiceKQ.vue b/src/views/Service/ServiceKQ.vue index de463dc..1585630 100644 --- a/src/views/Service/ServiceKQ.vue +++ b/src/views/Service/ServiceKQ.vue @@ -12,7 +12,6 @@ export default { centerNo: '', } }, - mounted() { console.log('xst mounted') this.checkAuth() @@ -127,13 +126,13 @@ export default { // }) // } else { // localStorage.setItem('reloadCount', 2) - if (miniprogram) { - // alert('支付宝') - window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` - } else { - // alert('浙里办') - window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` - } + if (miniprogram) { + // alert('支付宝') + window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` + } else { + // alert('浙里办') + window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` + } // } }, // 获取用户信息 @@ -143,8 +142,14 @@ export default { this.yxAxios.get(`${this.proxyUrl}/user/info/getPortalUserByNum?userNum=${localStorage.getItem('centerNo')}`).then((res) => { console.log('获取用户信息getPortalUserByNum:', res) if (res.data.code == 200) { - localStorage.setItem('userInfo', JSON.stringify(res.data.data.userInfo)) - this.userInfo = res.data.data.userInfo + let userInfo = res.data.data.userInfo + localStorage.setItem('userInfo', JSON.stringify(userInfo)) + this.userInfo = userInfo + localStorage.setItem('_user_nick', userInfo.travelerName) + this.$zwlogPvGlobal({ loadTime: new Date() }) + this.$nextTick(() => { + this.$zwlogPvGlobal({ responseTime: new Date() }) + }) } }) }, diff --git a/src/views/Yanxue/achievementsOne.vue b/src/views/Yanxue/achievementsOne.vue index 504b304..2faa7c5 100644 --- a/src/views/Yanxue/achievementsOne.vue +++ b/src/views/Yanxue/achievementsOne.vue @@ -1,48 +1,34 @@ \ No newline at end of file + diff --git a/src/views/answerRank/stars.vue b/src/views/answerRank/stars.vue index 8dfcf52..8b21c6e 100644 --- a/src/views/answerRank/stars.vue +++ b/src/views/answerRank/stars.vue @@ -1,435 +1,423 @@ \ No newline at end of file + -- libgit2 0.21.0