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

    module.init = function (page) {
        tools.doGet(getTopDeptId, {}, module.getInformation , true);
        if (document.body.scrollHeight <= document.body.offsetHeight){
            document.getElementById('bottomInformation').style.position = 'fixed';
            document.getElementById('bottomInformation').style.bottom = '0';

        }
    };

    module.getInformation = function (data) {
        console.log(data)
        module.data.deptId = data.data;
    }

    goAdd = function () {
        if($('#title').val()=="" || $('#title').val()==undefined){
            tools.initError('标题不能为空！');
        } else if($('#content').val()=="" || $('#content').val()==undefined){
            tools.initError('内容不能为空！');
        } else if($('#phone').val()=="" || $('#phone').val()==undefined){
            tools.initError('联系方式不能为空！');
        } else{
            var form = {
                title:$('#title').val(),
                communicateType:$('input:radio:checked').val(),
                content:$('#content').val(),
                name:$('#name').val(),
                phone:$('#phone').val(),
            }
            tools.doPost(communicateAdd, {
                title:$('#title').val(),
                communicateType:$('input:radio:checked').val(),
                content:$('#content').val(),
                name:$('#name').val(),
                phone:$('#phone').val(),
                deptId:module.data.deptId
            }, module.addEnd , true);
        }
    }

    module.addEnd = function(data){
        tools.initError('发布成功');
        setTimeout(function(){
            tools.skip('complaintList.html')
        },2000)
    }

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