profile.js 10.3 KB
$(document).ready(function() {
        var url = window.location.search;
        // console.log(url);
        if (url.indexOf('?') != -1) {
            //截取url ?id=1 第四位
            var str1 = url.substr(4)
                //公司介绍
            var url8 = "/recommend/recommendList"; // 接口    
            var header = {
                "Content-Type": "application/x-www-form-urlencoded",
            }
            var params = {
                    id: str1
                }
                // 调用公共ajax
            ajax(url8, "GET", header, params, 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}"  class="rounded img-fluid d-block mx-auto" alt="" style="width: 100%;">`
                $("#img1").html(img1)

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

                let img3 = `<img src="${res.data.img3}"  class="rounded img-fluid d-block mx-auto" alt="" style="width: 100%;height:50%">`
                $("#img3").html(img3)

                let bgimg = `
                    <header style="background: url(${res.data.img4}) no-repeat scroll center center;
                    -webkit-background-size: cover;
                    -moz-background-size: cover;
                    background-size: cover;
                    -o-background-size: cover;
                    height: 750px;">
                        <nav>
                            <div class="header-txt1">
                                <div  id="img-logo" style='width:300px;height:80px'>
                                        <img src="./img/portfolio/B1.png" onclick="window.location.href='index.html'">
                                </div>
                                <div class="header-right1">
                                    <div id="login-btn" class="header-btnL"></div>
                                    <a class="header-right-btn" onclick="setPersonal()">
                                        <img src="./img/portfolio/circle.png" style="width: 50px;height: 50px;">
                                    </a>
                                </div>
                            </div>
                        </nav>
                        <div class="header-text hidden-xs">
                            <div class="col-md-12 text-center">
                                <div><img src='${res.data.img}'></div>
                                <p style="color: #fff;  id="explain">${res.data.explain}</p>
                                <h1 style="color: #fff;" id="headTitle">欢迎加入上海国际货币经纪虚拟实习项目<br/>更快学习交易经纪人的职场能力!</h1>
                                <p style="color: #fff;padding-top: 20px;" id="titleExplain">${res.data.titleExplain}</p>
                                <div style="padding-top: 70px;display: flex;place-items: center;">
                                    <h5 style="position: absolute;background-color: #97dab6;border-radius: 50%;z-index: 2;width: 40px;height: 40px;opacity: 0.5;">&nbsp;</h5>
                                    <a onclick="setLearingContentId(1)" style="position: relative;left: 25px;color: #fff; z-index: 5;cursor: pointer;">加入虚拟实习项目</a>
                                </div>
                            </div>
                        </div>
                    </header>`
                $("#bgimg").html(bgimg)
                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)
                }
            }, function(res) {
                console.log(res);
            })

            //获取四张小图
            var url1 = "/recommendOne/recommendOneList"; // 接口    
            var header1 = {
                "Content-Type": "application/x-www-form-urlencoded",
                "token": localStorage.getItem('token'),
            }
            var params1 = {
                id: str1
            }
            ajax(url1, "GET", header1, params1, function(res) {
                    console.log(res);
                    $.each(res.data, function(key, value) {
                        let title = `<div class="col-md-6 box-item">
                    <a style='width:30%'><img src="${value.img}"></a>
                    <div class="col-xs-91">
                        <span>${value.title}</span>
                        <p style="color:#5A5A5A;font-size: 0.5em;font-family: Helvetica;">${value.englishTitle}</p>
                    </div>
                </div>`
                        $('#fourGroups').append(title)
                    })
                }, function(res) {
                    console.log(res);
                })
                //大标题
            var url2 = "/recommend/recommendTwoList"; // 接口    
            ajax(url2, "GET", header1, params1, function(res) {
                    console.log(res);
                    for (let i in res.data) {
                        console.log(res.data[i])
                        var newHeight = $('#get_right').css('height')
                            // console.log(newHeight);
                            //${$('#get_right').css('height') ? $('#get_right').css('height').replace('px', '')-150 : 100}
                            //${newHeight ? newHeight.replace('px','')-150 : 100}
                        let title = `
                        <div class='all-list'>
                            <!-- 左边 -->
                            <div class='list-left'>
                                <div class='yuan-num'>
                                    <!-- 圆 -->
                                    <div class='left-yuan'></div>
                                    <!-- 数字 -->
                                    <div class='left-num'>${res.data[i].id<10 ? '0'+res.data[i].id : res.data[i].id}</div>
                                </div>
                                <!-- 线 -->
                                <div class='left-xian' style="height: 100px;">&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">
                                
                                </div>
                                    <button class='title-btn'  onClick="setLearingContentId(${res.data[i].id})">下一步骤></button>
                            </div>
                        </div>`
                            // let content = ''
                        $('#recommend-List').append(title);

                    }
                    for (let i in res.data) {
                        if (res.data[i].recommendThrees.length) {
                            $.each(res.data[i].recommendThrees, function(index, item) {
                                console.log(item);
                                // recommendListId = item.id
                                if (index == item.id - 1) {

                                    let content = `<div>${item.subhead}</div>`
                                    $('#title_content').append(content)
                                }
                            })
                        }
                    }
                }, function(res) {
                    console.log(res);
                })
                //首页
            var url3 = "/warranty/warrantyList";
            ajax(url3, "GET", header1, function(res) {
                console.log(res);
            }, function(res) {
                console.log(res);
                let EWM = `<img src="${res.data.sevenimg4}" width="100%">`
                $('#ewm-footer').html(EWM)
            })

        }
    })
    // 传二级标题的id
function setLearingContentId(id) {
    console.log(id);
    window.location.href = 'learningContent.html?id=' + id
}
//获取用户VIP信息判断是否是VIP
function setPersonal() {
    var url = "/login/userInfo"; // 接口    
    var header = {
            "Content-Type": "application/json",
            "token": localStorage.getItem('token'),
        }
        // 调用公共ajax
    ajax(url, "GET", header, function(res) {
        console.log(res);
    }, function(res) {
        console.log(res);
        if (res.data.status1 == 1) {
            window.location.href = 'personalCenter.html'
        } else {
            window.location.href = 'personalCenter2.html'
        }
    })
}