recommend.js 3.8 KB
$(document).ready(function() {
        //查看已推荐的项目
        var pages = ''
        var page = 1
        var size = 4
        // xlPaging.js 使用方法
        $("#page").paging({
            nowPage: page, // 当前页码
            pageNum: pages, // 总页码
            buttonNum: size, //要展示的页码数量
            callback: function (num) { //回调函数
                console.log(num);
                page = num
                aaaa()
            }
        });
        aaaa()
        function aaaa(){
        var header = {
            "Content-Type": "application/json",
            "token": localStorage.getItem('token'),
        }
        var params = JSON.stringify({
            current: page,//开始页
            size: size,//展示条数
            })
            // 调用公共ajax
            var title
        ajax("/warrantyTwo/warrantyTwos", "POST", header, params, function(res) {
                console.log(res);
                pages = res.data.pages
                $("#recommend-num").html(res.data.records.length)
                $.each(res.data.records, function(key, value) {
                    let 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%">
                            </div>
                            <div class="par-proing-title-one">
                                <h5>${value.field}</h5>
                                <p>${value.futitle}</p>
                            </div>
                        </a>
                    </div>`

                    $('#allProject').append(title)
                })
            }, function(res) {
                console.log(res);
            })
        }
            //查看个人信息赋值名字
        var url2 = "/login/userInfo"; // 接口    
        // 调用公共ajax
        ajax(url2, "GET", header, function(res) {
                console.log(res);
            }, function(res) {
                console.log(res);
                $("#header-name").html(res.data.surname + res.data.userName)
                $("#title-name").html(res.data.surname + res.data.userName)
            })
            //首页
        var url3 = "/warranty/warrantyList";
        var header3 = {
            "Content-Type": "application/x-www-form-urlencoded"
        }
        ajax(url3, "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)
        })
    })
    //获取用户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);
}