index.js 10.6 KB
var url5 = "/login/userInfo"; // 接口  
var header = {
    "Content-Type": "application/x-www-form-urlencoded"
}
var header1 = {
    "Content-Type": "application/x-www-form-urlencoded",
    "token": localStorage.getItem('token'),
}
var header2 = {
    "Content-Type": "application/json",
    "token": localStorage.getItem('token'),
}
var header3 = {
    "Content-Type": "application/json",
}

$(document).ready(function() {

    var token = localStorage.getItem('token')
        //判断右上角是否登录
    if (token == null) {
        let loginTit1 = `
        <a href='login.html'>
            <div class="header-loginBtn" id="loginTitle">&nbsp;&nbsp;</div>
        </a>`
        $("#login-btn").html(loginTit1)
    } else {
        let loginTit2 = `
            <a href='login.html'>
                <div class="header-loginBtn" id="loginTitle">退出登录</div>
            </a>`
        $("#login-btn").html(loginTit2)
    }

    //首页
    var url = "/warranty/warrantyList"; // 接口    

    ajax(url, "GET", header, function(res) {
        console.log('1', res);
    }, function(res) {
        console.log(res);
        $('#onefields1').html(res.data.onefields1)
        $('#onefields2').html(res.data.onefields2)
        $('#twofields1').html(res.data.twofields1)
        $('#twofields2').html(res.data.twofields2)
        $('#twofields3').html(res.data.twofields3)
        $('#threefield1').html(res.data.threefield1)
        $('#threefield2').html(res.data.threefield2)
        $('#fourfields1').html(res.data.fourfields1)
        $('#fourfields2').html(res.data.fourfields2)
        $('#fourfields3').html(res.data.fourfields3)
        $('#fivefields1').html(res.data.fivefields1)
        $('#fivefields2').html(res.data.fivefields2)
        $('#sixfields1').html(res.data.sixfields1)
        $('#sixfields2').html(res.data.sixfields2)
        $('#sevenfields1').html(res.data.sevenfields1)
        $('#sevenfields2').html(res.data.sevenfields2)
            //图片
        let img1 = `<img src="${res.data.oneimg1}" class="img-responsive" alt="" style='width:100%;height:60%;'>`
        $('#oneimg1').html(img1)
        let img2 = `<img src="${res.data.twoimg2}"  alt="" style="width: 100%;height: 100%;">`
        $('#twoimg2').html(img2)
        let img3 = `<img src="${res.data.fourimg3}" alt=" " style="width: 100%;height: 100%;">`
        $('#fourimg3').html(img3)
        let EWM = `<img src="${res.data.sevenimg4}" width="100%">`
        $('#ewm-footer').html(EWM)
    })

    //获取四张小图
    var url1 = "/warrantyOne/warrantyOneList"; // 接口    
    ajax(url1, "GET", header1, function(res) {
        console.log(res);

    }, function(res) {
        console.log(res);
        $.each(res.data, function(key, value) {
            // console.log($(this));
            // console.log(value)
            let title = `
                <div class="col-md-6 box-item">
                    <div id="FourImage">
                        <img src="${value.img}">
                    </div>
                    <div class="col-xs-99" id="fourGroups_title">
                        <span id="FourTitle">${value.title}</span>
                        <p id="FourTxt" style="color:#5A5A5A;font-size: 0.5em;font-family: Helvetica;">${value.content}</p>
                    </div>
                </div>`
            $('#fourGroups').append(title)
        })
    })

    //企业实习项目
    var url2 = "/warrantyTwo/warrantyTwoList"; // 接口    
    // var header2 = {
    //     "Content-Type": "application/json",
    //     "token": localStorage.getItem('token'),
    // }
    var params = JSON.stringify({
        current: 1,
        size: 4
    })
    ajax(url2, "POST", header2, params, function(res) {
            console.log(res);
            $.each(res.data.records, function(key, value) {
                console.log(value)
                let title = `
            <div class="col-xs-6 col-lg-33 portfolio-post contentClick" style="margin-bottom: 2%;height:35%" id=${value.id} onClick="setProfileId(${value.id})">
                <article class="portfolio-post-item" style='height:100%'>
                    <div style="position: relative;height:100%">
                        <div style="position: relative;" style='height:100%'>
                            <img src="${value.img}" alt="" style='height:100%'>
                        </div>
                        <div style="position: absolute;bottom: 4%;right: 2%;line-height: 1;display: flex;width: 40%;place-items:center">
                            <div style="position: relative;margin-right: 2%;width: 25%;">
                                <img src="${value.img1}">
                            </div>
                            <div style="position: relative;">
                                <div style="font-size: 1.4em;color: #fff;padding-bottom:5%">${value.title}</div>
                                <div style="font-size: 1.4em;color: #fff; ">${value.yyTitle}</div>
                            </div>
                        </div>
                    </div>

                    <div class="portfolio-content-wrapper" style='height:100%'>
                        <div class="portfolio-content" style='height:100%;text-align:left'>
                            <h3 class="portfolio-title" style='height:70%;color:#fff;font-size:1em;line-height:2'>${value.content}</h3>
                            <div style="display: flex;text-align: left;place-items: center;padding: 6% 0 4%;height:30%">
                                <div style='width:60px;height:60px'>
                                    <img src="${value.img1}" style="width: 100%;height: 100%; ">
                                </div>
                                <div style="display: flex;flex-direction: column;padding-left: 2%; ">
                                    <div class="portfolio-cat" style='padding-bottom:5%'>${value.title}</div>
                                    <div class="portfolio-cat">${value.yyTitle}</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </article>
            </div>`
                $('#enterpriseProject').append(title)
            })
        }, function(res) {
            console.log(res);
        })
        //学长学姐分享
    var url7 = "/warrantyThree/warrantyThreeList"
    header5 = {
        "Content-Type": "application/x-www-form-urlencoded"
    }
    ajax(url7, "GET", header5, function(res) {

    }, function(res) {
        console.log(res);
        for (let i in res.data) {
            console.log(res.data[i]);
            let img = `<img src='${res.data[i].img}' style="width: 100%; ">`
            $("#head-img").append(img)

            $("#little-name").html(res.data[i].name)
            $("#remark").html(res.data[i].remark)
            $("#sketch").html(res.data[i].sketch)
            $("#h-name").html(res.data[i].name)
            $("#h-remark").html(res.data[i].remark)
            $("#header-content").html(res.data[i].content)

            let title = `
            <div class="training-block-one">
                <div class="inner-box">
                    <div class="content-box">
                        <figure><img src="img/portfolio/white.png" alt=""></figure>
                        <div class="text" style="top: 0px;">
                            <div style="display: flex;place-items: center;padding-left: 5%; ">
                                <div id="head-img" style="width:30%"><img src='${res.data[i].img}' style="width: 100%; "></div>
                                <div style='display:flex;flex-direction: column;padding-left: 8%;text-align: left;'>
                                    <h3 id="little-name" style="color: #323232;">${res.data[i].name}</h3>
                                    <p id="remark" style="color: #5a5a5a;">${res.data[i].remark}</p>
                                </div>
                            </div>
                            <h4 id="sketch" style="color: #5A5A5A;">${res.data[i].sketch}</h4>
                        </div>
                    </div>
                    <div class="overlay-box">
                        <div class="text" style="display: flex;">
                            <h4 id="h-name" style="padding-right: 10px;">${res.data[i].name}</h4>
                            <h4 id="h-remark">${res.data[i].remark}</h4>
                        </div>
                        <p id="header-content">${res.data[i].content}</p>
                    </div>
                </div>
            </div>`
            $(".owl-stage").append(title)





        }
    })

    //首页问题

    var url3 = "/warrantyFive/warrantyFiveList";
    ajax(url3, "GET", header1, function(res) {
        console.log(res);

    }, function(res) {
        console.log(res);
        $.each(res.data, function(key, value) {
            console.log(value.question);
            let title = `
                <div>
                <div  class='wenti-btn' id="question2" onClick="showAnswer(${value.id})" data-id='${key}'>${value.question}</div>
                <p id="answer${value.id}" data-id='${key}' style="color:#323232"></p>
                </div>`
            $('#clickQuestion').append(title)
        })
    })
});


//首页答案
function showAnswer(id) {
    console.log(1213);
    var url4 = "/warrantyFive/warrantyFiveAnswer"; // 接口    
    var params1 = {
            id: id
        }
        // 调用公共ajax
    ajax(url4, "GET", header1, params1, function(res) {
        console.log(res);
        $('#answer' + id).parent().parent().find('p').html('')
        $('#answer' + id).parent().parent().find('.wenti-btn').css('color', 'black')
            // console.log($('#answer' + id).parent().parent().find('p').html(''))
            // console.log($('#answer' + id).parent().parent().find('.wenti-btn').css('color', 'black'));
        $('#answer' + id).parent().find('#question2').css('color', '#66ca94')
        $('#answer' + id).html(res.data)
        console.log($(this))
    }, function(res) {
        console.log(res);

    })
}
//进入项目页
function setProfileId(id) {
    // location.href()
    console.log('1111', id);
    window.location.href = 'profile.html?id=' + id

}
//获取用户VIP信息判断是否是VIP
function setPersonal() {

    // 调用公共ajax
    ajax(url5, "GET", header2, function(res) {
        console.log(res);
    }, function(res) {
        console.log(res);
        if (res.data.status1 == 2) {
            window.location.href = 'personalCenter2.html'
        } else {
            window.location.href = 'personalCenter.html'
        }
    })
}
//浏览更多跳转
function morebro() {
    window.location.href = 'browseMore.html'
}
//登录
function loginStatus1() {
    window.location.href = 'login.html'
}