|
@@ -292,24 +292,24 @@ page {
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import wepy from '@wepy/core';
|
|
|
-import store from '@/store';
|
|
|
-import config from '@/config';
|
|
|
-import moment from 'moment';
|
|
|
-import { mapState } from '@wepy/x';
|
|
|
-import { checkLogin, checkHasUserInfo } from '@/service/user';
|
|
|
-import { queryInvitationStatisticsHttp, queeyBuriedEventLogHttp } from '@/packagesEnv/api/portrait';
|
|
|
+import wepy from '@wepy/core'
|
|
|
+import store from '@/store'
|
|
|
+import config from '@/config'
|
|
|
+import moment from 'moment'
|
|
|
+import { mapState } from '@wepy/x'
|
|
|
+import { checkLogin, checkHasUserInfo } from '@/service/user'
|
|
|
+import { queryInvitationStatisticsHttp, queeyBuriedEventLogHttp } from '@/packagesEnv/api/portrait'
|
|
|
|
|
|
-let numChart = null;
|
|
|
+let numChart = null
|
|
|
let resultData = {
|
|
|
data: [
|
|
|
|
|
|
]
|
|
|
}
|
|
|
function numChartData(F2, config) {
|
|
|
- let data = resultData.data;
|
|
|
- numChart = new F2.Chart({ ...config, appendPadding: [30, 30, 15, 5] });
|
|
|
- numChart.clear();
|
|
|
+ let data = resultData.data
|
|
|
+ numChart = new F2.Chart({ ...config, appendPadding: [30, 30, 15, 5] })
|
|
|
+ numChart.clear()
|
|
|
numChart.source(data, {
|
|
|
'x': {
|
|
|
type: 'linear',
|
|
@@ -319,7 +319,7 @@ function numChartData(F2, config) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- });
|
|
|
+ })
|
|
|
|
|
|
numChart.guide().text({
|
|
|
top: false,
|
|
@@ -332,7 +332,7 @@ function numChartData(F2, config) {
|
|
|
}, // 文本的图形样式属性
|
|
|
offsetX: 20, // x 方向的偏移量
|
|
|
offsetY: 12 // y 方向偏移量
|
|
|
- });
|
|
|
+ })
|
|
|
numChart.guide().text({
|
|
|
position: ['min', 'max'], // 文本的起始位置,值为原始数据值,支持 callback
|
|
|
content: '时长', // 显示的文本内容
|
|
@@ -342,8 +342,8 @@ function numChartData(F2, config) {
|
|
|
}, // 文本的图形样式属性
|
|
|
offsetX: -4, // x 方向的偏移量
|
|
|
offsetY: -20 // y 方向偏移量
|
|
|
- });
|
|
|
- numChart.tooltip(false);
|
|
|
+ })
|
|
|
+ numChart.tooltip(false)
|
|
|
numChart.point().position('x*y')
|
|
|
.size('r', [0, 30])
|
|
|
.shape('circle')
|
|
@@ -351,8 +351,8 @@ function numChartData(F2, config) {
|
|
|
opacity: 0.6
|
|
|
})
|
|
|
|
|
|
- numChart.render();
|
|
|
- return numChart;
|
|
|
+ numChart.render()
|
|
|
+ return numChart
|
|
|
}
|
|
|
wepy.page({
|
|
|
store,
|
|
@@ -379,9 +379,8 @@ wepy.page({
|
|
|
...mapState({ userInfo: state => state.user.userInfo, token: state => state.user.token })
|
|
|
},
|
|
|
onLoad() {
|
|
|
- checkHasUserInfo().then(() => {
|
|
|
- this.getData();
|
|
|
- })
|
|
|
+ checkHasUserInfo()
|
|
|
+ this.getData()
|
|
|
},
|
|
|
onReady() { },
|
|
|
methods: {
|
|
@@ -398,14 +397,14 @@ wepy.page({
|
|
|
this.imgSrc = res.tempFilePath
|
|
|
},
|
|
|
fail: res => {
|
|
|
- console.log('转图片失败', res);
|
|
|
+ console.log('转图片失败', res)
|
|
|
}
|
|
|
}, this)
|
|
|
},
|
|
|
async getData() {
|
|
|
- let res = await this.getInvitationStatistics();
|
|
|
+ let res = await this.getInvitationStatistics()
|
|
|
if (res && res.visitorTotal) { // 有访客,显示界面,再请求
|
|
|
- await this.getBuriedEventLog();
|
|
|
+ await this.getBuriedEventLog()
|
|
|
this.isPageShow = true
|
|
|
}
|
|
|
},
|
|
@@ -421,29 +420,29 @@ wepy.page({
|
|
|
endDate: endDate
|
|
|
}
|
|
|
return queryInvitationStatisticsHttp(paramObj).then(res => {
|
|
|
- this.isPageShow = false;
|
|
|
+ this.isPageShow = false
|
|
|
if (JSON.stringify(res.data) === '{}') { return };
|
|
|
- let resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- this.infoArr[0].value = resData.visitorTotal;
|
|
|
- this.infoArr[1].value = resData.invitationTimeTotal;
|
|
|
- this.infoArr[2].value = Number.isInteger(resData.avgTimePerDay) ? resData.avgTimePerDay : resData.avgTimePerDay.toFixed(2);
|
|
|
+ let resData = JSON.parse(JSON.stringify(res.data))
|
|
|
+ this.infoArr[0].value = resData.visitorTotal
|
|
|
+ this.infoArr[1].value = resData.invitationTimeTotal
|
|
|
+ this.infoArr[2].value = Number.isInteger(resData.avgTimePerDay) ? resData.avgTimePerDay : resData.avgTimePerDay.toFixed(2)
|
|
|
|
|
|
- let charArr = [];
|
|
|
- let resCharArr = resData.detailList;
|
|
|
+ let charArr = []
|
|
|
+ let resCharArr = resData.detailList
|
|
|
|
|
|
- let startMonthday = this.yearMonth + '01';
|
|
|
- let endMonthday = moment(this.yearMonth).endOf('month').format('YYYYMMDD');
|
|
|
+ let startMonthday = this.yearMonth + '01'
|
|
|
+ let endMonthday = moment(this.yearMonth).endOf('month').format('YYYYMMDD')
|
|
|
// 补齐坐标轴
|
|
|
for (let i = Number(startMonthday); i <= Number(endMonthday); i++) {
|
|
|
- let flag = true;
|
|
|
- let jItem = {};
|
|
|
+ let flag = true
|
|
|
+ let jItem = {}
|
|
|
resCharArr.forEach(j => {
|
|
|
- let JMs = j.date; // 时间戳
|
|
|
+ let JMs = j.date // 时间戳
|
|
|
if (i == JMs) {
|
|
|
- flag = false;
|
|
|
- jItem = j;
|
|
|
+ flag = false
|
|
|
+ jItem = j
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
if (flag) {
|
|
|
charArr.push({
|
|
|
date: i,
|
|
@@ -454,15 +453,15 @@ wepy.page({
|
|
|
charArr.push(jItem)
|
|
|
}
|
|
|
}
|
|
|
- let visitorNumArr = []; // 人数
|
|
|
- let invitationTimeArr = []; // 时长
|
|
|
+ let visitorNumArr = [] // 人数
|
|
|
+ let invitationTimeArr = [] // 时长
|
|
|
charArr.forEach(item => {
|
|
|
- let dateItem = String(item.date);
|
|
|
- item.date = moment(dateItem).format('DD');
|
|
|
- visitorNumArr.push({ x: item.date, y: item.invitationTime, r: item.visitorNum, color: '#5E8BCF' });
|
|
|
- invitationTimeArr.push({ x: item.date, y: item.invitationTime, r: item.invitationTime, color: '#D0DBED' });
|
|
|
+ let dateItem = String(item.date)
|
|
|
+ item.date = moment(dateItem).format('DD')
|
|
|
+ visitorNumArr.push({ x: item.date, y: item.invitationTime, r: item.visitorNum, color: '#5E8BCF' })
|
|
|
+ invitationTimeArr.push({ x: item.date, y: item.invitationTime, r: item.invitationTime, color: '#D0DBED' })
|
|
|
})
|
|
|
- resultData.data = invitationTimeArr.concat(visitorNumArr);
|
|
|
+ resultData.data = invitationTimeArr.concat(visitorNumArr)
|
|
|
// return new Promise((res, reject) => {
|
|
|
// this.canvasToImg();
|
|
|
// })
|
|
@@ -471,7 +470,7 @@ wepy.page({
|
|
|
})
|
|
|
},
|
|
|
getBuriedEventLog() { // 访客使用的功能
|
|
|
- let funArr = ['connect_wifi', 'navigation'];
|
|
|
+ let funArr = ['connect_wifi', 'navigation']
|
|
|
let $lt = ''
|
|
|
if (moment().format('YYYYMM') === this.yearMonth) {
|
|
|
$lt = moment().add(1, 'days').format('YYYYMMDD')
|
|
@@ -490,36 +489,36 @@ wepy.page({
|
|
|
return queeyBuriedEventLogHttp(paramObj).then(res => {
|
|
|
if (res.count) {
|
|
|
if (res.content[0].name === 'connect_wifi') {
|
|
|
- this.functionArr[0].value = res.count;
|
|
|
+ this.functionArr[0].value = res.count
|
|
|
} else {
|
|
|
- this.functionArr[1].value = res.count;
|
|
|
+ this.functionArr[1].value = res.count
|
|
|
}
|
|
|
- let maxValue = Math.max.apply(Math, this.functionArr.map(item => { return item.value }));
|
|
|
+ let maxValue = Math.max.apply(Math, this.functionArr.map(item => { return item.value }))
|
|
|
this.functionArr.forEach(item => {
|
|
|
item.wth = item.value / maxValue * 220 // 220 为最大宽度
|
|
|
})
|
|
|
} else {
|
|
|
this.functionArr.forEach(item => {
|
|
|
item.value = 0
|
|
|
- item.wth = 0;
|
|
|
+ item.wth = 0
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
checkTime(val) {
|
|
|
- wx.uma.trackEvent('portrait_visitor_card', { key: '访客-月份切换' });
|
|
|
- this.visible = !this.visible;
|
|
|
- this.chartFlag = false;
|
|
|
- this.yearMonth = val;
|
|
|
- this.yearMonthText = moment(this.yearMonth).format('YYYY.MM');
|
|
|
- this.getData();
|
|
|
+ wx.uma.trackEvent('portrait_visitor_card', { key: '访客-月份切换' })
|
|
|
+ this.visible = !this.visible
|
|
|
+ this.chartFlag = false
|
|
|
+ this.yearMonth = val
|
|
|
+ this.yearMonthText = moment(this.yearMonth).format('YYYY.MM')
|
|
|
+ this.getData()
|
|
|
},
|
|
|
changeMonth() {
|
|
|
- this.visible = !this.visible;
|
|
|
+ this.visible = !this.visible
|
|
|
}
|
|
|
}
|
|
|
-});
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<config>
|