Silent 6 years ago
parent
commit
f0889ff72f
2 changed files with 19 additions and 4 deletions
  1. 16 2
      wechat/pages/my-log/my-log.js
  2. 3 2
      wechat/pages/my-log/my-log.wxml

+ 16 - 2
wechat/pages/my-log/my-log.js

xqd
@@ -53,16 +53,30 @@ Page({
     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) {
-    console.log(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
+        'student_id': pt_student.id,
+        'year': year,
+        'month': month
       },
       success: res => {
         if (res.data.status == 'success') {

+ 3 - 2
wechat/pages/my-log/my-log.wxml

xqd
@@ -1,11 +1,12 @@
 <view>
   <calendar
-    bindnextMonth="next"
+    bindprevMonth="prevDate"
+    bindnextMonth="nextDate"
+    binddateChange="dateChange"
     days-color="{{loged}}"
     weeks-type="cn"
     show-more-days="true"
     active-type="rounded"
-    binddateChange="dateChange"
   />
   <zan-cell-group>
     <zan-cell title="本月积累学习时长" value="{{ thisMonthLearnTime }}"> </zan-cell>