profile.js 8.4 KB
var str1 = ''
var token = ''
var userId = ''
$(document).ready(function () {
    var url = window.location.search;
    // console.log(url);
    if (url.indexOf('?') != -1) {
        //截取url ?id=1 第四位
        str1 = url.substr(4)
        console.log(str1);
        token = localStorage.getItem('token')
        userId = localStorage.getItem("userId");

        //公司介绍
        var header = {
            "Content-Type": "application/x-www-form-urlencoded",
        }
        ajax("/recommend/recommendList", "GET", header, { id: str1 }, function (res) {
            // console.log(res);
            // console.log(res.data);
            // $('#titleExplain').html(res.data.titleExplain)
            // $('#explain').html(res.data.explain)
            $('#onefield').html(res.data.onefield)
            $('#onefield1').html(res.data.onefield1)
            $('#twofield').html(res.data.twofield)
            $('#twoName').html(res.data.twoName)
            $('#twoNames').html(res.data.twoNames)
            $('#twofield1').html(res.data.twofield1)
            $('#fourfield1').html(res.data.fourfield1)
            $('#fourfield2').html(res.data.fourfield2)
            $('#fourfield3').html(res.data.fourfield3)
            $('#fivefield').html(res.data.fivefield)
            $('#threefield').html(res.data.threefield)
            $('#threefield1').html(res.data.threefield1)
            // 图片
            // let logo = ` <img src="${res.data.img}" style="width: 100%;">`
            // $("#img-logo").html(logo)
            let img1 = `<img src="${res.data.img1}"  alt="" style="width: 100%;height:100%">`
            $("#img1").html(img1)

            let img2 = `<img src="${res.data.img2}"   alt="" style="width: 100%;height:100%">`
            $("#img2").html(img2)

            let img3 = `<img src="${res.data.img3}"  style="width: 100%;height:100%" alt="" >`
            $("#img3").html(img3)

            $("#profile_bg").css('background-image', "url(" + res.data.img4 + ")")
            $("#profile_head_logo").attr("src", res.data.img)
            $("#explain").html(res.data.explain)
            $("#titleExplain").html(res.data.titleExplain)
            let info = ` 
            <div class='btn-joinUs'>
                <h5
                    style="position: absolute;background-color: #97dab6;border-radius: 50%;z-index: 2;width: 0.50rem;height: 0.50rem;opacity: 0.5;">
                    &nbsp;</h5>
                <a onclick="setLearingContentId(${str1})" class='joinStudyPro'>加入实习项目</a>
            </div>`
            $('#jionInfo').html(info)
        }, function (res) {
            // console.log(res);
        })

        //获取四张小图
        var header1 = {
            "Content-Type": "application/x-www-form-urlencoded",
        }
        ajax("/recommendOne/recommendOneList", "GET", header1, { id: str1 }, function (res) {
            $.each(res.data, function (key, value) {
                let title = `
                        <div class="col-md-6 .col-sm-6 .col-xs-6 .col-lg-3 box-item">
                            <div class='four-to-one'><img src="${value.img}" style='width:100%'></div>
                            <div class="col-xs-91 four-to-tit">
                                <div class='four-to-one1'>${value.title}</div>
                                <div class='four-to-two1'>${value.englishTitle}</div>
                            </div>
                        </div>`
                $('#fourGroups').append(title)
            })
        }, function (res) { })




        var newId = ''
        if (userId != null && userId != '') {
            newId = userId
        } else {
            newId = 0
        }
        //大标题
        var header3 = {
            "Content-Type": "application/x-www-form-urlencoded",
            // "token": localStorage.getItem('token'),
        }
        ajax("/recommend/recommendTwoList", "GET", header3, { id: str1, userId: newId }, function (res) {
            console.log(res);
            for (let i in res.data) {
                //判断题目高度
                let singltItem = ''
                let content = ''
                let x = +i + 1
                let title = `
                        <div class='all-list'>
                            <!-- 左边 -->
                            <div class='list-left'>
                                <div class='yuan-num'>
                                    <!--  -->
                                    <div class='left-yuan'></div>
                                    <!-- 数字 -->
                                    <div class='left-num'>${x < 10 ? '0' + x : x}</div>
                                </div>
                                <!-- 线 -->
                                <div class='left-xian' style="height: 1rem;">&nbsp;</div>
                            </div>
                            <!-- 右边 -->
                            <div id="get_right" class='right-content'>
                                <!-- 大标题 -->
                                <div class='bigTitle' id="big-title">
                                    <div class='bigTitle-one' id="headline">${res.data[i].headline}</div>
                                    <div class='bigTitle-two' id='dateTime'>${res.data[i].dateTime}</div>
                                </div>
                                <!-- 小标题 -->
                                <div class='smallTitle' id="title_content">`
                $.each(res.data[i].recommendThrees, function (index, item) {
                    if (index == 0) {
                        console.log(i);
                        console.log(item);
                    }
                    if (index < 2) {
                        content += `<div>${item.subhead}</div>`
                    }
                })
                singltItem = title + content + ` </div>
                                <button class='title-btn'  onClick="setLearingContentId(${str1})">下一步骤></button>
                            </div>
                        </div>`
                $('#recommend-List').append(singltItem);

            }
            //  $(".all-list").last().find('#list-left').find('#left-xian').css('display','none')

        }, function (res) {
            console.log(res);
        })



        //首页底部二维码
        ajax("/warranty/warrantyList", "GET", header1, function (res) {
        }, function (res) {
            let EWM = `<img src="${res.data.sevenimg4}" width="100%">`
            $('#ewm-footer').html(EWM)
        })

    }
})
//添加项目
function setLearingContentId(id) {
    var header1 = {
        "Content-Type": "application/json",
        "token": localStorage.getItem('token'),
    }
    ajax("/login/userInfo", "GET", header1, function (res) {
        console.log(res);
    }, function (res) {
        // console.log(res);
        if (res.data.status1 == 2) {
            var url7 = "/userProgram/userProgramAdd/" + id;
            var header = {
                "Content-Type": "application/x-www-form-urlencoded",
                "token": localStorage.getItem('token'),
            }
            ajax(url7, "POST", header, function (res) {
                console.log(res);
            }, function (res) {
                console.log(res);
                window.location.href = 'learningContent.html?id=' + id
            }, function (res) {
                console.log(res);
                alert("登录才可以查看项目内容哦!")
                window.location.href = 'login.html'
            })
        } else {
            alert("请您充值会员才能查看此内容!")
            window.location.href = 'personalCenter.html'
        }
    }, function (res) {
        if (res) {
            alert("请您先登录,否则无法查看项目内容!")
            window.location.href = 'login.html'
        }
    })


}
//获取用户VIP信息判断是否是VIP
function setPersonal() {
    var header = {
        "Content-Type": "application/json",
        "token": localStorage.getItem('token'),
    }
    ajax("/login/userInfo", "GET", header, 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 (res) {
        if (res) {
            alert("请您先登录!")
            window.location.href = 'login.html'

        }
    })
}