网站
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.

4 年之前
4 年之前
4 年之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", "newApi", "paging"], function ($, template, Tools ) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. //新闻列表
  9. newsInformationList:'',
  10. //页码
  11. pageNum: 1,
  12. //页码集合
  13. pageList: [],
  14. //每页数量
  15. pageSize: 50,
  16. //总页数
  17. pageCount:0
  18. },
  19. };
  20. var tools = new Tools();
  21. module.init = function (page) {
  22. if(getQueryVariable('title') ){
  23. console.log('搜索进入')
  24. //新闻资讯
  25. tools.doGet(newList, {deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize,title:getQueryVariable('title')}, module.NewsInformation,true);
  26. }else{
  27. //新闻资讯
  28. tools.doGet(newList, {number:2,deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.NewsInformation,true);
  29. }
  30. };
  31. //获取地址栏参数
  32. function getQueryVariable(variable){
  33. var query = window.location.search.substring(1);
  34. var vars = query.split("&");
  35. for (var i=0;i<vars.length;i++) {
  36. var pair = vars[i].split("=");
  37. if(pair[0] == variable){return pair[1];}
  38. }
  39. return(false);
  40. }
  41. //新闻资讯数据
  42. module.NewsInformation = function (data) {
  43. if (data.code == 200) {
  44. var content = data.rows;
  45. var pageCount = (data.total/module.data.pageSize).toFixed(0);
  46. if (pageCount < 1){
  47. pageCount = 1;
  48. }
  49. if(module.data.newsInformationList == ''){
  50. // 初始化 分页器
  51. var page_s1=createPage('.page_s1');
  52. // 设置分页
  53. setPage(page_s1,{
  54. pageTotal: data.total, // 数据总条数
  55. pageSize: module.data.pageSize, // 每页显示条数
  56. pageCurrent: 1, // 当前页
  57. maxBtnNum: 5, // 最多按钮个数 (最少5个)
  58. })
  59. $('#page_s1').html('共'+pageCount+'页')
  60. }
  61. module.data.pageCount = pageCount;
  62. module.data.newsInformationList = content;
  63. var NewsInformationData = template('NewsInformationData', module.data);
  64. $("#NewsInformationContent").html(NewsInformationData);
  65. }
  66. }
  67. turnThePage = function (pageNum) {
  68. module.data.pageNum = pageNum ;
  69. if (getQueryVariable('title')){
  70. tools.doGet(newList, {deptId:100,pageNum:pageNum,pageSize:module.data.pageSize,title:getQueryVariable('title')}, module.NewsInformation,true);
  71. }else{
  72. tools.doGet(newList, {number:2,deptId:100,pageNum:pageNum,pageSize:module.data.pageSize}, module.NewsInformation,true);
  73. }
  74. }
  75. return module;
  76. });