recommend.js
3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
$(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);
}