49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
// template/document-box/document-box.js
|
|
Component({
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
className: String,
|
|
documents: {
|
|
type: Array,
|
|
observer(res) {
|
|
if (res && res.length > 0) this.init()
|
|
}
|
|
},
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
swiperCurrent: 0, // 轮播图下标
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
init() {
|
|
const query = wx.createSelectorQuery();
|
|
query.selectAll(`.main >>> .file-list`).boundingClientRect(rect => {
|
|
if (!rect) return
|
|
let page = {}
|
|
rect.forEach(element => page[element.dataset.index] = element.height)
|
|
this.setData({
|
|
page
|
|
})
|
|
}).exec();
|
|
},
|
|
|
|
// 新 轮播图 自动滑动事件,修改下标
|
|
bindchangeSwiper(e) {
|
|
let current = e.detail.current
|
|
this.setData({
|
|
swiperCurrent: current
|
|
})
|
|
setTimeout(() => this.triggerEvent("bindchange"), 500)
|
|
},
|
|
}
|
|
}) |