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

100 lines
3.3 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. //新闻列表
  19. };
  20. module.newsList = function (data) {
  21. if (data.code == 200) {
  22. var content = data.rows;
  23. module.data.newList = content;
  24. var newListData = template('newListData', module.data);
  25. $("#newListContent").html(newListData);
  26. var newImgList = [];
  27. content.map(rr=>{
  28. if (rr.infoImg!=null&&rr.infoImg!=""){
  29. newImgList.push(rr.infoImg);
  30. }
  31. })
  32. module.data.newImgList = newImgList;
  33. var newListDataImg = template('newListDataImg', module.data);
  34. $("#bannerFocusNextContent").html(newListDataImg);
  35. if ( content.length > 7){
  36. roll(20)
  37. }
  38. new Swiper('#bannerFocusNextWrap', {
  39. paginationClickable: true,
  40. pagination: '.a2',
  41. autoplay : 2000,
  42. loop:true
  43. })
  44. }
  45. }
  46. module.webList = function (data) {
  47. if (data.code == 200) {
  48. var content = data.data;
  49. module.data.webList = content;
  50. var webData = template('webData', module.data);
  51. $("#webContent").html(webData);
  52. var titData = template('titData', module.data);
  53. $("#titContent").html(titData);
  54. $('#ewm').attr('src', 'static/images/'+content.top.bz);
  55. }
  56. }
  57. searchChange = function () {
  58. tools.doGet(newsList, {pageNum:1,pageSize:8,infoName:$("#searchInput").val()}, module.newsList , true);
  59. }
  60. function roll(t) {
  61. var ul1 = document.getElementById("newListContent");
  62. var ul2 = document.getElementById("newListContent2");
  63. var ulbox = document.getElementById("review_box");
  64. ul2.innerHTML = ul1.innerHTML;
  65. ulbox.scrollTop = 0; // 开始无滚动时设为0
  66. var timer = setInterval(rollStart, t); // 设置定时器,参数t用在这为间隔时间(单位毫秒),参数t越小,滚动速度越快
  67. // 鼠标移入div时暂停滚动
  68. ulbox.onmouseover = function () {
  69. clearInterval(timer);
  70. }
  71. // 鼠标移出div后继续滚动
  72. ulbox.onmouseout = function () {
  73. timer = setInterval(rollStart, t);
  74. }
  75. }
  76. // 开始滚动函数
  77. function rollStart() {
  78. // 上面声明的DOM对象为局部对象需要再次声明
  79. var ul1 = document.getElementById("newListContent");
  80. var ul2 = document.getElementById("newListContent2");
  81. var ulbox = document.getElementById("review_box");
  82. // 正常滚动不断给scrollTop的值+1,当滚动高度大于列表内容高度时恢复为0
  83. console.log(ulbox.scrollTop+'--------'+ul1.scrollHeight)
  84. if (ulbox.scrollTop >= ul1.scrollHeight) {
  85. ulbox.scrollTop = 0;
  86. } else {
  87. ulbox.scrollTop += 1;
  88. }
  89. }
  90. return module;
  91. });