/**
 * 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(newsList, {pageNum:1,pageSize:8}, module.newsList , true);
        tools.doGet(webList, {}, module.webList , true);
        new Swiper('#bannerFocusNextWrap', {
            paginationClickable: true,
            pagination: '.a2',
            autoplay : 2000,
            loop:true
        })

        $("#nowDateNYR").html(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate());

    };

    module.newsList = function (data) {
        if (data.code == 200) {
            var content = data.rows;
            module.data.newList = content;
            var newListData = template('newListData', module.data);
            $("#newListContent").html(newListData);

            var newImgList = [];
            content.map(rr=>{
                if (rr.infoImg!=null&&rr.infoImg!=""){
                    newImgList.push(rr.infoImg);
                }
            })
            module.data.newImgList = newImgList;
            var newListDataImg = template('newListDataImg', module.data);
            $("#bannerFocusNextContent").html(newListDataImg);
        }
    }

    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);
        }
    }

    searchChange = function () {
        tools.doGet(newsList, {pageNum:1,pageSize:8,infoName:$("#searchInput").val()}, module.newsList , true);
    }

    return module;
});