learningContent.js 17.7 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
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 = ''
$(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="50%">`
                $('#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
                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>
                    <div id="content-l">
                    </div>`
                    $("#title-content").append(title)
                }
                for (let i in res.data) {
                    $.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>`
                        }
                        let title1 = `

                            <div id="content-list" class='leftClick' style='display:flex;margin-bottom:8px;cursor: pointer;'>
                                ` + html + `
                                <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)
                    })
                }
            }, 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'></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;">&nbsp;</div>
                        </div>
                        <!-- 题目 -->
                        <div class="list-right" id="dati-list">
                            <div class="questList" 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" id="ans1">
                                    <input type="radio" class="input-radio" value="${res.data[i].issue1}" name="${i}" />${res.data[i].issue1}</div>
                                <div style="display: flex;place-items: center; color: #5a5a5a;margin:10px 0" id="ans2">
                                    <input type="radio" class="input-radio" value="${res.data[i].issue2}" name="${i}" />${res.data[i].issue2}</div>
                                <div style="display: flex;place-items: center; color: #5a5a5a;margin:10px 0" id="ans3">
                                    <input type="radio" class="input-radio" value="${res.data[i].issue3}" name="${i}" />${res.data[i].issue3}</div>
                                <div style="display: flex;place-items: center; color: #5a5a5a;" id="ans4">
                                    <input type="radio" class="input-radio" value="${res.data[i].issue4}" 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'));
        console.log($(this).val())
        var first_id = $('.check').attr('data-id');
        var trueAnswer = answer1[$(this).parent().parent()[0].dataset.index].answer
        console.log(first_id);
        //获取答题
        var url1 = "/recommend/recommendFiveList";
        var header = {
            "Content-Type": "application/x-www-form-urlencoded",
            "token": localStorage.getItem('token'),
        }
        var params = {
            id: newId
        }
        var answer = ''

        ajax(url1, "GET", header, params, function(res) {
            console.log(res.data);
            for (let i in res.data) {
                console.log(res.data[i].answer);
                answer = res.data[i].answer

            }
        }, function(res) {
            console.log(res);
        })
        var a = {
            recommendFiveId: $(this).parents('.questList')[0].dataset.id,
            answer: $(this).val(),
            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() {

    console.log(arr);

    var url2 = "/recommend/userAnswerAdd"; // 接口
    var url3 = "/recommend/recommendFiveLists";
    var arr1 = new Object;
    arr1.userAnswerDto = arr;
    console.log(arr1);
    var params1 = JSON.stringify(arr1)
    console.log(params1);
    // 调用公共ajax
    ajax(url2, "POST", header1, params1, function(res) {
            console.log(res);

            // 调用公共ajax
            ajax(url3, "POST", header, params, function(data) {
                console.log(data);

            }, function(data) {
                console.log(data);
            })
        }, function(res) {
            console.log(res);
        })
        // $.ajax({
        //     type: 'POST',
        //     url: 'http://192.168.1.241:9004/recommend/userAnswerAdd',
        //     headers: {
        //         "Content-Type": "application/json",
        //         "token": localStorage.getItem('token'),
        //     },
        //     data: JSON.stringify({
        //         answer: arr,
        //         answer1: 0,
        //         recommendFiveId: 0,
        //         recommendThreeId: 0
        //     }),
        //     success: function(res) {
        //         console.log(res);
        //         $.ajax({
        //             type: 'GET',
        //             url: 'http://192.168.1.241:9004/recommend/recommendFiveLists',
        //             headers: {
        //                 "Content-Type": "application/x-www-form-urlencoded",
        //                 "token": localStorage.getItem('token'),
        //             },
        //             data: {
        //                 //二级标题
        //                 id: newId
        //             },
        //             data: JSON.stringify({
        //                 answer: arr,
        //                 answer1: 0,
        //                 recommendFiveId: 0,
        //                 recommendThreeId: 0
        //             }),
        //             success: function(res) {
        //                 console.log(res);

    //             }
    //         })
    //     }
    // })

}





//下一步
function setQuestionId() {

    $('.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() {
    // 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 information() {
    console.log(111);
    // 调用公共ajax
    ajax(url4, "GET", header1, function(res) {
            console.log(res);
            userId = res.data.id
            userName = res.data.surname + res.data.userName
            if (res.data.status1 == 1) {
                window.location.href = 'personalCenter.html'
            } else {
                window.location.href = 'personalCenter2.html'
            }
        }, function(res) {
            console.log(res);
        })
        // $.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);
        //         userId = res.data.id
        //         userName = res.data.surname + res.data.userName
        //         if (res.data.status1 == 1) {
        //             window.location.href = 'personalCenter.html'
        //         } else {
        //             window.location.href = 'personalCenter2.html'
        //         }
        //     }
        // })
}
//完成结束
function commitPro() {
    var url7 = "/userProgram/userProgramAdd"; // 接口
    // 调用公共ajax
    ajax(url7, "POST", header, params, function(res) {
            console.log(res);
            alert("恭喜您完成了一个新项目!")
        }, function(res) {
            console.log(res);
        })
        // $.ajax({
        //     type: 'POST',
        //     url: 'http://192.168.1.241:9004/userProgram/userProgramAdd',
        //     headers: {
        //         "Content-Type": "application/x-www-form-urlencoded",
        //         "token": localStorage.getItem('token'),
        //     },
        //     data: {
        //         id: newId
        //     },
        //     success: function(res) {
        //         // console.log(res);
        //         alert("恭喜您完成了一个新项目!")
        //     }
        // })
}