/**
 * 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(orcodeList, {
            code:getQueryVariable('id'),
            translate_dict: '1',
            bookId: JSON.parse(tools.getCookie('user')).bookId,
            deptId: JSON.parse(tools.getCookie('user')).deptId
        }, module.newsDetail , true);
        //新闻列表
        tools.doGet(orcodeList, {
            translate_dict:1,
            orderByColumn: 'code',
            isAsc: 'asc',
            pageNum:1,
            pageSize:10,
            bookId: JSON.parse(tools.getCookie('user')).bookId,
            deptId: JSON.parse(tools.getCookie('user')).deptId
        }, 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.assetType || ''));
            $('#operationType').html('经营属性：'+(content.operationType || ''));
            $('#secondParty').html('构建时间：'+(content.buildTime || ''));
            $('#location').html('坐落位置：'+(content.location || ''));
            $('#settleType').html('使用情况：'+(content.useType || ''));
            $('#totalAmount').html('数量/建筑面积：'+(content.netValue || ''));
            $('#settledAmount').html('计量单位：'+(content.unit || ''));
            $('#receivedAmount').html('原值：'+(content.originalValue || ''));
        }
    }

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