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.

69 lines
2.4 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. * @return {Object} ajax物件
  9. */
  10. fnGetNewsPage = function () {
  11. return g_api.ConnectLite(Service.apiwebcom, ComFn.GetNewsPage, {
  12. pageIndex: iPageIndex,
  13. pageSize: iPageCount,
  14. NewsType: '02'
  15. }, function (res) {
  16. if (res.RESULT) {
  17. var oRes = res.DATA.rel,
  18. sHtml = $('#temp_news').render(oRes.DataList);
  19. $('#newsList').html(sHtml);
  20. $(".rectThumb").imgLiquid({ fill: true });
  21. $("#pager").pagination({
  22. items: oRes.Total,
  23. itemsOnPage: iPageCount,
  24. currentPage: iPageIndex,
  25. displayedPages: 4,
  26. cssStyle: 'light-theme',
  27. onPageClick: fnChangePage
  28. });
  29. if (oRes.Total <= iPageCount) { $("#pager").hide(); }
  30. }
  31. });
  32. },
  33. /*
  34. * 目的 抓去活動資訊分頁資訊
  35. */
  36. fnChangePage = function () {
  37. iPageIndex = $("#pager").pagination('getCurrentPage');
  38. fnGetNewsPage();
  39. },
  40. init = function () {
  41. var myHelpers = {
  42. setDate: function (date) {
  43. return new Date(date).formate('yyyy/MM/dd');
  44. },
  45. setFilePath: function (val) {
  46. val = val || '';
  47. return gServerUrl + '/' + val.replace(/\\/g, "\/");
  48. },
  49. setContent: function (val) {
  50. val = val || '';
  51. return val.length > 266 ? val.substr(0, 266) + '...' : val;
  52. }
  53. };
  54. $.views.helpers(myHelpers);
  55. g_api.ConnectLite(Service.apiappcom, ComFn.GetSysSet, {
  56. SetItemID: 'NewsShowCount'
  57. }, function (res) {
  58. if (res.RESULT) {
  59. iPageCount = parseInt(res.DATA.rel || 10);
  60. }
  61. }).always(function () {
  62. fnGetNewsPage();
  63. });
  64. };
  65. init();
  66. });