/** * Created by Administrator on 2021/4/5. */ define(['jquery', "template", "Tools", 'swiper'], function ($, template, Tools, swiper) { //数据存储 var module = { data: { //服务器地址 serverApi:'', //焦点图数据 focusList: [], communicateList: [], newImgList:[], newList1:[], newList2:[], newList3:[], newList4:[], newList5:[], newList6:[], newList7:[], newList8:[], newList9:[], pageNum1: 1, pageNum2: 1, pageNum3: 1, pageNum4: 1, pageNum5: 1, pageNum6: 1, pageNum7: 1, pageNum8: 1, pageNum9: 1, }, }; var tools = new Tools(); module.init = function (page) { // //新闻列表 // tools.doGet(listSiyigongkai, { // pageNum:1, // pageSize:10, // bookId: JSON.parse(tools.getCookie('user')).bookId, // deptId: JSON.parse(tools.getCookie('user')).deptId // }, module.newsList4 , true); tools.doGet(webList, {}, module.webList , true); // new Swiper('#bannerFocusNextWrap', { // paginationClickable: true, // pagination: '.a2', // autoplay : 2000, // loop:true // }) console.log(JSON.parse(tools.getCookie('user'))) $("#deptName").html(JSON.parse(tools.getCookie('user')).deptName); if (tools.getCookie('user')){ $("#loginF").css('display','none'); $("#listB").css('display','flex'); changeList('1'); } var ulbox1 = document.getElementById("review_box1"); ulbox1.scrollTop = 0; // 开始无滚动时设为0 ulbox1.addEventListener('scroll', function() { if (ulbox1.scrollHeight - ulbox1.scrollTop === ulbox1.clientHeight) { module.data.pageNum1 += 1; changeList('1'); } }); var ulbox2 = document.getElementById("review_box2"); ulbox2.scrollTop = 0; // 开始无滚动时设为0 ulbox2.addEventListener('scroll', function() { if (ulbox2.scrollHeight - ulbox2.scrollTop === ulbox2.clientHeight) { module.data.pageNum2 += 1; changeList('2'); } }); var ulbox3 = document.getElementById("review_box3"); ulbox3.scrollTop = 0; // 开始无滚动时设为0 ulbox3.addEventListener('scroll', function() { if (ulbox3.scrollHeight - ulbox3.scrollTop === ulbox3.clientHeight) { module.data.pageNum3 += 1; changeList('3'); } }); var ulbox4 = document.getElementById("review_box4"); ulbox4.scrollTop = 0; // 开始无滚动时设为0 ulbox4.addEventListener('scroll', function() { if (ulbox4.scrollHeight - ulbox4.scrollTop === ulbox4.clientHeight) { module.data.pageNum4 += 1; changeList('4'); } }); var ulbox5 = document.getElementById("review_box5"); ulbox5.scrollTop = 0; // 开始无滚动时设为0 ulbox5.addEventListener('scroll', function() { if (ulbox5.scrollHeight - ulbox5.scrollTop === ulbox5.clientHeight) { module.data.pageNum5 += 1; changeList('5'); } }); var ulbox6 = document.getElementById("review_box6"); ulbox6.scrollTop = 0; // 开始无滚动时设为0 ulbox6.addEventListener('scroll', function() { if (ulbox6.scrollHeight - ulbox6.scrollTop === ulbox6.clientHeight) { module.data.pageNum6 += 1; changeList('6'); } }); var ulbox7 = document.getElementById("review_box7"); ulbox7.scrollTop = 0; // 开始无滚动时设为0 ulbox7.addEventListener('scroll', function() { if (ulbox7.scrollHeight - ulbox7.scrollTop === ulbox7.clientHeight) { module.data.pageNum7 += 1; changeList('7'); } }); var ulbox8 = document.getElementById("review_box8"); ulbox8.scrollTop = 0; // 开始无滚动时设为0 ulbox8.addEventListener('scroll', function() { if (ulbox8.scrollHeight - ulbox8.scrollTop === ulbox8.clientHeight) { module.data.pageNum8 += 1; changeList('8'); } }); var ulbox9 = document.getElementById("review_box9"); ulbox9.scrollTop = 0; // 开始无滚动时设为0 ulbox9.addEventListener('scroll', function() { if (ulbox9.scrollHeight - ulbox9.scrollTop === ulbox9.clientHeight) { module.data.pageNum9 += 1; changeList('9'); } }); }; module.newsList4 = function (data) { if (data.code == 200) { var content = data.rows; if (module.data.newList4.length >= data.total){ return; }else{ for (let i = 0 ; i < content.length ; i++){ module.data.newList4.push(content[i]); } } // module.data.newList4 = content; var newListData4 = template('newListData4', module.data); $("#newListContent_ul_4").html(newListData4); } } module.newsList7 = function (data) { if (data.code == 200) { var content = data.rows; if (module.data.newList7.length >= data.total){ return; }else{ for (let i = 0 ; i < content.length ; i++){ module.data.newList7.push(content[i]); } } // module.data.newList7 = content; var newListData7 = template('newListData7', module.data); $("#newListContent_ul_7").html(newListData7); } } module.newsList8 = function (data) { if (data.code == 200) { var content = data.rows; if (module.data.newList8.length >= data.total){ return; }else{ for (let i = 0 ; i < content.length ; i++){ module.data.newList8.push(content[i]); } } // module.data.newList8 = content; var newListData8 = template('newListData8', module.data); $("#newListContent_ul_8").html(newListData8); } } module.newsList9 = function (data) { if (data.code == 200) { var content = data.rows; if (module.data.newList9.length >= data.total){ return; }else{ for (let i = 0 ; i < content.length ; i++){ module.data.newList9.push(content[i]); } } // module.data.newList9 = content; var newListData9 = template('newListData9', module.data); $("#newListContent_ul_9").html(newListData9); } } module.webList = function (data) { if (data.code == 200) { var content = data.data; module.data.webList = content; var webData = template('webData', module.data); $("#webContent").html(webData); var titData = template('titData', module.data); $("#titContent").html(titData); $('#ewm').attr('src', 'static/images/'+content.top.bz); } } searchChange = function () { console.log(1111111111); tools.doGet(listSiyigongkai, {pageNum:1,pageSize:8,openName:$("#searchInput").val()}, module.newsList , true); } submitUser = function () { tools.doPost(checkFarmer, {memberName:$("#userName").val(),idcard:$("#password").val()}, module.checkFarmer , true); } clearCook = function () { tools.setCookie('user',''); tools.setCookie('farmerCode',''); $('#loginF').css('display','flex'); $('#listB').css('display','none'); } module.checkFarmer = function (data) { if (data.code == 200) { let seconds = 3600; let expires = new Date(new Date() * 1 + seconds * 1000); tools.setCookie("user", JSON.stringify(data.data), { expires: expires }); tools.doGet(familyMember, {idcard:$("#password").val(),familyStatus:"02"}, module.familyMember , true); } } module.familyMember = function (data) { if (data.code == 200) { const farmerCode = data.rows[0].farmerCode; tools.setCookie("farmerCode",farmerCode, { expires: 30 }); $('#loginF').css('display','none'); $('#listB').css('display','flex'); changeList('1'); } } changeList = function (type) { $('#new_list_1').css('display','none'); $('#new_list_2').css('display','none'); $('#new_list_3').css('display','none'); $('#new_list_4').css('display','none'); $('#new_list_5').css('display','none'); $('#new_list_6').css('display','none'); $('#new_list_7').css('display','none'); $('#new_list_8').css('display','none'); $('#new_list_9').css('display','none'); switch (type) { case '1': $('#new_list_1').css('display','block'); $("#nowDateNYR1").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()); tools.doGet(financePublicList, { pageNum:module.data.pageNum1, pageSize:10, orderByColumn: 'openNy', isAsc: 'desc', bookId: JSON.parse(tools.getCookie('user')).bookId, deptId: JSON.parse(tools.getCookie('user')).deptId }, module.newsList1 , true); break; case '2': $('#new_list_2').css('display','block'); $("#nowDateNYR2").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()); tools.doGet(contractionList, { pageNum:module.data.pageNum2, pageSize:10, orderByColumn: 'buildingTime', translate_dict: 1, isAsc: 'desc', bookId: JSON.parse(tools.getCookie('user')).bookId, deptId: JSON.parse(tools.getCookie('user')).deptId }, module.newsList2 , true); break; case '3': $('#new_list_3').css('display','block'); $("#nowDateNYR3").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()); tools.doGet(majorEventPublicList, { pageNum:module.data.pageNum3, pageSize:10, orderByColumn: 'openNy', isAsc: 'desc', bookId: JSON.parse(tools.getCookie('user')).bookId, deptId: JSON.parse(tools.getCookie('user')).deptId }, module.newsList3 , true); break; case '4': $('#new_list_4').css('display','block'); $("#nowDateNYR4").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()); tools.doGet(listSiyigongkai, { pageNum:module.data.pageNum4, pageSize:10, bookId: JSON.parse(tools.getCookie('user')).bookId, deptId: JSON.parse(tools.getCookie('user')).deptId }, module.newsList4 , true); break; case '5': $('#new_list_5').css('display','block'); $("#nowDateNYR5").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()); break; case '6': $('#new_list_6').css('display','block'); $("#nowDateNYR6").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()); break; case '7': tools.doGet(orcodeList, { translate_dict:1, orderByColumn: 'code', isAsc: 'asc', pageNum:module.data.pageNum7, pageSize:10, bookId: JSON.parse(tools.getCookie('user')).bookId, deptId: JSON.parse(tools.getCookie('user')).deptId }, module.newsList7 , true); $('#new_list_7').css('display','block'); $("#nowDateNYR7").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()); break; case '8': tools.doGet(assetresourceOrcodeList, { translate_dict:1, orderByColumn: 'code', isAsc: 'asc', pageNum:module.data.pageNum8, pageSize:10, bookId: JSON.parse(tools.getCookie('user')).bookId }, module.newsList8 , true); $('#new_list_8').css('display','block'); $("#nowDateNYR8").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()); break; case '9': tools.doGet(tempWorkerPublicList, { translate_dict:1, orderByColumn: 'openNy', isAsc: 'asc', pageNum:module.data.pageNum9, pageSize:10, bookId: JSON.parse(tools.getCookie('user')).bookId, deptId: JSON.parse(tools.getCookie('user')).deptId }, module.newsList9 , true); $('#new_list_9').css('display','block'); $("#nowDateNYR9").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate()); break; default: break; } } module.newsList1 = function (data) { if (data.code == 200) { var content = data.rows; if (module.data.newList1.length >= data.total){ return; }else{ for (let i = 0 ; i < content.length ; i++){ module.data.newList1.push(content[i]); } } var newListData1 = template('newListData1', module.data); $("#newListContent_ul_1").html(newListData1); } } module.newsList2 = function (data) { if (data.code == 200) { var content = data.rows; if (module.data.newList2.length >= data.total){ return; }else{ for (let i = 0 ; i < content.length ; i++){ module.data.newList2.push(content[i]); } } var newListData2 = template('newListData2', module.data); $("#newListContent_ul_2").html(newListData2); } } module.newsList3 = function (data) { if (data.code == 200) { var content = data.rows; if (module.data.newList3.length >= data.total){ return; }else{ for (let i = 0 ; i < content.length ; i++){ module.data.newList3.push(content[i]); } } // module.data.newList3 = content; var newListData3 = template('newListData3', module.data); $("#newListContent_ul_3").html(newListData3); } } function roll(t) { var ul1 = document.getElementById("newListContent"); var ul2 = document.getElementById("newListContent2"); var ulbox = document.getElementById("review_box"); ul2.innerHTML = ul1.innerHTML; ulbox.scrollTop = 0; // 开始无滚动时设为0 var timer = setInterval(rollStart, t); // 设置定时器,参数t用在这为间隔时间(单位毫秒),参数t越小,滚动速度越快 // 鼠标移入div时暂停滚动 ulbox.onmouseover = function () { clearInterval(timer); } // 鼠标移出div后继续滚动 ulbox.onmouseout = function () { timer = setInterval(rollStart, t); } } // 开始滚动函数 function rollStart() { // 上面声明的DOM对象为局部对象需要再次声明 var ul1 = document.getElementById("newListContent"); var ul2 = document.getElementById("newListContent2"); var ulbox = document.getElementById("review_box"); // 正常滚动不断给scrollTop的值+1,当滚动高度大于列表内容高度时恢复为0 console.log(ulbox.scrollTop+'--------'+ul1.scrollHeight) if (ulbox.scrollTop >= ul1.scrollHeight) { ulbox.scrollTop = 0; } else { ulbox.scrollTop += 1; } } return module; });