// pages/art/art.js const app = getApp() const util = require('../../utils/util.js'); const APIClient = require('../../utils/APIClient.js'); const login = require('../../utils/loginSchedule.js'); /** * productionData 分项data * questionsData 疑问data * courseData 科目信息 * num1 分享得值 * num2 科目得值 * position 定位id值 * questionsdian 点的显示 * list 更改后时间的值 * lessonListHeight 定义高度 * previewHeight 定义高度 * productionMore和questionsMore展开是否显示 * strategy 更改
* 其他的页面组件就看这个就行了 基本上都是都是一样的 */ Page({ data: { productionData: {}, questionsData: {}, courseData: {}, num1: 0, num2: 0, position: '', questionsdian: '', list: [], lessonListHeight: '', previewHeight: '', productionMore: '', questionsMore: '', wxObjectives: [], canvasHeight: '', flag: true, materialData: [], loginType: 1, timeList: [], teacher: '', messageNum: '', uploadNum: '', userKey: '' }, /* 区分答疑和分享 */ distinction: function(type, columnId, pageNo, pageSize, success) { login.getOpenidSessionKey(function(res) { //console.log(res.data.data.uid); APIClient.getProductionSchedule({ uid: res.data.data.uid }, { "type": type, "category": columnId, "pageNo": pageNo, "pageSize": pageSize }).success(success) }, function() { }); }, /*点击加载更多*/ onMyEvent: function(e){ let type = e.currentTarget.dataset.type; const columnId = util.column('6').columnId; if(type == 1) { this.data.num1++ this.setData({ num1: this.data.num1, messageNum: 5*this.data.num1 }) // wx.setStorageSync('messageNum', 5*this.data.num1); this.distinction(type, columnId, 1, 5*this.data.num1, res => { if(res.data.success) { console.log(res.data.data) this.setData({ questionsData: res.data.data, }) if(res.data.data) { res.data.data.list.forEach(item => { this.data.timeList.push(util.formatDate(item.gmtCreated,4)); }); this.setData({ timeList: this.data.timeList, questionsdian: util.replyNo(res.data.data.list) }) if(5*this.data.num1 > res.data.data.totalSize) { this.setData({ questionsMore: '' }) } } } }); } if(type == 2) { this.data.num2++ this.setData({ num: this.data.num2, uploadNum: 5*this.data.num2 }) // wx.setStorageSync('uploadNum', 5*this.data.num2); this.distinction(type, columnId, 1, 5*this.data.num2, res => { if(res.data.success) { console.log(res.data.data) res.data.data.list.forEach(item => { this.data.timeList.push(util.formatDate(item.gmtCreated,4)); }); this.setData({ timeList: this.data.timeList, productionData: res.data.data }) if(5*this.data.num2 > res.data.data.totalSize) { this.setData({ productionMore: '' }) } } }); } }, /*点击获取canvas高度*/ onGetHeight: function (e) { const canvasHeight = this.selectComponent("#chat").data.canvasHeight; this.setData({ canvasHeight, }) }, /*点击定位*/ location: function (e) { const position = e.currentTarget.dataset.id; console.log(position) this.setData({ position }) }, onLoad: function (options) { //this.chat = this.selectComponent("#chat"); if(options.type == "noTv") { this.setData({ loginType: "" }) } let scene = decodeURIComponent(options.scene); if (scene && scene !== 'undefined') { let idParam = scene.split('&')[0]; let showIdParam = scene.split('&')[1]; let idKey = idParam.split('=')[0]; let idvalue = idParam.split('=')[1]; this.setData({ userKey: idvalue }) } if(wx.getStorageSync('user')) { this.setData({ teacher: wx.getStorageSync('user').data.data.isTeacher }) } }, onShow: function () { /*科目信息*/ login.getOpenidSessionKey((res) => { APIClient.getEachSchedule({ uid: res.data.data.uid }, { "category": 6 }).success((res) => { const lessonListLength = util.studyPageTime(res.data.data.lessonPage.list).length; const previewLength = util.filter(res.data.data.lessonPage.list).length; console.log(res) if(lessonListLength > 4) { this.setData({ lessonListHeight: 72 }) } if(previewLength > 4){ this.setData({ previewHeight: 72 }) } this.setData({ courseData: res.data.data, materialData: util.filter(res.data.data.lessonPage.list), list: util.studyPageTime(res.data.data.lessonPage.list), wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives) }) }) }, () => { this.setData({ flag: !this.data.flag }) }, this.data.loginType, this.data.userKey); const columnId = util.column('6').columnId; const uploadNum = this.data.uploadNum ? this.data.uploadNum : '2'; const messageNum = this.data.messageNum ? this.data.messageNum : '2'; /* 分享 */ this.distinction(2, columnId, 1, uploadNum, res => { if(res.data.success) { console.log(res.data.data) this.setData({ productionData: res.data.data }) if(res.data.data) { res.data.data.list.forEach(item => { this.data.timeList.push(util.formatDate(item.gmtCreated,4)); }); this.setData({ timeList: this.data.timeList, }) if(res.data.data.totalSize > 2) { this.setData({ productionMore: true }) } } } }); /* 答疑 */ this.distinction(1, columnId, 1, messageNum, res => { if(res.data.success) { console.log(res.data.data) this.setData({ questionsData: res.data.data }) if(res.data.data) { res.data.data.list.forEach(item => { this.data.timeList.push(util.formatDate(item.gmtCreated,4)); }); this.setData({ timeList: this.data.timeList, questionsdian: util.replyNo(res.data.data.list) }) if(res.data.data.totalSize > 2) { this.setData({ questionsMore: true }) } } } }); }, keep: function () { }, /* 转发*/ onShareAppMessage: function (ops) { if (ops.from === 'button') { // 来自页面内转发按钮 console.log(ops.target) } const postId = ops.target.dataset.postid; const imageUrl= ops.target.dataset.imageurl[0]; return { title: '小学王者班', path: `pages/transmit/transmit?ind=7&postId=${postId}`, imageUrl, success: function (res) { // 转发成功 console.log("转发成功:" + JSON.stringify(res)); }, fail: function (res) { // 转发失败 console.log("转发失败:" + JSON.stringify(res)); } } }, /*获取个人信息弹框*/ jurisdiction: function () { this.setData({ flag: !this.data.flag }) this.onShow(); }, })