const app = getApp(); Page({ /** * 页面的初始数据 */ data: { bookId: '', consumer: '', bookInfo: {}, menuList: [], loading: true, name: '', school: '', class: '', learnTime: '2', taskShow: false, dataList: [], //任务单 tasksListData: [], //已填写任务单messsge taskInfo: {}, //选中任务单目录 tasksData: {}, //已填写任务单 userId: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).id, isUpdate: false, taskId: 0, //默认选中目录id autosize: { maxHeight: 120, minHeight: 80, }, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { if (options) { this.setData({ bookId: options.bookId, consumer: options.consumer }); this.getResourceData() } }, getResourceData() { this.setData({ loading: true, }); let query = { path: '*', queryType: '*', productId: this.data.bookId, cmsPath: 'jsek_learningTasks', // cmsType: '*', itemFields: { SysType: 'CmsFolder' }, pading: { start: 0, size: 999 } } app.MG.store.getProductDetail(query).then((res) => { this.setData({ bookInfo: res.datas, }); if (res.datas.cmsDatas[0].datas) { let list = res.datas.cmsDatas[0].datas let dataLists = [] list.forEach(async (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 } } const data = await app.MG.store.getProductDetail(query).then((res1) => { // item.children = res1.datas.cmsDatas[0].datas return res1.datas.cmsDatas[0].datas }) item.children = data } dataLists.push(item) }) this.setData({ menuList: dataLists, loading: false }); console.log(this.data.menuList) } this.getTasksList() }) }, getTask(e) { console.log(e, 123) let data = e.currentTarget.dataset.item this.setData({ taskShow: true, }); this.taskSelect(data) }, onVisibleChange(e) { this.setData({ taskShow: e.detail.visible, }); }, onCloseTask() { this.setData({ taskShow: false, dataList: [] }); }, getTasksList() { let query = { start: 0, size: 999, sort: { type: 'Desc', field: 'CreateDate' }, appRefCode: app.config.appRefCode, topicIdOrRefCode: 'learningTasks' } app.MG.ugc.getTopicMessageList(query).then((res) => { this.setData({ tasksListData: res.datas, }); }) }, taskSelect(item) { if (!item.children) { this.setData({ taskInfo: item, dataList: [] }); if (this.data.tasksListData.length > 0) { this.data.tasksListData.forEach((item1) => { let content = JSON.parse(item1.content) if (content.id == this.data.taskInfo.id && content.userId == this.data.userId) { isUpdate.value = true tasksData.value = item1 form.name = content.userName form.school = content.school form.class = content.class form.learnTime = content.learnTime this.setData({ isUpdate: true, tasksData: item1, name: content.userName, school: content.school, class: content.class, learnTime: content.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 = '' } }) this.setData({ dataList: content.evaluate }); } console.log(1111) } else { this.goDetail(item) } }) } else { this.goDetail(item) } } }, goDetail(item) { this.setData({ dataList: [] }); let query = { path: '*', queryType: '*', productId: this.data.bookId, cmsPath: item.productLinkPath, // cmsType: '*', itemFields: { SysType: 'CmsFolder', subtaskDescription: [], learningSuggestions: [] }, pading: { start: 0, size: 99 } } app.MG.store.getProductDetailNoChildren(query).then((res) => { if (res.datas.cmsDatas[0].datas.length > 0) { res.datas.cmsDatas[0].datas.forEach((item) => { item.introspection = '' item.completion = '' item.selfEvaluation = '' item.mateEvaluation = '' item.teacherEvaluation = '' }) } this.setData({ dataList: res.datas.cmsDatas[0].datas }); console.log(this.data.dataList, 444) }) }, getChildTasksList() { let query = { start: 0, size: 999, sort: { type: 'Desc', field: 'CreateDate' }, appRefCode: app.config.appRefCode, topicIdOrRefCode: 'learningTasks', parentId: this.data.tasksData.id } app.MG.ugc.getChildTopicMessageList(query).then((res) => { if (res.datas.length > 0) { this.data.dataList.forEach((item) => { console.log(item, 1) res.datas.forEach((item1) => { let content = JSON.parse(item1.content) if (content.teacherComment) { content.teacherComment.forEach((item2) => { if (item.id == item2.childTaskId) { item.teacherEvaluation.push(item2) } }) } if (content.mateComment) { content.mateComment.forEach((item3) => { if (item.id == item3.childTaskId) { item.mateEvaluation.push(item3) } }) } }) }) } }) }, //任务填写 //反思 onIntrospectionInput(e) { console.log(e) }, //完成情况 onCompletionInput(e) { }, //自己评价 onSelfInput(e) { }, //同伴评价 onMateInput(e) { }, //老师评价 onTeacherInput(e) { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })