网站
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

newDetail.js 3.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", "newApi", 'swiper'], function ($, template, Tools ) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. //焦点图数据
  9. focusListTop: [],
  10. newsInformationList:''
  11. },
  12. };
  13. var tools = new Tools();
  14. module.init = function (page) {
  15. //获取焦点图信息
  16. tools.doGet(websitePicture, {picType:1,status:0,orderByColumn:'picSort',isAsc:'desc'}, module.focusNewsTop , true);
  17. //底部友情链接
  18. tools.doGet(friendsLinks, {}, module.bottomFriendsLinks, true);
  19. //console.log(getQueryVariable('id'))
  20. //新闻资讯
  21. tools.doGet(newDetail + '/'+getQueryVariable('id'), {}, module.NewsInformation,true);
  22. //网站配置信息(网站名称 底部联系方式 公安备案号 网站备案号)
  23. tools.getWebConfig();
  24. };
  25. //焦点图数据
  26. module.focusNewsTop = function (data) {
  27. if (data.code == 200) {
  28. let focusArray = [];
  29. if(data.data.length<1){
  30. focusArray.push({
  31. picUrl:'../../../static/images/banner1.png'
  32. },{
  33. picUrl:'../../../static/images/banner2.png'
  34. },{
  35. picUrl:'../../../static/images/banner3.png'
  36. })
  37. }else{
  38. data.data.forEach(res=>{
  39. focusArray.push({
  40. picUrl:'/api'+res.picUrl
  41. })
  42. })
  43. }
  44. module.data.focusListTop = focusArray;
  45. var bannerFocusDataTop = template('bannerFocusDataTop', module.data);
  46. $("#bannerFocusTopContent").html(bannerFocusDataTop);
  47. new Swiper('#bannerFocusWrapTop', {
  48. paginationClickable: true,
  49. autoplay : 4000,
  50. loop:true
  51. })
  52. }
  53. }
  54. //底部友情链接
  55. module.bottomFriendsLinks = function (data) {
  56. if (data.code == 200) {
  57. var content = data.data;
  58. //console.log(content)
  59. module.data.friendsLinksList = content;
  60. var friendsLinksData = template('friendsLinksData', module.data);
  61. $("#friendsLinksContent").html(friendsLinksData);
  62. }
  63. }
  64. //获取地址栏参数
  65. function getQueryVariable(variable){
  66. var query = window.location.search.substring(1);
  67. var vars = query.split("&");
  68. for (var i=0;i<vars.length;i++) {
  69. var pair = vars[i].split("=");
  70. if(pair[0] == variable){return pair[1];}
  71. }
  72. return(false);
  73. }
  74. //新闻资讯数据
  75. module.NewsInformation = function (data) {
  76. //console.log(data)
  77. if (data.code == 200) {
  78. var content = data.data;
  79. $("#newTitle").html(content.title);
  80. $("#newTime").html(content.newsTime);
  81. $("#newCome").html(content.realname);
  82. $("#newContent").html(content.content);
  83. if(content.attachment){
  84. var content = content.attachment.split(',');
  85. let list = [];
  86. content.map(rr=>{
  87. list.push({
  88. fileUrl:rr,
  89. fileName:rr.substr(27,rr.length)
  90. })
  91. })
  92. module.data.attachmentList = list;
  93. var attachmentListData = template('attachmentListData', module.data);
  94. $("#attachmentListContent").html(attachmentListData);
  95. }
  96. }
  97. }
  98. return module;
  99. });