profile.js
7.2 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
$(document).ready(function() {
var url = window.location.search;
// console.log(url);
if (url.indexOf('?') != -1) {
//截取url ?id=1 第四位
var str1 = url.substr(4)
$.ajax({
type: 'GET',
url: "http://192.168.1.241:9004/recommend/recommendList",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
},
// data: localStorage.getItem('userId'),
data: {
id: str1
},
success: function(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 str = `<img src="${res.data.img1}" class="rounded img-fluid d-block mx-auto" alt="" style="border: 1px dashed #333;width: 100%;">`
$('#img3').html(str)
}
})
//获取四张小图
$.ajax({
type: 'GET',
url: 'http://192.168.1.241:9004/recommendOne/recommendOneList',
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
},
data: {
id: str1
},
success: function(res) {
// console.log('222', res);
$.each(res.data, function(key, value) {
// console.log($(this));
// console.log(value)
let title = `<div class="col-md-6 box-item">
<a style='width:30%'><img src="${value.img}"></a>
<div class="col-xs-91">
<span>${value.title}</span>
<p style="color:#5A5A5A;font-size: 0.5em;font-family: Helvetica;">${value.englishTitle}</p>
</div>
</div>`
$('#fourGroups').append(title)
})
}
})
//大标题
$.ajax({
type: 'GET',
url: 'http://192.168.1.241:9004/recommend/recommendTwoList',
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
},
data: {
id: str1
},
success: function(res) {
console.log('11111', res.data);
// let arr = Array(res.data)
// console.log(arr, 'arr')
// var recommendListId = ''
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 title = `
<div class='all-list'>
<!-- 左边 -->
<div class='list-left'>
<div class='yuan-num'>
<!-- 圆 -->
<div class='left-yuan'></div>
<!-- 数字 -->
<div class='left-num'>${res.data[i].id<10 ? '0'+res.data[i].id : res.data[i].id}</div>
</div>
<!-- 线 -->
<div class='left-xian' style="height: 100px;"> </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">
</div>
<button class='title-btn' onClick="setLearingContentId(${res.data[i].id})">下一步骤></button>
</div>
</div>`
// let content = ''
$('#recommend-List').append(title);
}
for (let i in res.data) {
if (res.data[i].recommendThrees.length) {
$.each(res.data[i].recommendThrees, function(index, item) {
console.log(item);
// recommendListId = item.id
if (index == item.id - 1) {
let content = `<div>${item.subhead}</div>`
$('#title_content').append(content)
}
})
}
}
}
})
}
})
// 传二级标题的id
function setLearingContentId(id) {
console.log(id);
window.location.href = 'learningContent.html?id=' + id
}
//获取用户VIP信息判断是否是VIP
function setPersonal() {
$.ajax({
type: 'GET',
url: 'http://192.168.1.241:9004/login/userInfo',
headers: {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
},
success: function(res) {
console.log(res);
if (res.data.status1 == 1) {
window.location.href = 'personalCenter.html'
} else {
window.location.href = 'personalCenter2.html'
}
}
})
}