|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- /**
- * Created by Administrator on 2021/4/5.
- */
- define(['jquery', "template", "Tools", 'swiper'], function ($, template, Tools, swiper) {
- //数据存储
- var module = {
- data: {
- //服务器地址
- serverApi:'',
- //焦点图数据
- focusList: [],
- communicateList: [],
- newImgList:[]
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
- //新闻列表
- tools.doGet(listSiyigongkai, {pageNum:1,pageSize:8}, module.newsList4 , true);
- tools.doGet(webList, {}, module.webList , true);
- // new Swiper('#bannerFocusNextWrap', {
- // paginationClickable: true,
- // pagination: '.a2',
- // autoplay : 2000,
- // loop:true
- // })
- changeList('1');
-
- };
-
- module.newsList4 = function (data) {
- if (data.code == 200) {
- var content = data.rows;
- module.data.newList4 = content;
- var newListData4 = template('newListData4', module.data);
- $("#newListContent_ul_4").html(newListData4);
- }
- }
-
- 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', '/api/'+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);
-
- }
-
- 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');
- $('#new_list').css('display','block');
- }
- }
-
- 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');
- 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:1,
- 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:1,
- 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:1,
- 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:1,pageSize:8}, 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;
-
- }
-
- }
-
- module.newsList1 = function (data) {
- if (data.code == 200) {
- var content = data.rows;
- module.data.newList1 = content;
- var newListData1 = template('newListData1', module.data);
- $("#newListContent_ul_1").html(newListData1);
- }
- }
-
- module.newsList2 = function (data) {
- if (data.code == 200) {
- var content = data.rows;
- module.data.newList2 = content;
- var newListData2 = template('newListData2', module.data);
- $("#newListContent_ul_2").html(newListData2);
- }
- }
-
- module.newsList3 = function (data) {
- if (data.code == 200) {
- var content = data.rows;
- 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;
- });
|