1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- // compontents/lesson_list/lessonList.js
- Component({
- /**
- * 组件的属性列表
- * 跟curriculum一样
- */
- properties: {
- materialData: {
- type: Array,
- value: []
- },
- height: {
- type: String,
- value: ''
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- flag: false,
- animationData: {},
- downUp: '展开',
- src: '../../pages/image/toDown.png'
- },
- /**
- * 组件的方法列表
- */
- methods: {
- onTap (e) {
- let flage = e.target.dataset.flag;
- const height = this.properties.materialData.length * 70;
- if(flage){
-
- this.util(flage, '280rpx');
- 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()
- })
- },
- //点击预览图片
- preview (e) {
- const warePath = e.currentTarget.dataset.warepath;
- wx.downloadFile({
- url: warePath,
- success: function (res) {
- var filePath = res.tempFilePath
- wx.openDocument({
- filePath: filePath,
- success: function (res) {
- console.log('打开文档成功')
- }
- })
- }
- })
- }
- }
- })
|