2026-01-09 17:15:08 +08:00
|
|
|
|
// pages/components/card_plugin/card_plugin.js
|
|
|
|
|
|
Component({
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 组件的属性列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
options: {
|
|
|
|
|
|
multipleSlots: true,
|
|
|
|
|
|
addGlobalClass: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
properties: {
|
|
|
|
|
|
customStyle: null,
|
|
|
|
|
|
className: null,
|
|
|
|
|
|
headerStyle: null,
|
|
|
|
|
|
contentStyle: null,
|
|
|
|
|
|
footerStyle: null,
|
2026-02-02 16:58:37 +08:00
|
|
|
|
showMoreBar: { type: Boolean, value: true },
|
|
|
|
|
|
showAll: { type: Boolean, value: false },
|
2026-01-09 17:15:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
lifetimes: {
|
|
|
|
|
|
attached() {
|
2026-01-21 17:05:30 +08:00
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
|
// this.getSlotHeight();
|
|
|
|
|
|
// }, 100);
|
2026-01-09 17:15:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 组件的初始数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
data: {
|
|
|
|
|
|
showMore: false,
|
2026-02-02 16:58:37 +08:00
|
|
|
|
// showMoreBar: true,
|
2026-01-09 17:15:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 组件的方法列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
getSlotHeight() {
|
|
|
|
|
|
// 1. 创建组件内的节点查询器(必须加.in(this))
|
|
|
|
|
|
const query = wx.createSelectorQuery().in(this);
|
|
|
|
|
|
// 2. 查询插槽容器节点
|
|
|
|
|
|
query
|
2026-01-21 17:05:30 +08:00
|
|
|
|
.select('#contentSlot')
|
2026-01-09 17:15:08 +08:00
|
|
|
|
.boundingClientRect((rect) => {
|
|
|
|
|
|
if (rect) {
|
|
|
|
|
|
const height = rect.height; // 获取节点高度(单位px)
|
|
|
|
|
|
const fontSizeSetting = wx.getAppBaseInfo().fontSizeSetting;
|
|
|
|
|
|
this.setData({ showMoreBar: height >= fontSizeSetting * 3 * 1.57 });
|
|
|
|
|
|
|
|
|
|
|
|
// 可将高度通过自定义事件传递给父页面
|
|
|
|
|
|
// this.triggerEvent("slotHeightChange", { height });
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// console.warn("未查询到插槽容器节点");
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.exec(); // 执行查询
|
|
|
|
|
|
},
|
|
|
|
|
|
click(e: any) {
|
2026-01-21 17:05:30 +08:00
|
|
|
|
this.triggerEvent('tap', e);
|
2026-01-09 17:15:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
showMoreTap() {
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
showMore: !this.data.showMore,
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|