Parcourir la source

新增加载更多加载完成后隐藏,查看图片刷新页面,首页学过的课程展开

Limengbo il y a 6 ans
Parent
commit
f1d249a857

+ 43 - 1
compontents/curriculum/curriculum.js

@@ -10,6 +10,10 @@ Component({
     studyLog: {
       type: Array,
       value: []
+    },
+    height: {
+      type: String,
+      value: ''
     }
   },
 
@@ -17,14 +21,52 @@ Component({
    * 组件的初始数据
    */
   data: {
-
+    flag: false,
+    animationData: {},
+    downUp: '展开',
+    src: '../../pages/image/toDown.png',
   },
 
   /**
    * 组件的方法列表
    */
   methods: {
+    onTap (e) {
+      let flage = e.target.dataset.flag;
+      const height = this.properties.studyLog.length * 68;
+      if(flage){
+        this.util(flage, '700rpx');
+        this.setData({
+          'flag': false,
+          'downUp': '展开',
+          'src':'../../pages/image/toDown.png'
+      })
+      } else {
+        this.util(flage, height + 'rpx');
+        this.setData({
+          'flag': true,
+          'downUp': '收起',
+          'src': '../../pages/image/toUp.png'
+        })
+      }
+    },
+    /* 创建动画并执行 */
+    util (flag, height) {
+      // 创建动画实例   
+      var animation = wx.createAnimation({  
+        duration: 200,  //动画时长  
+        timingFunction: "linear", //线性  
+        delay: 0  //0则不延迟  
+      });
+      
+      this.animation = animation;
+
+      animation.height(height).step();
 
+      this.setData({  
+        animationData: animation.export()  
+      })  
+    }
   },
   ready: function () {
     //console.log(this.properties.studyLog)

+ 6 - 3
compontents/curriculum/curriculum.wxml

@@ -3,11 +3,14 @@
   <view class="record_title">
     <text>学习记录</text>
   </view>
-  <view class="record_con" wx:for="{{studyLog}}" wx:key="{{item.lessonId}}">
-    <view class="record_list">
+  <view class="record_con" animation="{{animationData}}" style="height:{{height}}rpx">
+    <view class="record_list" wx:for="{{studyLog}}" wx:key="{{item.lessonId}}">
       <text>{{item.lessonTitle}}</text>
       <text>{{item.gmtCreated}}</text>
     </view>
   </view>
-  
+  <view class="unfold" wx:if="{{height}}">
+      <image class="dirImg" src="{{src}}"></image>
+      <text data-flag="{{flag}}" bindtap="onTap">{{downUp}}</text>
+  </view>
 </view>

+ 24 - 0
compontents/curriculum/curriculum.wxss

@@ -6,6 +6,12 @@
     padding: 28rpx 28rpx 81rpx 28rpx;
     box-sizing:border-box;
     background:#fff;
+    position: relative;
+    
+}
+
+.record_con {
+    overflow: hidden;
 }
 
 .record_title {
@@ -34,4 +40,22 @@
 .record_list text {
     color: #444;
     font-size: 28rpx;
+}
+
+.unfold {
+    position: absolute;
+    right: 28rpx;
+    bottom: 24rpx;
+    font-size: 28rpx;
+    line-height: 28rpx;
+    height: 28rpx;
+    color: #93AAFA;
+}
+.dirImg{
+  width: 16rpx;
+  height: 9rpx;
+  position: absolute;
+  top: 50%;
+  left: -20rpx;
+  margin-top: -5rpx;
 }

+ 19 - 8
pages/art/art.js

@@ -68,6 +68,11 @@ Page({
             this.setData({
               questionsdian: util.replyNo(res.data.data.list)
             })
+            if(5*this.data.num1 > res.data.data.totalSize) {
+              this.setData({
+                questionsMore: ''
+              })
+            }
           }    
         }
       });
@@ -83,7 +88,12 @@ Page({
           console.log(res.data.data)
           this.setData({
             productionData: res.data.data,
-          })  
+          }) 
+          if(5*this.data.num2 > res.data.data.totalSize) {
+            this.setData({
+              productionMore: ''
+            })
+          }
         }
       });
     }
@@ -101,13 +111,6 @@ Page({
 
 
   onLoad: function (options) {
-    //分享按钮
-    wx.showShareMenu({
-      withShareTicket: true
-    })
-  },
-
-  onShow: function () {
     const columnId = util.column('6').columnId;
     /* 分享 */
     this.distinction(2, columnId, 1, 2, res => {
@@ -184,6 +187,14 @@ Page({
         }
       })
     });
+    //分享按钮
+    wx.showShareMenu({
+      withShareTicket: true
+    })
+  },
+
+  onShow: function () {
+
   },
   /* 转发*/
   onShareAppMessage: function (ops) {

+ 5 - 0
pages/chinese/chinese.js

@@ -65,6 +65,11 @@ Page({
             this.setData({
               questionsdian: util.replyNo(res.data.data.list)
             })
+            if(5*this.data.num1 > res.data.data.totalSize) {
+              this.setData({
+                questionsMore: ''
+              })
+            }
           }      
         }
       });

+ 6 - 1
pages/english/english.js

@@ -65,7 +65,12 @@ Page({
             this.setData({
               questionsdian: util.replyNo(res.data.data.list)
             })
-          }       
+          }   
+          if(5*this.data.num1 > res.data.data.totalSize) {
+            this.setData({
+              questionsMore: ''
+            })
+          }    
         }
       });
     }

+ 7 - 1
pages/index/index.js

@@ -17,7 +17,8 @@ Page({
     time: "",
     rankData: {},
     share: false,
-    studyLog: []
+    studyLog: [],
+    height: ''
   },
   
   lower: function (e) {
@@ -66,6 +67,11 @@ Page({
           time: util.day(res.data.data.timeSpend),
           studyLog: util.studyTime(res.data.data.studyLog)
         })
+        if(res.data.data.studyLog.length > 10) {
+          this.setData({
+            height: '700'
+          })
+        }
       })
       //获取排名
       APIClient.getFriendSchedule('wx/friendsRank/user', {

+ 3 - 1
pages/index/index.wxml

@@ -96,7 +96,9 @@
             </view>
             <!-- 课模板 -->
             <view>
-              <curriculum studyLog="{{ studyLog }}"/>
+              <curriculum 
+              studyLog="{{ studyLog }}"
+              height="{{height}}"/>
             </view>
           </view>
       </scroll-view>

+ 5 - 0
pages/language/language.js

@@ -65,6 +65,11 @@ Page({
             this.setData({
               questionsdian: util.replyNo(res.data.data.list)
             })
+            if(5*this.data.num1 > res.data.data.totalSize) {
+              this.setData({
+                questionsMore: ''
+              })
+            }
           }           
         }
       });

+ 5 - 0
pages/mathematics/mathematics.js

@@ -65,6 +65,11 @@ Page({
             this.setData({
               questionsdian: util.replyNo(res.data.data.list)
             })
+            if(5*this.data.num1 > res.data.data.totalSize) {
+              this.setData({
+                questionsMore: ''
+              })
+            }
           }           
         }
       });

+ 19 - 8
pages/science/science.js

@@ -67,6 +67,11 @@ Page({
             this.setData({
               questionsdian: util.replyNo(res.data.data.list)
             })
+            if(5*this.data.num1 > res.data.data.totalSize) {
+              this.setData({
+                questionsMore: ''
+              })
+            }
           }        
         }
       });
@@ -82,7 +87,12 @@ Page({
           console.log(res.data.data)
           this.setData({
             productionData: res.data.data,
-          })  
+          })
+          if(5*this.data.num2 > res.data.data.totalSize) {
+            this.setData({
+              productionMore: ''
+            })
+          }
         }
       });
     }
@@ -96,13 +106,6 @@ Page({
     })
   },
   onLoad: function (options) {
-    //分享按钮
-    wx.showShareMenu({
-      withShareTicket: true
-    })
-  },
-
-  onShow: function () {
     const columnId = util.column('5').columnId;
     /* 分享 */
     this.distinction(2, columnId, 1, 2, res => {
@@ -182,6 +185,14 @@ Page({
         }
       })
     });
+    //分享按钮
+    wx.showShareMenu({
+      withShareTicket: true
+    })
+  },
+
+  onShow: function () {
+    
   },
   /* 转发*/
   onShareAppMessage: function (ops) {