common.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. var ac_filename = window.location.pathname;
  2. ac_filename = ac_filename.split('/').pop();
  3. ac_filename = ac_filename && ac_filename!='index' ? '_'+ac_filename : '';
  4. var ac_val = parseInt($.fn.cookie('ac_val')) || 0;
  5. var camp_ac_val = parseInt($.fn.cookie('camp_ac_val')) || 0;
  6. var sub_pop_num = parseInt($.fn.cookie('sub_pop_num')) || 0;
  7. $(function () {
  8. //返回
  9. $('.head_return_page_but').click(function () {
  10. window.history.go(-1);
  11. });
  12. //菜单
  13. $('.pop_up_menu_box > i, .head_menu_but').click(function () {
  14. $('.head_menu_but').toggleClass('head_menu_but_open');
  15. $('.pop_up_menu_box').toggleClass('pop_up_menu_show');
  16. });
  17. //关闭弹框
  18. $('.christmas_body .christmas_close_2,.christmas_body .christmas_main_but').click(function(){
  19. ac_val += 1;
  20. $('.christmas_popup_box').remove();
  21. $.fn.cookie('ac_val',ac_val,{expires: 0.33, path: '/'});
  22. });
  23. $(".camp_close_btn").click(function () {
  24. camp_ac_val += 1;
  25. $('.camp_popup_box').show();
  26. $.fn.cookie('camp_ac_val',camp_ac_val,{expires: 0.33, path: '/'});
  27. });
  28. //活动弹框次数
  29. var ac_type = $('.christmas_popup_box').data('type');
  30. if(ac_val >= 4 || ac_type != 1){
  31. $('.christmas_popup_box').remove();
  32. }else{
  33. ac_val += 1;
  34. $('.christmas_popup_box').show();
  35. $.fn.cookie('ac_val',ac_val,{expires: 0.33, path: '/'});
  36. }
  37. $(".read_popup_box a").click(function () {
  38. cpslog([702, {map:{pop_url:$('.read_popup_box .rpb_img a').attr('href')}}, 'read_click'])
  39. //写cookie 有效期1小时
  40. $.fn.cookie('close_continue_tips',1,{expires: 0.33, path: '/'});
  41. $('.read_popup_box').remove();
  42. if (!$(this).hasClass("rpbm_close_but")) {
  43. window.location.href=$(this).attr('href');
  44. }
  45. });
  46. $(".custom_popup_box a").click(function () {
  47. cpslog([702, {map:{pop_url:$('.custom_popup_box .rpb_img a').attr('href')}}, 'custom_click'])
  48. //写cookie 有效Ø期2.5天
  49. var sourceId = $(".custom_popup_box").data('resouce_id');
  50. $.fn.cookie('close_custom_tips_'+sourceId,1,{expires: 2.5, path: '/'});
  51. //关闭
  52. $('.custom_popup_box').remove();
  53. if (!$(this).hasClass("rpbm_close_but")) {
  54. window.location.href=$(this).attr('href');
  55. }
  56. });
  57. if ($('.custom_popup_box').length) {
  58. cpslog([701, {map:{pop_url:$('.custom_popup_box .rpb_img a').attr('href')}}])
  59. }
  60. if ($('.read_popup_box').length) {
  61. cpslog([701, {map:{pop_url:$('.read_popup_box .rpb_img a').attr('href')}}])
  62. }
  63. //消耗活动
  64. if ($('.camp_popup_box').length) {
  65. var camp_ac_type = $('.camp_popup_box').data('type');
  66. if(camp_ac_val >= 4 || camp_ac_type != 1){
  67. $('.camp_popup_box').remove();
  68. }else{
  69. camp_ac_val += 1;
  70. $('.camp_popup_box').show();
  71. $.fn.cookie('camp_ac_val',camp_ac_val,{expires: 0.33, path: '/'});
  72. }
  73. $(".camp_popup_box a").click(function () {
  74. camp_ac_val += 1;
  75. cpslog([702, {map:{pop_url:$('.camp_popup_box .christmas_main_but').attr('href')}}, 'camp_click'])
  76. //写cookie 有效Ø期0.33天
  77. $.fn.cookie('camp_ac_val',camp_ac_val,{expires: 0.33, path: '/'});
  78. //关闭
  79. $('.camp_popup_box').remove();
  80. if (!$(this).hasClass("christmas_close_2")) {
  81. window.location.href=$(this).attr('href');
  82. }
  83. });
  84. cpslog([701, {map:{pop_url:$('.camp_popup_box .christmas_main_but').attr('href')}}]);
  85. }
  86. //消耗活动首页banner
  87. if( $('#banner_campaign').length){
  88. $('#banner_campaign').click(function(){
  89. cpslog([702, {map:{banner_url:$('#banner_campaign a').attr('href')}}, 'banner_camp_click']);
  90. })
  91. cpslog([701, {map:{banner_url:$('#banner_campaign a').attr('href')}}]);
  92. }
  93. //卡片活动banner
  94. if( $('#card_banner').length){
  95. console.log(111);
  96. $('#card_banner').click(function(){
  97. cpslog([702, {map:{banner_url:$('#card_banner a').attr('href')}}, 'banner_card_flip_click']);
  98. })
  99. cpslog([701, {map:{banner_url:$('#card_banner a').attr('href')}}]);
  100. }
  101. //读书订阅活动
  102. if ($('.sub_pop').length){
  103. $('.sub_close_btn').click(function () {
  104. sub_pop_num++;
  105. $('.sub_pop').hide();
  106. $.fn.cookie('sub_pop_num',sub_pop_num,{expires: 0.33, path: '/'});
  107. })
  108. cpslog([701, {map:{pop_url:$('.sub_pop .christmas_main_but').attr('href')}}]);
  109. }
  110. });
  111. var commont = {
  112. /**
  113. * 切割参数
  114. * @param sname string 要获取的参数
  115. * @param str string 被切割的字符
  116. * @param smark string 用于切割字符
  117. * @returns {string}
  118. */
  119. getQueryString: function (sname, str, smark) {
  120. str = str ? str : window.location.search;
  121. smark = smark ? smark : '&';
  122. if (sname) {
  123. var c_start = str.indexOf(sname + "=");
  124. if (c_start != -1) {
  125. c_start = c_start + sname.length + 1;
  126. var c_end = str.indexOf(smark, c_start);
  127. if (c_end == -1) c_end = str.length;
  128. return decodeURIComponent(str.substring(c_start, c_end));
  129. }
  130. }
  131. return "";
  132. }
  133. };