网站
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

214 rader
7.7 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. tools.doGet(listSiyigongkai, {pageNum:1,pageSize:8}, module.newsList4 , true);
  20. tools.doGet(webList, {}, module.webList , true);
  21. // new Swiper('#bannerFocusNextWrap', {
  22. // paginationClickable: true,
  23. // pagination: '.a2',
  24. // autoplay : 2000,
  25. // loop:true
  26. // })
  27. changeList('1');
  28. };
  29. module.newsList4 = function (data) {
  30. if (data.code == 200) {
  31. var content = data.rows;
  32. module.data.newList4 = content;
  33. var newListData4 = template('newListData4', module.data);
  34. $("#newListContent_ul_4").html(newListData4);
  35. }
  36. }
  37. module.webList = function (data) {
  38. if (data.code == 200) {
  39. var content = data.data;
  40. module.data.webList = content;
  41. var webData = template('webData', module.data);
  42. $("#webContent").html(webData);
  43. var titData = template('titData', module.data);
  44. $("#titContent").html(titData);
  45. $('#ewm').attr('src', 'static/images/'+content.top.bz);
  46. }
  47. }
  48. searchChange = function () {
  49. console.log(1111111111);
  50. tools.doGet(listSiyigongkai, {pageNum:1,pageSize:8,openName:$("#searchInput").val()}, module.newsList , true);
  51. }
  52. submitUser = function () {
  53. tools.doPost(checkFarmer, {memberName:$("#userName").val(),idcard:$("#password").val()}, module.checkFarmer , true);
  54. }
  55. module.checkFarmer = function (data) {
  56. if (data.code == 200) {
  57. let seconds = 3600;
  58. let expires = new Date(new Date() * 1 + seconds * 1000);
  59. tools.setCookie("user", JSON.stringify(data.data), { expires: expires });
  60. tools.doGet(familyMember, {idcard:$("#password").val(),familyStatus:"02"}, module.familyMember , true);
  61. }
  62. }
  63. module.familyMember = function (data) {
  64. if (data.code == 200) {
  65. const farmerCode = data.rows[0].farmerCode;
  66. tools.setCookie("farmerCode",farmerCode, { expires: 30 });
  67. $('#loginF').css('display','none');
  68. $('#new_list').css('display','block');
  69. }
  70. }
  71. changeList = function (type) {
  72. $('#new_list_1').css('display','none');
  73. $('#new_list_2').css('display','none');
  74. $('#new_list_3').css('display','none');
  75. $('#new_list_4').css('display','none');
  76. $('#new_list_5').css('display','none');
  77. $('#new_list_6').css('display','none');
  78. switch (type) {
  79. case '1':
  80. $('#new_list_1').css('display','block');
  81. $("#nowDateNYR1").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate());
  82. tools.doGet(financePublicList, {
  83. pageNum:1,
  84. pageSize:10,
  85. orderByColumn: 'openNy',
  86. isAsc: 'desc',
  87. bookId: JSON.parse(tools.getCookie('user')).bookId,
  88. deptId: JSON.parse(tools.getCookie('user')).deptId
  89. }, module.newsList1 , true);
  90. break;
  91. case '2':
  92. $('#new_list_2').css('display','block');
  93. $("#nowDateNYR2").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate());
  94. tools.doGet(contractionList, {
  95. pageNum:1,
  96. pageSize:10,
  97. orderByColumn: 'buildingTime',
  98. translate_dict: 1,
  99. isAsc: 'desc',
  100. bookId: JSON.parse(tools.getCookie('user')).bookId,
  101. deptId: JSON.parse(tools.getCookie('user')).deptId
  102. }, module.newsList2 , true);
  103. break;
  104. case '3':
  105. $('#new_list_3').css('display','block');
  106. $("#nowDateNYR3").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate());
  107. tools.doGet(majorEventPublicList, {
  108. pageNum:1,
  109. pageSize:10,
  110. orderByColumn: 'openNy',
  111. isAsc: 'desc',
  112. bookId: JSON.parse(tools.getCookie('user')).bookId,
  113. deptId: JSON.parse(tools.getCookie('user')).deptId
  114. }, module.newsList3 , true);
  115. break;
  116. case '4':
  117. $('#new_list_4').css('display','block');
  118. $("#nowDateNYR4").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate());
  119. tools.doGet(listSiyigongkai, {pageNum:1,pageSize:8}, module.newsList4 , true);
  120. break;
  121. case '5':
  122. $('#new_list_5').css('display','block');
  123. $("#nowDateNYR5").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate());
  124. break;
  125. case '6':
  126. $('#new_list_6').css('display','block');
  127. $("#nowDateNYR6").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate());
  128. break;
  129. }
  130. }
  131. module.newsList1 = function (data) {
  132. if (data.code == 200) {
  133. var content = data.rows;
  134. module.data.newList1 = content;
  135. var newListData1 = template('newListData1', module.data);
  136. $("#newListContent_ul_1").html(newListData1);
  137. }
  138. }
  139. module.newsList2 = function (data) {
  140. if (data.code == 200) {
  141. var content = data.rows;
  142. module.data.newList2 = content;
  143. var newListData2 = template('newListData2', module.data);
  144. $("#newListContent_ul_2").html(newListData2);
  145. }
  146. }
  147. module.newsList3 = function (data) {
  148. if (data.code == 200) {
  149. var content = data.rows;
  150. module.data.newList3 = content;
  151. var newListData3 = template('newListData3', module.data);
  152. $("#newListContent_ul_3").html(newListData3);
  153. }
  154. }
  155. function roll(t) {
  156. var ul1 = document.getElementById("newListContent");
  157. var ul2 = document.getElementById("newListContent2");
  158. var ulbox = document.getElementById("review_box");
  159. ul2.innerHTML = ul1.innerHTML;
  160. ulbox.scrollTop = 0; // 开始无滚动时设为0
  161. var timer = setInterval(rollStart, t); // 设置定时器,参数t用在这为间隔时间(单位毫秒),参数t越小,滚动速度越快
  162. // 鼠标移入div时暂停滚动
  163. ulbox.onmouseover = function () {
  164. clearInterval(timer);
  165. }
  166. // 鼠标移出div后继续滚动
  167. ulbox.onmouseout = function () {
  168. timer = setInterval(rollStart, t);
  169. }
  170. }
  171. // 开始滚动函数
  172. function rollStart() {
  173. // 上面声明的DOM对象为局部对象需要再次声明
  174. var ul1 = document.getElementById("newListContent");
  175. var ul2 = document.getElementById("newListContent2");
  176. var ulbox = document.getElementById("review_box");
  177. // 正常滚动不断给scrollTop的值+1,当滚动高度大于列表内容高度时恢复为0
  178. console.log(ulbox.scrollTop+'--------'+ul1.scrollHeight)
  179. if (ulbox.scrollTop >= ul1.scrollHeight) {
  180. ulbox.scrollTop = 0;
  181. } else {
  182. ulbox.scrollTop += 1;
  183. }
  184. }
  185. return module;
  186. });