| | |
| | | data: { |
| | | height: '', //屏幕高度 |
| | | bookId: '', |
| | | cmsPath: '', |
| | | consumer: '', |
| | | bookInfo: {}, |
| | | menuList: [], |
| | |
| | | name: '', |
| | | school: '', |
| | | class: '', |
| | | learnTime: '2', |
| | | learnTime: '0小时', |
| | | taskShow: false, |
| | | dataList: [], //任务单 |
| | | tasksListData: [], //已填写任务单messsge |
| | |
| | | userId: 0, |
| | | userName: '', |
| | | isUpdate: false, |
| | | taskId: 0, //默认选中目录id |
| | | taskId: '', //默认选中目录id |
| | | autosize: { |
| | | maxHeight: 120, |
| | | minHeight: 80, |
| | |
| | | disabled: false, |
| | | dialogVisible: false, |
| | | invitee: "", |
| | | teacherEvaluated: false, |
| | | evaluated: false, |
| | | rowCol: [{ |
| | | width: '50%', |
| | | }, |
| | | { |
| | | width: '100%' |
| | | }, |
| | | { |
| | | width: '80%' |
| | | }, |
| | | { |
| | | width: '100%' |
| | | }, { |
| | | width: '100%' |
| | | }, |
| | | ], |
| | | }, |
| | | onShow() { |
| | | var that = this; |
| | |
| | | */ |
| | | onLoad(options) { |
| | | if (options) { |
| | | console.log(options, 666) |
| | | this.setData({ |
| | | bookId: options.bookId, |
| | | taskId: options.bookId, |
| | | cmsPath: options.cmsPath, |
| | | taskId: options.taskId, |
| | | consumer: options.consumer, |
| | | userId: options.userId, |
| | | userName: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).name |
| | | userName: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).nickName |
| | | }); |
| | | if (options.consumer) { |
| | | this.setData({ |
| | | cmsPath: options.cmsPath, |
| | | bookId: options.bookId, |
| | | taskId: options.bookId, |
| | | taskId: options.taskId, |
| | | consumer: options.consumer, |
| | | userId: options.userId, |
| | | disabled: true |
| | | }); |
| | | } else { |
| | | this.setData({ |
| | | userId: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).id, |
| | | userId: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).userId, |
| | | disabled: false |
| | | }); |
| | | } |
| | | this.getResourceData() |
| | | this.getLearnTime() |
| | | } |
| | | |
| | | }, |
| | | |
| | | getLearnTime() { |
| | | app.MG.identity |
| | | .getUserKey({ |
| | | domain: 'cloudLearningTime', |
| | | keys: [this.data.bookId] |
| | | }) |
| | | .then((res) => { |
| | | if (res.length > 0 && JSON.parse(res[0].value) && JSON.parse(res[0].value).length > 0) { |
| | | let time = JSON.parse(res[0].value)[0].learnTime |
| | | let minutes = Number(time) / (1000 * 60) |
| | | let hours = Number(time) / (1000 * 60 * 60) |
| | | if (minutes > 0 && minutes < 60) { |
| | | this.setData({ |
| | | learnTime: Math.round(minutes) + '分钟', |
| | | }); |
| | | } else if (minutes > 60) { |
| | | this.setData({ |
| | | learnTime: Math.round(hours) + '小时', |
| | | }); |
| | | } else { |
| | | this.setData({ |
| | | learnTime: '0小时', |
| | | }); |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | getResourceData() { |
| | | this.setData({ |
| | | menuList: [], |
| | | loading: true, |
| | | }); |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: this.data.bookId, |
| | | cmsPath: 'jsek_learningTasks', |
| | | cmsPath: this.data.cmsPath, |
| | | // cmsType: '*', |
| | | itemFields: { |
| | | SysType: 'CmsFolder' |
| | |
| | | }); |
| | | if (res.datas.cmsDatas[0].datas) { |
| | | let list = res.datas.cmsDatas[0].datas |
| | | this.setData({ |
| | | menuList: list, |
| | | }); |
| | | let dataList = [] |
| | | list.forEach((item) => { |
| | | if (item.childrenFolderCount > 0) { |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: this.data.bookId, |
| | | cmsPath: item.productLinkPath, |
| | | // cmsType: '*', |
| | | itemFields: { |
| | | SysType: 'CmsFolder' |
| | | }, |
| | | pading: { |
| | | start: 0, |
| | | size: 99 |
| | | } |
| | | } |
| | | app.MG.store.getProductDetail(query).then((res) => { |
| | | item.children = res.datas.cmsDatas[0].datas |
| | | }) |
| | | } |
| | | dataList.push(item) |
| | | }) |
| | | setTimeout(() => { |
| | | this.setData({ |
| | | menuList: dataList, |
| | | loading: false, |
| | | }); |
| | | }, 500) |
| | | if (this.data.taskId) { |
| | | this.data.menuList.forEach((item) => { |
| | | if (item.id == this.data.taskId) { |
| | | setTimeout(() => { |
| | | this.data.menuList.forEach((item) => { |
| | | if (item.id == this.data.taskId) { |
| | | this.setData({ |
| | | taskInfo: item, |
| | | }); |
| | | } else if (item.children) { |
| | | item.children.forEach((item1) => { |
| | | if (item1.id == this.data.taskId) { |
| | | this.setData({ |
| | | taskInfo: item1, |
| | | }); |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, 500) |
| | | } else { |
| | | setTimeout(() => { |
| | | if (this.data.menuList[0].children) { |
| | | this.setData({ |
| | | taskInfo: item, |
| | | taskInfo: this.data.menuList[0].children[0], |
| | | }); |
| | | } else { |
| | | this.setData({ |
| | | taskInfo: this.data.menuList[0], |
| | | }); |
| | | } |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | taskInfo: this.data.menuList[0], |
| | | }); |
| | | }, 500) |
| | | } |
| | | } |
| | | this.getTasksList() |
| | | setTimeout(() => { |
| | | this.getTasksList() |
| | | }, 500) |
| | | }) |
| | | }, |
| | | |
| | | getTask(e) { |
| | | console.log(e, 123) |
| | | let data = e.currentTarget.dataset.item |
| | | if (data.childrenFolderCount > 0) { |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: this.data.bookId, |
| | | cmsPath: data.productLinkPath, |
| | | // cmsType: '*', |
| | | itemFields: { |
| | | SysType: 'CmsFolder' |
| | | }, |
| | | pading: { |
| | | start: 0, |
| | | size: 99 |
| | | } |
| | | } |
| | | app.MG.store.getProductDetail(query).then((res1) => { |
| | | this.data.menuList.forEach((item) => { |
| | | if (item.id == data.id) { |
| | | item.children = res1.datas.cmsDatas[0].datas |
| | | } |
| | | }) |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | taskShow: true, |
| | | }); |
| | | } |
| | | this.taskSelect(data) |
| | | |
| | | let item = e.currentTarget.dataset.item |
| | | this.taskSelect(item) |
| | | }, |
| | | |
| | | onVisibleChange(e) { |
| | | this.setData({ |
| | | taskShow: e.detail.visible, |
| | |
| | | this.setData({ |
| | | tasksListData: res.datas, |
| | | }); |
| | | this.taskSelect(this.data.taskInfo) |
| | | if (this.data.taskInfo.name) { |
| | | this.taskSelect(this.data.taskInfo) |
| | | } |
| | | }) |
| | | }, |
| | | taskSelect(item) { |
| | |
| | | if (this.data.tasksListData.length > 0) { |
| | | this.data.tasksListData.forEach((item1) => { |
| | | let content = JSON.parse(item1.content) |
| | | this.setData({ |
| | | name: content.userName, |
| | | school: content.school, |
| | | class: content.class, |
| | | learnTime: content.learnTime, |
| | | }); |
| | | if (content.id == this.data.taskInfo.id) { |
| | | if (content.userId == this.data.userId) { |
| | | this.setData({ |
| | |
| | | name: content.userName, |
| | | school: content.school, |
| | | class: content.class, |
| | | learnTime: content.learnTime, |
| | | taskShow: true, |
| | | learnTime: this.data.learnTime, |
| | | }); |
| | | this.getChildTasksList() |
| | | if (content.evaluate.length > 0) { |
| | | content.evaluate.forEach((element) => { |
| | | if (this.data.consumer == 'classmate') { |
| | | element.mateEvaluation = '' |
| | | } |
| | | if (this.data.consumer == 'teacher') { |
| | | element.teacherEvaluation = '' |
| | | } |
| | | }) |
| | | if (this.data.name && this.data.school && this.data.class) { |
| | | this.setData({ |
| | | dataList: content.evaluate, |
| | | }); |
| | | |
| | | taskShow: true, |
| | | }) |
| | | this.getChildTasksList() |
| | | if (content.evaluate.length > 0) { |
| | | this.setData({ |
| | | dataList: content.evaluate, |
| | | }); |
| | | } |
| | | } else { |
| | | wx.showToast({ |
| | | title: "请先填写个人信息", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | this.goDetail(item) |
| | | return false |
| | | } |
| | | }) |
| | | |
| | | } else { |
| | | } |
| | | if (this.data.dataList.length == 0) { |
| | | this.goDetail(item) |
| | | } |
| | | } |
| | | |
| | | }, |
| | | goDetail(item) { |
| | | this.setData({ |
| | |
| | | item.teacherEvaluation = '' |
| | | }) |
| | | } |
| | | this.setData({ |
| | | dataList: res.datas.cmsDatas[0].datas, |
| | | }); |
| | | if (this.data.name && this.data.school && this.data.class) { |
| | | this.setData({ |
| | | dataList: res.datas.cmsDatas[0].datas, |
| | | taskShow: true, |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: "请先填写个人信息", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | getChildTasksList() { |
| | |
| | | if (res.datas.length > 0) { |
| | | let list = [] |
| | | this.data.dataList.forEach((item) => { |
| | | item.teacherEvaluation = [] |
| | | item.mateEvaluation = [] |
| | | res.datas.forEach((item1) => { |
| | | let content = JSON.parse(item1.content) |
| | | if (content.teacherComment) { |
| | | if (content.teacherComment.length > 0) { |
| | | content.teacherComment.forEach((item2) => { |
| | | if (item.id == item2.childTaskId) { |
| | | item.teacherEvaluation.push(item2) |
| | | item.teacherEvaluation = [item2] |
| | | if (this.data.consumer == 'teacher') { |
| | | this.setData({ |
| | | evaluated: true |
| | | }); |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | if (content.mateComment) { |
| | | if (item.teacherEvaluation && item.teacherEvaluation.length > 0) { |
| | | this.setData({ |
| | | teacherEvaluated: true |
| | | }); |
| | | } |
| | | if (content.mateComment.length > 0) { |
| | | content.mateComment.forEach((item3) => { |
| | | if (item.id == item3.childTaskId) { |
| | | item.mateEvaluation.push(item3) |
| | | item.mateEvaluation = [...item.mateEvaluation, item3] |
| | | if (this.data.consumer == 'classmate') { |
| | | if (item.mateEvaluation && item.mateEvaluation.length > 0) { |
| | | let data = item.mateEvaluation.find( |
| | | (item) => item.userId == this.data.userId |
| | | ) |
| | | if (data) { |
| | | this.setData({ |
| | | evaluated: true |
| | | }); |
| | | item.mateEvaluation = [data] |
| | | } else { |
| | | this.setData({ |
| | | evaluated: false |
| | | }); |
| | | item.mateEvaluation = '' |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | |
| | | this.setData({ |
| | | dataList: list |
| | | }); |
| | | console.log(this.data.dataList, 777) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 个人信息填写 |
| | | bindTnputBlur(e) { |
| | | this.setData({ |
| | | name: e.detail.value |
| | | }) |
| | | }, |
| | | onSchoolInput(e) { |
| | | this.setData({ |
| | | school: e.detail.value |
| | | }) |
| | | }, |
| | | bindClassBlur(e) { |
| | | this.setData({ |
| | | class: e.detail.value |
| | | }) |
| | | }, |
| | | |
| | | //任务填写 |
| | | //反思 |
| | | onIntrospectionInput(e) { |
| | | console.log(e) |
| | | let index = e.target.dataset.index |
| | | let data = 'dataList[' + index + '].introspection' |
| | | this.setData({ |
| | | [data]: e.detail.value |
| | | }); |
| | | console.log(this.data.dataList) |
| | | }, |
| | | //完成情况 |
| | | onCompletionInput(e) { |
| | |
| | | this.setData({ |
| | | [data]: e.detail.value |
| | | }); |
| | | console.log(this.data.dataList) |
| | | }, |
| | | //同伴评价 |
| | | onMateInput(e) { |
| | |
| | | }) |
| | | }, |
| | | onInviteeChange(e) { |
| | | console.log(e) |
| | | this.setData({ |
| | | invitee: e.detail.value |
| | | }); |
| | |
| | | wx.showShareMenu({ |
| | | withShareTicket: true |
| | | }); |
| | | console.log(888) |
| | | }, |
| | | confirmBtn1() { |
| | | wx.showToast({ |
| | | title: "教师已经评价,不能再邀请教师评价!", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | }, |
| | | submitComment() { |
| | | let mateEvaluationList = [] |
| | | let teacherEvaluationList = [] |
| | | this.data.dataList.forEach((item) => { |
| | | if (this.data.consumer == 'classmate') { |
| | | if (item.mateEvaluation == '') { |
| | | wx.showToast({ |
| | | title: "请先填评价", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | } else { |
| | | if (item.mateEvaluation && item.mateEvaluation != '') { |
| | | mateEvaluationList.push({ |
| | | childTaskId: item.id, |
| | | userId: this.data.userId, |
| | | userName: this.data.userName, |
| | | evaluation: item.mateEvaluation |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (this.data.consumer == 'teacher') { |
| | | if (item.teacherEvaluation == '') { |
| | | wx.showToast({ |
| | | title: "请先填评价", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | } else { |
| | | if (item.teacherEvaluation && item.teacherEvaluation != '') { |
| | | teacherEvaluationList.push({ |
| | | childTaskId: item.id, |
| | | userId: this.data.userId, |
| | | userName: this.data.userName, |
| | | evaluation: item.teacherEvaluation |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | if (this.data.consumer == 'classmate') { |
| | | if (mateEvaluationList.length < this.data.dataList.length) { |
| | | wx.showToast({ |
| | | title: "请先填写评价", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | } |
| | | } |
| | | if (this.data.consumer == 'teacher') { |
| | | if (teacherEvaluationList.length < this.data.dataList.length) { |
| | | wx.showToast({ |
| | | title: "请先填写评价", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | } |
| | | } |
| | | let content = { |
| | | id: this.data.taskInfo.id, |
| | | taskName: this.data.taskInfo.name, |
| | |
| | | onShareAppMessage() { |
| | | return { |
| | | title: '评价学习任务单', |
| | | path: `packageBookService/pages/bookServices/detail/components/learnTask/index?bookId=${this.data.bookId}&consumer=${this.data.invitee}&taskId=${this.data.taskInfo.id}&userId=${this.data.userId}`, |
| | | path: `packageBookService/pages/bookServices/detail/components/learnTask/index?bookId=${this.data.bookId}&consumer=${this.data.invitee}&taskId=${this.data.taskInfo.id}&userId=${this.data.userId}&cmsPath=${this.data.cmsPath}`, |
| | | imgUrl: 'https://jsek.bnuic.com/home/image/click-icon.png', |
| | | } |
| | | } |