const app = getApp() const util = require("../../../utils/util"); const api = require('../../../api/api.js'); const user = require('../../../utils/user.js'); import moment from 'moment' Page({ data: { evalId:'', skillList:[], sumStudyTime:'', currentTab:'4', typeList: [ {text:'全部',value:''} ], type: '', date: moment(new Date()).format('YYYY-MM'), currentDate: new Date().getTime(), minDate: new Date('2022-01-01').getTime(), pickerShow:false, star:0, evalShow:false, courseList:[], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.selectComponent('#tabs').resize(); this.getStudyDuration(); this.getTypeList(); // this.getMyCourse(); }, onClickShow(){ this.setData({ evalShow: false, }); }, submitEval(){ if(this.data.star==0){ wx.showToast({ title: '请选择评价星级', icon:'none' }) }else{ util.request(api.workerCourseScore, { enrolmentId:this.data.evalId, workerScore:this.data.star }, 'GET').then(res=> { if (res.errno === 0) { wx.showToast({ title: '评价成功', icon:'none' }) this.setData({ evalShow:false, }); this.getMyCourse() }else{ wx.showToast({ title: res.errmsg, icon:'none' }) } }); } }, stop:function(){ //阻止弹框冒泡和捕获的空事件,不要删除!!! }, goStar(e){ let id=e.currentTarget.dataset.id; this.setData({ evalShow: true, star:0, evalId:id }); }, onChange(event) { this.setData({ star: event.detail, }); }, getMyCourse(){ util.request(api.getMyCourse, { categorySubId:this.data.type, courseType:this.data.currentTab, studyType :'2', yearMonth:this.data.date }, 'GET').then(res=> { if (res.errno === 0) { this.setData({ courseList:res.data }); } }); }, getStudyDuration(){ util.request(api.getStudyDuration, { }, 'GET').then(res=> { if (res.errno === 0) { this.setData({ sumStudyTime:res.data.sumStudyTime, skillList:res.data.willSkill }); } }); }, getTypeList(){ util.request(api.getCategoryDict, { }, 'GET').then(res=> { if (res.errno === 0) { let list=res.data; let current=[{text:'全部',value:''}]; list.forEach(item=>{ let obj={text:item.type,value:item.id}; current.push(obj); }); this.setData({ typeList:current, type:'' }); } }); }, dropdownChange(e){ let type=e.detail; this.setData({ type:type }); this.getMyCourse(); }, dateSelect(){ this.setData({ pickerShow:true }) }, onCancel(){ this.setData({ pickerShow:false }) }, onConfirm(e){ console.log(e); let date=moment(e.detail).format('YYYY-MM'); this.setData({ date:date, pickerShow:false }); this.getMyCourse(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getMyCourse(); }, switchTab(e){ let tab=e.detail.name; this.setData({ currentTab:tab, courseList:[] }); this.getMyCourse(); }, goHistory(){ wx.pageScrollTo({ selector: '.tab-sticky', duration: 300 }) this.setData({ currentTab:'history' }); }, goLearn(e){ // let id=e.currentTarget.dataset.id; let courseid=e.currentTarget.dataset.courseid; let userInfo = wx.getStorageSync('userInfo'); util.request(api.startStudy, { courseId:courseid, workerNo: userInfo.workerNo, }, 'GET').then(res=> { if (res.errno == 0) { let id=res.data.enrolmentId; wx.navigateTo({ url: '/pages/upgrade/courseDetail/courseDetail?id='+id+'&courseid='+courseid, }); } }); }, continueLearn(e){ let id=e.currentTarget.dataset.id; let courseid=e.currentTarget.dataset.courseid; wx.navigateTo({ url: '/pages/upgrade/courseDetail/courseDetail?id='+id+'&courseid='+courseid, }); }, onHide: function () { }, onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, })