Kaynağa Gözat

調整首頁

SyuanYu 10 ay önce
ebeveyn
işleme
7b91ff97e4
3 değiştirilmiş dosya ile 445 ekleme ve 18 silme
  1. 206 12
      hhh_index.html
  2. 238 5
      js/index.js
  3. 1 1
      template/footer.html

+ 206 - 12
hhh_index.html

@@ -1312,8 +1312,21 @@
     </div>
   </section> -->
 
-  <!-- 動態載入 -->
-   <div id="topCarousel"></div>
+  <!-- 上方輪播 -->
+  <div id="topCarousel">
+    <section class="w-100 position-relative top-carousel">
+      <button class="text-center d-none d-lg-block close-btn">
+        <i class="fas fa-chevron-up" style="transform: translateY(-2px)"></i>
+        <p>隱藏</p>
+      </button>
+      <div class="container-fluid mx-auto" style="max-width: 1300px">
+        <div class="slider-content"></div>
+        <!-- 輪播進度條 -->
+        <div class="bullet-list"></div>
+      </div>
+    </section>
+  </div>
+
   <div id="navbar">
     <nav class="navbar navbar-expand-lg navbar-light bg-light p-2 p-lg-0">
       <div class="container-fluid flex-row-reverse flex-lg-row">
@@ -1898,13 +1911,6 @@
         </div>
       </div>
     </nav>
-
-
-
-
-
-
-
   </div>
 
   <!-- searchModal -->
@@ -2204,9 +2210,197 @@
     </div>
   </div>
 
-  <!-- 動態載入 -->
-  <div id="btn-box"></div>
-  <div id="footer"></div>
+  <!-- 右下角按鈕區塊 -->
+  <div id="btn-box">
+    <button data-gt-target="#top" data-gt-duration="100" data-gt-offset="0" class="gotop-btn" title="GoTop">
+      <!-- <span class="top_img"></span> -->
+      <img src="https://hhh.com.tw/hhh_index/images/icon/feather-chevron-right.svg" alt="">
+    </button>
+
+    <button title="裝修預算諮詢" class="d-none d-md-inline calculator-btn" data-ga="Go_To_Calculator">
+      <a href="https://hhh.com.tw/calculator_request/index.html" target="_blank">
+        <img src="https://hhh.com.tw/hhh_index/images/icon/ionic-ios-calculator.svg" alt=""
+          style="width: 22px; margin-left: 3px;">
+        <p>裝修計算機</p>
+      </a>
+    </button>
+
+    <button title="+好物商城" class="d-none d-md-inline shop-btn" data-ga="Go_To_Shop">
+      <a href="https://shop.hhh.com.tw/" target="_blank">
+        <img src="https://hhh.com.tw/hhh_index/images/icon/feather-shopping-cart.svg" alt="">
+        <p>+好物</p>
+      </a>
+    </button>
+
+    <div class="d-md-none justify-content-evenly mb-menu">
+      <section title="裝修計算機" data-ga="Go_To_Calculator">
+        <a href="https://hhh.com.tw/calculator_request/index.html" target="_blank">
+          <img src="https://hhh.com.tw/hhh_index/images/icon/calculator_request.svg" alt="裝修計算機">
+          <h4>裝修計算機</h4>
+        </a>
+      </section>
+
+      <section title="+好物商城" data-ga="Go_To_Shop">
+        <a href="https://shop.hhh.com.tw/" target="_blank">
+          <img src="https://hhh.com.tw/hhh_index/images/icon/feather-shopping-cart.svg" alt="+好物商城">
+          <h4>+好物</h4>
+        </a>
+      </section>
+
+      <section data-ga="Go_To_Member">
+        <a href="https://m.hhh.com.tw/users">
+          <img src="https://hhh.com.tw/hhh_index/images/icon/material-people.svg" alt="會員"
+            style="filter: invert(67%) sepia(0%) saturate(0%) hue-rotate(242deg) brightness(91%) contrast(93%);">
+          <h4>會員</h4>
+        </a>
+      </section>
+    </div>
+  </div>
+
+  <div id="footer">
+    <footer class="footer">
+      <div class="container" style="margin:0 auto;">
+        <div class="row">
+          <div class="col-12 col-lg-4 about-list">
+            <section>
+              <h4>相關連結</h4>
+              <div class="d-flex justify-content-lg-center">
+                <ul>
+                  <li>
+                    <a href="https://event.hhh.com.tw/agent/lecture.html" target="_blank">
+                      <img src="https://hhh.com.tw/hhh_index/images/menu/freelecture.svg" alt="免費報名幸福講堂">
+                      免費報名幸福講堂
+                    </a>
+                  </li>
+                  <li>
+                    <a href="https://event.hhh.com.tw/agent/" target="_blank">
+                      <img src="https://hhh.com.tw/hhh_index/images/menu/agent.svg" alt="幸福經紀人">
+                      幸福經紀人 <span>0800-366-086</span>
+                    </a>
+                  </li>
+                  <!-- <li>
+                    <a href="">
+                      <img src="https://hhh.com.tw/hhh_index/images/menu/lecture.svg" alt="">
+                      講堂活動
+                    </a>
+                  </li> -->
+                  <li>
+                    <a href="http://gstv.com.tw/" target="_blank">
+                      <img src="https://hhh.com.tw/hhh_index/images/menu/tv.svg" alt="幸福空間居家台">
+                      幸福空間居家台
+                    </a>
+                  </li>
+                  <li>
+                    <a href="https://event.hhh.com.tw/contest/2018/" target="_blank">
+                      <img src="https://hhh.com.tw/hhh_index/images/menu/prize.svg" alt="ADA 亞洲設計獎">
+                      ADA 亞洲設計獎
+                    </a>
+                  </li>
+                  <!-- <li>
+                    <a href="">
+                      <img src="https://hhh.com.tw/hhh_index/images/menu/champion.svg" alt="">
+                      國際設計大獎代辦
+                    </a>
+                  </li> -->
+                  <li>
+                    <a href="https://www.leju.com.tw/" target="_blank">
+                      <img src="https://hhh.com.tw/hhh_index/images/menu/Image-1@2x.png" alt="樂居網">
+                      樂居網
+                    </a>
+                  </li>
+                </ul>
+              </div>
+            </section>
+          </div>
+          <div class="col-12 col-lg-4 follow-list">
+            <section>
+              <h4>追蹤我們</h4>
+              <div class="d-flex flex-column align-items-center">
+                <section class="media">
+                  <a href="https://www.facebook.com/hhhfb" target="_blank">
+                    <img src="../../img/media/fb.svg" alt="Facebook" class="media-item before">
+                    <img src="../../img/media/fb_h.svg" alt="Facebook" class="media-item after">
+                  </a>
+                  <a href="https://page.line.me/ovs4341s?openQrModal=true" target="_blank">
+                    <img src="../../img/media/ln.svg" alt="Line" class="media-item before">
+                    <img src="../../img/media/ln_h.svg" alt="Line" class="media-item after">
+                  </a>
+                  <a href="https://www.youtube.com/user/gorgeousspace" target="_blank">
+                    <img src="../../img/media/yt.svg" alt="YouTube" class="media-item before">
+                    <img src="../../img/media/yt_h.svg" alt="YouTube" class="media-item after">
+                  </a>
+                  <a href="https://www.instagram.com/gorgeous_space/" target="_blank">
+                    <img src="../../img/media/ig.svg" alt="Instagram" class="media-item before">
+                    <img src="../../img/media/ig_h.svg" alt="Instagram" class="media-item after">
+                  </a>
+                  <!-- <a href="" target="_blank">
+                    <img src="../../img/media/rb.svg" alt="" class="media-item before">
+                    <img src="../../img/media/rb_h.svg" alt="" class="media-item after rounded-circle">
+                  </a> -->
+                  <a href="https://www.tiktok.com/@gorgeousspace" target="_blank">
+                    <img src="../../img/media/tt.svg" alt="Tiktok" class="media-item before">
+                    <img src="../../img/media/tt_h.svg" alt="Tiktok" class="media-item after rounded-circle">
+                  </a>
+                </section>
+                <!-- <section class="fb-list">
+                  <a href="https://www.facebook.com/agent.hhh.com.tw" target="_blank">
+                    <img src="hhh_index/images/media/fb_h.svg" alt="agent">
+                    幸福經紀人粉絲專頁
+                  </a>
+                  <a href="https://www.facebook.com/retire.tw/" target="_blank">
+                    <img src="hhh_index/images/media/fb_h.svg" alt="retire">
+                    退休好幸福粉絲專頁
+                  </a>
+                </section> -->
+              </div>
+            </section>
+          </div>
+          <div class="col-12 col-lg-4 more-list">
+            <section>
+              <h4 class="d-none d-lg-block">了解更多</h4>
+              <div class="d-flex flex-column mt-2 mt-lg-0">
+                <section class="subscriber-item">
+                  <input type="email" placeholder="訂閱電子報,請輸入您的 Email">
+                  <button class="d-flex justify-content-center align-items-center subscriber-btn">
+                    <span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>
+                    <p>訂閱</p>
+                  </button>
+                </section>
+                <div class="d-lg-flex justify-content-center">
+                  <section class="mt-4 link">
+                    <a href="https://hhh.com.tw/about/contact/" target="_blank">
+                      聯絡我們
+                    </a>
+                    <a href="https://hhh.com.tw/about/privacy_policy" target="_blank">
+                      隱私保護
+                    </a>
+                    <a href="https://hhh.com.tw/about/" target="_blank">
+                      關於我們
+                    </a>
+                    <a href="https://hhh.com.tw/about/timeline/" target="_blank">
+                      公司歷程
+                    </a>
+                    <a href="https://www.104.com.tw/company/d6hr8sg" target="_blank">
+                      企業徵才
+                    </a>
+                    <a href="https://hhh.com.tw/about/sitemap/" target="_blank">
+                      網站地圖
+                    </a>
+                  </section>
+                </div>
+              </div>
+            </section>
+          </div>
+          <h2 class="d-none d-md-block">
+            幸福空間 版權所有 © Gorgeous Space Co.Ltd. All Rights Reserved
+          </h2>
+          <h2 class="d-block d-md-none">
+            幸福空間 版權所有 <br> © Gorgeous Space Co.Ltd. All Rights Reserved
+          </h2>
+        </div>
+      </div>
+    </footer>
+  </div>
 
   <!-- Bootstrap -->
   <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"

+ 238 - 5
js/index.js

@@ -34,10 +34,10 @@ window.onload = function () {
   //   // renderBanner(result);
   // });
 
-  $('#navbar').load('https://hhh.com.tw/hhh-test/template/navbar.html');
-  $('#footer').load('https://hhh.com.tw/hhh-test/template/footer.html');
-  $('#btn-box').load('https://hhh.com.tw/hhh-test/template/button.html');
-  $('#topCarousel').load('https://hhh.com.tw/hhh-test/template/top_carousel.html');
+  // $('#navbar').load('https://hhh.com.tw/hhh-test/template/navbar.html');
+  // $('#footer').load('https://hhh.com.tw/hhh-test/template/footer.html');
+  // $('#btn-box').load('https://hhh.com.tw/hhh-test/template/button.html');
+  // $('#topCarousel').load('https://hhh.com.tw/hhh-test/template/top_carousel.html');
 };
 
 function hhh_user_api_login() {
@@ -138,7 +138,7 @@ function renderBanner(data) {
     adNamesMain.push(adNameMain);
 
     str += `
-      <a href="${temp[i]["link"]}" target="_blank"   data-ga4="${temp[i]["id"]}${temp[i]["alt"]}">
+      <a href="${temp[i]["link"]}" target="_blank" data-ga4="${temp[i]["id"]}${temp[i]["alt"]}">
         <section class="info-item">
           <span class="logo-img">
             <img class="img-${temp[i].logo_icon} ${temp[i].logo_icon === "" ? "d-none" : ""}" src="./img/index/banner_logo/${temp[i].logo_icon}.png">
@@ -1636,4 +1636,237 @@ $(window).scroll(function () {
   } else {
     $('.btn-box').fadeOut();
   }
+});
+
+// 上方輪播
+$.ajax({
+  method: "get",
+  url: "./json/data_index.json",
+  // url: "https://m3.hhh.com.tw:18689/genjson_new?filename=realtime.json",
+  dataType: "json",
+}).done((data) => {
+  result = [...data];
+  renderTopCarousel(result);
+  console.log('result', result);
+}).fail((error) => {
+  console.log('genjson_new error', error);
+});
+
+// 渲染頂部輪播
+function renderTopCarousel(data) {
+  let temp = data[0]["data"];
+  console.log('temp', temp);
+  renderBullet(temp);
+  renderBannerStr("slider-content", temp);
+  let randomInt = getRandomInt(7);
+
+  let adTopup_count = []
+  // 新刊頭 Banner ga4 (一開始進來先送,剩下輪播送)
+  setTimeout(() => {
+    let list_Topup_Banner = document.querySelectorAll('.slider-content .slide-item');
+    let ad_first;
+    try {
+      ad_first = list_Topup_Banner[randomInt].getAttribute('data_id');
+    } catch (e) {
+      ad_first = '加載問題,請無視';
+      console.log(ad_first);
+    }
+
+    dataLayer.push({
+      'event': 'Banner_Impression',
+      'ad_name': ad_first,
+      'ad_location': '新刊頭Banner'
+    });
+    adTopup_count.push(ad_first)
+  }, 1000);
+
+
+  $(".slider-content").slick({
+    dots: false,
+    infinite: true,
+    speed: 500,
+    autoplay: true,
+    autoplaySpeed: 3000,
+    slidesToScroll: 1,
+    arrows: true,
+    initialSlide: randomInt, // 起始順序
+    prevArrow:
+      '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
+    nextArrow:
+      '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
+  });
+  $(".bullet").removeClass("bullet-active");
+  $(".bullet")
+    .eq($(".slick-active").data("slick-index"))
+    .addClass("bullet-active");
+
+  $(".slider-content").on("afterChange", function (event, slick, currentSlide) {
+    // 輪播
+    $(".bullet").removeClass("bullet-active");
+    $(`.bullet.item-${currentSlide}`).addClass("bullet-active");
+  });
+}
+
+function renderBannerStr(sec, data) {
+  let adNamesTop = [];
+  let str = "";
+  for (let i = 0; i < data.length; i++) {
+    let adNameTop = `${data[i]["id"]}${data[i]["alt"]}`;
+    adNamesTop.push(adNameTop);
+
+    if (data[i]["Dwebp"]) {
+      str += `
+    <a href="${data[i]["link"]}" data-ga4="${data[i]["id"]}${data[i]["alt"]}">
+      <img class="${sec}-${i + 1} slide-item img-fluid" src="${data[i]["Dwebp"]}" data-bg="${data[i]["Dwebp"]}" alt="${data[i]["alt"]}"  data_id="${data[i]["id"]}${data[i]["alt"]}">
+    </a>`;
+    } else {
+      str += `
+    <a href="${data[i]["link"]}" data-ga4="${data[i]["id"]}${data[i]["alt"]}">
+      <img class="${sec}-${i + 1} slide-item img-fluid" src="${data[i]["DimgUrl"]}" data-bg="${data[i]["DimgUrl"]}" alt="${data[i]["alt"]}" data_id="${data[i]["id"]}${data[i]["alt"]}">
+    </a>`;
+    }
+  }
+  $(`.${sec}`).html(str);
+  // ga4-banners
+  adNamesTop.forEach((adNameTop) => {
+    document.querySelectorAll(`a[data-ga4="${adNameTop}"]`).forEach((element) => {
+      element.addEventListener('click', function () {
+        dataLayer.push({
+          'event': 'Banner_Click',
+          'ad_name': adNameTop,
+          'ad_location': '新刊頭'
+        });
+      });
+    });
+  });
+}
+
+function renderBullet(data) {
+  let str = "";
+  for (let i = 0; i < data.length; i++) {
+    str += `<div class="bullet item-${i}"></div>`;
+  }
+  $(".bullet-list").html(str);
+}
+
+// 範圍內取隨機整數 (0-8)
+function getRandomInt(max) {
+  return Math.floor(Math.random() * max);
+}
+
+$(".top-carousel .close-btn").click(function () {
+  $(this).css("display", "none");
+  $(".top-carousel").addClass("banner-close");
+  sticky = 0;
+});
+
+// 右下按鈕
+$(".gotop-btn").click(() => {
+  $("html, body").animate(
+    {
+      scrollTop: 0,
+    }, 0
+  );
+});
+
+// 右下按鈕滑入顯示
+$(".calculator-btn").hover(function () {
+  $(".calculator-btn").addClass("show");
+}, function () {
+  $(".calculator-btn").removeClass("show");
+});
+
+$(".shop-btn").hover(function () {
+  $(".shop-btn").addClass("show");
+}, function () {
+  $(".shop-btn").removeClass("show");
+});
+
+// 判斷按鈕顯示 or 隱藏
+$(window).scroll(function () {
+  if ($(this).scrollTop()) {
+    $('#btn-box').fadeIn();
+  } else {
+    $('#btn-box').fadeOut();
+  }
+});
+
+document.querySelector('button[data-ga="Go_To_Calculator"]').addEventListener('click', function () {
+  dataLayer.push({
+    'event': 'Go_To_Calculator',
+    'btn_location': 'FixedBTN'
+  });
+});
+
+document.querySelector('button[data-ga="Go_To_Shop"]').addEventListener('click', function () {
+  dataLayer.push({
+    'event': 'Go_To_Shop',
+    'btn_location': 'FixedBTN'
+  });
+});
+
+// Footer
+$(".follow-list a").on({
+  mouseenter: function () {
+    // $(this).find(".media-item.before").hide();
+    // $(this).find(".media-item.after").show();
+    $(this).find(".media-item.before").css("opacity", "0");
+    $(this).find(".media-item.after").css("opacity", "1");
+  },
+  mouseleave: function () {
+    // $(this).find(".media-item.before").show();
+    // $(this).find(".media-item.after").hide();
+    $(this).find(".media-item.before").css("opacity", "1");
+    $(this).find(".media-item.after").css("opacity", "0");
+  }
+});
+
+let formData = {
+  email: ""
+};
+
+// 訂閱
+$('.subscriber-btn, .subscriber-mb-btn').on('click', function () {
+  let parent = $(this).closest('.subscriber-item'); // 對應父元素
+  parent.find('.spinner-border').addClass('show');
+  let mail = parent.find('input').val();
+  console.log("Input value:", mail);
+
+  let regex = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
+
+  let validate = regex.test(mail); // 判斷 mail 格式
+  if (!validate) {
+    parent.addClass('input-error');
+    parent.find('.spinner-border').removeClass('show');
+    parent.find('button p').text('email 格式錯誤');
+  } else {
+    parent.removeClass('input-error');
+    let formData = { email: mail };
+    let email = JSON.stringify(formData);
+    $.ajax({
+      method: "post",
+      url: "https://hhh.com.tw/adapter/index?http_method=POST&api_url=/third/v1/edm/subscriber",
+      contentType: "application/json",
+      data: email
+    }).done((data) => {
+      parent.find('.spinner-border').removeClass('show');
+      parent.find('button p').text('已完成訂閱!');
+    }).fail((error) => {
+      parent.find('.spinner-border').removeClass('show');
+      parent.find('button p').text('訂閱失敗,請稍後再試');
+    });
+  }
+});
+
+$('.subscriber-item input').on('focusin', function () {
+  console.log('focusin');
+  let parent = $(this).closest('.subscriber-item');
+  parent.addClass('input-focus');
+  let buttonText = parent.find('button p').text();
+  if (buttonText !== "訂閱") {
+    parent.find('button p').text('訂閱');
+    parent.removeClass('input-error');
+  }
+}).on('focusout', function () {
+  $(this).closest('.subscriber-item').removeClass('input-focus');
 });

+ 1 - 1
template/footer.html

@@ -169,7 +169,7 @@
     console.log("Input value:", mail);
 
     let regex = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
-    
+
     let validate = regex.test(mail); // 判斷 mail 格式
     if (!validate) {
       parent.addClass('input-error');