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.

152 lines
5.4 KiB

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