profile.js 11.4 KB
$(document).ready(function() {
        var url = window.location.search;
        // console.log(url);
        if (url.indexOf('?') != -1) {
            //截取url ?id=1 第四位
            var str1 = url.substr(4)
            console.log(str1);
            //公司介绍
            var url8 = "/recommend/recommendList"; // 接口    
            var header = {
                "Content-Type": "application/x-www-form-urlencoded",
            }
            var params = {
                id: str1
            }
            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 profile-footerImg1" alt="" >`
                $("#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" class="header-img1">
                                        <img src="./img/portfolio/whiteLogo.png" onclick="window.location.href='index.html'" style="width: 100%;">
                                </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">
                            <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 id="titleExplain">${res.data.titleExplain}</p>
                                <div class='btn-joinUs'>
                                    <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(${str1})" class='joinStudyPro'>加入实习项目</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">
                            <div class='four-to-one'><img src="${value.img}" style='width:100%'></div>
                            <div class="col-xs-91 four-to-tit">
                                <span class='four-to-one'>${value.title}</span>
                                <p class='four-to-two'>${value.englishTitle}</p>
                            </div>
                        </div>`
                    $('#fourGroups').append(title)
                })
            }, function(res) {})

            //大标题
            var url2 = "/recommend/recommendTwoList";
            var header3 = {
                "Content-Type": "application/x-www-form-urlencoded",
                "token": localStorage.getItem('token'),
            }
            ajax(url2, "GET", header3, 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 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: 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">`
                    $.each(res.data[i].recommendThrees, function(index, item) {
                        if (index == 0) {
                            console.log(i);
                            console.log(item);
                        }

                        // recommendListId = item.id
                        if (index < 2) {
                            content += `<div>${item.subhead}</div>`

                            //$('#title_content').append(content)
                        }
                    })

                    // $('#recommend-List').append(title);
                    singltItem = title + content + ` </div>
                                <button class='title-btn'  onClick="setLearingContentId(${str1})">下一步骤></button>
                            </div>
                        </div>`
                    $('#recommend-List').append(singltItem);

                }
            }, 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)
            })

        }
    })
    //添加项目
function setLearingContentId(id) {
        var header1 = {
            "Content-Type": "application/json",
            "token": localStorage.getItem('token'),
        }
        // 调用公共ajax
        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("登录才可以查看项目内容哦!")
                    })
            } else {
               alert("请您充值会员才能查看此内容!")
            }
        }, function(res) {
            if (res) {
                alert("请您先登录!")
            }
        })
   

}
//获取用户VIP信息判断是否是VIP
function setPersonal() {   
    var header = {
            "Content-Type": "application/json",
            "token": localStorage.getItem('token'),
        }
        // 调用公共ajax
    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("请您先登录!")
        }
    })
}