feat: 电子药箱小程序 - 4Tab药品管理
- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
// components/collapse/collapse.ts
|
||||
export { }
|
||||
Component({
|
||||
properties: {
|
||||
title: {
|
||||
type: String,
|
||||
value: ''
|
||||
},
|
||||
titleStyle: {
|
||||
type: String,
|
||||
value: ''
|
||||
},
|
||||
defaultOpen: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
disableOpen: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
offsetHeight: {
|
||||
type: Number,
|
||||
value: 0
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
open: false,
|
||||
contentHeight: 0
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
ready(this: WechatMiniprogram.Component.TrivialInstance) {
|
||||
this.setData({ open: this.data.defaultOpen })
|
||||
this.calcHeight()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
toggle(this: WechatMiniprogram.Component.TrivialInstance) {
|
||||
if (this.data.disableOpen) return;
|
||||
|
||||
const open = !this.data.open;
|
||||
this.setData({ open }, () => {
|
||||
if (open) {
|
||||
// 等展开后再算高度
|
||||
this.calcHeight();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
calcHeight(this: WechatMiniprogram.Component.TrivialInstance) {
|
||||
const query = this.createSelectorQuery()
|
||||
query.select('#content').boundingClientRect()
|
||||
query.exec(res => {
|
||||
if (res && res[0]) {
|
||||
this.setData({
|
||||
contentHeight: res[0].height
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user