index.js 10.9 KB
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() {
   
        //判断右上角是否登录
    // if (token == null) {
    //     let loginTit1 = `
    //     <a href='login.html'>
    //         <div class="header-loginBtn" id="loginTitle">登录</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)
    // }
    

    //首页
    ajax("/warranty/warrantyList", "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: 100%;">`
        $('#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}" style="width: 100%;height: 100%;">`
        $('#ewm-footer').html(EWM)
    })
    var header8 = {
            "Content-Type": "application/x-www-form-urlencoded",
        }
        //获取四张小图
    ajax("/warrantyOne/warrantyOneList", "GET", header8, 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="imgList col-xs-6 col-lg-3">
                    <div id="FourImage">
                        <img src="${value.img}" style='width:100%'>
                    </div>
                    <div id="FourTitle">${value.title}</div>
                    <div id="FourTxt">${value.content}</div>
                </div>`
            $('#fourGroups').append(title)
        })
    })

    //企业实习项目
    var header2 = {
        "Content-Type": "application/json",
        // "token": localStorage.getItem('token'),
    }
    var params = JSON.stringify({
        current: 1,
        size: 4
    })
    ajax("/warrantyTwo/warrantyTwoList", "POST", header2, params, function(res) {
            // console.log(res);
            $.each(res.data.records, function(key, value) {
                // console.log(value)
                let title1 = `
                <div class="proContent" style="background: url('${value.img}') no-repeat;background-size: 100% 100%" id=${value.id} onClick="setProfileId(${value.id})">
                    <div class="aa_content">
                        <div class="prowaiImg">
                            <img src="${value.img1}" style='width:100%;height:100%'>
                        </div>
                        <div class="proInfo">
                            <div class="pro_py">${value.title}</div>
                            <div class="pro_yy">${value.yyTitle}</div>
                        </div>
                    </div>
                    <div class="box" style="background: url('img/index/5-3.png') no-repeat;background-size: 100% 100%">
                        <div class="pro_tit">${value.content}</div>
                        <div class="aa_content">
                            <div class="prowaiImg">
                                <img src="${value.img1}" style='width:100%;height:100%'>
                            </div>
                            <div class="proInfo">
                                <div class="pro_py">${value.title}</div>
                                <div class="pro_yy">${value.yyTitle}</div>
                            </div>
                        </div>
                    </div>
                </div>`
                let title = `
            <div class="col-xs-6 col-lg-33 portfolio-post contentClick" id=${value.id} onClick="setProfileId(${value.id})">
                <div 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%' class='noticeimg-head'>
                        </div>
                        <div class='par-headImg-all' >
                            <div class='par-headImg1'>
                                <img src="${value.img1}">
                            </div>
                            <div class='par-headTitle' >
                                <div class='par-headTitle1'>${value.title}</div>
                                <div class='par-headTitle2'>${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>
                </div>
            </div>`
                $('#enterpriseProject').append(title1)
            })
        }, function(res) {
            // console.log(res);
        })
        //学长学姐分享
    header5 = {
        "Content-Type": "application/x-www-form-urlencoded"
    }
    ajax("/warrantyThree/warrantyThreeList", "GET", header5, function(res) {
    }, function(res) {
        // console.log(res);
        for (let i in res.data) {
            // console.log(res.data[i]);
            // console.log(res.data[i].name);
            let title = `
            <div class="post-slide">
                <div class="swiper_wai">
                    <div class="share_all">
                        <div class="share_top">
                            <div class="share_img">
                                <img src="${res.data[i].img}" style="width: 100%;">
                            </div>
                            <div class="share_name">
                                <div class="share_name1">${res.data[i].name}</div>
                                <div class="share_info">${res.data[i].remark}</div>
                            </div>
                        </div>
                        <div class="share_title">${res.data[i].sketch}</div>
                    </div>
                    <div class="swiper_box">
                        <div class="swi_names">
                            <div class="swi_name">${res.data[i].name}</div>
                            <div class="swi_info">${res.data[i].remark}</div>
                        </div>
                        <div class="swi_cont">${res.data[i].content}</div>
                    </div>
                </div>
            </div>
            `
            $(".swiperNew").append(title)

        }
    })
    

    //首页问题
    ajax("/warrantyFive/warrantyFiveList", "GET", header, function(res) {
        // console.log(res);
    }, function(res) {
        // console.log(res);
        $.each(res.data, function(key, value) {
            // console.log(value.question);
            let title = `
                <div class='questionList'>
                    <div  class='wenti-btn' id="question2" onClick="showAnswer(${value.id})" data-id='${key}'>${value.question}</div>
                    <p class='wenti_daan' id="answer${value.id}" data-id='${key}'></p>
                </div>`
            $('#clickQuestion').append(title)
        })
    })
});


//首页答案
function showAnswer(id) {
    var params1 = {
            id: id
        }
    ajax("/warrantyFive/warrantyFiveAnswer", "GET", header, params1, function(res) {
        // console.log(res);
        $('#answer' + id).parent().parent().find('p').html('')
        $('#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) {})
}
//进入项目页
function setProfileId(id) {
    // location.href()
    // console.log('1111', id);
    window.location.href = 'profile.html?id=' + id

}
//获取用户VIP信息判断是否是VIP
function setPersonal() {
    var header2 = {
        "Content-Type": "application/json",
        "token": localStorage.getItem('token'),
    }
    ajax("/login/userInfo", "GET", header2, function(res) {
        // console.log(res);
    }, function(res) {
        localStorage.setItem("name", res.data.surname + res.data.userName);
        // console.log(res);
        if (res.data.status1 == 2) {
            window.location.href = 'personalCenter2.html'
        } else {
            window.location.href = 'personalCenter.html'
        }
    }, function(res) {
        // console.log(res);
        if (res) {
            alert("请您先登录!")
        }
    })
}
//浏览更多跳转
function morebro() {
    window.location.href = 'browseMore.html'
}
//登录
function loginStatus1() {
    window.location.href = 'login.html'
}