learningContent.js
21.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
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
var userName = ''
var newId = ''
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 = ''
let ii = 0;
for (let i in res.data) {
let title = `
<h3 id="title-head" ` + `data-id='` + res.data[i].id + `'>${res.data[i].headline}</h3>
<ul 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>`
// }
if (val.type) {
var selected = 'checkStatus'
} else {
var selected = ''
}
title1 += `
<li id="content-list" data-index="` + ii + `" class='leftClick' style='display:flex;margin-bottom:8px;cursor: pointer;margin-left: 10px;
place-items: center;'>
<div class="noCheck ` + `${selected}` + `" ` + `data-id='` + val.id + `' style='margin-right:6px'></div>
<a class='learn-erji-title' style='flex:1'>${val.subhead}</a>
</li>`
// $("#content-l").append(title1)
//$('.divClass').eq(0).css('display', 'block').siblings().css('display', 'none')
//右边显示1
let work = `
<a href="${val.downloadHomework}" target="_blank" class='show1-Btn1-a'>
<img src='./images/03-4.png'>
<span style='padding-left:10px'>下载实习作业</span>
</a>`
$("#downloadWork").html(work);
ii++;
})
singleItem = title + title1 + `</ul>`
$("#title-content").append(singleItem)
}
}, function(res) {
console.log(res);
})
}
$('#title-content').on('click', 'h3', function(e) {
console.log(1231332132131);
$(this).next('ul').slideToggle().siblings('ul').slideUp(); //去掉siblis后面的就是普通的菜单收缩框
});
})
//点击判断显示
$('#title-content').on('click', '.leftClick', function(e) {
var first_id1 = $('.check').parents('#content-list')
console.log(first_id1);
//判断第一个没有上一步,最后一个没有下一步
let length = $('#title-content li').length - 1;
if ($(this).data('index') == 0) {
console.log('我是第一个');
$(".show2-last-Btn").css('display', 'none')
$(".show-Btn-last-yuan").css('display', 'none')
$(".show2-last-Btn1").css('display', 'none')
} else if ($(this).data('index') == length) {
console.log('我是最后一个');
$(".learn-next-Btn").css('display', 'none')
$(".learn-next-yuan").css('display', 'none')
$(".learn-next-Btn1").css('display', 'none')
} else {
$(".show2-last-Btn").css('display', 'block')
$(".show-Btn-last-yuan").css('display', 'block')
$(".learn-next-Btn").css('display', 'block')
$(".learn-next-yuan").css('display', 'block')
}
//选中按钮添加圆圈样式
$(this).find('.noCheck').addClass('check');
$(this).siblings().find('.noCheck').removeClass('check')
$(this).parents().siblings().find('.check').removeClass('check')
let indexs = $(this).index();
$('.divClass').eq(indexs).css('display', 'block').siblings().css('display', 'none')
// $(this).next().siblings().css("color", "#66CA94")
var first_id = $(this).find('.check').attr('data-id');
console.log(first_id);
var url8 = "/recommend/recommendTwoList";
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var params = {
id: newId
}
// var index = $('#content-list').index($(this).find('.noCheck'))
// alert(index)
ajax(url8, "GET", header, params, function(res) {
console.log(res);
// let status = ''
for (let i in res.data) {
$.each(res.data[i].recommendThrees, function(index, val) {
//console.log(val);
// status = val.status
if (val.id == first_id) {
if (val.status == '1') {
$(".div_show1").show()
$(".div_show2").hide()
$(".div_show3").hide()
$(".div_show4").hide()
$("#particulars").html(val.particulars)
$("#accomplish").html(val.accomplish)
} else if (val.status == '2') {
$(".div_show1").hide()
$(".div_show2").show()
$(".div_show3").hide()
$(".div_show4").hide()
//获取答题
var url1 = "/recommend/recommendFiveList";
var params1 = {
id: first_id
}
ajax(url1, "GET", header, params1, function(res) {
console.log(res);
answer1 = res.data
for (let i in res.data) {
let x = +i + 1;
console.log(x);
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'>${x<10? '0'+x : x}</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 id="timu1" >${res.data[i].id+'.'+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);
})
} 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()
var url12 = "/warrantyTwo/warrantyTwoById"
var header12 = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var params12 = {
id: newId
}
ajax(url12, "GET", header12, params12, function(res) {
console.log(res.data);
let title = `<div>${res.data.username}同学于${res.data.longTime}参与并完成了${res.data.company}公司在Start-Line的${res.data.project}实习项目</div>`
$("#footer-personalInfo").html(title)
}, function(res) {
console.log(res);
})
}
}
recommendThreeId = val.id
})
}
// console.log(status);
}, 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");
var first_id = $('.check').attr('data-id');
console.log(first_id);
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'),
}
//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" });
// }
// }
console.log(arr);
// JSON.stringify()
var aa = JSON.stringify(arr);
console.log(aa);
var params = aa
// console.log(params1);
//保存答案
ajax(url, "POST", header1, params, function(res) {
console.log(res);
var params1 = {
id: res.data
}
// 答案回显
ajax(url3, "GET", header, params1, function(res1) {
var data = res1.data
for (var i in data) {
if (data[i].answer === data[i].answer1) {
console.log(1111111111);
$("#" + (data[i].recommendFiveId) + 'answer' + data[i].answer1).css({ "background": 'url("images/radio.png") no-repeat center', "background-size": "20px" });
} else {
console.log(2222)
$("#left-yuan" + (data[i].recommendFiveId)).css('background-color', '#FF6F6F')
$("#" + (data[i].recommendFiveId) + 'answer' + data[i].answer).css('background', 'url("images/red.png") no-repeat center');
$("#" + (data[i].recommendFiveId) + 'answer' + data[i].answer1).css({ "background": 'url("images/radio.png") no-repeat center', "background-size": "20px" });
}
}
}, function(data) {
console.log(data);
})
}, function(res) {
console.log(res);
})
}
//上一步
function last() {
$('.check').addClass('check');
$('.check').parent('#content-list').prev().trigger('click');
}
//下一步
function next() {
var first_id = $('.check').attr('data-id');
console.log(first_id);
var url = '/userJl/userJlAdd/' + first_id
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
ajax(url, "POST", header, function(res) {
console.log(res);
}, function(res) {
console.log(res);
})
$('.check').addClass('checkStatus').removeClass('check');
// console.log($('.checkStatus').eq(-1).parent('#content-list').next().length);
$('.checkStatus').eq(-1).parent('#content-list').next().trigger('click');
if ($('.checkStatus').eq(-1).parent('#content-list').next().length == 0) {
console.log(121212)
console.log($('.checkStatus').eq(-1).parent('#content-list').parent().next());
$('.checkStatus').eq(-1).parent('#content-list').parent().next().trigger('click')
$('.checkStatus').eq(-1).parent('#content-list').parent().next().next().find('#content-list').eq(0).trigger('click')
}
}
//完成作业
function postData() {
alert("恭喜你,完成了一个作业~")
}
//提交作业
$(".fileTxt").change(function(e) {
//一级标题id
var first_id1 = $('.check').parents('#content-l').prev().attr('data-id');
//二级标题id
var first_id = $('.check').attr('data-id');
// console.log(newId);项目id
//上传作业
var fileList = e.target.files[0]
if (fileList) {
var formData = new FormData();
formData.append('file', fileList)
$.ajax({
url: 'http://wz.j.brotop.cn/upload/uploadList',
dataType: 'json',
type: 'POST',
async: false,
data: formData,
processData: false, // 使数据不做处理
contentType: false, // 不要设置Content-Type请求头
success: function(data) {
// console.log(data);
internshipJob = data.data
if (internshipJob) {
var url12 = "/warrantyTwo/warrantyTwoById"
var header12 = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var params12 = {
id: newId
}
ajax(url12, "GET", header12, params12, function(res) {
// console.log(res.data);
username = res.data.username
var url1 = '/recommendFour/recommendFourAdd'
var header = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
// console.log(username);
// console.log(internshipJob);
var params = JSON.stringify({
internshipJob: internshipJob, //提交作业
recommendThreeId: first_id, //二级标题id
recommendTwoId: first_id1, //一级标题id
userName: username, //用户名称
warrantyTwoId: newId //项目id
})
ajax(url1, "POST", header, params, function(res1) {
console.log(res1);
alert('提交成功!')
}, function(res1) {
console.log(res1);
})
}, function(res) {})
// alert(data.message)
}
},
error: function(response) {
console.log(response);
}
});
}
});
//下载保存
function downloadFile() {
// html2canvas(document.querySelector('#footer_download'), {
// useCORS: true,
// logging: true,
// timeout: 500,
// allowTaint: false,
// }).then(canvas => {
// console.log(canvas)
// // canvas为转换后的Canvas对象
// let link = document.createElement("a");
// link.href = canvas.toDataURL();
// link.setAttribute("download", "证书.png");
// link.style.display = "none"; //a标签隐藏
// document.body.appendChild(link);
// link.click();
// let oImg = new Image();
// oImg.setAttribute("crossOrigin", 'Anonymous');
// oImg.crossOrigin = "anonymous"
// console.log(oImg);
// oImg.src = canvas.toDataURL(); // 导出图片
// document.body.appendChild(oImg); // 将生成的图片添加到body
// });
}
//完成结束
function commitPro() {
var url = '/userProgram/userProgramUpdate/' + newId
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var params = { id: newId }
ajax(url, "PUT", header, params, function(res) {
console.log(res);
$('.check').addClass('checkStatus').removeClass('check');
alert("恭喜您完成了一个新项目!")
}, function(res) {
console.log(res);
})
}
//获取用户VIP信息判断是否是VIP
function setPersonal() {
var url4 = "/login/userInfo"; // 接口
// 调用公共ajax
ajax(url4, "GET", header1, 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'
}
})
}