1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
(function(){
angular.module("app.collect")
.controller("userengagementCtrl",["$rootScope","$scope","HttpService","ToolService","DateService","$filter", "$translate",userengagementCtrl]);
function userengagementCtrl($rootScope,$scope,HttpService,ToolService,DateService,$filter, $translate){
//时间控件
$scope.beginDate = DateService.getDay(0);
$scope.$on("beginDate",function(e,msg){
$scope.beginDate = msg;
$scope.contrastType=='channel'&&$scope.query();
});
$scope.contrastType = 'channel';
$scope.changeContrastType = function(flag) {
if($scope.contrastType==flag){return false};
$scope.contrastType = flag;
$scope.channelid = '';
$scope.beginDateList = [];
flag=='channel'&&$scope.query();
}
$scope.querySelectInfos = function() {
$translate(["请选择", "自然量"]).then(function(translations) {
$scope.initSelects(translations["请选择"], translations["自然量"]);
}, function(tranIds) {
$scope.initSelects(tranIds["请选择"], tranIds["自然量"]);
});
}
$scope.initSelects = function(noFilter, nat) {
var channelparams = ToolService.getChannelCampaignParams("channel", $scope.appid);
var channelPM = HttpService.getInfo(channelparams.url);
$scope.channelNameInit = noFilter + channelparams.txt;;
channelPM.then(function(data) {
if (!(!$rootScope.isall && $rootScope.curRoleAuth && !$rootScope.curRoleAuth.isNatureOpen)) {
data.unshift({ id: "-1", name: nat });
}
$scope.channelList = data;
});
var params = {
appid: $scope.appid,
datatype: 'list',
viewtype: 'chart',
func: 'duration'
}
var pageListPM = HttpService.getReportData('page_duration_ids',params);
pageListPM.then(function(data){
data.val.filter(function(value){
value.name = value.pageid
})
data.val.unshift({pageid: "all",name:$filter('translate')('请选择pageid')})
$scope.pageList = data.val;
});
}
$scope.channelid = '';
$scope.$on("channelid", function(e, msg) {
$scope.channelid = msg.info;
$scope.query();
});
$scope.beginDateList = [];
$scope.$on("beginDateList",function(e,msg){
$scope.beginDateList = msg
$scope.query();
});
$scope.channelRe = 0;
$scope.clear = function(){
$scope.channelid = '';
$scope.channelRe++
$scope.beginDateList = [];
$scope.query();
}
$scope.pageList = [];
$scope.pageListInit = 'all';
$scope.pageId = 'all';
$scope.$on('pageId', function(e, msg) {
if($scope.pageId == msg.info.pageid){return false};
$scope.pageId = msg.info.pageid;
$scope.pageViewDurationQuery()
});
$scope.$watch("{appid:appid,lang:lang}", function(n, o) {
if (angular.isUndefined($scope.appid)) { return false; }
$scope.channelid = '';
$scope.channelRe++
$scope.querySelectInfos();
$scope.query();
if(n && o && n!==o){
// $scope.initData();
// console.log(1)
}
});
$scope.report = [
{name:'userengagement_session_by',title:'单次使用时长分布'},
{name:'userengagement_user_by',title:'使用时长分布'},
{name:'userengagement_page_by',title:'App页面浏览时长分布'},
{name:'userengagement_freq_by',title:'使用频率分布'},
]
// var color5 = ["#5c6bc0", "#50bd3e", "#cddc39", "#fb7f0b", "#fec107"];
var color5 = ["#1FB9E9", "#A0E1F5", "#F8A20F", "#FBD799", "#00B37F", "#93DFC9", "#F9593A", "#FCC2B7", "#5F97FB", '#ca8622'];
var opacity = 0.1;
$scope.query = function() {
if (angular.isUndefined($scope.appid)) { return false; }
var params = {
startdate: $scope.beginDate,
enddate: $scope.beginDate,
appid: $scope.appid,
datatype: 'chart',
viewtype: 'chart',
func: 'duration',
duration_dates:$scope.beginDateList.join(','),
duration_cid:$scope.channelid
}
$scope.singleUseTimeQuery(params)
$scope.totalUseTimeQuery(params)
$scope.pageViewDurationQuery()
$scope.usageFrequencyQuery(params)
}
$scope.singleUseTimeQuery = function(params) {
var by = $scope.contrastType=='channel'&&$scope.channelid==''?'date':$scope.contrastType;
$scope.singleUseTimeConfig = {color:color5,opacity:opacity};
var singleUseTimePM = HttpService.getReportData($scope.report[0].name + by,params);
$scope.singleUseTimeLoading = true;
singleUseTimePM.then(function(data){
$scope.singleUseTimeData = data;
$scope.singleUseTimeLoading = false;
});
var params1 = JSON.parse(JSON.stringify(params));
params1.viewtype = 'list'
var singleUseTimeListPM = HttpService.getReportData($scope.report[0].name + $scope.contrastType,params1);
singleUseTimeListPM.then(function(data){
$scope.singleUseTimeTableData = data;
$scope.singleUseTimeDataCondition = ToolService.getChartConditions($filter('translate')("用户参与度-")+$scope.report[0].title,$scope.report[0].name + $scope.contrastType,params1);
});
}
$scope.totalUseTimeQuery = function(params) {
var by = $scope.contrastType=='channel'&&$scope.channelid==''?'date':$scope.contrastType;
$scope.totalUseTimeConfig = {color:color5,opacity:opacity};
var totalUseTimePM = HttpService.getReportData($scope.report[1].name + by,params);
$scope.totalUseTimeLoading = true;
totalUseTimePM.then(function(data){
$scope.totalUseTimeData = data;
$scope.totalUseTimeLoading = false;
});
var params1 = JSON.parse(JSON.stringify(params));
params1.viewtype = 'list'
var totalUseTimeListPM = HttpService.getReportData($scope.report[1].name + $scope.contrastType,params1);
totalUseTimeListPM.then(function(data){
$scope.totalUseTimeTableData = data;
$scope.totalUseTimeDataCondition = ToolService.getChartConditions($filter('translate')("用户参与度-")+$scope.report[1].title,$scope.report[1].name + $scope.contrastType,params1);
});
}
$scope.pageViewDurationQuery = function() {
var params = {
startdate: $scope.beginDate,
enddate: $scope.beginDate,
appid: $scope.appid,
datatype: 'chart',
viewtype: 'chart',
func: 'duration',
duration_dates:$scope.beginDateList.join(','),
duration_cid:$scope.channelid
}
$scope.pageId!='all'?params.duration_pageid = $scope.pageId:'';
var by = $scope.contrastType=='channel'&&$scope.channelid==''?'date':$scope.contrastType;
$scope.pageViewDurationConfig = {color:color5,opacity:opacity};
var pageViewDurationPM = HttpService.getReportData($scope.report[2].name+ by,params);
$scope.pageViewDurationLoading = true;
pageViewDurationPM.then(function(data){
$scope.pageViewDurationData = data;
$scope.pageViewDurationLoading = false;
});
var params1 = JSON.parse(JSON.stringify(params));
params1.viewtype = 'list'
var pageViewDurationListPM = HttpService.getReportData($scope.report[2].name + $scope.contrastType,params1);
pageViewDurationListPM.then(function(data){
$scope.pageViewDurationTableData = data;
$scope.pageViewDurationDataCondition = ToolService.getChartConditions($filter('translate')("用户参与度-")+$scope.report[2].title,$scope.report[2].name + $scope.contrastType,params1);
});
}
$scope.usageFrequencyQuery = function(params) {
var by = $scope.contrastType=='channel'&&$scope.channelid==''?'date':$scope.contrastType;
$scope.usageFrequencyConfig = {color:color5,opacity:opacity};
var usageFrequencyPM = HttpService.getReportData($scope.report[3].name+ by,params);
$scope.usageFrequencyLoading = true;
usageFrequencyPM.then(function(data){
$scope.usageFrequencyData = data;
$scope.usageFrequencyLoading = false;
});
var params1 = JSON.parse(JSON.stringify(params));
params1.viewtype = 'list'
var usageFrequencyListPM = HttpService.getReportData($scope.report[3].name + $scope.contrastType,params1);
usageFrequencyListPM.then(function(data){
$scope.usageFrequencyTableData = data;
$scope.usageFrequencyDataCondition = ToolService.getChartConditions($filter('translate')("用户参与度-")+$scope.report[3].title,$scope.report[3].name + $scope.contrastType,params1);
});
}
// $scope.mapData = {
// help:[],
// name:['排重激活设备数'],
// column:['省份'],
// key:['北京','上海','河北','黑龙江','新疆'],
// val:[['111','222','234','323','1234']]
// }
}
})();