learningContent.js
16.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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
var userName = ''
var newId = ''
var userId = ''
var recommendTwoId = ''
var recommendThreeId = ''
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var header5 = {
"Content-Type": "application/x-www-form-urlencoded",
}
var params = {
id: newId
}
var header1 = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
var url8 = "/recommend/recommendTwoList"; // 接口
var answer1 = ''
var textStatus = 0
$(document).ready(function() {
var url = window.location.search;
// console.log(url);
if (url.indexOf('?') != -1) {
newId = url.substr(4)
// console.log(newId);
//底部二维码
var url9 = "/warranty/warrantyList"; // 接口
ajax(url9, "GET", header5, function(res) {
console.log('1', res);
}, function(res) {
console.log(res);
let EWM = `<img src="${res.data.sevenimg4}" width="100%">`
$('#ewm-footer').html(EWM)
})
//获取左边实习内容list
var url8 = "/recommend/recommendTwoList"; // 接口
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var params = {
id: newId
}
ajax(url8, "GET", header, params, function(res) {
// console.log(res);
//左边list
let singleItem = ''
for (let i in res.data) {
// console.log(res.data);
// recommendTwoId = res.data[i].id
// console.log(res.data[i].id);
let title = `
<div style='cursor: pointer;'>
<div id="title-head">${res.data[i].headline}</div>
<div id="content-l">
`
let title1 = '';
$.each(res.data[i].recommendThrees, function(index, val) {
// console.log(val);
//左边菜单
let html = '';
// if (index == 0) {
// html = `<div class="noCheck check"` + `data-id='` + val.id + `' style='margin-right:6px'></div>`
// } else {
// html = `<div class="noCheck" ` + `data-id='` + val.id + `' style='margin-right:6px'></div>`
// }
title1 += `
<div id="content-list" class='leftClick' style='display:flex;margin-bottom:8px;cursor: pointer;'>
<div class="noCheck" ` + `data-id='` + val.id + `' style='margin-right:6px'></div>
<div style='flex:1'>${val.subhead}</div>
</div>`
// $("#content-l").append(title1)
//$('.divClass').eq(0).css('display', 'block').siblings().css('display', 'none')
//右边显示1
let work = `
<a href="${val.downloadHomework}" target="_blank">
<img src='./images/03-4.png' style="padding-right: 5%;">
<span>下载实习作业</span>
</a>`
$("#downloadWork").html(work)
})
singleItem = title + title1 + `</div> </div>`
$("#title-content").append(singleItem)
}
}, function(res) {
console.log(res);
})
//获取答题
var url1 = "/recommend/recommendFiveList";
ajax(url1, "GET", header, params, function(res) {
console.log(res);
answer1 = res.data
for (let i in res.data) {
let title = `
<div class='all-list'>
<!-- 左边 -->
<div class='list-left'>
<div class='yuan-num'>
<!-- 圆 -->
<div class='left-yuan' id='left-yuan${res.data[i].id}'></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 class="list-right" id="dati-list">
<div class="questList" id="questList${res.data[i].id}" data-index="${i}" data-id='${res.data[i].id}'><div id="timu" >${res.data[i].topic}</div>
<div style="display: flex;place-items: center; color: #5a5a5a;margin:10px 0" >
<input id="${res.data[i].id}answer1" type="radio" class="input-radio" value="${res.data[i].issue1}" data-id="1" name="${i}" />${res.data[i].issue1}</div>
<div style="display: flex;place-items: center; color: #5a5a5a;margin:10px 0" >
<input id="${res.data[i].id}answer2" type="radio" class="input-radio" value="${res.data[i].issue2}" data-id="2" name="${i}" />${res.data[i].issue2}</div>
<div style="display: flex;place-items: center; color: #5a5a5a;margin:10px 0" >
<input id="${res.data[i].id}answer3" type="radio" class="input-radio" value="${res.data[i].issue3}" data-id="3" name="${i}" />${res.data[i].issue3}</div>
<div style="display: flex;place-items: center; color: #5a5a5a;" >
<input id="${res.data[i].id}answer4" type="radio" class="input-radio" value="${res.data[i].issue4}" data-id="4" name="${i}" />${res.data[i].issue4}</div>
</div>
</div>
</div>`
$('#recommend-List').append(title);
}
}, function(res) {
console.log(res);
})
}
})
//点击判断显示
$('#title-content').on('click', '.leftClick', function(e) {
console.log(e)
console.log($(this));
$(this).find('.noCheck').addClass('check');
$(this).siblings().find('.noCheck').removeClass('check')
let indexs = $(this).index();
$('.divClass').eq(indexs).css('display', 'block').siblings().css('display', 'none')
// $(this).next().siblings().css("color", "#66CA94")
// 调用公共ajax
var url8 = "/recommend/recommendTwoList"; // 接口
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var params = {
id: newId
}
ajax(url8, "GET", header, params, function(res) {
console.log(res);
for (let i in res.data) {
$.each(res.data[i].recommendThrees, function(index, val) {
console.log(val);
// status = val.status
$("#particulars").html(val.particulars)
$("#accomplish").html(val.accomplish)
recommendThreeId = val.id
// console.log(recommendThreeId);
})
}
// console.log(status);
if (val.status == '1') {
$(".div_show1").show()
$(".div_show2").hide()
$(".div_show3").hide()
$(".div_show4").hide()
} else if (val.status == '2') {
$(".div_show1").hide()
$(".div_show2").show()
$(".div_show3").hide()
$(".div_show4").hide()
} else if (val.status == '3') {
$(".div_show1").hide()
$(".div_show2").hide()
$(".div_show3").show()
$(".div_show4").hide()
} else if (val.status == '4') {
$(".div_show1").hide()
$(".div_show2").hide()
$(".div_show3").hide()
$(".div_show4").show()
}
}, function(res) {
console.log(res);
})
})
var arr = []
//答题选择
$('#recommend-List').on('click', '.input-radio', function(e) {
// console.log($(this).parent().parent()[0].dataset.index)
// console.log($(this).parents('.questList')[0].dataset.index)
// console.log($(this).parents('.questList')[0].dataset.id)
// console.log(answer1[$(this).parent().parent()[0].dataset.index].answer)
// console.log($(this).parents('.questList'));
if (textStatus == 1) {
return;
}
console.log($(this).val())
console.log($(this).data('id'));
var first_id = $('.check').attr('data-id');
var trueAnswer = answer1[$(this).parent().parent()[0].dataset.index].answer
console.log(first_id);
var a = {
recommendFiveId: $(this).parents('.questList')[0].dataset.id,
answer: $(this).data('id'),
answer1: trueAnswer,
recommendThreeId: first_id,
}
if (arr.length == 0) {
arr.push(a)
return;
}
var same = 0;
var sameid = '';
for (const i in arr) {
if (arr[i].recommendFiveId == $(this).parents('.questList')[0].dataset.id) {
same = 1;
sameid = i;
}
}
if (same == 0) {
arr.push(a)
} else {
arr[sameid].answer = $(this).val();
}
console.log(arr);
})
//完成答案按钮
function getValue() {
$("input").filter(":radio").removeAttr("checked");
console.log(arr);
textStatus = 1
var url = "/recommend/userAnswerAdd"; // 接口
var url3 = "/recommend/recommendFiveLists";
var header1 = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var params1 = {
id: newId
}
//answer 用户答案
//answer1 正确答案
var newArr = [{
recommendFiveId: 1,
"answer": 1,
"answer1": 1
}, {
recommendFiveId: 2,
"answer": 2,
"answer1": 1
}]
for (var i in newArr) {
if (newArr[i].answer == newArr[i].answer1) {
console.log(1111111111);
$("#" + (newArr[i].recommendFiveId) + 'answer' + newArr[i].answer1).css({ "background": 'url("images/radio.png") no-repeat center', "background-size": "20px" });
} else {
console.log(2222)
$("#left-yuan" + (newArr[i].recommendFiveId)).css('background-color', '#FF6F6F')
$("#" + (newArr[i].recommendFiveId) + 'answer' + newArr[i].answer).css('background', 'url("images/red.png") no-repeat center');
$("#" + (newArr[i].recommendFiveId) + 'answer' + newArr[i].answer1).css({ "background": 'url("images/radio.png") no-repeat center', "background-size": "20px" });
}
}
var params = JSON.stringify(arr)
console.log(params);
// 调用公共ajax
ajax(url, "POST", header1, params, function(res) {
console.log(res);
// 调用公共ajax
ajax(url3, "GET", header, params1, function(data) {
console.log(data);
console.log(newArr);
}, function(data) {
console.log(data);
})
}, function(res) {
console.log(res);
})
}
//上一步
function last() {
$('.check').addClass('check');
$('.check').parent('#content-list').prev().trigger('click');
}
//下一步
function next() {
$('.check').addClass('checkStatus').removeClass('check');
$('.checkStatus').eq(-1).parent('#content-list').next().trigger('click');
// $("#overchange").hide()
// $("#nextchange").show()
// window.location.href = 'question.html?id=' + newId
// console.log(newId);
}
//获取用户VIP信息判断是否是VIP
function setPersonal() {
var url4 = "/login/userInfo"; // 接口
// 调用公共ajax
ajax(url4, "GET", header1, function(res) {
console.log(res);
}, function(res) {
console.log(res);
userId = res.data.id
userName = res.data.surname + res.data.userName
if (res.data.status1 == 2) {
window.location.href = 'personalCenter2.html'
} else {
window.location.href = 'personalCenter.html'
}
})
}
//提交作业
function postData() {
$('#img-upload').click();
// var formData = new FormData();
// formData.append("photo", $("#photo")[0].files[0]);
// formData.append("service", 'App.Passion.UploadFile');
let files = $("#photo")[0].files[0]
// console.log(formData);
// console.log(userId);
// console.log(userName);
// console.log(files);
// console.log(recommendThreeId);
var url5 = "/recommendFour/recommendFourAdd"; // 接口
var url6 = "/userProgram/userProgramUpdate"; // 接口
var params3 = JSON.stringify({
internshipJob: files, //提交作业
recommendThreeId: recommendThreeId, //二级标题id
recommendTwoId: recommendTwoId, //大标题id
userId: userId, //用户id
userName: userName, //用户名
warrantyTwoId: newId //项目id
})
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var header1 = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
// 调用公共ajax
ajax(url5, "POST", header1, params3, function(res) {
console.log(res);
ajax(url6, "PUT", header, params, function(res) {
console.log(res);
}, function(res) {
console.log(res);
})
}, function(res) {
console.log(res);
})
// $.ajax({
// type: 'POST',
// url: 'http://192.168.1.241:9004/recommendFour/recommendFourAdd',
// headers: {
// "Content-Type": "application/json",
// // "token": localStorage.getItem('token'),
// },
// data: JSON.stringify({
// internshipJob: files, //提交作业
// recommendThreeId: recommendThreeId, //二级标题id
// recommendTwoId: recommendTwoId, //大标题id
// userId: userId, //用户id
// userName: userName, //用户名
// warrantyTwoId: newId //项目id
// }),
// contentType: false,
// processData: false,
// success: function(res) {
// //完成项目
// $.ajax({
// type: 'PUT',
// url: 'http://192.168.1.241:9004/userProgram/userProgramUpdate',
// headers: {
// "Content-Type": "application/x-www-form-urlencoded",
// "token": localStorage.getItem('token'),
// },
// data: {
// id: newId
// },
// success: function(res) {
// // console.log(res);
// }
// })
// },
// error: function(res) {
// alert("上传失败!")
// }
// })
}
//完成结束
function commitPro() {
var url7 = "/userProgram/userProgramAdd"; // 接口
// 调用公共ajax
ajax(url7, "POST", header, params, function(res) {
console.log(res);
alert("恭喜您完成了一个新项目!")
}, function(res) {
console.log(res);
})
}
// function goBack() {
// var url = "/login/loginRegistered"; // 接口
// var header = {
// "Content-Type": "application/json"
// }
// var params = JSON.stringify({
// code: localStorage.getItem('code'),
// phoneNumber: localStorage.getItem('phoneNumber')
// })
// // 调用公共ajax
// ajax(url, "POST", header, params, function(res) {
// console.log(res);
// if (res.statusCode !== '0') {
// alert(res.msg)
// return false
// }
// //status 1 保存 2 主页
// //Status1 1 主页 2 项目页
// if (res.data.status === 1) {
// window.location.href = 'save.html'
// } else if (res.data.Status1 === 2) {
// window.location.href = 'participated.html'
// // window.location.href = 'browseMore.html'
// } else {
// window.location.href = 'index.html'
// }
// }, function(res) {
// console.log(res);
// })
// }