special_analysis.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. var cur_brand = '',cur_type = 1,program_arr = [],brand_arr = [];
  2. function getBrandDetail(){
  3. getPlacementDetailList(1);
  4. getPieData(cur_type);
  5. getRatingCharts(cur_type);
  6. getNetChart(cur_type,'');
  7. getDoubanChart(cur_type);
  8. getRankList(cur_type);
  9. changeTagName();
  10. }
  11. function itemCheck(o){
  12. var item = $("input[name='item']:checked"), ids = [];
  13. item.each(function(){
  14. ids.push($(this).val());
  15. });
  16. if(item.length > 2){
  17. alert("请选择两个对标的品牌。");
  18. $(o).attr("checked", false);
  19. $.checkbox();
  20. return false;
  21. }
  22. $.cookie.set("benchCheckNum",ids.join(","));
  23. }
  24. function setBenchmark(){
  25. var item = $("input[name='item']:checked"), ids = [];
  26. if(item.length <= 0){
  27. alert("请至少选择一个对标的品牌。");
  28. return false;
  29. }
  30. if(item.length > 2){
  31. alert("请选择两个对标的品牌。");
  32. return false;
  33. }
  34. item.each(function(){
  35. ids.push($(this).val());
  36. });
  37. window.open("benchmarking.do?ids="+encodeURIComponent(ids.join("|")),"new");
  38. }
  39. /**
  40. * 切换时间
  41. */
  42. function changeTab(day){
  43. var end_date = '', start_date = '';
  44. if(day > 0){
  45. end_date = new Date().addDate(-1).Format("yyyy-MM-dd"),
  46. start_date = new Date(end_date).addDate(-day).Format("yyyy-MM-dd");
  47. $('#start_time').val(start_date);
  48. $('#end_time').val(end_date);
  49. }else{
  50. $('#start_time').val('');
  51. $('#end_time').val('');
  52. }
  53. $(".text").input();
  54. getBrandAnalysisList(1);
  55. /*getPlacementDetailList(1);
  56. getPieData(cur_type);
  57. getRatingCharts(cur_type);
  58. getNetChart(cur_type,'');
  59. getDoubanChart(cur_type);
  60. getRankList(cur_type);
  61. changeTagName();*/
  62. }
  63. function changeType(type){
  64. if(type == 4){
  65. $('#tv_title').hide();
  66. $('#tv_div').hide();
  67. }else{
  68. $('#tv_title').show();
  69. $('#tv_div').show();
  70. }
  71. cur_type = type;
  72. getBrandDetail();
  73. changeTagName();
  74. }
  75. function changeBrand(brand){
  76. cur_brand = brand;
  77. getBrandDetail();
  78. }
  79. function getBrandAnalysisList(page){
  80. page = page || 1;
  81. var pageSize = "10", data = {
  82. "pageNo": page,
  83. "pageSize": pageSize,
  84. "keyword": $("#keyword").val(),
  85. "type": $("#type").val(),
  86. "second_ind":$("#second_ind").val(),
  87. "beginDate": $("#start_time").val(),
  88. "endDate": $("#end_time").val()
  89. }, html = "";
  90. $("#brand_analysis_page, #brand_analysis_list").empty();
  91. ajax("ajax_special_analysis_list.do",data,function(res){
  92. if(res.code == 1 && res.data.records.length > 0){
  93. $.each(res.data.records, function(index, item){
  94. if(index == 0){
  95. cur_brand = item.brand;
  96. }
  97. html += "<tr data-brand='"+item.brand+"'>"+
  98. "<td>"+$.orderNum(page,pageSize,index)+"</td>"+
  99. "<td>"+item.mediaName+"</td>"+
  100. "<td>"+item.showTime+"</td>"+
  101. "<td>"+item.showDate+"</td>"+
  102. "<td>"+item.showEnv+"</td>"+
  103. "<td>"+item.tvName+"</td>"+
  104. "<td>"+item.showDuration+"</td>"+
  105. "<td>"+item.productName+"</td>"+
  106. "<td>"+item.brandName+"</td>"+
  107. "<td>"+item.firstInd+"</td>"+
  108. "<td>"+item.secondInd+"</td>"+
  109. "<td>"+item.advMaster+"</td>"+
  110. "<td>"+item.phone+"</td>"+
  111. "<td>"+item.price+"</td>"+
  112. "<td><input type='checkbox' class='checkbox {click:itemCheck}' name='item' "+($.cookie.get("benchCheckNum").indexOf(item.brand) != -1 ? 'checked':'')+" value='"+item.brand+"' /><label></label></td>"+
  113. "</tr>";
  114. });
  115. $("#brand_analysis_list").html(html);
  116. $.radio();
  117. $.checkbox();
  118. var newpage = new createPage(res.data.total,page,pageSize,3,"brandAnalysisPageGo");
  119. $("#brand_analysis_page").html(newpage.pageHtml);
  120. $('#brand_analysis_count').html(res.data.count);
  121. /**
  122. * 点击事件
  123. */
  124. $("#brand_analysis_list>tr>td:not(td:last-child)").on("click",function(){
  125. $(this).closest("tr").addClass("active").siblings().removeClass("active");
  126. changeBrand($(this).closest("tr").data("brand"));
  127. });
  128. $("#brand_analysis_list>tr:eq(0)>td:eq(1)").click();
  129. }else{
  130. $("#brand_analysis_list").info("暂无数据。");
  131. $('#brand_analysis_count').html(0);
  132. }
  133. });
  134. }
  135. brandAnalysisPageGo = getBrandAnalysisList;
  136. function getPlacementDetailList(page){
  137. page = page || 1;
  138. var pageSize = "10",keyword = $("#keyword").val(),beginDate = $("#start_time").val(),
  139. endDate = $("#end_time").val(),data = {
  140. "type": $("#type").val(),
  141. "pageNo": page,
  142. "pageSize": pageSize,
  143. "keyword": keyword,
  144. "beginDate": beginDate,
  145. "endDate": endDate
  146. }, html = "";
  147. $("#placement_detail_page, #placement_detail_list").empty();
  148. ajax("ajax_placement_detail_list.do",data,function(res){
  149. if(res.code == 1 && res.list.length > 0){
  150. $.each(res.list, function(index, item){
  151. //广告形式,1节目冠名2特约播映3互动支持4合作伙伴5指定产品6指定用车7其他
  152. var f = ['','冠名','特约','互动支持','合作伙伴','指定产品','指定用车','其他'];
  153. var forms = item.form ? item.form.split(",") : [] ,t_tmp = [];
  154. for(var i in forms){
  155. t_tmp.push(f[ forms[i] ]);
  156. }
  157. var platforms = item.platform ? item.platform.split(",") : [];
  158. platforms = unique(platforms);
  159. html += "<tr data-id='"+item.id+"'>"+
  160. "<td>"+$.orderNum(page,pageSize,index)+"</td>"+
  161. "<td>"+item.brand+"</td>"+
  162. "<td>"+(item.advertiser ? item.advertiser : '-')+"</td>"+
  163. "<td>"+(item.second_ind ? item.second_ind : '-')+"</td>"+
  164. "<td>"+(item.first_ind ? item.first_ind : '-')+"</td>"+
  165. "<td>"+item.program_name+"</td>"+
  166. "<td>"+(item.show_time ? item.show_time : '-')+"</td>"+
  167. "<td>"+ ((item.type == 1 || item.type == 2) ? "第" + item.show_phase +"期" : (item.episode ? "第"+ item.episode+"集" : '-'))+"</td>"+
  168. "<td>"+(platforms?platforms.join(','):'-')+"</td>"+
  169. "<td>"+(item.net_platform ? (item.net_platform.split(',').length > 2 ? '全网' : item.net_platform) : '-')+"</td>"+
  170. "<td>"+t_tmp.join(',')+"</td>"+
  171. "<td><span class='orange'>"+item.total+"</span></td>"+
  172. "<td>"+item.sum_frequency+"</td>"+
  173. "<td>"+item.sum_length+"</td>"+
  174. "<td>"+item.price+"</td>"+
  175. "</tr>";
  176. });
  177. $("#placement_detail_list").html(html);
  178. var newpage = new createPage(res.count,page,pageSize,3,"placementDetailPageGo");
  179. $("#placement_detail_page").html(newpage.pageHtml);
  180. $('#placement_detail_count').html(res.count);
  181. /**
  182. * 点击事件
  183. */
  184. $("#placement_detail_list>tr>td").on("click",function(){
  185. $(this).closest("tr").addClass("active").siblings().removeClass("active");
  186. var url = 'open_show_analyse.do?id='+$(this).closest("tr").data("id");
  187. url += '&name='+name;
  188. url += '&beginDate='+beginDate;
  189. url += '&endDate='+endDate;
  190. $.openWindow('',url, 960, 610, true, null, 'auto');
  191. });
  192. }else{
  193. $("#placement_detail_list").info("暂无数据。");
  194. $('#placement_detail_count').html(0);
  195. }
  196. });
  197. }
  198. placementDetailPageGo = getPlacementDetailList;
  199. function getPieData(type){
  200. var data = {
  201. "type" : type,
  202. "brand": cur_brand,
  203. "name": $("#keyword").val(),
  204. "beginDate": $("#start_time").val(),
  205. "endDate": $("#end_time").val()
  206. };
  207. program_arr = [];
  208. ajax("list_program_placement4Brand.do",data,function(res){
  209. if(res.code == 1 && res.list.length > 0){
  210. var legend = [];
  211. var series_frequency = [];
  212. var series_length = [];
  213. $.each(res.list, function(index, item){
  214. var program = "《"+item.program_name+"》" + ((type == 1 || type == 2) ? ("-" + (res.adMode[item.form-1] != undefined ? res.adMode[item.form-1].val : "")) : '');
  215. legend.push(program);
  216. program_arr.push(item.program_name);
  217. var lv1 = {
  218. value:item.frequency,
  219. name:program
  220. };
  221. series_frequency.push(lv1);
  222. var lv2 = {
  223. value:item.length,
  224. name:program
  225. };
  226. series_length.push(lv2);
  227. if(index > 13){
  228. return false;
  229. }
  230. });
  231. trend_pie("频次分布",legend,series_frequency,'frequency_pie');
  232. trend_pie("时长分布",legend,series_length,'length_pie');
  233. }else{
  234. $("#frequency_pie,#length_pie").info("暂无数据。", true);
  235. }
  236. },false);
  237. }
  238. function getRatingCharts(type){
  239. getRatingChart(type,1,1);
  240. getRatingChart(type,2,1);
  241. }
  242. function getRatingRatio(obj){
  243. getRatingChart(cur_type,1,$(obj).val())
  244. }
  245. function getRatingRatio2(obj){
  246. getRatingChart(cur_type,2,$(obj).val())
  247. }
  248. /**
  249. * 电视频道品牌软广植入受众人群一览
  250. * @param type 1综艺 2栏目 3电视剧 4电影
  251. * @param rateType 1:35城 2:29城
  252. * @param ratioValue 1:4岁以上 2:A18-45 3:F18-45
  253. */
  254. function getRatingChart(type,rateType,ratioValue){
  255. var data = {
  256. "type" : type,
  257. "rateType" : rateType,
  258. "brand": cur_brand,
  259. "name": $("#keyword").val(),
  260. "beginDate": $("#start_time").val(),
  261. "endDate": $("#end_time").val()
  262. };
  263. ajax("list_program_rating4Brand.do",data,function(res){
  264. if(res.code == 1 && res.list.length > 0){
  265. var legend = ['收视率(%)','到达率(000)'],xdata = [],ydata = [],ys = [];
  266. if(type == 3){
  267. $('#rating_ratio_div_1').hide();
  268. $('#rating_ratio_div_2').hide();
  269. }else{
  270. $('#rating_ratio_div_1').show();
  271. $('#rating_ratio_div_2').show();
  272. }
  273. $.each(res.list, function(index, item){
  274. var program = "《"+item.program_name+"》" + ((type == 1 || type == 2) ? ("-" + (res.adMode[item.form-1] != undefined ? res.adMode[item.form-1].val : "")) : '');
  275. xdata.push(program);
  276. if(ratioValue == 2){
  277. ydata.push(item.audience_rating_20_45);
  278. ys.push(item.avg_num_20_45);
  279. }else if(ratioValue == 3){
  280. ydata.push(item.audience_rating_18_45_woman);
  281. ys.push(item.avg_num_18_45_woman);
  282. }else if(ratioValue == 4){
  283. ydata.push(item.audience_rating_18_30_woman);
  284. ys.push(item.avg_num_18_30_woman);
  285. }else if(ratioValue == 5){
  286. ydata.push(item.audience_rating_20_45_man);
  287. ys.push(item.avg_num_20_45_man);
  288. }else{
  289. ydata.push(item.audience_rating_4);
  290. ys.push(item.avg_num_4);
  291. }
  292. if(index > 8){
  293. return false;
  294. }
  295. });
  296. trendBarWithLine(legend,xdata,ydata,ys,(rateType==1?'rating_35':'rating_29'));
  297. }else{
  298. $("#"+(rateType==1?'rating_35':'rating_29')).info("暂无数据。",true);
  299. }
  300. },false);
  301. }
  302. /**
  303. * 网络综艺节目植入效果一览
  304. */
  305. function getNetChart(type,platform){
  306. var data = {
  307. "platform":platform,
  308. "type" : type,
  309. "brand": cur_brand,
  310. "name": $("#keyword").val(),
  311. "beginDate": $("#start_time").val(),
  312. "endDate": $("#end_time").val()
  313. };
  314. ajax("list_program_net_data4Brand.do",data,function(res){
  315. if(res.code == 1 && res.list.length > 0){
  316. var legend = ['点击率(千万)','网站评分(分)'],xdata = [],ydata = [],ys = [],platforms = [],html = "";
  317. $.each(res.list, function(index, item){
  318. var program = "《"+item.program_name+"》" + ((type == 1 || type == 2) ? ("-" + (res.adMode[item.form-1] != undefined ? res.adMode[item.form-1].val : "")) : '');
  319. xdata.push(program);
  320. platforms.push(item.platform_name);
  321. xdata = unique(xdata);
  322. if(xdata.length > 9){
  323. return false;
  324. }
  325. });
  326. // xdata = unique(xdata);
  327. $.each(res.list, function(index, item){
  328. var program = "《"+item.program_name+"》" + ((type == 1 || type == 2) ? ("-" + (res.adMode[item.form-1] != undefined ? res.adMode[item.form-1].val : "")) : '');
  329. for(var i in xdata){
  330. if(xdata[i] == program){
  331. ydata[i] = ((ydata[i] ? ydata[i] : 0)*100 + item.click_times*100) / 100;
  332. ys[i] = item.score || "";
  333. }
  334. }
  335. //ydata.push(item.click_times);
  336. //ys.push(item.score);
  337. });
  338. if(platform == ''){
  339. html += '<input type="radio" name="net_ratio" class="radio {click:clickNetRatio}" value="" checked/><label>综合</label>&nbsp;&nbsp;&nbsp;&nbsp;';
  340. platforms = unique(platforms);
  341. for(var i in platforms){
  342. html += "<input type='radio' name='net_ratio' class='radio {click:clickNetRatio}' value='"+platforms[i]+"' /><label>"+platforms[i]+"</label>&nbsp;&nbsp;&nbsp;&nbsp;";
  343. }
  344. $('#platform_ratios').html(html).attr("align","center");
  345. }
  346. trendBarWithLine(legend,xdata,ydata,ys,'net_chart');
  347. }else{
  348. $("#net_chart").info("暂无数据。",true);
  349. }
  350. $.radio();
  351. },false);
  352. }
  353. function clickNetRatio(obj){
  354. getNetChart(cur_type,$(obj).val());
  355. }
  356. /**
  357. * 植入综艺豆瓣网评价
  358. */
  359. function getDoubanChart(type){
  360. var data = {
  361. "type" : type,
  362. "brand": cur_brand,
  363. "name": $("#keyword").val(),
  364. "beginDate": $("#start_time").val(),
  365. "endDate": $("#end_time").val()
  366. };
  367. ajax("list_program_douban_data4Brand.do",data,function(res){
  368. if(res.code == 1 && res.list.length > 0){
  369. var legend = ['评论人数(万)','豆瓣评分(分)'],xdata = [],ydata = [],ys = [];
  370. $.each(res.list, function(index, item){
  371. var program = "《" +item.program_name+"》" + ((type == 1 || type == 2) ? ("-" + (res.adMode[item.form-1] != undefined ? res.adMode[item.form-1].val : "")) : '');
  372. xdata.push(program);
  373. ydata.push(item.comment_count);
  374. ys.push(item.score);
  375. if(index > 8) {
  376. return false;
  377. }
  378. });
  379. trendBarWithLine(legend,xdata,ydata,ys,'douban_chart');
  380. }else{
  381. $("#douban_chart").info("暂无数据。",true);
  382. }
  383. },false);
  384. }
  385. /**
  386. * 产品专题广告投放排名
  387. */
  388. function getRankList(type){
  389. var data = {
  390. "type" : type,
  391. "name": $("#keyword").val(),
  392. "beginDate": $("#start_time").val(),
  393. "endDate": $("#end_time").val()
  394. },html="";
  395. ajax("list_special_product_rank.do",data,function(res){
  396. if(res.code == 1 && res.data){
  397. if(res.data.programRankList.length > 0){
  398. var list = sortProgramRankList(res.data.programRankList,program_arr);
  399. $.each(list, function(index, item){
  400. html += "<tr class='"+(isInArray2(program_arr, item.program_name) ? 'trHover':'')+"'>"+
  401. "<td>"+item.rank+"</td>"+
  402. "<td>"+item.program_name+"</td>"+
  403. "<td>"+item.frequency+"</td>"+
  404. "<td>"+item.length+"</td>"+
  405. "</tr>";
  406. });
  407. $("#program_rank_list").html(html);
  408. }else{
  409. $("#program_rank_list").info("暂无数据。");
  410. }
  411. if(res.data.brandRankList.length > 0){
  412. var list2 = sortBrandRankList(res.data.brandRankList);
  413. html = '';
  414. $.each(list2, function(index, item){
  415. html += "<tr class='"+(cur_brand == item.brand ? 'trHover':'')+"'>"+
  416. "<td>"+item.rank+"</td>"+
  417. "<td>"+item.brand+"</td>"+
  418. "<td>"+item.frequency+"</td>"+
  419. "<td>"+item.length+"</td>"+
  420. "</tr>";
  421. });
  422. $("#brand_rank_list").html(html);
  423. }else{
  424. $("#brand_rank_list").info("暂无数据。");
  425. }
  426. }else{
  427. $("#program_rank_list, #brand_rank_list").info("暂无数据。");
  428. }
  429. },false);
  430. }
  431. /**
  432. * 查询品牌植入排名
  433. * @param oldList 传入全部数组
  434. * @param curArray
  435. * @returns {Array} 返回排名数组
  436. */
  437. function sortProgramRankList(oldList,curArray){
  438. var newList = new Array(),top = 0;
  439. for(var i = 0; i < oldList.length ; i++){
  440. if(oldList[i].program_name == curArray[0]){
  441. top = oldList[i].rank;
  442. break;
  443. }
  444. }
  445. var start = (top - 9 > 0) ? top - 9 : 1;
  446. var end = (start + 19 > oldList.length) ? oldList.length : start + 19;
  447. if(end - start + 1 < 20){
  448. start = start - (20 - 1 - end + start);
  449. }
  450. for(var i = 0,j = 0;i < oldList.length; i++){
  451. if(oldList[i].rank >= start && oldList[i].rank <= end){
  452. newList[j] = oldList[i];
  453. j ++;
  454. }
  455. }
  456. return newList;
  457. }
  458. function sortBrandRankList(oldList){
  459. var newList = new Array(),top = 0;
  460. for(var i = 0; i < oldList.length ; i++){
  461. if(oldList[i].brand == cur_brand){
  462. top = oldList[i].rank;
  463. break;
  464. }
  465. }
  466. var start = (top - 9 > 0) ? top - 9 : 1;
  467. var end = (start + 19 > oldList.length) ? oldList.length : start + 19;
  468. if(end - start + 1 < 20){
  469. start = start - (20 - 1 - end + start);
  470. }
  471. for(var i = 0,j = 0;i < oldList.length; i++){
  472. if(oldList[i].rank >= start && oldList[i].rank <= end){
  473. newList[j] = oldList[i];
  474. j ++;
  475. }
  476. }
  477. return newList;
  478. }
  479. function changeTagName(){
  480. $("span[name='brand_tag']").html("《"+cur_brand+"》");
  481. $("span[name='type_tag']").html(cur_type.toString().decode(1,"综艺节目",2,"栏目",3,"电视剧",4,"电影",""));
  482. $("span[name='tv_tag']").html(cur_type.toString().decode(1,"电视综艺",2,"电视栏目",3,"电视剧",4,"植入电影",""));
  483. $("span[name='net_title1']").html(cur_type.toString().decode(1,"网络综艺节目植入效果一览",2,"网络栏目植入效果一览",3,"电视剧软植效果一览",4,"植入电影点击率一览",""));
  484. $("span[name='net_title2']").html(cur_type.toString().decode(1,"植入综艺豆瓣网评价",2,"植入栏目豆瓣网评价",3,"电视剧软植豆瓣评价",4,"植入电影豆瓣评分一览",""));
  485. }