var app = getApp() var api = require('../../utils/api.js'); Page({ data: { loged: [ { month: 'current', day: '1', color: '#77b9b9' }, { month: 'current', day: '2', color: '#77b9b9' }, { month: 'current', day: '3', color: '#f65556' }, { month: 'current', day: '4', color: '#f65556' }, { month: 'current', day: '5', color: '#f65556' }, { month: 'current', day: '6', color: '#77b9b9' }, { month: 'current', day: '7', color: '#77b9b9' }, { month: 'current', day: '8', color: '#77b9b9' }, { month: 'current', day: '9', color: '#77b9b9' }, ], thisMonthLearnTime: 0, totalLearnTime: 0, checkCardDays: 0 }, prevDate: function(e) { this.getMyLearnInfo(e.detail.currentYear, e.detail.currentMonth) }, nextDate: function (e) { this.getMyLearnInfo(e.detail.currentYear, e.detail.currentMonth) }, dateChange: function(e) { this.getMyLearnInfo(e.detail.currentYear, e.detail.currentMonth) }, onLoad: function () { this.getMyLearnInfo() }, getMyLearnInfo: function(year, month) { var date = new Date(), year = year || date.getFullYear(), month = month || date.getMonth() + 1 var pt_student = wx.getStorageSync('pt_student') wx.request({ url: api.getMyLearnInfoUrl, method: 'GET', data: { 'student_id': pt_student.id, 'year': year, 'month': month }, success: res => { if (res.data.status == 'success') { // console.log(res) this.setData({ loged: res.data.checkCardList, thisMonthLearnTime: res.data.thisMonthLearnTime, totalLearnTime: res.data.totalLearnTime, checkCardDays: res.data.checkCardDays }) } } }) } })