浏览代码

feat: pc首页新增底部悬浮广告位

cuiyalong 1 年之前
父节点
当前提交
9fe7b41edd
共有 2 个文件被更改,包括 64 次插入0 次删除
  1. 2 0
      src/web/templates/pc/newIndex.html
  2. 62 0
      src/web/templates/pc/template/index/index-bottom-float-ad.html

+ 2 - 0
src/web/templates/pc/newIndex.html

@@ -220,6 +220,8 @@
   <script type="text/javascript" src='{{Msg "seo" "cdn"}}/js/index/index_swiper.js?v={{Msg "seo" "version"}}'></script>
   <!-- 活动弹窗 -->
   {{include "/pc/template/index/activity-dialog.html"}}
+  <!-- 新增底部悬浮广告位 -->
+  {{include "/pc/template/index/index-bottom-float-ad.html"}}
   <!-- 新用户弹窗 -->
   <!-- include "/common/pc_ad_dialog.html" -->
   <script type="text/javascript" src='{{Msg "seo" "cdn"}}/js/index/index_2023.12.js?v={{Msg "seo" "version"}}'></script>

+ 62 - 0
src/web/templates/pc/template/index/index-bottom-float-ad.html

@@ -0,0 +1,62 @@
+<div class="pc-index-bottom">
+  <img class="bottom-member-ad" adv_name="PC首页广告位-底部" src="" alt="底部广告位">
+</div>
+
+<script>
+  $(function () {
+    // 首页底部广告位
+    {{$bottom:=(Ad "jy_pc_index_bottom" -1 .Host)}}
+    var bottom_img = ({{$bottom}})
+
+    // 首页底部样式调整,适配广告位
+    function fixBottomADHeight (type) {
+      var adHeight = $('.pc-index-bottom').height()
+      if (type) {
+        $(".jy_renzheng").css('padding-bottom', adHeight)
+        $(".j-bottom").attr('data-padding-bottom', Number($(".j-bottom").css('padding-bottom').replace('px', '')))
+        $(".j-bottom").css('padding-bottom', Number($(".j-bottom").css('padding-bottom').replace('px', '')) + adHeight)
+      } else {
+        $(".jy_renzheng").css('padding-bottom', 0)
+        $(".j-bottom").css('padding-bottom', Number($(".j-bottom").attr('data-padding-bottom')))
+      }
+    }
+    $('.pc-index-bottom .bottom-member-ad').on('load', function () {
+      fixBottomADHeight(true)
+    })
+    $('.pc-index-bottom .bottom-member-ad').attr('src', bottom_img[0].s_pic)
+    $('.pc-index-bottom .bottom-member-ad').unbind('click').click(function () {
+      window.open(bottom_img[0].s_link)
+    })
+
+
+    clearInterval(memberTimer)
+    var memberTimer = setInterval(function () {
+      if (window.memberStatus >= 0) {
+        clearInterval(memberTimer)
+      }
+      adBottomFn()
+    }, 2000)
+    function adBottomFn () {
+      if (window.memberStatus > 0) {
+        $('.pc-index-bottom').hide()
+        fixBottomADHeight(false)
+      } else {
+        var top1 = 0;
+        var top2 = 0;
+        var timer = null; 
+        $(document).scroll(function(){
+          clearTimeout(timer)
+          timer = setTimeout(isScrollEnd, 1000);
+          top1 = document.documentElement.scrollTop || document.body.scrollTop;
+          $('.pc-index-bottom').fadeOut()
+        })
+        function isScrollEnd() {
+          top2 = document.documentElement.scrollTop || document.body.scrollTop;
+          if(top1 == top2 && (window.memberStatus <= 0 || !window.memberStatus)){
+            $('.pc-index-bottom').fadeIn()
+          }
+        }
+      }
+    }
+  })
+</script>