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

    module.init = function (page) {
        //新闻管理列表
        tools.doGet(dictType + '/communicate_type', {}, module.dictType , true);


    };

    //获取地址栏参数
    function getQueryVariable(variable){
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return(false);
    }

    module.dictType = function (data) {
        module.data.communicateOptions = data.data;
        tools.doGet(communicateDetail + '/' + getQueryVariable('id'), {}, module.newList , true);
    }

    //新闻列表
    module.newList = function (data) {
        console.log(data)
        if (data.code == 200) {
            var content = data.data;
            content.communicateType = module.selectDictLabel(module.data.communicateOptions,content.communicateType)
            module.data.newList = content;
            var newData = template('newData', module.data);
            $("#newContent").html(newData);
            if (document.body.scrollHeight > document.body.offsetHeight){
                document.getElementById('bottomInformation').style.position = 'relative';
            }
        }
    }

    module.selectDictLabel = function (datas, value) {
        var actions = [];
        Object.keys(datas).some((key) => {
            if (datas[key].dictValue == ('' + value)) {
                actions.push(datas[key].dictLabel);
                return true;
            }
        })
        return actions.join('');
    }

    goDetail = function(id){
        tools.skip('/agriculturalLawEnforcement/view/workDynamics/workDetail.html?id='+id);
    }
    return module;
});