recommend.js
3.9 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
110
111
112
113
114
115
116
117
118
119
$(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);
}