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

    module.init = function (page) {
        //新闻详情
        tools.doGet(assetresourceOrcodeList, {
            code:getQueryVariable('id'),
            translate_dict: '1',
            bookId: JSON.parse(tools.getCookie('user')).bookId
        }, module.newsDetail , true);
        //新闻列表
        tools.doGet(assetresourceOrcodeList, {
            translate_dict:1,
            orderByColumn: 'code',
            isAsc: 'asc',
            pageNum:1,
            pageSize:10,
            bookId: JSON.parse(tools.getCookie('user')).bookId
        }, module.newsList , true);
        tools.doGet(webList, {}, module.webList , 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.webList = function (data) {
        if (data.code == 200) {
            var content = data.data;
            module.data.webList = content;
            var webData = template('webData', module.data);
            $("#webContent").html(webData);
            $('#ewm').attr('src', 'static/images/'+content.top.bz);
        }
    }

    module.newsDetail = function (data) {
        if (data.code == 200) {
            var content = data.rows[0];
            $('#name').html(content.name);
            $('#code').html('资源编码：' + (content.code || ''));
            $('#biddingType').html('资源分类：'+(content.resourceSort || ''));
            $('#secondParty').html('资源类型：'+(content.resourceType || ''));
            $('#location').html('坐落位置：'+(content.location || ''));
            $('#east').html('东至：'+(content.east || ''));
            $('#west').html('西至：'+(content.west || ''));
            $('#south').html('南至：'+(content.south || ''));
            $('#north').html('北至：'+(content.north || ''));
            $('#settleType').html('面积：'+(content.totalArea || '') + '亩');
            $('#totalAmount').html('使用情况：'+(content.useType || ''));
        }
    }

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

    return module;
});
