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.

120 lines
4.3 KiB

2 years ago
  1. $(function () {
  2. 'use strict';
  3. var sLang = $('[http-equiv="content-language"]').attr('content') || 'zh-TW',
  4. bEn = sLang === 'en',
  5. iPageIndex = 1,
  6. iPageCount = 10,
  7. /*
  8. * 目的 抓取國家
  9. */
  10. fnGetArguments = function () {
  11. return g_api.ConnectLite(Service.apiappcom, ComFn.GetArguments, {
  12. ArgClassID: 'Area',
  13. OrderBy: 'id',
  14. LevelOfArgument: 1
  15. }, function (res) {
  16. if (res.RESULT) {
  17. var saRes = res.DATA.rel;
  18. $('#area').html(createOptions(saRes, 'id', bEn ? 'text_en' : 'text', true)).val('TWN').select2({
  19. placeholder: bEn ? 'Select Country' : '請選擇國家'
  20. });
  21. }
  22. });
  23. },
  24. /*
  25. * 目的 抓去展覽資訊前n筆
  26. */
  27. fnGetExhibitionsTop = function () {
  28. var sKeyWords = $('#keyword').val(),
  29. sArea = $('#area').val(),
  30. sDateStart = $('#datestart').val(),
  31. sDateEnd = $('#dateend').val();
  32. if (!sDateStart) {
  33. sDateStart = newDate();
  34. }
  35. g_api.ConnectLite(Service.apiwebcom, ComFn.GetExhibitionPage, {
  36. pageIndex: iPageIndex,
  37. pageSize: iPageCount,
  38. IsShowWebSim: "Y",
  39. KeyWords: sKeyWords,
  40. Area: sArea,
  41. DateStart: sDateStart,
  42. DateEnd: sDateEnd
  43. }, function (res) {
  44. if (res.RESULT) {
  45. var oRes = res.DATA.rel,
  46. sHtml = $('#temp_expo').render(oRes.DataList);
  47. $('.expoList').html(sHtml);
  48. $(".squareThumb").imgLiquid({ fill: false });
  49. $("#pager").pagination({
  50. items: oRes.Total,
  51. itemsOnPage: iPageCount,
  52. currentPage: iPageIndex,
  53. displayedPages: 4,
  54. cssStyle: 'light-theme',
  55. onPageClick: fnChangePage
  56. });
  57. if (oRes.Total <= iPageCount) { $("#pager").hide(); }
  58. }
  59. });
  60. },
  61. /*
  62. * 目的 抓去活動資訊分頁資訊
  63. */
  64. fnChangePage = function () {
  65. iPageIndex = $("#pager").pagination('getCurrentPage');
  66. fnGetExhibitionsTop();
  67. },
  68. init = function () {
  69. var myHelpers = {
  70. getYear: function (date) {
  71. var y = new Date(date).getFullYear();
  72. return y;
  73. },
  74. getMonth: function (date) {
  75. var m = new Date(date).getMonth();
  76. return m + 1;
  77. },
  78. setRangeDate: function (date1, date2) {
  79. var r1 = new Date(date1).formate('yyyy/MM/dd'),
  80. r2 = new Date(date2).formate('MM/dd');
  81. return r1 + '-' + r2;
  82. },
  83. setFilePath: function (val) {
  84. val = val || '';
  85. return gServerUrl + '/' + val.replace(/\\/g, "\/");
  86. },
  87. setContent: function (val) {
  88. val = val || '';
  89. return val.length > 66 ? val.substr(0, 66) + '...' : val;
  90. }
  91. };
  92. $.views.helpers(myHelpers);
  93. if (bEn) {
  94. $.datepicker.setDefaults($.datepicker.regional[""]);
  95. }
  96. $(".datepicker").datepicker({
  97. changeYear: true,
  98. changeMonth: true,
  99. dateFormat: 'yy/mm/dd'
  100. });
  101. $.whenArray([g_api.ConnectLite(Service.apiappcom, ComFn.GetSysSet, {
  102. SetItemID: 'ExhibitionsShowCount'
  103. }, function (res) {
  104. if (res.RESULT) {
  105. iPageCount = parseInt(res.DATA.rel || 10);
  106. }
  107. }), fnGetArguments()]).done(function () {
  108. fnGetExhibitionsTop();
  109. });
  110. $('[type="submit"]').on('click', function () {
  111. iPageIndex = 1;
  112. fnGetExhibitionsTop();
  113. });
  114. };
  115. init();
  116. });