123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308 |
- const app = require('../../utils/util.js');
- const tools = require('../../utils/tools.js');
- Page({
- data: {
- isRz: false,
- showMore: false, //更多
- showzs: false, //证书显示
- show: false, //协议显示
- notice: "暂无未读通知",
- classInfo: {}, //班级信息
- kcArr: [], //课程列表
- sfmArr: [], //换算时分秒数组
- studentName: "", //学生名字
- status: '', //状态
- myCanvasId: 0, //画布id
- byzsbj: app.globalData.imgUrl+"/images/zsbj.jpg", //结业证背景 用于合成图片
- IngCourseArr: [], //如果有正在进行的课就存一下
- istask: false, //判断班级群是否添加
- istask1: false, //学员登记表是否完成
- istask2: false, //课程是否完成
- istask3: false, //期末考试是否完成
- istask4: false, //综合反馈是否完成
- currentId: null,
- currentName: "",
- tva: 32,
- noticeVis: false,
- defAvatarm:app.globalData.imgUrl+ "/images/mm.jpg",
- defAvatarf: app.globalData.imgUrl+"/images/fm.jpg",
- gender_icon_m:app.globalData.imgUrl+ "/images/g_m.png",
- gender_icon_f: app.globalData.imgUrl+"/images/g_f.png",
- cardVis: false,
- stuItem: null,
- pageNum: 1,
- pageSize: 4,
- stuInfo: {},
- jobArr: [],
- classVis: false,
- classErrVis: false,
- classNVis: false,
- scheduleList: [],
- icon_school:app.globalData.imgUrl+"/images/icon_school.png",
- icon_doc:app.globalData.imgUrl+"/images/icon_doc.png"
- },
- // 查询我是否认证
- isRz(sessionKey) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/selStudentSessionKey',
- method: "post",
- data: {
- sessionKey
- },
- success: (res) => {
- if (res.data.code == 0 && (res.data.data !== null || res.data.data !== "")) {
- this.setData({
- isRz: false
- })
- this.isClass(sessionKey)
- } else {
- this.setData({
- isRz: true
- })
- }
- }
- })
- },
- // 取消认证
- escRz() {
- wx.switchTab({
- url: '/pages/index/index',
- })
- },
- // 确认认证
- goRz() {
- wx.navigateTo({
- url: '/pages/Identity/Identity',
- })
- },
- // 查询我是否有班&&班级名字
- isClass(sessionKey) {
- var that = this;
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/selMyClas',
- method: "post",
- data: {
- sessionKey
- },
- success: (res) => {
- if (res.data.code == 0) {
- let classInfo = res.data.data;
- classInfo.clasBegin = app.timeFmt(classInfo.clasBegin, "yyyy\/MM\/dd hh:mm ");
- classInfo.clasEnd = app.timeFmt(classInfo.clasEnd, "yyyy\/MM\/dd hh:mm ");
- console.log(classInfo);
- // classInfo.clasBegin=app.timeFilter(classInfo.clasBegin);
- // classInfo.clasEnd=app.timeFilter(classInfo.clasEnd);
- //console.log("classInfo.clasBegin:",app.timeFilter(classInfo.clasBegin));
- that.setData({
- classInfo: classInfo,
- classVis: true
- })
- this.isAgree(sessionKey);
- this.getMynotice(sessionKey);
- // this.getMycourse(sessionKey);
- // this.checkTaskList(sessionKey);
- // this.checkTaskList3(sessionKey, res.data.data.id);
- // this.checkTaskList4(sessionKey, res.data.data.id);
- } else {
- if (res.data.msg == "运行时异常:学员不可同时存在两个班级中。") {
- that.setData({ classErrVis: true });
- // wx.showModal({
- // content: "学员不可同时存在多个班级中哦",
- // showCancel: false,
- // success(res) {
- // if (res.confirm) {
- // wx.switchTab({
- // url: '../index/index'
- // })
- // }
- // }
- // })
- return false;
- } else {
- that.setData({ classNVis: true });
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/selClasToo',
- method: "post",
- data: {
- sessionKey,
- isActive: 0
- },
- success: (res) => {
- console.log(res);
- let list = res.data.data.map(item => {
- item.clasBegin = app.timeFmt(item.clasBegin, "yyyy\/MM\/dd hh:mm ");
- item.clasEnd = app.timeFmt(item.clasEnd, "yyyy\/MM\/dd hh:mm ");
- return item;
- })
- that.setData({ scheduleList: list })
- }
- })
- // wx.showModal({
- // content: "您当前还没有正在开放的班级!",
- // showCancel: false,
- // success(res) {
- // if (res.confirm) {
- // wx.switchTab({
- // url: '../index/index'
- // })
- // }
- // }
- // })
- return false;
- }
- }
- }
- })
- },
- // 协议是否已同意
- isAgree(sessionKey) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/selStudentSessionKey',
- method: "post",
- data: {
- sessionKey
- },
- success: (res) => {
- if (res.data.code == 0 && res.data.data) {
- if (res.data.data.agreement == 0) {
- this.setData({
- studentName: res.data.data.studentName,
- show: false
- });
- } else {
- this.setData({
- studentName: res.data.data.studentName,
- show: true
- });
- }
- }
- }
- })
- },
- // 点击同意协议 并且记一下
- hidePopup() {
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/verification',
- method: "post",
- data: {
- sessionKey: this.data.sessionKey
- },
- success: (res) => {
- this.setData({
- show: false
- });
- }
- })
- },
- moreThink() {
- wx.switchTab({
- url: '../index/index'
- })
- },
- // 检查班级群是否加了 && 学员登记任务check
- checkTaskList(sessionKey) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/selStudentSessionKey',
- method: "post",
- data: {
- sessionKey
- },
- success: (res) => {
- if (res.data.code == 0) {
- console.log(res)
- this.setData({
- studentName: res.data.data.studentName,
- })
- if (res.data.data.joinClas == 0) {
- this.setData({
- istask: true
- })
- }
- if (res.data.data.register == 0) {
- this.setData({
- istask1: true
- })
- }
- }
- }
- })
- },
- // 期末考试任务检查
- checkTaskList3(sessionKey, id) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/exam/clasExamstatus',
- method: "post",
- data: {
- sessionKey: sessionKey,
- clasId: id
- },
- success: (res) => {
- console.log(res)
- if (res.data.code == 0 && res.data.status == 1) {
- this.setData({
- istask3: true
- })
- }
- }
- })
- },
- // 综合反馈任务check
- checkTaskList4(sessionKey, id) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/exam/status',
- method: "post",
- data: {
- sessionKey: sessionKey,
- clasId: id
- },
- success: (res) => {
- if (res.data.code == 0 && res.data.status == 1) {
- this.setData({
- istask4: true
- })
- }
- }
- })
- },
- // 页面上显示的我的未读通知
- getMynotice(sessionKey) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/eduNoticeSee/list',
- method: "post",
- data: {
- sessionKey: sessionKey,
- isSee: 1
- // isNotice: 0
- },
- fail: () => {
- this.setData({
- noticeVis: false
- })
- },
- success: (res) => {
- if (res.data.code == 0) {
- if (res.data.list && res.data.list.length !== 0) {
- this.setData({
- notice: res.data.list[0].noticeContent,
- noticeVis: true
- });
- } else {
- this.setData({
- noticeVis: false
- });
- }
- } else {
- this.setData({
- noticeVis: false
- });
- }
- }
- })
- },
- // 跳转通知页
- gomyNotice() {
- wx.navigateTo({
- url: '../myNotice/myNotice'
- })
- },
- // 学员登记表
- goWrite() {
- if (this.data.classInfo.id == -1) {
- wx.navigateTo({
- url: '../studentRegistration/studentRegistration'
- })
- } else {
- if (!this.data.istask) {
- wx.showModal({
- showCancel: false,
- content: "请先去扫描二维码加入班级群吧",
- success(res) {
- if (res.confirm) {
- wx.switchTab({
- url: '../myMission/myMission'
- })
- }
- }
- })
- return false
- }
- wx.navigateTo({
- url: '../studentRegistration/studentRegistration'
- })
- }
- },
- // 学院介绍
- toAdd1() {
- wx.navigateTo({
- url: '../schoolIntrouce/schoolIntrouce'
- })
- },
- // 学员名单
- toAdd2() {
- wx.navigateTo({
- url: '../studentList/studentList?id=' + this.data.classInfo.id
- })
- },
- // 项目组名单
- toAdd3() {
- wx.navigateTo({
- url: '../groupsList/groupsList'
- })
- },
- // 我的课程
- getMycourse(sessionKey) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/course/selectBySessionKey',
- method: "post",
- data: {
- sessionKey: sessionKey
- },
- success: (res) => {
- console.log(res, "我的课程")
- this.setData({
- kcArr: res.data.list,
- istask2: res.data.allDone,
- currentName: "",
- currentId: null
- });
- for (let i = 0; i < res.data.list.length; i++) {
- if (res.data.list[i].isLive == -1) {
- // 这个节课未全部完成
- if (res.data.list[i].isDone == "0") {
- // 这个视频已经进行了 看一半或者看完了
- if (res.data.list[i].isStudyDone == 0 || res.data.list[i].isStudyDone == 1) {
- this.setData({
- currentName: res.data.list[i].courseName,
- currentId: res.data.list[i].id
- })
- }
- }
- }
- }
- let result = [];
- if (res.data.list)
- for (let i = 0; i < res.data.list.length; i++) {
- result.push({
- courseTime: res.data.list[i].courseTime
- });
- }
- const timesArr = result.map((item) => {
- return item.courseTime;
- });
- let sfmArr = [];
- for (let i = 0; i < timesArr.length; i++) {
- let value = timesArr[i];
- const resultValue = this.handler(value);
- sfmArr.push({
- courseTime: resultValue
- })
- this.setData({
- sfmArr: sfmArr
- })
- }
- }
- })
- },
- // 时间换算
- handler(value) {
- //换算为秒 进制1000
- const second = Math.floor(value / 1000); //判断是否够1秒
- if (second < 1) {
- return "0秒";
- }
- const secondValue = second % 60; // 秒
- const minutes = Math.floor(second / 60); //判断是否够1分钟
- if (minutes < 1) {
- return `${secondValue}秒`;
- }
- const minutesValue = minutes % 60; //分
- const hours = Math.floor(minutes / 60); //判断是否够1小时
- if (hours < 1) {
- return `${minutesValue}分${secondValue}秒`;
- }
- const hoursValue = hours % 60; //小时
- return `${hoursValue}时${minutesValue}分${secondValue}秒`;
- },
- // 查看更多列表展开
- listToggle: function () {
- this.setData({
- showMore: !this.data.showMore
- })
- },
- // 去学习
- goStudy(e) {
- let id = e.currentTarget.dataset.item.id //此课程的id
- let courseUrl = e.currentTarget.dataset.item.courseUrl //此课程的id
- let courseName = e.currentTarget.dataset.item.courseName //此课程的id
- let courseInfo = e.currentTarget.dataset.item.courseInfo //此课程的id
- if (this.data.classInfo.id == -1) {
- if (e.currentTarget.dataset.item.isLive == 1) {
- if (e.currentTarget.dataset.item.isActive == 1) {
- wx.navigateTo({
- url: '../zbDetails/zbDetails?id=' + id
- })
- } else if (e.currentTarget.dataset.item.isActive == -1) {
- if (courseUrl == null || courseUrl == "") {
- wx.showModal({
- showCancel: false,
- content: "直播回放还未上传噢"
- })
- } else {
- wx.navigateTo({
- url: '../livePlayback/livePlayback?courseName=' + courseName + '&courseUrl=' + courseUrl + '&courseInfo=' + courseInfo
- })
- }
- } else {
- wx.showModal({
- showCancel: false,
- content: "直播还未开始哦"
- })
- return false;
- }
- } else {
- wx.navigateTo({
- url: '../dbDetails/dbDetails?id=' + id
- })
- }
- } else {
- console.log(this.data.istask)
- if (!this.data.istask) {
- wx.showModal({
- showCancel: false,
- content: "请先去扫描二维码加入班级群吧",
- success(res) {
- if (res.confirm) {
- wx.switchTab({
- url: '../myMission/myMission'
- })
- }
- }
- })
- return false
- }
- if (!this.data.istask1) {
- wx.showModal({
- showCancel: false,
- content: "请先填写学员登记表再来学习哦!"
- })
- return false
- }
- // 直播
- if (e.currentTarget.dataset.item.isLive == 1) {
- if (e.currentTarget.dataset.item.isActive == 1) {
- wx.navigateTo({
- url: '../zbDetails/zbDetails?id=' + id
- })
- } else if (e.currentTarget.dataset.item.isActive == -1) {
- if (courseUrl == null || courseUrl == "") {
- wx.showModal({
- showCancel: false,
- content: "直播回放还未上传噢"
- })
- } else {
- wx.navigateTo({
- url: '../livePlayback/livePlayback?courseName=' + courseName + '&courseUrl=' + courseUrl + '&courseInfo=' + courseInfo
- })
- }
- } else {
- wx.showModal({
- showCancel: false,
- content: "直播还未开始哦"
- })
- return false;
- }
- } else {
- if (this.data.currentId != null) {
- // 没学或者没学完
- if (e.currentTarget.dataset.item.isDone == 0) {
- if (id == this.data.currentId) {
- wx.navigateTo({
- url: '../dbDetails/dbDetails?id=' + id
- })
- } else {
- // 有未完成的但不是我 就不能跳转
- wx.showModal({
- showCancel: false,
- content: "请确认您的 ‘" + this.data.currentName + "’ 这节课中的学习、考试、评价是否都已完成?"
- })
- }
- } else {
- // 我看完了这个视频 还能看
- wx.navigateTo({
- url: '../dbDetails/dbDetails?id=' + id
- })
- }
- } else {
- wx.navigateTo({
- url: '../dbDetails/dbDetails?id=' + id
- })
- }
- }
- }
- },
- // 去考试
- gokhAnswer(e) {
- console.log(e)
- wx.showLoading({
- mask: true,
- title: '加载中',
- })
- if (this.data.classInfo.id == -1) {
- this.examination(e.currentTarget.dataset.item.id);
- wx.hideLoading();
- } else {
- wx.hideLoading();
- if (!this.data.istask) {
- wx.showModal({
- showCancel: false,
- content: "请先去扫描二维码加入班级群吧",
- success(res) {
- if (res.confirm) {
- wx.switchTab({
- url: '../myMission/myMission'
- })
- }
- }
- })
- return false
- }
- if (!this.data.istask1) {
- wx.showModal({
- showCancel: false,
- content: "请先填写学员登记表再来学习哦!"
- })
- return false
- }
- let isStudyDone = e.currentTarget.dataset.item.isStudyDone
- console.log(isStudyDone, '我是学习的')
- if (isStudyDone != 1) {
- wx.showModal({
- showCancel: false,
- content: "您当前的学习课程还未完成哦,请先完成再来考试吧!"
- })
- return false
- } else {
- this.examination(e.currentTarget.dataset.item.id);
- }
- }
- },
- // 考试方法单拿出来
- examination(id) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/exam/examList',
- method: "post",
- data: {
- sessionKey: this.data.sessionKey,
- courseId: id,
- clasId: this.data.classInfo.id
- },
- success: (res) => {
- if (res.data.code == 0) {
- if (res.data.list.length == 0) {
- wx.showModal({
- showCancel: false,
- content: '老师还未出考试题哦'
- })
- } else {
- console.log(res, '1111')
- if (res.data.list[0]) {
- if (res.data.list[0].answersId) {
- this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'answerAfterclass');
- } else {
- this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'answerAfterclass');
- }
- }
- }
- }
- }
- })
- },
- //去评价
- gopjClass(e) {
- if (this.data.classInfo.id == -1) {
- this.evaluate(e.currentTarget.dataset.item.id)
- } else {
- if (!this.data.istask) {
- wx.showModal({
- showCancel: false,
- content: "请先去扫描二维码加入班级群吧",
- success(res) {
- if (res.confirm) {
- wx.switchTab({
- url: '../myMission/myMission'
- })
- }
- }
- })
- return false
- }
- if (!this.data.istask1) {
- wx.showModal({
- showCancel: false,
- content: "请先填写学员登记表再来学习哦!"
- })
- return false
- }
- let isStudyDone = e.currentTarget.dataset.item.isStudyDone
- if (isStudyDone != 1) {
- wx.showModal({
- showCancel: false,
- content: "您的学习课程还未完成哦,请先完成再来评价吧!"
- })
- return false
- } else {
- this.evaluate(e.currentTarget.dataset.item.id)
- }
- }
- },
- // 评价方法单拿出来
- evaluate(id) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/exam/quesExamList',
- method: "post",
- data: {
- sessionKey: this.data.sessionKey,
- courseId: id,
- clasId: this.data.classInfo.id
- },
- success: (res) => {
- if (res.data.code == 0) {
- if (res.data.list.length == 0) {
- wx.showModal({
- showCancel: false,
- content: '老师还未出评价模板哦'
- })
- } else {
- if (res.data.list[0]) {
- if (res.data.list[0].answersId) {
- this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'evaluationCourse');
- } else {
- this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'evaluationCourse');
- }
- }
- }
- }
- }
- })
- },
- // 查看详情成绩
- gockcj(e) {
- console.log(e.currentTarget.dataset.item.isExamId)
- if (e.currentTarget.dataset.item.isExamId) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/answer/detail',
- method: "post",
- data: {
- answersId: e.currentTarget.dataset.item.isExamId
- },
- success: (res) => {
- if (res.data.list[0] && res.data.list[0].answerScore >= 0 && res.data.list[0].answerScore != null) {
- wx.navigateTo({
- url: '/pages/grade/grade?answersId=' + e.currentTarget.dataset.item.isExamId,
- })
- } else {
- wx.showModal({
- showCancel: false,
- content: '当前老师批阅中,请耐心等待'
- })
- }
- },
- fail: () => {
- wx.showModal({
- showCancel: false,
- content: '当前老师批阅中,请耐心等待'
- })
- }
- })
- }
- },
- // 查看详情评价
- gockpj(e) {
- wx.navigateTo({
- url: '/pages/evaluationCourseDetail/evaluationCourseDetail?answersId=' + e.currentTarget.dataset.item.isFeedbackId,
- })
- },
- // 期末考试
- goQmks() {
- if (this.data.classInfo.id == -1) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/exam/examList',
- method: "post",
- data: {
- sessionKey: this.data.sessionKey,
- clasId: this.data.classInfo.id
- },
- success: (res) => {
- if (res.data.code == 0) {
- if (res.data.list.length == 0) {
- wx.showModal({
- showCancel: false,
- content: '期末考试还未开始哦!'
- })
- } else {
- if (res.data.list[0].answersId) {
- if (res.data.list[0].status == '1') {
- wx.request({
- url: app.globalData.publicUrl + '/wx/answer/detail',
- method: "post",
- data: {
- answersId: res.data.list[0].answersId
- },
- success: (res1) => {
- if (res1.data.list[0].answerScore >= 0 && res1.data.list[0].answerScore != null) {
- wx.navigateTo({
- url: '/pages/grade/grade?answersId=' + res.data.list[0].answersId,
- })
- } else {
- wx.showModal({
- showCancel: false,
- content: '当前老师批阅中,请耐心等待'
- })
- }
- }
- })
- } else {
- this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'answerAfterclass');
- }
- } else {
- this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'answerAfterclass');
- }
- }
- }
- }
- })
- } else {
- if (!this.data.istask) {
- wx.showModal({
- showCancel: false,
- content: "请先去扫描二维码加入班级群吧",
- success(res) {
- if (res.confirm) {
- wx.switchTab({
- url: '../myMission/myMission'
- })
- }
- }
- })
- return false
- }
- if (!this.data.istask2) {
- wx.showModal({
- showCancel: false,
- content: "您的课程任务还未全部完成哦!请先去完成再来期末考试吧!"
- })
- return false
- }
- wx.request({
- url: app.globalData.publicUrl + '/wx/exam/examList',
- method: "post",
- data: {
- sessionKey: this.data.sessionKey,
- clasId: this.data.classInfo.id
- },
- success: (res) => {
- if (res.data.code == 0) {
- if (res.data.list.length == 0) {
- wx.showModal({
- showCancel: false,
- content: '期末考试还未开始哦!'
- })
- } else {
- if (res.data.list[0].answersId) {
- if (res.data.list[0].status == '1') {
- wx.request({
- url: app.globalData.publicUrl + '/wx/answer/detail',
- method: "post",
- data: {
- answersId: res.data.list[0].answersId
- },
- success: (res1) => {
- if (res1.data.list[0].answerScore >= 0 && res1.data.list[0].answerScore != null) {
- wx.navigateTo({
- url: '/pages/grade/grade?answersId=' + res.data.list[0].answersId,
- })
- } else {
- wx.showModal({
- showCancel: false,
- content: '当前老师批阅中,请耐心等待'
- })
- }
- }
- })
- } else {
- this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'answerAfterclass');
- }
- } else {
- this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'answerAfterclass');
- }
- }
- }
- }
- })
- }
- },
- // 综合反馈表
- goWrite2() {
- if (this.data.istask4) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/exam/quesExamList',
- method: "post",
- data: {
- sessionKey: this.data.sessionKey,
- questSub: '1',
- clasId: this.data.classInfo.id
- },
- success: (res) => {
- if (res.data.code == 0) {
- if (res.data.list[0]) {
- if (res.data.list[0].answersId) {
- wx.navigateTo({
- url: '/pages/feedBackDetail/feedBackDetail?answersId=' + res.data.list[0].answersId,
- })
- } else {
- this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'feedBack');
- }
- }
- }
- }
- })
- } else {
- wx.request({
- url: app.globalData.publicUrl + '/wx/exam/quesExamList',
- method: "post",
- data: {
- sessionKey: this.data.sessionKey,
- questSub: '1',
- clasId: this.data.classInfo.id
- },
- success: (res) => {
- if (res.data.code == 0) {
- if (res.data.list.length == 0) {
- wx.showModal({
- showCancel: false,
- content: '当前综合反馈还不可以填写哦!'
- })
- } else {
- if (res.data.list[0].answersId) {
- if (res.data.list[0].status == '1') {
- wx.navigateTo({
- url: '/pages/feedBackDetail/feedBackDetail?answersId=' + res.data.list[0].answersId,
- })
- } else {
- this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'feedBack');
- }
- } else {
- this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'feedBack');
- }
- }
- }
- }
- })
- }
- },
- // 我的积分
- goMyPoints() {
- wx.navigateTo({
- url: '../myPoints/myPoints'
- })
- },
- // 领取结业证
- // lq() {
- // if (!this.data.istask3) {
- // wx.showModal({
- // showCancel: false,
- // content: "您的期末考试还未完成哦!"
- // })
- // return false
- // }
- // wx.showLoading({
- // mask: true,
- // title: '加载中',
- // })
- // this.setData({
- // myCanvasId: this.data.myCanvasId + 1
- // })
- // let str = this.data.studentName + "同志:"
- // let str1 = "于" + this.data.classInfo.beginDate + "至" + this.data.classInfo.endDate + "参加学习" + this.data.classInfo.clasName + "完成规定培训内容。准予结业,特发此证。"
- // let strArr1 = [];
- // // let a = str1.slice(0, 22);
- // // let b = str1.slice(22, 36);
- // // let c = str1.slice(36, 50);
- // // let d = str1.slice(50, 67);
- // // strArr1.push(a, b, c, d);
- // // const ctx = wx.createCanvasContext(this.data.myCanvasId);
- // // ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
- // // ctx.setFillStyle("#000");
- // // ctx.setFontSize(15); //字大小
- // // ctx.font = 'normal bold 15px sans-serif'
- // // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
- // let a = str1.slice(0, 22);
- // let b = str1.slice(22, 37);
- // let c = str1.slice(37, 52);
- // let d = str1.slice(52, 67);
- // strArr1.push(a, b, c, d);
- // const ctx = wx.createCanvasContext(this.data.myCanvasId);
- // ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
- // ctx.setFillStyle("#000");
- // ctx.setFontSize(15); //字大小
- // ctx.font = 'normal bold 15px sans-serif'
- // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
- // let leftPositionAarr = [60, 30, 30, 30]
- // ctx.fillText(str, 30, 160);
- // for (let i = 0; i < strArr1.length; i++) {
- // ctx.fillText(strArr1[i], leftPositionAarr[i], 190 + i * 30);
- // }
- // ctx.draw();
- // wx.hideLoading();
- // this.setData({
- // showzs: true
- // });
- // wx.request({
- // url: app.globalData.publicUrl + '/wx/student/wxGraduation',
- // method: "post",
- // data: {
- // sessionKey: this.data.sessionKey
- // },
- // success: (res) => {
- // console.log(res.data, "领取结业证提交")
- // }
- // })
- // },
- //孙喆 2020-9-22 10:38最后更改
- lq() {
- var that = this;
- if (!this.data.istask3) {
- wx.showModal({
- showCancel: false,
- content: "您的期末考试还未完成哦!"
- })
- return false
- }
- wx.showLoading({
- mask: true,
- title: '加载中',
- })
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/wxGraduation',
- method: "post",
- data: {
- sessionKey: this.data.sessionKey
- },
- success: (res) => {
- console.log(res);
- console.log(res.data, "领取结业证提交")
- wx.hideLoading();
- if (res.data.code == 500) {
- wx.showModal({
- showCancel: false,
- content: "领取失败,请稍后再试"
- })
- } else {
- that.setData({
- myCanvasId: that.data.myCanvasId + 1
- })
- let str = that.data.studentName + " 同志于" + app.dateFilter(that.data.classInfo.beginDate) + "-" + app.dateFilter(that.data.classInfo.endDate) + "参加" + that.data.classInfo.clasName + ",完成规定培训内容。准予结业,特发此证。"
- //汉字占两格,英文数字占一格
- let re = /^[\u4e00-\u9fa5]$/;
- let stra = str.split("");
- let tva = 30; //阈值
- let strTar = [];
- let num = 0;
- let st = "";
- for (let i = 0; i < str.length; i++) {
- let s = stra.shift()
- st = st + s;
- num += re.test(s) ? 2 : 1;
- tva = strTar.length < 1 ? that.data.tva - 4 : that.data.tva;
- if (num >= tva || i == str.length - 1) {
- strTar.push(st);
- num = 0;
- st = "";
- }
- }
- const ctx = wx.createCanvasContext(that.data.myCanvasId);
- ctx.drawImage(that.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
- ctx.setFillStyle("#000");
- ctx.setFontSize(14); //字大小
- ctx.font = 'normal bold 14px sans-serif'
- ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
- let leftPositionAarr = [59, 30]
- let graduationNum = res.data.data.graduationNum != "" ? "编号:" + res.data.data.graduationNum : "";
- ctx.fillText(graduationNum, 130, 150);
- let topPt = 190 - (strTar.length - 4) * 5;
- let lineHeight = 30 - (strTar.length > 4 ? strTar.length > 6 ? 10 : (strTar.length - 4) * 5 : 0)
- for (let i = 0; i < strTar.length; i++) {
- ctx.fillText(strTar[i], i == 0 ? leftPositionAarr[0] : leftPositionAarr[1], topPt + i * lineHeight);
- }
- ctx.draw();
- that.setData({
- showzs: true
- });
- }
- },
- fail: () => {
- wx.hideLoading();
- wx.showModal({
- showCancel: false,
- content: "网络错误,请稍后再试"
- })
- }
- })
- },
- // 存储结业证
- saveZs() {
- wx.canvasToTempFilePath({ //把当前画布指定区域的内容导出生成指定大小的图片
- canvasId: this.data.myCanvasId,
- success(res) {
- wx.authorize({ //向用户发起授权请求
- scope: 'scope.writePhotosAlbum', //保存相册授权
- success: () => {
- wx.saveImageToPhotosAlbum({ //保存图片到系统相册
- filePath: res.tempFilePath,
- success: () => {
- wx.showToast({
- title: '图片保存成功'
- })
- }
- })
- }
- })
- }
- })
- },
- // 证书隐藏
- onClose1() {
- this.setData({
- showzs: false
- });
- },
- toPath(id, paperId, answersId, address, status) {
- wx.navigateTo({
- url: '/pages/' + address + '/' + address + '?id=' + id + '&paperId=' + paperId + '&answersId=' + answersId + '&status=' + status,
- })
- },
- beginKao(id, paperId, sessionKey, address) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/exam/begin',
- method: "post",
- data: {
- sessionKey: sessionKey,
- id: id,
- paperId: paperId
- },
- success: (res) => {
- if (res.data.code == 0) {
- this.setData({
- status: res.data.status
- })
- this.toPath(id, paperId, res.data.answersId, address);
- }
- }
- })
- },
- onClickShow(e) {
- this.setData({ stuItem: e.currentTarget.dataset.item });
- this.setData({ cardVis: true });
- },
- onClickHide() {
- this.setData({ cardVis: false });
- },
- onUnload() {
- this.setData({ cardVis: false,pageNum:1,stuInfo:{} });
- },
- onHide() {
- this.setData({ cardVis: false,pageNum:1,stuInfo:{} });
- },
- studentList(page) {
- var that = this;
- return new Promise((resolve, reject) => {
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/progress',
- method: "post",
- data: {
- sessionKey: that.data.sessionKey,
- pageNum: page,
- pageSize: that.data.pageSize
- },
- success: (res) => {
- if (res.data.code == 0) {
- let info = res.data.data;
- info.list = info.list.map(item => {
- if (item.studentHead == "" || item.studentHead == null) {
- item.avatar = item.studentSex == 1 ? that.data.defAvatarf : that.data.defAvatarm;
- } else {
- item.avatar = item.studentHead;
- }
- return item;
- })
- console.log(info);
- resolve(info)
- }
- },
- fail: (error) => {
- reject(error)
- }
- })
- })
- },
- getjob(sessionKey) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/position',
- method: "get",
- data: {
- sessionKey
- },
- success: (res) => {
- console.log(res, '我是获取到的数组')
- let Arr = [];
- res.data.data.forEach(item => {
- let newdata = {};
- newdata.dictLabel = item.dictLabel;
- newdata.dictValue = item.dictValue;
- Arr.push(newdata);
- });
- this.setData({
- jobArr: Arr
- })
- },
- fail: () => {
- wx.hideLoading();
- }
- })
- },
- onReachBottom() {
- console.log("下拉刷新");
- var that = this;
- if (that.data.classVis && that.data.stuInfo.list.length > 0) {
- var page = that.data.pageNum;
- page++;
- that.setData({ pageNum: page });
- wx.showLoading({
- title: '加载更多',
- })
- that.studentList(this.data.pageNum).then(res => {
- wx.hideLoading();
-
- let oldList = that.data.stuInfo.list.slice();
- let newInfo = Object.assign({}, that.data.stuInfo, res)
- console.log("that.data.pageNum",that.data.pageNum);
- console.log("res.pages:",res.pages);
- if (that.data.pageNum <= res.pages) {
- newInfo.list=oldList.concat(newInfo.list)
- that.setData({
- stuInfo:newInfo
- });
- }else{
- wx.showToast({
- title: '没有更多了',
- })
- }
- console.log(res)
- },()=>{
- wx.hideLoading();
- wx.showToast({
- title: '加载失败',
- })
- })
- }
- },
- // onReachBottom: function () {
- // var that = this;
- // console.log(that)
- // var page = that.data.page
- // page++;
- // that.setData({
- // page: page
- // })
- // // 显示加载图标
- // wx.showLoading({
- // title: '玩命加载中',
- // })
- // wx.request({
- // url: '', //请求的接口地址
- // data: {
- // page: that.data.page, // 页数
- // },
- // header: {
- // 'content-type': 'application/json'
- // },
- // method: 'GET',
- // success: function (res) {
- // console.log(res)
- // var goods = that.data.grade.concat(res.data.data.list) //grade 为一进入页面请求完数据定义的集合
- // if (res.data.data.list == '') {
- // console.log(1)
- // wx.showToast({
- // title: '暂无更多',
- // icon: 'none',
- // })
- // } else {
- // that.setData({
- // grade : goods,
- // });
- // }
- // wx.hideLoading();
- // },
- // })
- // },
- async onShow() {
- console.log(app.globalData.imgUrl);
- var that = this;
- // wx.showLoading({
- // title: '加载中',
- // mask:true
- // })
- const sessionKey = await tools.checkSessionAndLogin();
- this.setData({
- sessionKey
- });
- await this.isRz(sessionKey)
- that.getjob(sessionKey)
- console.log(that.data.classVis);
- this.studentList(this.data.pageNum).then((info) => {
- this.setData({ stuInfo: info });
- console.log(this.data.stuInfo)
- })
- }
- })
|