159 lines
5.7 KiB
JavaScript
159 lines
5.7 KiB
JavaScript
(function(){
|
|
X.pageLogic['userinfo'] = {
|
|
init : function(parms){
|
|
var me = this;
|
|
|
|
var event_list,start_time,end_time,userdata;
|
|
|
|
|
|
// 日期渲染
|
|
X.daterender("#analtsis-condition-date",function(start, end, label){
|
|
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
|
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
|
start_time = startTime;
|
|
end_time = endTime;
|
|
updatasolouser();
|
|
})
|
|
|
|
$(document).off('click','.userinfo-event-list-title-box').on('click','.userinfo-event-list-title-box',function(){
|
|
|
|
if($(this).next().css('display') == 'block'){
|
|
$(this).next().hide();
|
|
}else {
|
|
$(this).next().show();
|
|
}
|
|
|
|
});
|
|
|
|
X.api("ck/event_list","get",{},function(d){
|
|
event_list = d;
|
|
if(X['DATA']['search-user-id']){
|
|
updatasolouser();
|
|
}
|
|
});
|
|
|
|
|
|
$(document).off('click','.analtsis-condition').on('click','.analtsis-condition',function(){
|
|
var type = $(".userinfo-pie-echarts").css("display");
|
|
if(type == 'none'){
|
|
$(".analysis-echarts").css("width","calc( 100% - 401px)");
|
|
$(".userinfo-pie-echarts").show();
|
|
}else {
|
|
$(".analysis-echarts").css("width","100%");
|
|
$(".userinfo-pie-echarts").hide();
|
|
}
|
|
|
|
userinfoechert(userdata.event_count);
|
|
if(userdata.proportion.length > 0){
|
|
userinfopieechart(userdata.proportion);
|
|
}
|
|
});
|
|
|
|
function updatasolouser(){
|
|
var time = $("#analtsis-condition-date").val();
|
|
var timearr = time.split(" ");
|
|
start_time = timearr[0] + " "+"00:00:00";
|
|
end_time = timearr[2]+" "+"23:59:59";
|
|
|
|
X.api("ck/solo_user","post",{account_id:X.DATA['search-user-id'],event_list:event_list,start_time:start_time,end_time:end_time},function(val){
|
|
userdata = val
|
|
if(val.event_count.length > 0){
|
|
userinfoechert(val.event_count);
|
|
}
|
|
if(val.proportion.length > 0){
|
|
userinfopieechart(val.proportion);
|
|
}
|
|
X.laytpldata("#user-left-content-box-dot",val['details_data'],".user-left-content-box",function(){});
|
|
|
|
X.laytpldata("#userinfo-event-box-dot",val['details_user'],".userinfo-event-box",function(){});
|
|
|
|
})
|
|
};
|
|
|
|
function userinfopieechart(data){
|
|
|
|
var myChart = echarts.init(document.getElementById('userinfo-pie'));
|
|
|
|
var option = {
|
|
color: ['#4daef5','#5dd7d1','#bae5f6','#f8e7bb','#ad91d9','#7be0b8','#f78499','#fa9c6d','#fecde2','#677a9b','#4295da'],
|
|
title: {
|
|
left: 'center'
|
|
},
|
|
tooltip: {
|
|
trigger: 'item',
|
|
formatter: '{a} <br/>{b} : {c} ({d}%)'
|
|
},
|
|
label:{
|
|
formatter: '{b}\n{d}%',
|
|
},
|
|
series: [
|
|
{
|
|
name: '姓名',
|
|
type: 'pie',
|
|
radius: '50%',
|
|
center: ['50%', '50%'],
|
|
data: data,
|
|
emphasis: {
|
|
itemStyle: {
|
|
shadowBlur: 10,
|
|
shadowOffsetX: 0,
|
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
}
|
|
}
|
|
}
|
|
]
|
|
};
|
|
myChart.setOption(option,true);
|
|
};
|
|
|
|
function userinfoechert(data){
|
|
var xAxisData = data.date;
|
|
var seriesData = [];
|
|
var arr = {
|
|
name:'总量',
|
|
type: 'bar',
|
|
barWidth : 30,
|
|
data: data.event_values,
|
|
}
|
|
seriesData.push(arr);
|
|
|
|
var myChart = echarts.init(document.getElementById('userinfo-echarts'));
|
|
|
|
var option = {
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
axisPointer: {
|
|
type: 'shadow'
|
|
}
|
|
},
|
|
color: X.DATA.echartscolor,
|
|
grid: {
|
|
left: '2%',
|
|
right: '2%',
|
|
bottom: '2%',
|
|
top: '10%',
|
|
containLabel: true
|
|
},
|
|
xAxis: [
|
|
{
|
|
type: 'category',
|
|
axisTick: {show: false},
|
|
data: xAxisData
|
|
}
|
|
],
|
|
yAxis: [
|
|
{
|
|
type: 'value'
|
|
}
|
|
],
|
|
series: seriesData
|
|
};
|
|
myChart.resize();
|
|
myChart.setOption(option,true);
|
|
}
|
|
|
|
|
|
}
|
|
};
|
|
})();
|