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.

67 lines
2.2 KiB

2 years ago
  1. $(function () {
  2. 'use strict';
  3. var sLang = $('[http-equiv="content-language"]').attr('content') || 'zh-TW',
  4. sId = getUrlParam('id') || '1',
  5. iPageIndex = 1,
  6. iPageCount = 2,
  7. /*
  8. * 目的 抓去活動資訊明細
  9. * @param {String} id 當前消息ID
  10. * @return {Object} ajax物件
  11. */
  12. fnGetNewsInfo = function (id) {
  13. return g_api.ConnectLite(Service.apiwebcom, ComFn.GetNewsInfo, {
  14. Id: sId
  15. }, function (res) {
  16. if (res.RESULT) {
  17. var saRes = res.DATA.rel,
  18. sHtml = $('#temp_newsdetail').render(saRes);
  19. $('#newsDetail').html(sHtml);
  20. }
  21. });
  22. },
  23. /*
  24. * 目的 抓去活動資訊分頁資訊
  25. * @return {Object} ajax物件
  26. */
  27. fnGetNewsPage = function () {
  28. return g_api.ConnectLite(Service.apiwebcom, ComFn.GetNewsPage, {
  29. pageIndex: iPageIndex,
  30. pageSize: iPageCount,
  31. NewsType: '02'
  32. }, function (res) {
  33. if (res.RESULT) {
  34. var oRes = res.DATA.rel,
  35. sHtml = $('#temp_news').render(oRes.DataList);
  36. $('.listNews').html(sHtml);
  37. }
  38. });
  39. },
  40. init = function () {
  41. var myHelpers = {
  42. setDate: function (date) {
  43. return new Date(date).formate('yyyy/MM/dd');
  44. },
  45. setNewsContent: function (val) {
  46. val = val || '';
  47. val = val.replaceAll('http:', 'https:');
  48. return val;
  49. }
  50. };
  51. $.views.helpers(myHelpers);
  52. fnGetNewsInfo(sId);
  53. g_api.ConnectLite(Service.apiappcom, ComFn.GetSysSet, {
  54. SetItemID: 'NewsShowCount'
  55. }, function (res) {
  56. if (res.RESULT) {
  57. iPageCount = parseInt(res.DATA.rel || 10);
  58. }
  59. }).always(function () {
  60. fnGetNewsPage(iPageIndex);
  61. });
  62. };
  63. init();
  64. });