learningContent.js 31.3 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 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
var userName = ''
var userId = ''
var newId = ''
var recommendTwoId = ''
var recommendThreeId = ''
var first_id
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 answer1 = ''
var textStatus = 0
var screenWidth = ''
$(document).ready(function () {
    var u = navigator.userAgent;
    if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {//安卓手机
        // alert("安卓手机");
    } else if (u.indexOf('iPhone') > -1) {//苹果手机
        // alert("苹果手机");
    } else if (u.indexOf('Windows Phone') > -1) {//winphone手机
        // alert("winphone手机");
    }
    //获取屏幕宽度
    screenWidth = $(window).width()
    //获取url
    var url = window.location.search;
    //截取url的id
    if (url.indexOf('?') != -1) {
        newId = url.substr(4)
        //底部二维码   
        ajax("/warranty/warrantyList", "GET", header5, function (res) {
        }, function (res) {
            let EWM = `<img src="${res.data.sevenimg4}" width="100%">`
            $('#ewm-footer').html(EWM)
        })
        //获取左边实习内容list
        var header = {
            "Content-Type": "application/x-www-form-urlencoded",
            "token": localStorage.getItem('token'),
        }
        userId = localStorage.getItem("userId");
        ajax("/recommend/recommendTwoList", "GET", header, { id: newId, userId: userId }, function (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) {
                    if (val.type) {
                        var selected = 'checkStatus'
                    } else {
                        var selected = ''
                    }
                    title1 += `
                        <li id="content-list" data-index="` + ii + `" class='leftClick' style='display:flex;margin-bottom:0.2rem;cursor: pointer;margin-left: 10px;
                        place-items: center;'>
                            <div class="noCheck ` + `${selected}` + `" ` + `data-id='` + val.id + `' style='margin-right:10px'></div>
                            <a class='learn-erji-title' style='flex:1'>${val.subhead}</a>
                        </li>`
                    ii++;
                })
                singleItem = title + title1 + `</ul>`
                $('#title-content ul').eq(0).css('display', 'block')

                $("#title-content").append(singleItem)
                first_id = $('#title-content li').find('div').attr('data-id');
                // console.log(first_id)
                AJAX()
         
            }
            $('#title-content ul li').eq(0).trigger('click');
            console.log(11111111,$('#title-content ul li').eq(0).attr('data-index'));
        }, function (res) {
            // console.log(res);
        })
       
    }
})
var cc = 1;
var dd = 1;

$('#title-content').on('click', 'h3', function (e) {
    $(this).next('ul').slideToggle().siblings('ul').slideUp(); //去掉siblis后面的就是普通的菜单收缩框
})
//点击判断显示
$('#title-content').on('click', '.leftClick', function (e) {
    // console.log(screenWidth);
    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('我是最后一个');
        if (screenWidth < 768) {
            $(".learn-next-Btn").css('display', 'none')
            $(".learn-next-yuan").css('display', 'none')
            $(".learn-next-Btn1").css('display', 'block')
        } else {
            $(".learn-next-Btn").css('display', 'block')
            $(".learn-next-yuan").css('display', 'block')
            $(".learn-next-Btn1").css('display', 'none')
        }
    } else {
        if (screenWidth < 768) {
            $(".learn-next-Btn").css('display', 'none')
            $(".learn-next-Btn1").css('display', 'block')
            $(".learn-next-yuan").css('display', 'none')
            $(".show2-last-Btn").css('display', 'none')
            $(".show-Btn-last-yuan").css('display', 'none')
            $(".show2-last-Btn1").css('display', 'block')
        } else {
            $(".learn-next-yuan").css('display', 'block')
            $(".learn-next-Btn").css('display', 'block')
            $(".learn-next-Btn1").css('display', 'none')
            $(".show2-last-Btn").css('display', 'block')
            $(".show-Btn-last-yuan").css('display', 'block')
            $(".show2-last-Btn1").css('display', 'none')
        }
    }


    //选中按钮添加圆圈样式
    $(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")
    first_id = $(this).find('.check').attr('data-id');
    AJAX()
    // console.log(first_id);

    // var index = $('#content-list').index($(this).find('.noCheck'))
    // alert(index)

})
function AJAX() {
    var header = {
        "Content-Type": "application/x-www-form-urlencoded",
        "token": localStorage.getItem('token'),
    }
    var params = {
        id: newId,
        userId: userId
    }

    ajax("/recommend/recommendTwoList", "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)
                        // console.log(val.downloadHomework);
                        if (val.downloadHomework == '' || val.downloadHomework == null) {
                            $(".show1-BtnAll").css("display", "none")
                        } else {
                            $(".show1-BtnAll").css("display", "flex")
                        }
                        let work = ` 
                            <a href="${val.downloadHomework}" class='show1-Btn1-a'>
                                    <img src='./images/03-4.png'>
                                <span style='padding-left:10px'>下载实习作业</span>
                            </a>`
                        $("#downloadWork").html(work);
                        if (val.video == '' || val.video == null) {
                            $("#video").css("display", "none")
                        } else {
                            $("#video").css("display", "block")
                            let videos = `
                            <video controls class='videos' src="${val.video}"></video>
                            `
                            $('#video').html(videos)
                        }


                    } else if (val.status == '2') {
                        $(".div_show1").hide()
                        $(".div_show2").show()
                        $(".div_show3").hide()
                        $(".div_show4").hide()
                        if (cc == 1) {
                            //获取答题
                            var params1 = {
                                id: first_id
                            }
                            ajax("/recommend/recommendFiveList", "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:200px;">&nbsp;</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 class='option'>
                                                        <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 class='option'>
                                                        <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 class='option'>
                                                        <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 class='option'>
                                                        <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);
                            })
                            // 答案回显
                            ajax("/recommend/recommendFiveLists", "GET", header, params1, function (res1) {
                                if (res1.data != null && res1.data != '') {
                                    var data = res1.data
                                    for (var i in data) {
                                        if (data[i].answer === data[i].answer1) {
                                            $("#" + (data[i].recommendFiveId) + 'answer' + data[i].answer1).css({ "background": 'url("images/radio.png") no-repeat center', "background-size": "20px" });
                                        } else {
                                            $("#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" });
                                        }
                                    }
                                    $(".option input").attr("disabled", "disabled");
                                    $(".datiall button").attr("disabled", "disabled");

                                }
                            }, function (data) {
                                // console.log(data);
                            })
                            cc += 1;
                        }
                    } 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()
                        if (dd == 1) {
                            var header12 = {
                                "Content-Type": "application/x-www-form-urlencoded",
                                "token": localStorage.getItem('token'),
                            }
                            var params12 = {
                                id: newId
                            }
                            ajax("/warrantyTwo/warrantyTwoById", "GET", header12, params12, function (res) {
                                // console.log(res.data);
                                let title = `<img src="${res.data.img}" style="margin-top:1%;width:100%;height:100%">`
                                $(".company_img").html(title)
                                let title1 = `<div>${res.data.username}同学于${res.data.longTime}参与并完成了${res.data.company}公司在Start-Line${res.data.project}实习项目</div>`
                                $("#footer-personalInfo").html(title1)
                                for (var i in res.data.ability) {
                                    let title2 = `<li>${res.data.ability[i]}</li>`
                                    $('.show4-ul').append(title2);
                                }
                            }, function (res) {
                                // console.log(res);
                            })

                            ajax("/warrantyTwo/proveList", "GET", header12, params12, function (res) {
                                // console.log(res);
                                for (var i in res.data) {
                                    let title = `
                                <div class="show4-qianming">
                                    <p>签名:${res.data[i].name}</p>
                                    <p>部门职位:${res.data[i].position}</p>
                                    <p>公司名称:${res.data[i].appellative}</p>
                                </div>`
                                    $(".show4-qianming-all").append(title)
                                }
                            }, function (res) {
                                // console.log(res);
                            })
                            dd += 1;
                        }
                    }
                }
                recommendThreeId = val.id
            })
        }
    }, 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() {
    // $(".checkAnswers").change(function(){
    $("input").filter(":radio").removeAttr("checked");
    var first_id = $('.check').attr('data-id');
    // console.log(first_id);
    textStatus = 1
    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 aa = JSON.stringify(arr);
    var params = aa
    //保存答案
    ajax("/recommend/userAnswerAdd", "POST", header1, params, function (res) {
        // console.log(res);
        var params1 = {
            id: res.data
        }
        // 答案回显
        ajax("/recommend/recommendFiveLists", "GET", header, params1, function (res1) {
            var data = res1.data
            for (var i in data) {

                if (data[i].answer === data[i].answer1) {
                    $("#" + (data[i].recommendFiveId) + 'answer' + data[i].answer1).css({ "background": 'url("images/radio.png") no-repeat center', "background-size": "20px" });
                } else {
                    $("#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');
    // $('.check').parent('#content-list').parent().prev()
    $('.check').parent('#content-list').parent().prev().prev().prev().trigger('click')
    // console.log($('.check').parent('#content-list').parent().prev().prev().find('li'));
    $('.check').parent('#content-list').parent().prev().prev().find('li').eq(-1).trigger('click')



}

//下一步
function next() {
    // first_id = $('#title-content li').find('div').attr('data-id');
    var first_id = $('.check').attr('data-id');
    if (first_id == undefined) {
        first_id = $('#title-content li').find('div').attr('data-id');
    }
    console.log('12131', first_id)
    var url = '/userJl/userJlAdd/' + first_id
    var header = {
        "Content-Type": "application/x-www-form-urlencoded",
        "token": localStorage.getItem('token'),
    }

    //改变type的值
    ajax(url, "POST", header, function (res) {
        // console.log(res);
    }, function (res) {
        // console.log(res);
        // 一个都没选的状态
        if ($('.checkStatus').length == 0) {
            noCheck()
        } else {
            // 全选
            if ($('.checkStatus').length == $('.noCheck').length) {
                allCheck()
            } else {
                // 选了一半
                // var checkStatus
                // var classArr = $('.check').parent('#content-list').prev().find('div')[0].classList
                // if(checkStatus != classArr[1]){
                //     console.log('不等');
                //     alert('连起来')
                //    return 
                // }else{
                //     console.log('等于');
                //     halfCheck()
                // }
                halfCheck()
               
            }

        }
    },function (res) {
       alert("请先完成上一个!")
    })


}
// 全选
function allCheck() {
    console.log(1111);
    if ($('.check').eq(-1).parent('#content-list').next().length > 0) {
        $('.check').eq(-1).parent('#content-list').next().trigger('click');

    } else {
        // 最后一个
        $('.check').eq(-1).parent('#content-list').parent().next().trigger('click')
        $('.check').eq(-1).parent('#content-list').parent().next().next().find('#content-list').eq(0).trigger('click')
    }
}
// 选了一半
function halfCheck() {
    console.log(222);
    // console.log($('.check').parent('#content-list').prev().find('div')[0].classList);
   
    if ($('.checkStatus').eq(-1).parent('#content-list').next().length > 0) {
        if ($('.check').parent('#content-list').next().length > 0) {
            console.log(221133);
            $('.check').addClass('checkStatus').removeClass('check');
            $('.checkStatus').eq(-1).parent('#content-list').next().trigger('click');
        } else {
            console.log(2244545454);
            $('.check').addClass('checkStatus').removeClass('check');
            $('.checkStatus').parent('#content-list').parent().next().trigger('click')
            $('.checkStatus').parent('#content-list').parent().next().next().find('#content-list').eq(0).trigger('click')
        }
    } else {
        console.log($('.checkStatus').eq(-1).parent('#content-list').parent().next());
        if ($('.checkStatus').eq(-1).parent('#content-list').parent().next().length > 0) {
            console.log(2221);
            $('.check').addClass('checkStatus').removeClass('check');
            $('.checkStatus').eq(-1).parent('#content-list').next().trigger('click')
            // $('.checkStatus').eq(-1).parent('#content-list').parent().next().next().find('#content-list').eq(0).trigger('click')
        } else {
            //全部都答了
            // $('.check').addClass('checkStatus').removeClass('check');
            // $('.checkStatus').parent('#content-list').parent().next().trigger('click')
            // $('.checkStatus').parent('#content-list').parent().next().next().find('#content-list').eq(0).trigger('click')
            if ($('.check').parent('#content-list').next().length > 0) {
                if ($('.checkStatus').length == 0) {
                    console.log(1231223);
                    $('.check').parent('#content-list').next().trigger('click')
                } else {
                    console.log(1233333333);
                    $('.check').addClass('checkStatus').removeClass('check');
                    $('.checkStatus').parent('#content-list').next().trigger('click')
                }
            } else {
                console.log(1211111111);
                $('.check').parent('#content-list').parent().next().trigger('click')
                $('.check').parent('#content-list').parent().next().next().find('#content-list').eq(0).trigger('click')
            }

        }

    }
}
// 一个没选
function noCheck() {
    // 一个以上
    if ($('.check').eq(-1).parent('#content-list').next().length > 0) {
        console.log(3333);
        $('.check').addClass('checkStatus').removeClass('check');
        $('.checkStatus').eq(-1).parent('#content-list').next().trigger('click');

    } else {
        // 最后一个
        console.log(444);
        $('.check').addClass('checkStatus').removeClass('check');
        $('.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')
    }
}
var workStatus = false

//提交作业
$(".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 header12 = {
                        "Content-Type": "application/x-www-form-urlencoded",
                        "token": localStorage.getItem('token'),
                    }
                    var params12 = {
                        id: newId
                    }
                    ajax("/warrantyTwo/warrantyTwoById", "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('提交成功!')
                            workStatus = true
                            $(".show1-Btn3").css("display", "flex")
                        }, function (res1) {
                            // console.log(res1);
                        })
                    }, function (res) { })
                }
            },
            error: function (response) {
                // console.log(response);
            }
        });
    }
});
//完成作业
function postData() {
    // console.log(workStatus);
    if (workStatus == true) {
        alert("恭喜你,完成了一个作业~")
    } else {
        alert("请您先提交作业!")
    }
}
//下载保存
let btn1 = document.querySelector('#btn1')
btn1.onclick = function () {
    layer.load(1);
    var header5 = {
        "Content-Type": "application/x-www-form-urlencoded",
        "token": localStorage.getItem('token'),
    }
    var params5 = {
        id: newId
    }
    ajax("/photo/test1", "GET", header5, params5, function (res) {
        console.log(res);
        let a = document.createElement('a')
        let event = new MouseEvent('click')
        a.download = '证书.pdf'
        a.href = res.data
        a.dispatchEvent(event)
        // download(res.data, 'certificate.png')
    }, function (res) {
        // console.log(res);
    })
}
// 下载图片
function download(link, picName) {
    let img = new Image()
    img.setAttribute('crossOrigin', 'Anonymous')
    img.onload = function () {
        let canvas = document.createElement('canvas')
        let context = canvas.getContext('2d')
        canvas.width = img.width
        canvas.height = img.height
        context.drawImage(img, 0, 0, img.width, img.height)
        let url = canvas.toDataURL('images/png')
        let a = document.createElement('a')
        let event = new MouseEvent('click')
        a.download = picName || 'default.png'
        a.href = url
        a.dispatchEvent(event)
    }
    img.src = link + '?v=' + Date.now()
    // console.log(img.src);
    setTimeout(function () {
        layer.closeAll('loading');
    }, 2000);
}
// 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);
        if (res.data == true) {
            var first_id = $('.check').attr('data-id');
            // console.log(first_id);
            var url1 = '/userJl/userJlAdd/' + first_id
            var header1 = {
                "Content-Type": "application/x-www-form-urlencoded",
                "token": localStorage.getItem('token'),
            }
            //改变type的值
            ajax(url1, "POST", header1, function (res) {
                // console.log(res);
            }, function (res) {
                // console.log(res);
                $('.check').addClass('checkStatus').removeClass('check');
                alert("恭喜您完成了一个新项目!")
                window.location.href = 'participated.html'
            })
        }
    }, function (res) {
        // console.log(res);
    })
}
//获取用户VIP信息判断是否是VIP
function setPersonal() {
    // 调用公共ajax
    ajax("/login/userInfo", "GET", header1, function (res) {
    }, function (res) {
        if (res.data.status1 == 2) {
            window.location.href = 'personalCenter2.html'
        } else {
            window.location.href = 'personalCenter.html'
        }
    })
}