1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060 |
- 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: "../../images/zsbj.jpg", //结业证背景 用于合成图片
- IngCourseArr: [], //如果有正在进行的课就存一下
- istask: false, //判断班级群是否添加
- istask1: false, //学员登记表是否完成
- istask2: false, //课程是否完成
- istask3: false, //期末考试是否完成
- istask4: false, //综合反馈是否完成
- currentId: null,
- currentName: "",
- tva: 32,
- },
- // 查询我是否认证
- 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) {
- wx.request({
- url: app.globalData.publicUrl + '/wx/student/selMyClas',
- method: "post",
- data: {
- sessionKey
- },
- success: (res) => {
-
- if (res.data.code == 0) {
- this.setData({
- classInfo: res.data.data
- })
-
-
- 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 == "运行时异常:学员不可同时存在两个班级中。") {
- wx.showModal({
- content: "学员不可同时存在多个班级中哦",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.switchTab({
- url: '../index/index'
- })
- }
- }
- })
- return false;
- } else {
- 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
- },
- success: (res) => {
- if (res.data.code == 0) {
- if (res.data.list && res.data.list.length !== 0)
- this.setData({
- notice: res.data.list[0].noticeContent
- });
- }
- }
- })
- },
- // 跳转通知页
- 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();
- 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);
- }
- }
- })
- },
- async onShow() {
- // wx.showLoading({
- // title: '加载中',
- // mask:true
- // })
- const sessionKey = await tools.checkSessionAndLogin();
- this.setData({
- sessionKey
- });
- this.isRz(sessionKey)
- }
- })
|