recommend.js 3.9 KB
$(document).ready(function () {
    //查看个人信息赋值名字
    console.log(localStorage.getItem('name'));
    $("#header-name").html(localStorage.getItem('name'))
    $("#title-name").html(localStorage.getItem('name'))
    //首页
    var header3 = {
        "Content-Type": "application/x-www-form-urlencoded"
    }
    ajax("/warranty/warrantyList", "GET", header3, function (res) {
        console.log('1', res);
    }, function (res) {
        console.log(res);
        let EWM = `<img src="${res.data.sevenimg4}" width="100%">`
        $('#ewm-footer').html(EWM)
    })
    //查看已推荐的项目
    var pages =2
    var page = 1
    var size = 4
   
    
    function xlPag() {
        var header = {
            "Content-Type": "application/json",
            "token": localStorage.getItem('token'),
        }
        var params = JSON.stringify({
            current: page,//开始页
            size: size,//展示条数
        })
        var title
        ajax("/warrantyTwo/warrantyTwos", "POST", header, params, function (res) {
            console.log(res);
            if(res.data.pages == 1){
                pages = res.data.pages+1
            }else{
                pages = res.data.pages
            }
            $("#recommend-num").html(res.data.records.length)
            $('#allProject').html('')
            if(res.data.records == null ||res.data.records == ''){
                title = `
                    <div style='font-size:0.4rem;width:100%;text-align:center'>
                       暂无数据
                    </div>`

                $('#allProject').append(title)
            }else{
                $.each(res.data.records, function (key, value) {
                    title = `
                       <div class="col-lg-32 col-sm-60 par-pro-one" onClick="setLearingContentId(${value.id})">
                           <a class="portfolio-box3" style="display: flex;">
                               <div class="par-pro-img1">
                                   <img src="${value.img2}" alt="" style="width:100%;height:100%">
                               </div>
                               <div class="par-proing-title-one">
                                   <div>${value.field}</div>
                                   <p>${value.futitle}</p>
                               </div>
                           </a>
                       </div>`
   
                   $('#allProject').append(title)
               })
            }
          
        }, function (res) {
            console.log(res);
        })
    }
     // xlPaging.js 使用方法
     $("#page").paging({
        nowPage: page, // 当前页码
        pageNum: pages, // 总页码
        buttonNum: size, //要展示的页码数量
        callback: function (num) { //回调函数
            console.log(num);
            console.log(pages);
            page = num
            xlPag()
        }
    });
    xlPag()
})
//获取用户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 == 2) {
            window.location.href = 'personalCenter2.html'
        } else {
            window.location.href = 'personalCenter.html'
        }
    })
}

function setLearingContentId(id) {
    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
    })
    // console.log(id);
}