You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
5.9 KiB

2 years ago
  1. $(function () {
  2. 'use strict';
  3. var sLang = $('[http-equiv="content-language"]').attr('content') || 'zh-TW',
  4. iNewsTopCount = 8,
  5. org = null,
  6. /*
  7. * 目的 初始化輪播圖片
  8. */
  9. fnSwiper = function () {
  10. var iLen = $(".bannerslide ul li").size(),//抓數量
  11. iRand_no = Math.floor(Math.random() * iLen);//避免零
  12. if ($(window).width() > 801) {
  13. var mySwiper = new Swiper('.bannerslide', {
  14. paginationClickable: true,
  15. slidesPerView: 'auto',
  16. loop: true,
  17. centeredSlides: true,
  18. spaceBetween: 0,
  19. initialSlide: 0,
  20. navigation: {
  21. nextEl: '.banner-next',
  22. prevEl: '.banner-prev'
  23. },
  24. autoplay: {
  25. delay: 5000
  26. },
  27. pagination: {
  28. el: '.swiper-pagination',
  29. clickable: true
  30. }
  31. });
  32. }
  33. else {
  34. var swiperBanner = new Swiper('.bannerslide', {
  35. autoplay: {
  36. delay: 5000
  37. },
  38. pagination: {
  39. el: '.swiper-pagination',
  40. clickable: true
  41. },
  42. loop: true,
  43. initialSlide: iRand_no
  44. });
  45. }
  46. },
  47. /*
  48. * 目的 會展花絮輪播圖片
  49. */
  50. fnSwiper_Exp = function () {
  51. if ($(window).width() > 801) {
  52. new Swiper('.exposlide', {
  53. slidesPerView: 4,
  54. slidesPerGroup: 4,
  55. spaceBetween: 15,
  56. autoplay: 5000,
  57. loop: true,
  58. simulateTouch: false, //重要!影響chrome電腦點擊
  59. navigation: {
  60. nextEl: '#indexExpo .swiper-button-next',
  61. prevEl: '#indexExpo .swiper-button-prev'
  62. }
  63. });
  64. } else {
  65. new Swiper('.exposlide', {
  66. autoplay: 5000,
  67. loop: true,
  68. navigation: {
  69. nextEl: '#indexExpo .swiper-button-next',
  70. prevEl: '#indexExpo .swiper-button-prev'
  71. }
  72. });
  73. }
  74. },
  75. /*
  76. * 目的 抓去輪播
  77. */
  78. fnGetBanners = function (org) {
  79. return fnGetWebSiteSetting(function (saRes) {
  80. var sHtml = $('#temp_banner').render(saRes);
  81. if (saRes.length > 0) {
  82. $('#bannerWrapper .swiper-wrapper').html(sHtml);
  83. //$(".recThumb").imgLiquid({ fill: true });
  84. }
  85. if (saRes.length > 1) {
  86. $('.NoShowInMobile').show();
  87. fnSwiper();
  88. }
  89. }, 'Carousel', sLang);
  90. },
  91. /*
  92. * 目的 抓去服務
  93. */
  94. fnGetService = function (org) {
  95. return fnGetWebSiteSetting(function (saRes) {
  96. var sHtml = $('#temp_service').render(saRes);
  97. if (saRes.length > 0) {
  98. $('#listservice').html(sHtml + '<p class="clear">&nbsp;</p>');
  99. }
  100. }, 'ServiceItems', sLang);
  101. },
  102. /*
  103. * 目的 設置視頻專區
  104. */
  105. fnGetVideo = function (org) {
  106. var sVideoUrl = { 'zh-TW': org.VideoUrl, 'zh': org.VideoUrl_CN, 'en': org.VideoUrl_EN }[sLang] || '',
  107. sVideoDescription = { 'zh-TW': org.VideoDescription, 'zh': org.VideoDescription_CN, 'en': org.VideoDescription_EN }[sLang] || '';
  108. if (sVideoUrl) {
  109. $('#VideoUrl').attr('src', sVideoUrl);
  110. }
  111. if (org.sVideoDescription) {
  112. $('#VideoDescription').html(sVideoDescription);
  113. }
  114. },
  115. /*
  116. * 目的 抓去服務花絮前n筆
  117. */
  118. fnGetNewsTop = function () {
  119. return g_api.ConnectLite(Service.apiwebcom, ComFn.GetNewsPage, {
  120. pageIndex: 1,
  121. pageSize: iNewsTopCount,
  122. NewsType: '02'
  123. }, function (res) {
  124. if (res.RESULT) {
  125. var oRes = res.DATA.rel,
  126. sHtml = $('#temp_news').render(oRes.DataList);
  127. $('#indexExpo .indexGallery').html(sHtml);
  128. $(".rectThumb").imgLiquid({ fill: true });
  129. fnSwiper_Exp();
  130. }
  131. });
  132. },
  133. init = function () {
  134. var myHelpers = {
  135. setDate: function (date) {
  136. return new Date(date).formate('yyyy/MM/dd');
  137. },
  138. setRangeDate: function (date1, date2) {
  139. var r1 = new Date(date1).formate('yyyy/MM/dd'),
  140. r2 = new Date(date2).formate('MM/dd');
  141. return r1 + '-' + r2;
  142. },
  143. setFilePath: function (val) {
  144. val = val || '';
  145. return gServerUrl + '/' + val.replace(/\\/g, "\/");
  146. },
  147. setFileName: function (val) {
  148. val = val || '';
  149. return val.split('.')[0] || '';
  150. },
  151. setContent: function (val) {
  152. val = val || '';
  153. return val.length > 66 ? val.substr(0, 66) + '...' : val;
  154. }
  155. };
  156. $.views.helpers(myHelpers);
  157. runByOrgInfo(fnGetBanners);
  158. runByOrgInfo(fnGetService);
  159. runByOrgInfo(fnGetVideo, true);
  160. fnGetNewsTop();
  161. };
  162. init();
  163. });