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

101 line
3.4 KiB

  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", 'swiper'], function ($, template, Tools, swiper) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. //服务器地址
  9. serverApi:'',
  10. //焦点图数据
  11. focusList: [],
  12. communicateList: [],
  13. newImgList:[]
  14. },
  15. };
  16. var tools = new Tools();
  17. module.init = function (page) {
  18. tools.doGet(webList, {}, module.webList , true);
  19. //新闻列表
  20. };
  21. module.newsList = function (data) {
  22. if (data.code == 200) {
  23. var content = data.rows;
  24. module.data.newList = content;
  25. var newListData = template('newListData', module.data);
  26. $("#newListContent").html(newListData);
  27. var newImgList = [];
  28. content.map(rr=>{
  29. if (rr.infoImg!=null&&rr.infoImg!=""){
  30. newImgList.push(rr.infoImg);
  31. }
  32. })
  33. module.data.newImgList = newImgList;
  34. var newListDataImg = template('newListDataImg', module.data);
  35. $("#bannerFocusNextContent").html(newListDataImg);
  36. if ( content.length > 7){
  37. roll(20)
  38. }
  39. new Swiper('#bannerFocusNextWrap', {
  40. paginationClickable: true,
  41. pagination: '.a2',
  42. autoplay : 2000,
  43. loop:true
  44. })
  45. }
  46. }
  47. module.webList = function (data) {
  48. if (data.code == 200) {
  49. var content = data.data;
  50. $("#tt").html(content.top.contentValue);
  51. $("#phone").html('投诉电话:' + content.botoom2[0].contentValue);
  52. $("#zcdw").html('支持单位:' + content.botoom3[1].contentValue);
  53. $('#ewm').attr('src', 'static/images/'+content.top.bz);
  54. }
  55. }
  56. searchChange = function () {
  57. tools.doGet(newsList, {pageNum:1,pageSize:8,infoName:$("#searchInput").val()}, module.newsList , true);
  58. }
  59. function roll(t) {
  60. var ul1 = document.getElementById("newListContent");
  61. var ul2 = document.getElementById("newListContent2");
  62. var ulbox = document.getElementById("review_box");
  63. ul2.innerHTML = ul1.innerHTML;
  64. ulbox.scrollTop = 0; // 开始无滚动时设为0
  65. var timer = setInterval(rollStart, t); // 设置定时器,参数t用在这为间隔时间(单位毫秒),参数t越小,滚动速度越快
  66. // 鼠标移入div时暂停滚动
  67. ulbox.onmouseover = function () {
  68. clearInterval(timer);
  69. }
  70. // 鼠标移出div后继续滚动
  71. ulbox.onmouseout = function () {
  72. timer = setInterval(rollStart, t);
  73. }
  74. }
  75. // 开始滚动函数
  76. function rollStart() {
  77. // 上面声明的DOM对象为局部对象需要再次声明
  78. var ul1 = document.getElementById("newListContent");
  79. var ul2 = document.getElementById("newListContent2");
  80. var ulbox = document.getElementById("review_box");
  81. // 正常滚动不断给scrollTop的值+1,当滚动高度大于列表内容高度时恢复为0
  82. console.log(ulbox.scrollTop+'--------'+ul1.scrollHeight)
  83. if (ulbox.scrollTop >= ul1.scrollHeight) {
  84. ulbox.scrollTop = 0;
  85. } else {
  86. ulbox.scrollTop += 1;
  87. }
  88. }
  89. return module;
  90. });