123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675 |
- $(function(){
- // 一级行业select控件初始化
- var firstIndSelect = $('select[name="firstInd"]').select2({
- placeholder: "请输入一级行业",
- allowClear: true,
- width:'286px',
- ajax:{
- url: _PUBLIC_ +'ad-select/top_category_by_type.do',
- dataType:'json',
- quietMillis:100,
- data:function(params){
- return {
- name : params.term,
- type : 0, //栏目管理
- pageNo : params.page || 1,
- pageSize : 20
- }
- },
- processResults: function (data, params) {
- params.page = params.page || 1;
- return {
- results: data.results,
- pagination: {
- more: (params.page * 20) < data.total
- }
- };
- },
- cache: true
- }
- });
-
- //解绑二级行业select控件初始化
- $('select[name="firstInd"]').live('change',function(){
- $('select[name="secondInd"]').html('<option value=""></option>');
- });
-
- // 二级行业select控件初始化
- var secondIndSelect = $('select[name="secondInd"]').select2({
- placeholder: "请输入二级行业",
- allowClear: true,
- width:'286px',
- ajax:{
- url: _PUBLIC_ +'ad-select/second_category_by_type.do',
- dataType:'json',
- quietMillis:100,
- data:function(params){
- return {
- name : params.term,
- type : 0, //栏目管理,
- parentName : $('#firstInd').val(),
- pageNo : params.page || 1,
- pageSize : 20
- }
- },
- processResults: function (data, params) {
- params.page = params.page || 1;
- return {
- results: data.results,
- pagination: {
- more: (params.page * 20) < data.total
- }
- };
- },
- cache: true
- }
- });
- $('select[name="showEnv"]').select2({
- placeholder: "请选择播出环境",
- allowClear: true,
- width: '286px'
- });
- // 播出媒体
- var mediaNameSelect = $('select[name="mediaName"]').select2({
- placeholder: "请输入播出媒体",
- allowClear: true,
- width:'286px',
- ajax:{
- url: _PUBLIC_ +'ad-media/select/list.do',
- dataType:'json',
- quietMillis:100,
- data:function(params){
- return {
- name : params.term,
- pageNo : params.page || 1,
- pageSize : 20
- }
- },
- processResults: function (data, params) {
- params.page = params.page || 1;
- return {
- results: data.results,
- pagination: {
- more: (params.page * 20) < data.total
- }
- };
- },
- cache: true
- }
- });
-
- $('select[name="type"]').select2({
- placeholder: "请选择类型",
- allowClear: true,
- width: '100px'
- });
- });
- var cur_brand = '',cur_secondInd = '',cur_type = '' , cur_type_name= '';
- function getBrandDetail(){
- // 媒体分布
- getMediaChartsData();
- // 广告分布
- getTVChartsData();
- // 二级行业品牌频次分布
- getSecondIndChartsFrequencyData();
- // 二级行业品牌时长分布
- getSecondIndChartsDurationData();
- // 产品T30排序分布
- getProductRankList();
- // 栏目T30排序分布
- getPlatformRankList();
- // 修改产品名称
- changeTagName();
- }
- // 获取对标对象
- function itemCheck(o){
- var item = $("input[name='item']:checked"), ids = [] , productNameList = [],productTypeList = [];
- if(item.length > 3){
- alert("最多选择三个对标产品。");
- $(o).attr("checked", false);
- $.checkbox();
- return false;
- }
- item.each(function(){
- var type = $(this).attr('data-type');
- var data = $(this).val().split("_");
- ids.push(data[0]);
- productTypeList.push(type);
- productNameList.push(data[1]);
- });
- if(productTypeList.length > 0 && (new Set(productTypeList)).size != 1){
- alert("请选择同是产品或栏目对标分析。");
- $(o).attr("checked", false);
- $.checkbox();
- return false;
- }
- if((new Set(productNameList)).size != productNameList.length){
- alert("已存在,请选择不同的对标产品。");
- $(o).attr("checked", false);
- $.checkbox();
- return false;
- }
- $.cookie.set("benchCheckNum",ids.join(","));
- }
- // 对标
- function setBenchmark(){
- var item = $("input[name='item']:checked"), ids = [], productNameList = [], productTypeList = [];
- if(item.length <= 0){
- alert("请至少选择一个对标的产品。");
- return false;
- }
- if(item.length > 3){
- alert("最多选择三个对标的产品。");
- return false;
- }
- item.each(function(){
- var type = $(this).attr('data-type');
- var data = $(this).val().split("_");
- ids.push(data[0]);
- productTypeList.push(type);
- productNameList.push(data[1]);
- });
- if(productTypeList.length > 0 && (new Set(productTypeList)).size != 1){
- alert("请选择同是产品或栏目对标分析。");
- return false;
- }
- if((new Set(productNameList)).size != productNameList.length){
- alert("已存在,请选择不同的对标产品。");
- return false;
- }
- window.open("benchmarking.do?type="+productTypeList[0]+"&ids="+encodeURIComponent(ids.join("|")),"new");
- }
- /**
- * 切换时间
- */
- function changeTab(day){
- var end_date = '', start_date = '';
- if(day > 0){
- end_date = new Date().addDate(-1).Format("yyyy-MM-dd"),
- start_date = new Date(end_date).addDate(-day).Format("yyyy-MM-dd");
- $('#start_time').val(start_date);
- $('#end_time').val(end_date);
- }else{
- $('#start_time').val('');
- $('#end_time').val('');
- }
- $(".text").input();
- //专题广告电视投放一览
- getBrandAnalysisList(1);
- }
- // 获取选中产品--并显示分析
- function changeBrand(brand,secondInd,type){
- cur_brand = brand;
- cur_secondInd = secondInd;
- cur_type = type;
- cur_type_name = (type == '0' ? "产品" : "栏目");
- getBrandDetail();
- }
- // 一级行业select控件初始化
- var firstIndSelect = $('select[name="firstInd"]').select2({
- placeholder: "请输入一级行业",
- allowClear: true,
- width:'286px',
- ajax:{
- url: _PUBLIC_ +'ad-select/top_category_by_type.do',
- dataType:'json',
- quietMillis:100,
- data:function(params){
- return {
- name : params.term,
- type : 0, //栏目管理
- pageNo : params.page || 1,
- pageSize : 20
- }
- },
- processResults: function (data, params) {
- params.page = params.page || 1;
- return {
- results: data.results,
- pagination: {
- more: (params.page * 20) < data.total
- }
- };
- },
- cache: true
- }
- });
-
- //解绑二级行业select控件初始化
- $('select[name="firstInd"]').live('change',function(){
- $('select[name="secondInd"]').html('<option value=""></option>');
- });
-
- // 二级行业select控件初始化
- var secondIndSelect = $('select[name="secondInd"]').select2({
- placeholder: "请输入二级行业",
- allowClear: true,
- width:'286px',
- ajax:{
- url: _PUBLIC_ +'ad-select/second_category_by_type.do',
- dataType:'json',
- quietMillis:100,
- data:function(params){
- return {
- name : params.term,
- type : 0, //栏目管理,
- parentName : $('#firstInd').val(),
- pageNo : params.page || 1,
- pageSize : 20
- }
- },
- processResults: function (data, params) {
- params.page = params.page || 1;
- return {
- results: data.results,
- pagination: {
- more: (params.page * 20) < data.total
- }
- };
- },
- cache: true
- }
- });
- // 专题广告电视投放一览
- function getBrandAnalysisList(page){
- page = page || 1;
- var pageSize = "20", data = {
- "pageNo": page,
- "pageSize": pageSize,
- "startDate": $("#start_time").val(),
- "endDate": $("#end_time").val(),
- "type": $("#type").val(),
- "keyword": $.trim($("#keyword").val()),
- "mediaName": $("#mediaName").val(),
- "showEnv": $("#showEnv").val(),
- "firstInd":$("#firstInd").val(),
- "secondInd":$("#secondInd").val(),
- }, html = "";
- $("#brand_analysis_page, #brand_analysis_list").empty();
- ajax("ajax_list.do",data,function(res){
- if(res.code == 1 && res.data.records.length > 0){
- $.each(res.data.records, function(index, item){
- if(index == 0){
- cur_brand = item.productName;
- cur_secondInd = item.secondInd;
- cur_type = item.type;
- }
- html += "<tr data-brand='"+item.productName+"' data-second_ind='"+item.secondInd+"' data-type='"+item.type+"'>"+
- "<td>"+$.orderNum(page,pageSize,index)+"</td>"+
- "<td>"+item.mediaName+"</td>"+
- "<td>"+item.showTime+"</td>"+
- "<td>"+item.showDate+"</td>"+
- "<td>"+item.showEnvMsg+"</td>"+
- "<td><a class='blue' href=javascript:void(0); onclick=toTheatreAnalysis('"+item.tvName+"') >"+item.tvName+"</a></td>"+
- "<td>"+item.showDuration+"</td>"+
- "<td>"+item.productName+"</td>"+
- "<td>"+item.brandName+"</td>"+
- "<td>"+item.firstInd+"</td>"+
- "<td>"+item.secondInd+"</td>"+
- "<td>"+item.advMaster+"</td>"+
- "<td>"+item.phone+"</td>"+
- "<td>"+item.price+"</td>"+
- "<td><input type='checkbox' class='checkbox {click:itemCheck}' name='item' "+($.cookie.get("benchCheckNum").indexOf(item.id) != -1 ? 'checked':'')+" value='"+item.id+"_"+item.productName+"' data-type='"+item.type+"' /><label></label></td>"+
- "</tr>";
- });
- $("#brand_analysis_list").html(html);
- $('#brand_analysis_count').html(res.data.total);
- $.radio();
- $.checkbox();
- var newpage = new createPage(res.data.total,page,pageSize,3,"getBrandAnalysisList");
- $("#brand_analysis_page").html(newpage.pageHtml);
- $('#brand_analysis_count').html(res.data.count);
- /**
- * 产品名称点击事件
- */
- $("#brand_analysis_list>tr>td:not(td:last-child)").on("click",function(){
- $(this).closest("tr").addClass("active").siblings().removeClass("active");
- changeBrand($(this).closest("tr").data("brand"),$(this).closest("tr").data("second_ind"),$(this).closest("tr").data("type"));
- });
- $("#brand_analysis_list>tr:eq(0)>td:eq(1)").click();
-
- }else{
- $("#brand_analysis_list").info("暂无数据。");
- $("#frequency_pie,#length_pie").info("暂无数据。", true);
- $("#rating_35,#rating_29").info("暂无数据。", true);
- $("#net_chart,#douban_chart").info("暂无数据。", true);
- $("span[name='brand_tag']").html('“”');
- $("span[name='secondInd_tag']").html('“”');
- $('#brand_analysis_count').html(0);
- // 产品T30排序分布
- getProductRankList();
- // 栏目T30排序分布
- getPlatformRankList();
- }
- });
- }
- // 媒体分布
- function getMediaChartsData(){
- var data = {
- "type" : cur_type,
- "productName": cur_brand,
- "startDate": $("#start_time").val(),
- "endDate": $("#end_time").val()
- };
- ajax("media_dist.do",data,function(res){
- if(res.code == 1 && res.data.length > 0){
-
- var legend= [], series = [],xdata = [],ydata = [];
- var xOther = 0, yOther = 0;
- data1 = res.data.sort(function(a,b){
- return b.duration-a.duration;
- });
- $.each(data1, function(index, item){
- if (index >= 10){
- yOther += item.duration;
- return true;
- }
- legend.push(item.name);
- // 时长
- var lv2 = {
- value: item.duration,
- name : item.name
- };
- ydata.push(lv2);
- });
- data2 = res.data.sort(function(a,b){
- return b.total-a.total;
- });
- $.each(data2, function(index, item){
- if (index >= 10){
- xOther += item.total;
- return true;
- }
- legend.push(item.name);
- // 频次
- var lv1 = {
- value: item.total,
- name : item.name
- };
- xdata.push(lv1);
- });
- // 其它
- if (xOther > 0){
- var temp = {
- value: xOther,
- name : '其它'
- };
- xdata.push(temp);
- }
- if (yOther > 0){
- var temp = {
- value: yOther,
- name : '其它'
- };
- ydata.push(temp);
- }
- drawPie("频次分布",xdata,'frequency_pie');
- drawPie("时长分布",ydata,'length_pie');
- }else{
- $("#frequency_pie,#length_pie").info("暂无数据。", true);
- }
- },false);
- }
- //电视剧分布
- function getTVChartsData(){
- var data = {
- "type" : cur_type,
- "productName": cur_brand,
- "startDate": $("#start_time").val(),
- "endDate": $("#end_time").val()
- };
- ajax("tv_dist.do",data,function(res){
- if(res.code == 1 && res.data.length > 0){
- var legend= [], series = [],xdata = [],ydata = [];
- var xOther = 0, yOther = 0;
- data1 = res.data.sort(function(a,b){
- return b.duration-a.duration;
- });
- $.each(data1, function(index, item){
- if (index >= 10){
- yOther += item.duration;
- return true;
- }
- legend.push(item.name);
- // 时长
- var lv2 = {
- value: item.duration,
- name : item.name
- };
- ydata.push(lv2);
- });
- data2 = res.data.sort(function(a,b){
- return b.total-a.total;
- });
- $.each(data2, function(index, item){
- if (index >= 10){
- xOther += item.total;
- return true;
- }
- legend.push(item.name);
- // 频次
- var lv1 = {
- value: item.total,
- name : item.name
- };
- xdata.push(lv1);
- });
- // 其它
- if (xOther > 0){
- var temp = {
- value: xOther,
- name : '其它'
- };
- xdata.push(temp);
- }
- if (yOther > 0){
- var temp = {
- value: yOther,
- name : '其它'
- };
- ydata.push(temp);
- }
- drawPie("频次分布",xdata,'rating_35');
- drawPie("时长分布",ydata,'rating_29');
- }else{
- $("#rating_35,#rating_29").info("暂无数据。", true);
- }
- },false);
- }
- //二级行业品牌频次分布TOP10
- function getSecondIndChartsFrequencyData(){
- var data = {
- "type" : cur_type,
- "launch": 0, // 频次
- "secondInd": cur_secondInd,
- "startDate": $("#start_time").val(),
- "endDate": $("#end_time").val()
- };
- ajax("second_ind_dist.do",data,function(res){
- if(res.code == 1 && res.data.length > 0){
- var series_frequency = [], xOther = 0;
- $.each(res.data, function(index, item){
- if (index >= 10){
- xOther += item.total;
- return true;
- }
- var lv1 = {
- value: item.total,
- name : item.name
- };
- series_frequency.push(lv1);
- });
- // 其它
- if (xOther > 0){
- var temp = {
- value: xOther,
- name : '其它'
- };
- series_frequency.push(temp);
- }
- drawPie("频次分布",series_frequency,'net_chart');
- }else{
- $("#net_chart").info("暂无数据。", true);
- }
- },false);
- }
- //二级行业品牌时长分布TOP10
- function getSecondIndChartsDurationData(){
- var data = {
- "type" : cur_type,
- "launch": 1, // 时长
- "secondInd": cur_secondInd,
- "startDate": $("#start_time").val(),
- "endDate": $("#end_time").val()
- };
- ajax("second_ind_dist.do",data,function(res){
- if(res.code == 1 && res.data.length > 0){
- var series_length = [], xOther = 0;
- $.each(res.data, function(index, item){
- if (index >= 10){
- xOther += item.duration;
- return true;
- }
- var lv2 = {
- value:item.duration,
- name:item.name
- };
- series_length.push(lv2);
- });
- // 其它
- if (xOther > 0){
- var temp = {
- value: xOther,
- name : '其它'
- };
- series_length.push(temp);
- }
- drawPie("时长分布",series_length,'douban_chart');
- }else{
- $("#douban_chart").info("暂无数据。", true);
- }
- },false);
- }
- /**
- * 产品专题广告投放排名
- */
- function getProductRankList(){
- var data = {
- "type" : 0,
- "startDate": $("#start_time").val(),
- "endDate": $("#end_time").val()
- },html="";
- ajax("product_rank.do",data,function(res){
- if(res.code == 1 && res.data){
- if(res.data.length > 0){
- $.each(res.data, function(index, item){
- html += "<tr class='"+(cur_brand == item.productName && cur_secondInd == item.secondInd ? 'trHover':'')+"'>"+
- "<td>"+(index+1)+"</td>"+
- "<td>"+item.productName+"</td>"+
- "<td>"+item.secondInd+"</td>"+
- "<td>"+item.frequency+"</td>"+
- "<td>"+item.duration+"</td>"+
- "</tr>";
- });
- $("#program_rank_list").html(html);
- }else{
- $("#program_rank_list").info("暂无数据。");
- }
- }
- },false);
- }
- /**
- * 栏目专题广告投放排名
- */
- function getPlatformRankList(){
- var data = {
- "type" : 1,
- "startDate": $("#start_time").val(),
- "endDate": $("#end_time").val()
- },html="";
- ajax("product_rank.do",data,function(res){
- if(res.code == 1 && res.data){
- if(res.data.length > 0){
- $.each(res.data, function(index, item){
- html += "<tr class='"+(cur_brand == item.productName && cur_secondInd == item.secondInd ? 'trHover':'')+"'>"+
- "<td>"+(index+1)+"</td>"+
- "<td>"+item.productName+"</td>"+
- "<td>"+item.secondInd+"</td>"+
- "<td>"+item.frequency+"</td>"+
- "<td>"+item.duration+"</td>"+
- "</tr>";
- });
- $("#brand_rank_list").html(html);
- }else{
- $("#brand_rank_list").info("暂无数据。");
- }
- }
- },false);
- }
- // 扇形图显示
- function drawPie(title,series, divId){
- option = {
- tooltip: {
- trigger: 'item',
- formatter: '{a} <br/>{b} : {c} ({d}%)'
- },
- series: [
- {
- color: ['#1890FF','#F6BD16','#E8684A','#6DC8EC','#9270CA','#FF9D4D','#269A99','#73A0FA','#5AD8A6','#5D7092','#6DC8EC','#9270CA','#FF9D4D','#269A99'],
- name:title,
- type: 'pie',
- radius: '75%',
- center: ['50%', '50%'],
- data: series,
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- }
- }
- ]
- };
- var myChart = echarts.init(document.getElementById(divId));
- document.getElementById(divId).setAttribute('_echarts_instance_', '')
- myChart.clear();
- myChart.setOption(option);
- }
- // 修改产品名称
- function changeTagName(){
- $("span[name='type_tag']").html(cur_type_name);
- $("span[name='brand_tag']").html('“'+cur_brand+'”');
- $("span[name='secondInd_tag']").html('“'+cur_secondInd+'”');
- }
|