网站
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

index.js 3.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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, { configKey: 'web.open' }, 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.rows;
  50. content.map(rr=>{
  51. if (rr.configKey == 'web.open.technique'){
  52. $("#zcdw").html(rr.configValue);
  53. }
  54. if (rr.configKey == "web.open.phone"){
  55. $("#phone").html(rr.configValue);
  56. }
  57. if (rr.configKey == "web.open.qrcode"){
  58. $('#ewm').attr('src', rr.configValue);
  59. }
  60. if (rr.configKey == "web.open.title"){
  61. $("#tt").html(rr.configValue);
  62. }
  63. })
  64. }
  65. }
  66. searchChange = function () {
  67. tools.doGet(newsList, {pageNum:1,pageSize:8,infoName:$("#searchInput").val()}, module.newsList , true);
  68. }
  69. function roll(t) {
  70. var ul1 = document.getElementById("newListContent");
  71. var ul2 = document.getElementById("newListContent2");
  72. var ulbox = document.getElementById("review_box");
  73. ul2.innerHTML = ul1.innerHTML;
  74. ulbox.scrollTop = 0; // 开始无滚动时设为0
  75. var timer = setInterval(rollStart, t); // 设置定时器,参数t用在这为间隔时间(单位毫秒),参数t越小,滚动速度越快
  76. // 鼠标移入div时暂停滚动
  77. ulbox.onmouseover = function () {
  78. clearInterval(timer);
  79. }
  80. // 鼠标移出div后继续滚动
  81. ulbox.onmouseout = function () {
  82. timer = setInterval(rollStart, t);
  83. }
  84. }
  85. // 开始滚动函数
  86. function rollStart() {
  87. // 上面声明的DOM对象为局部对象需要再次声明
  88. var ul1 = document.getElementById("newListContent");
  89. var ul2 = document.getElementById("newListContent2");
  90. var ulbox = document.getElementById("review_box");
  91. // 正常滚动不断给scrollTop的值+1,当滚动高度大于列表内容高度时恢复为0
  92. console.log(ulbox.scrollTop+'--------'+ul1.scrollHeight)
  93. if (ulbox.scrollTop >= ul1.scrollHeight) {
  94. ulbox.scrollTop = 0;
  95. } else {
  96. ulbox.scrollTop += 1;
  97. }
  98. }
  99. return module;
  100. });