/**
 * Created by Administrator on 2021/4/5.
 */
define(['jquery', "template", "Tools", 'swiper'], function ($, template, Tools, swiper) {
    //数据存储
    var module = {
        data: {
            type:0
        },
    };
    var tools = new Tools();

    module.init = function (page) {
        //背景高度
        module.register();
        module.data.type = getQueryVariable("type")
        //网站配置信息（网站名称 底部联系方式 公安备案号 网站备案号）
        tools.getWebConfig();
        setTimeout(function(){
            //主题图片切换
            module.switchTheme();
        },500)
    };
    //主题图片切换
    module.switchTheme = function(){
        if(themeColor == 'red'){
            if (getQueryVariable('type')){
                document.getElementById('registerTit').src = '../../static/images/registerTit_red.png'
            }else{
                document.getElementById('icon1').src = '../../static/images/register_icon2_red.png'
                document.getElementById('icon2').src = '../../static/images/register_icon1_red.png'
            }
        }else if(themeColor == 'green'){
            if (getQueryVariable('type')){
                document.getElementById('registerTit').src = '../../static/images/registerTit.png'
            }else{
                document.getElementById('icon2').src = '../../static/images/register_icon1.png'
                document.getElementById('icon1').src = '../../static/images/register_icon2.png'
            }
        }
    }

    //底部友情链接
    module.bottomFriendsLinks = function (data) {
        if (data.code == 200) {
            var content = data.data;
            //console.log(content)
            module.data.friendsLinksList = content;
            var friendsLinksData = template('friendsLinksData', module.data);
            $("#friendsLinksContent").html(friendsLinksData);
        }
    }
    //获取地址栏参数
    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.register = function(){
        document.getElementById('registerBody').style.height = (document.body.offsetHeight - 112) +'px';
    }

    goAgree = function(){
        tools.skip('registerFrom.html?type='+module.data.type)
    }

    goRegister = function(){
        tools.skip('register.html')
    }

    return module;
});
