/**
 * Created by Administrator on 2021/4/5.
 */
define(['jquery', "template", "Tools", 'swiper', 'dateTime'], function ($, template, Tools, swiper) {
    //数据存储
    var module = {
        data: {
            //服务器地址
            serverApi:'',
            //焦点图数据
            focusList: [],
            communicateList: [],
            newImgList:[]
        },
    };
    var tools = new Tools();

    module.init = function (page) {
        tools.doGet(webList, { configKey: 'web.open' }, module.webList , true);

        $("#signStartTimeStr").datetime({
            type: "date",
            value: [new Date().getFullYear(),new Date().getMonth()+1,new Date().getDate()],
            success: function (res) {
                //console.log(res)
            }
        })
    };

    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.rows;

            content.map(rr=>{
                if (rr.configKey == 'web.open.technique'){
                    $("#zcdw").html(rr.configValue);
                }
                if (rr.configKey == "web.open.phone"){
                    $("#phone").html(rr.configValue);
                }
                if (rr.configKey == "web.open.qrcode"){
                    $('#ewm').attr('src', rr.configValue);
                }
                if (rr.configKey == "web.open.title"){
                    $("#tt").html(rr.configValue);
                }
            })

        }
    }

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

    return module;
});
