lessonList.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // compontents/lesson_list/lessonList.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. lessonData: {
  8. type: Array,
  9. value: []
  10. }
  11. },
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. flag: false,
  17. animationData: {},
  18. },
  19. /**
  20. * 组件的方法列表
  21. */
  22. methods: {
  23. onTap (e) {
  24. let flage = e.target.dataset.flag;
  25. const height = this.properties.lessonData.length * 70;
  26. if(flage){
  27. this.util(flage, '270rpx');
  28. this.setData({'flag': false})
  29. } else {
  30. this.util(flage, height + 'rpx');
  31. this.setData({'flag': true})
  32. }
  33. },
  34. /* 创建动画并执行 */
  35. util (flag, height) {
  36. // 创建动画实例
  37. var animation = wx.createAnimation({
  38. duration: 200, //动画时长
  39. timingFunction: "linear", //线性
  40. delay: 0 //0则不延迟
  41. });
  42. this.animation = animation;
  43. animation.height(height).step();
  44. this.setData({
  45. animationData: animation.export()
  46. })
  47. }
  48. }
  49. })