statisticsItem.js
2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// components/dateScreen/dateScreen.js
Component({
options: {
multipleSlots: true,
},
/**
* 组件的属性列表
*/
properties: {
// hideColon 是否隐藏colon , 默认false
// name : - 唯一key , 数据的键值
// label : 文案
// col : 占24分之几
// valueWidth : 值的宽度,默认为100%
// labelWidth : 标签宽度,默认为150px
// slot : 整体的插槽名,优先级高于name
// itemStyle: 每一项的样式
// tooltip: boolean 是否用tooltip 展示data数据
// tooltipProps: el-tooltip 的传参
// render ?:(h,{ data,schemaItem,schema } )=>{} 自定义渲染
// isHide 是否隐藏 (data)=>boolean || boolean
// parentProps:{
// className:'text-hide' // 默认
// },
schema: {
type: Array,
value: [],
observer: function (schema) {
const hasMore = Array.isArray(schema) && schema.some((item) => item && item.isMore);
this.setData({
hasMore,
expanded: hasMore ? this.data.expanded : false,
});
this.measureMoreHeight();
},
},
data: {
type: Object,
value: {},
},
title: {
type: String,
value: "",
},
beTap: {
type: Boolean,
value: true,
},
hideValue: {
type: String,
value: "2",
},
},
/**
* 组件的初始数据
*/
data: {
expanded: false,
hasMore: false,
moreHeight: 0,
arrowIcon: "/packageIndex/images/down-arrow-double.png",
tooltipIconPath: "/images/tips-icon.png",
},
lifetimes: {
ready() {
this.measureMoreHeight();
},
},
/**
* 组件的方法列表
*/
methods: {
onToggleMore() {
if (!this.data.hasMore) return;
if (this.data.expanded) {
this.setData({ expanded: false });
return;
}
this.measureMoreHeight(() => {
this.setData({ expanded: true });
});
},
handleTapItem() {
this.triggerEvent("tapItem", {
// item: this.data.normalizedList[nextIndex],
});
},
measureMoreHeight(done) {
wx.nextTick(() => {
const query = this.createSelectorQuery().in(this);
query.select("#moreMeasureInner").boundingClientRect();
query.exec((res) => {
const rect = res && res[0];
const height = Math.max(0, Math.round((rect && rect.height) || 0));
if (height !== this.data.moreHeight) {
this.setData({ moreHeight: height }, () => {
if (typeof done === "function") done();
});
return;
}
if (typeof done === "function") done();
});
});
},
},
});