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

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