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.

94 lines
3.5 KiB

2 years ago
  1. $(function () {
  2. 'use strict';
  3. var sLang = $('[http-equiv="content-language"]').attr('content') || 'zh-TW',
  4. iPageIndex = 1,
  5. iPageCount = 10,
  6. /*
  7. * 目的 抓去活動資訊明細
  8. * @param {String} id 當前消息ID
  9. * @return {Object} ajax物件
  10. */
  11. fnGetNewsInfo = function (id) {
  12. return g_api.ConnectLite(Service.apiwebcom, ComFn.GetNewsInfo, {
  13. Id: id
  14. }, function (res) {
  15. if (res.RESULT) {
  16. var saRes = res.DATA.rel,
  17. sHtml = $('#temp_newsdetail').render(saRes);
  18. $('.news-detail').html(sHtml).find('a').click(function () {
  19. $('#p_news_detail').hide();
  20. $('#p_news_list').show();
  21. });
  22. $('#p_news_detail').show();
  23. $('#p_news_list').hide();
  24. }
  25. });
  26. },
  27. /*
  28. * 目的 抓去活動資訊分頁資訊
  29. * @return {Object} ajax物件
  30. */
  31. fnGetNewsPage = function () {
  32. return g_api.ConnectLite(Service.apiwebcom, ComFn.GetNewsPage, {
  33. pageIndex: iPageIndex,
  34. pageSize: iPageCount,
  35. NewsType: '01'
  36. }, function (res) {
  37. if (res.RESULT) {
  38. var oRes = res.DATA.rel,
  39. sHtml = $('#temp_newslist').render(oRes.DataList);
  40. $('.new-news').html(sHtml).find('a').click(function () {
  41. var sId = $(this).attr('data-key');
  42. fnGetNewsInfo(sId);
  43. });//oRes.Total
  44. $("#pager").pagination({
  45. items: oRes.Total,
  46. itemsOnPage: iPageCount,
  47. currentPage: iPageIndex,
  48. displayedPages: 4,
  49. cssStyle: 'light-theme',
  50. onPageClick: fnChangePage
  51. });
  52. if (oRes.Total <= iPageCount) { $("#pager").hide(); }
  53. }
  54. });
  55. },
  56. /*
  57. * 目的 抓去活動資訊分頁資訊
  58. */
  59. fnChangePage = function () {
  60. iPageIndex = $("#pager").pagination('getCurrentPage');
  61. fnGetNewsPage();
  62. },
  63. init = function () {
  64. var myHelpers = {
  65. setDate: function (date) {
  66. var dDate = new Date(date),
  67. iDay = dDate.getDate(),
  68. monName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  69. return monName[dDate.getMonth()] + ' ' + (iDay < 10 ? '0' + iDay : iDay) + ', ' + dDate.getFullYear();
  70. },
  71. setNewsContent: function (val) {
  72. val = val || '';
  73. if (window.location.protocol === 'https:') {
  74. val = val.replaceAll('http:', 'https:');
  75. }
  76. return val;
  77. }
  78. };
  79. $.views.helpers(myHelpers);
  80. g_api.ConnectLite(Service.apiappcom, ComFn.GetSysSet, {
  81. SetItemID: 'NewsShowCount'
  82. }, function (res) {
  83. if (res.RESULT) {
  84. iPageCount = parseInt(res.DATA.rel || 10);
  85. }
  86. }).always(function () {
  87. fnGetNewsPage();
  88. });
  89. };
  90. init();
  91. });