SyuanYu il y a 2 ans
Parent
commit
7a86a7eb3e
1 fichiers modifiés avec 8 ajouts et 2 suppressions
  1. 8 2
      hhh_index/js/index.js

+ 8 - 2
hhh_index/js/index.js

@@ -14,7 +14,6 @@ let totalPages = {
 };
 };
 
 
 window.onload = function () {
 window.onload = function () {
-  //hhh_user_api();
   // if(screen.width < 900) {
   // if(screen.width < 900) {
   //    window.location.href = "../index_designerList_mb.html";
   //    window.location.href = "../index_designerList_mb.html";
   // }
   // }
@@ -33,7 +32,6 @@ window.onload = function () {
   //   // renderBanner(result);
   //   // renderBanner(result);
   // });
   // });
 
 
-  //$('#navbar').load('./hhh_index/template/nav-new.html');
   $('#navbar').load('./hhh_index/template/nav-new.html', function () {
   $('#navbar').load('./hhh_index/template/nav-new.html', function () {
     hhh_user_api();
     hhh_user_api();
   });
   });
@@ -177,6 +175,13 @@ function renderBanner(data) {
   }
   }
 
 
   $(`.banner-slider`).html(str);
   $(`.banner-slider`).html(str);
+
+  // 範圍內取隨機整數(0-8)
+  function getRandomInt(max) {
+    return Math.floor(Math.random() * max);
+  }
+  let randomInt = getRandomInt(9);
+
   // 輪播設定
   // 輪播設定
   $('.banner-slider').slick({
   $('.banner-slider').slick({
     dots: true,
     dots: true,
@@ -189,6 +194,7 @@ function renderBanner(data) {
     slidesToScroll: 1,
     slidesToScroll: 1,
     centerMode: true,
     centerMode: true,
     variableWidth: true,
     variableWidth: true,
+    initialSlide: randomInt, // 起始順序
     prevArrow:
     prevArrow:
       '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="color: white;transform: translateY(-10px);"></i></button>',
       '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="color: white;transform: translateY(-10px);"></i></button>',
     nextArrow:
     nextArrow: