profile.js
11.4 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
$(document).ready(function() {
var url = window.location.search;
// console.log(url);
if (url.indexOf('?') != -1) {
//截取url ?id=1 第四位
var str1 = url.substr(4)
console.log(str1);
//公司介绍
var url8 = "/recommend/recommendList"; // 接口
var header = {
"Content-Type": "application/x-www-form-urlencoded",
}
var params = {
id: str1
}
ajax(url8, "GET", header, params, function(res) {
// console.log(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 logo = ` <img src="${res.data.img}" style="width: 100%;">`
// $("#img-logo").html(logo)
let img1 = `<img src="${res.data.img1}" class="rounded img-fluid d-block mx-auto" alt="" style="width: 100%;">`
$("#img1").html(img1)
let img2 = `<img src="${res.data.img2}" alt="" style="width: 100%;height:50%">`
$("#img2").html(img2)
let img3 = `<img src="${res.data.img3}" class="rounded img-fluid d-block mx-auto profile-footerImg1" alt="" >`
$("#img3").html(img3)
let bgimg = `
<header style="background: url(${res.data.img4}) no-repeat scroll center center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
height: 750px;">
<nav>
<div class="header-txt1">
<div id="img-logo" class="header-img1">
<img src="./img/portfolio/whiteLogo.png" onclick="window.location.href='index.html'" style="width: 100%;">
</div>
<div class="header-right1">
<div id="login-btn" class="header-btnL"></div>
<a class="header-right-btn" onclick="setPersonal()">
<img src="./img/portfolio/circle.png" style="width: 50px;height: 50px;">
</a>
</div>
</div>
</nav>
<div class="header-text">
<div class="col-md-12 text-center">
<div><img src='${res.data.img}'></div>
<p style="color: #fff; id="explain">${res.data.explain}</p>
<h1 style="color: #fff;" id="headTitle">欢迎加入上海国际货币经纪虚拟实习项目<br/>更快学习交易经纪人的职场能力!</h1>
<p id="titleExplain">${res.data.titleExplain}</p>
<div class='btn-joinUs'>
<h5 style="position: absolute;background-color: #97dab6;border-radius: 50%;z-index: 2;width: 40px;height: 40px;opacity: 0.5;"> </h5>
<a onclick="setLearingContentId(${str1})" class='joinStudyPro'>加入实习项目</a>
</div>
</div>
</div>
</header>`
$("#bgimg").html(bgimg)
var token = localStorage.getItem('token')
//判断右上角是否登录
if (token == null) {
let loginTit1 = `
<a href='login.html'>
<div class="header-loginBtn" id="loginTitle">登 录</div>
</a>`
$("#login-btn").html(loginTit1)
} else {
let loginTit2 = `
<a href='login.html'>
<div class="header-loginBtn" id="loginTitle">退出登录</div>
</a>`
$("#login-btn").html(loginTit2)
}
}, function(res) {
// console.log(res);
})
//获取四张小图
var url1 = "/recommendOne/recommendOneList";
var header1 = {
"Content-Type": "application/x-www-form-urlencoded",
// "token": localStorage.getItem('token'),
}
var params1 = {
id: str1
}
ajax(url1, "GET", header1, params1, function(res) {
// console.log(res);
$.each(res.data, function(key, value) {
let title = `
<div class="col-md-6 box-item">
<div class='four-to-one'><img src="${value.img}" style='width:100%'></div>
<div class="col-xs-91 four-to-tit">
<span class='four-to-one'>${value.title}</span>
<p class='four-to-two'>${value.englishTitle}</p>
</div>
</div>`
$('#fourGroups').append(title)
})
}, function(res) {})
//大标题
var url2 = "/recommend/recommendTwoList";
var header3 = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
ajax(url2, "GET", header3, params1, function(res) {
console.log(res);
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 singltItem = ''
let content = ''
let x = +i + 1
let title = `
<div class='all-list'>
<!-- 左边 -->
<div class='list-left'>
<div class='yuan-num'>
<!-- 圆 -->
<div class='left-yuan'></div>
<!-- 数字 -->
<div class='left-num'>${x<10 ? '0'+x : x}</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">`
$.each(res.data[i].recommendThrees, function(index, item) {
if (index == 0) {
console.log(i);
console.log(item);
}
// recommendListId = item.id
if (index < 2) {
content += `<div>${item.subhead}</div>`
//$('#title_content').append(content)
}
})
// $('#recommend-List').append(title);
singltItem = title + content + ` </div>
<button class='title-btn' onClick="setLearingContentId(${str1})">下一步骤></button>
</div>
</div>`
$('#recommend-List').append(singltItem);
}
}, function(res) {
console.log(res);
})
//首页底部二维码
var url3 = "/warranty/warrantyList";
ajax(url3, "GET", header1, function(res) {
// console.log(res);
}, function(res) {
// console.log(res);
let EWM = `<img src="${res.data.sevenimg4}" width="100%">`
$('#ewm-footer').html(EWM)
})
}
})
//添加项目
function setLearingContentId(id) {
var header1 = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
// 调用公共ajax
ajax("/login/userInfo", "GET", header1, function(res) {
console.log(res);
}, function(res) {
// console.log(res);
if (res.data.status1 == 2) {
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
}, function(res) {
console.log(res);
alert("登录才可以查看项目内容哦!")
})
} else {
alert("请您充值会员才能查看此内容!")
}
}, function(res) {
if (res) {
alert("请您先登录!")
}
})
}
//获取用户VIP信息判断是否是VIP
function setPersonal() {
var header = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
// 调用公共ajax
ajax("/login/userInfo", "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(res) {
if (res) {
alert("请您先登录!")
}
})
}