@10yun/cv-mobile-ui 0.5.20 → 0.5.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugins/jumps.js +57 -12
- package/plugins/lbs.js +17 -8
- package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
- package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
- package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
- package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
- package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
- package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
- package/uni-ui/lib/uni-card/uni-card.vue +124 -1
- package/uni-ui/lib/uni-col/uni-col.vue +1 -1
- package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
- package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
- package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
- package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
- package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
- package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
- package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
- package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
- package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
- package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
- package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
- package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
- package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
- package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
- package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
- package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
- package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
- package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
- package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
- package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
- package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
- package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
- package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
- package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
- package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
- package/uni-ui/lib/uni-group/uni-group.vue +85 -1
- package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
- package/uni-ui/lib/uni-list/uni-list.vue +81 -1
- package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
- package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
- package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
- package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
- package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
- package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
- package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
- package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
- package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
- package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
- package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
- package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
- package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
- package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
- package/uni-ui/lib/uni-row/uni-row.vue +1 -1
- package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
- package/uni-ui/lib/uni-section/uni-section.vue +109 -1
- package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
- package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
- package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
- package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
- package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
- package/uni-ui/lib/uni-table/uni-table.vue +297 -1
- package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
- package/uni-ui/lib/uni-td/uni-td.vue +78 -1
- package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
- package/uni-ui/lib/uni-th/uni-th.vue +224 -1
- package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
- package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
- package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
|
@@ -1 +1,346 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<!-- #ifdef APP-NVUE -->
|
|
3
2
|
<cell :keep-scroll-position="keepScrollPosition">
|
|
4
3
|
<!-- #endif -->
|
|
5
4
|
<view
|
|
6
5
|
:class="{ 'uni-list-item--disabled': disabled }"
|
|
7
6
|
:style="{ 'background-color': customStyle.backgroundColor }"
|
|
8
7
|
:hover-class="(!clickable && !link) || disabled || showSwitch ? '' : 'uni-list-item--hover'"
|
|
9
8
|
class="uni-list-item"
|
|
10
9
|
@click="onClick"
|
|
11
10
|
>
|
|
12
11
|
<view v-if="!isFirstChild" class="border--left" :class="{ 'uni-list--border': border }"></view>
|
|
13
12
|
<view
|
|
14
13
|
class="uni-list-item__container"
|
|
15
14
|
:class="{ 'container--right': showArrow || link, 'flex--direction': direction === 'column' }"
|
|
16
15
|
:style="{
|
|
17
16
|
paddingTop: padding.top,
|
|
18
17
|
paddingLeft: padding.left,
|
|
19
18
|
paddingRight: padding.right,
|
|
20
19
|
paddingBottom: padding.bottom
|
|
21
20
|
}"
|
|
22
21
|
>
|
|
23
22
|
<slot name="header">
|
|
24
23
|
<view class="uni-list-item__header">
|
|
25
24
|
<view v-if="thumb" class="uni-list-item__icon">
|
|
26
25
|
<image :src="thumb" class="uni-list-item__icon-img" :class="['uni-list--' + thumbSize]" />
|
|
27
26
|
</view>
|
|
28
27
|
<view v-else-if="showExtraIcon" class="uni-list-item__icon">
|
|
29
28
|
<uni-icons
|
|
30
29
|
:customPrefix="extraIcon.customPrefix"
|
|
31
30
|
:color="extraIcon.color"
|
|
32
31
|
:size="extraIcon.size"
|
|
33
32
|
:type="extraIcon.type"
|
|
34
33
|
/>
|
|
35
34
|
</view>
|
|
36
35
|
</view>
|
|
37
36
|
</slot>
|
|
38
37
|
<slot name="body">
|
|
39
38
|
<view
|
|
40
39
|
class="uni-list-item__content"
|
|
41
40
|
:class="{ 'uni-list-item__content--center': thumb || showExtraIcon || showBadge || showSwitch }"
|
|
42
41
|
>
|
|
43
42
|
<text
|
|
44
43
|
v-if="title"
|
|
45
44
|
class="uni-list-item__content-title"
|
|
46
45
|
:class="[ellipsis !== 0 && ellipsis <= 2 ? 'uni-ellipsis-' + ellipsis : '']"
|
|
47
46
|
>
|
|
48
47
|
{{ title }}
|
|
49
48
|
</text>
|
|
50
49
|
<text v-if="note" class="uni-list-item__content-note">{{ note }}</text>
|
|
51
50
|
</view>
|
|
52
51
|
</slot>
|
|
53
52
|
<slot name="footer">
|
|
54
53
|
<view
|
|
55
54
|
v-if="rightText || showBadge || showSwitch"
|
|
56
55
|
class="uni-list-item__extra"
|
|
57
56
|
:class="{ 'flex--justify': direction === 'column' }"
|
|
58
57
|
>
|
|
59
58
|
<text v-if="rightText" class="uni-list-item__extra-text">{{ rightText }}</text>
|
|
60
59
|
<uni-badge v-if="showBadge" :type="badgeType" :text="badgeText" :custom-style="badgeStyle" />
|
|
61
60
|
<switch v-if="showSwitch" :disabled="disabled" :checked="switchChecked" @change="onSwitchChange" />
|
|
62
61
|
</view>
|
|
63
62
|
</slot>
|
|
64
63
|
</view>
|
|
65
64
|
<uni-icons v-if="showArrow || link" :size="16" class="uni-icon-wrapper" color="#bbb" type="arrowright" />
|
|
66
65
|
</view>
|
|
67
66
|
<!-- #ifdef APP-NVUE -->
|
|
68
67
|
</cell>
|
|
69
68
|
<!-- #endif -->
|
|
70
69
|
* ListItem 列表子组件
|
|
71
70
|
* @description 列表子组件
|
|
72
71
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=24
|
|
73
72
|
* @property {String} title 标题
|
|
74
73
|
* @property {String} note 描述
|
|
75
74
|
* @property {String} thumb 左侧缩略图,若thumb有值,则不会显示扩展图标
|
|
76
75
|
* @property {String} thumbSize = [lg|base|sm] 略缩图大小
|
|
77
76
|
* @value lg 大图
|
|
78
77
|
* @value base 一般
|
|
79
78
|
* @value sm 小图
|
|
80
79
|
* @property {String} badgeText 数字角标内容
|
|
81
80
|
* @property {String} badgeType 数字角标类型,参考[uni-icons](https://ext.dcloud.net.cn/plugin?id=21)
|
|
82
81
|
* @property {Object} badgeStyle 数字角标样式
|
|
83
82
|
* @property {String} rightText 右侧文字内容
|
|
84
83
|
* @property {Boolean} disabled = [true|false] 是否禁用
|
|
85
84
|
* @property {Boolean} clickable = [true|false] 是否开启点击反馈
|
|
86
85
|
* @property {String} link = [navigateTo|redirectTo|reLaunch|switchTab] 是否展示右侧箭头并开启点击反馈
|
|
87
86
|
* @value navigateTo 同 uni.navigateTo()
|
|
88
87
|
* @value redirectTo 同 uni.redirectTo()
|
|
89
88
|
* @value reLaunch 同 uni.reLaunch()
|
|
90
89
|
* @value switchTab 同 uni.switchTab()
|
|
91
90
|
* @property {String | PageURIString} to 跳转目标页面
|
|
92
91
|
* @property {Boolean} showBadge = [true|false] 是否显示数字角标
|
|
93
92
|
* @property {Boolean} showSwitch = [true|false] 是否显示Switch
|
|
94
93
|
* @property {Boolean} switchChecked = [true|false] Switch是否被选中
|
|
95
94
|
* @property {Boolean} showExtraIcon = [true|false] 左侧是否显示扩展图标
|
|
96
95
|
* @property {Object} extraIcon 扩展图标参数,格式为 {color: '#4cd964',size: '22',type: 'spinner'}
|
|
97
96
|
* @property {String} direction = [row|column] 排版方向
|
|
98
97
|
* @value row 水平排列
|
|
99
98
|
* @value column 垂直排列
|
|
100
99
|
* @event {Function} click 点击 uniListItem 触发事件
|
|
101
100
|
* @event {Function} switchChange 点击切换 Switch 时触发
|
|
102
101
|
*/
|
|
103
102
|
name: 'UniListItem',
|
|
104
103
|
emits: ['click', 'switchChange'],
|
|
105
104
|
props: {
|
|
106
105
|
direction: {
|
|
107
106
|
type: String,
|
|
108
107
|
default: 'row'
|
|
109
108
|
},
|
|
110
109
|
title: {
|
|
111
110
|
type: String,
|
|
112
111
|
default: ''
|
|
113
112
|
},
|
|
114
113
|
note: {
|
|
115
114
|
type: String,
|
|
116
115
|
default: ''
|
|
117
116
|
},
|
|
118
117
|
ellipsis: {
|
|
119
118
|
type: [Number, String],
|
|
120
119
|
default: 0
|
|
121
120
|
},
|
|
122
121
|
disabled: {
|
|
123
122
|
type: [Boolean, String],
|
|
124
123
|
default: false
|
|
125
124
|
},
|
|
126
125
|
clickable: {
|
|
127
126
|
type: Boolean,
|
|
128
127
|
default: false
|
|
129
128
|
},
|
|
130
129
|
showArrow: {
|
|
131
130
|
type: [Boolean, String],
|
|
132
131
|
default: false
|
|
133
132
|
},
|
|
134
133
|
link: {
|
|
135
134
|
type: [Boolean, String],
|
|
136
135
|
default: false
|
|
137
136
|
},
|
|
138
137
|
to: {
|
|
139
138
|
type: String,
|
|
140
139
|
default: ''
|
|
141
140
|
},
|
|
142
141
|
showBadge: {
|
|
143
142
|
type: [Boolean, String],
|
|
144
143
|
default: false
|
|
145
144
|
},
|
|
146
145
|
showSwitch: {
|
|
147
146
|
type: [Boolean, String],
|
|
148
147
|
default: false
|
|
149
148
|
},
|
|
150
149
|
switchChecked: {
|
|
151
150
|
type: [Boolean, String],
|
|
152
151
|
default: false
|
|
153
152
|
},
|
|
154
153
|
badgeText: {
|
|
155
154
|
type: String,
|
|
156
155
|
default: ''
|
|
157
156
|
},
|
|
158
157
|
badgeType: {
|
|
159
158
|
type: String,
|
|
160
159
|
default: 'success'
|
|
161
160
|
},
|
|
162
161
|
badgeStyle: {
|
|
163
162
|
type: Object,
|
|
164
163
|
default() {
|
|
165
164
|
return {};
|
|
166
165
|
}
|
|
167
166
|
},
|
|
168
167
|
rightText: {
|
|
169
168
|
type: String,
|
|
170
169
|
default: ''
|
|
171
170
|
},
|
|
172
171
|
thumb: {
|
|
173
172
|
type: String,
|
|
174
173
|
default: ''
|
|
175
174
|
},
|
|
176
175
|
thumbSize: {
|
|
177
176
|
type: String,
|
|
178
177
|
default: 'base'
|
|
179
178
|
},
|
|
180
179
|
showExtraIcon: {
|
|
181
180
|
type: [Boolean, String],
|
|
182
181
|
default: false
|
|
183
182
|
},
|
|
184
183
|
extraIcon: {
|
|
185
184
|
type: Object,
|
|
186
185
|
default() {
|
|
187
186
|
return {
|
|
188
187
|
type: '',
|
|
189
188
|
color: '#000000',
|
|
190
189
|
size: 20,
|
|
191
190
|
customPrefix: ''
|
|
192
191
|
};
|
|
193
192
|
}
|
|
194
193
|
},
|
|
195
194
|
border: {
|
|
196
195
|
type: Boolean,
|
|
197
196
|
default: true
|
|
198
197
|
},
|
|
199
198
|
customStyle: {
|
|
200
199
|
type: Object,
|
|
201
200
|
default() {
|
|
202
201
|
return {
|
|
203
202
|
padding: '',
|
|
204
203
|
backgroundColor: '#FFFFFF'
|
|
205
204
|
};
|
|
206
205
|
}
|
|
207
206
|
},
|
|
208
207
|
keepScrollPosition: {
|
|
209
208
|
type: Boolean,
|
|
210
209
|
default: false
|
|
211
210
|
}
|
|
212
211
|
},
|
|
213
212
|
watch: {
|
|
214
213
|
'customStyle.padding': {
|
|
215
214
|
handler(padding) {
|
|
216
215
|
if (typeof padding == 'number') {
|
|
217
216
|
padding += '';
|
|
218
217
|
}
|
|
219
218
|
let paddingArr = padding.split(' ');
|
|
220
219
|
if (paddingArr.length === 1) {
|
|
221
220
|
const allPadding = paddingArr[0];
|
|
222
221
|
this.padding = {
|
|
223
222
|
top: allPadding,
|
|
224
223
|
right: allPadding,
|
|
225
224
|
bottom: allPadding,
|
|
226
225
|
left: allPadding
|
|
227
226
|
};
|
|
228
227
|
} else if (paddingArr.length === 2) {
|
|
229
228
|
const [verticalPadding, horizontalPadding] = paddingArr;
|
|
230
229
|
this.padding = {
|
|
231
230
|
top: verticalPadding,
|
|
232
231
|
right: horizontalPadding,
|
|
233
232
|
bottom: verticalPadding,
|
|
234
233
|
left: horizontalPadding
|
|
235
234
|
};
|
|
236
235
|
} else if (paddingArr.length === 4) {
|
|
237
236
|
const [topPadding, rightPadding, bottomPadding, leftPadding] = paddingArr;
|
|
238
237
|
this.padding = {
|
|
239
238
|
top: topPadding,
|
|
240
239
|
right: rightPadding,
|
|
241
240
|
bottom: bottomPadding,
|
|
242
241
|
left: leftPadding
|
|
243
242
|
};
|
|
244
243
|
}
|
|
245
244
|
},
|
|
246
245
|
immediate: true
|
|
247
246
|
}
|
|
248
247
|
},
|
|
249
248
|
// inject: ['list'],
|
|
250
249
|
data() {
|
|
251
250
|
return {
|
|
252
251
|
isFirstChild: false,
|
|
253
252
|
padding: {
|
|
254
253
|
top: '',
|
|
255
254
|
right: '',
|
|
256
255
|
bottom: '',
|
|
257
256
|
left: ''
|
|
258
257
|
}
|
|
259
258
|
};
|
|
260
259
|
},
|
|
261
260
|
mounted() {
|
|
262
261
|
this.list = this.getForm();
|
|
263
262
|
// 判断是否存在 uni-list 组件
|
|
264
263
|
if (this.list) {
|
|
265
264
|
if (!this.list.firstChildAppend) {
|
|
266
265
|
this.list.firstChildAppend = true;
|
|
267
266
|
this.isFirstChild = true;
|
|
268
267
|
}
|
|
269
268
|
}
|
|
270
269
|
},
|
|
271
270
|
methods: {
|
|
272
271
|
/**
|
|
273
272
|
* 获取父元素实例
|
|
274
273
|
*/
|
|
275
274
|
getForm(name = 'uniList') {
|
|
276
275
|
let parent = this.$parent;
|
|
277
276
|
let parentName = parent.$options.name;
|
|
278
277
|
while (parentName !== name) {
|
|
279
278
|
parent = parent.$parent;
|
|
280
279
|
if (!parent) return false;
|
|
281
280
|
parentName = parent.$options.name;
|
|
282
281
|
}
|
|
283
282
|
return parent;
|
|
284
283
|
},
|
|
285
284
|
onClick() {
|
|
286
285
|
if (this.to !== '') {
|
|
287
286
|
this.openPage();
|
|
288
287
|
return;
|
|
289
288
|
}
|
|
290
289
|
if (this.clickable || this.link) {
|
|
291
290
|
this.$emit('click', {
|
|
292
291
|
data: {}
|
|
293
292
|
});
|
|
294
293
|
}
|
|
295
294
|
},
|
|
296
295
|
onSwitchChange(e) {
|
|
297
296
|
this.$emit('switchChange', e.detail);
|
|
298
297
|
},
|
|
299
298
|
openPage() {
|
|
300
299
|
if (['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'].indexOf(this.link) !== -1) {
|
|
301
300
|
this.pageApi(this.link);
|
|
302
301
|
} else {
|
|
303
302
|
this.pageApi('navigateTo');
|
|
304
303
|
}
|
|
305
304
|
},
|
|
306
305
|
pageApi(api) {
|
|
307
306
|
let callback = {
|
|
308
307
|
url: this.to,
|
|
309
308
|
success: (res) => {
|
|
310
309
|
this.$emit('click', {
|
|
311
310
|
data: res
|
|
312
311
|
});
|
|
313
312
|
},
|
|
314
313
|
fail: (err) => {
|
|
315
314
|
this.$emit('click', {
|
|
316
315
|
data: err
|
|
317
316
|
});
|
|
318
317
|
}
|
|
319
318
|
};
|
|
320
319
|
switch (api) {
|
|
321
320
|
case 'navigateTo':
|
|
322
321
|
uni.navigateTo(callback);
|
|
323
322
|
break;
|
|
324
323
|
case 'redirectTo':
|
|
325
324
|
uni.redirectTo(callback);
|
|
326
325
|
break;
|
|
327
326
|
case 'reLaunch':
|
|
328
327
|
uni.reLaunch(callback);
|
|
329
328
|
break;
|
|
330
329
|
case 'switchTab':
|
|
331
330
|
uni.switchTab(callback);
|
|
332
331
|
break;
|
|
333
332
|
default:
|
|
334
333
|
uni.navigateTo(callback);
|
|
335
334
|
}
|
|
336
335
|
}
|
|
337
336
|
}
|
|
337
|
+
<template>
|
|
338
|
+
<!-- #ifdef APP-NVUE -->
|
|
339
|
+
<cell :keep-scroll-position="keepScrollPosition">
|
|
340
|
+
<!-- #endif -->
|
|
341
|
+
<view
|
|
342
|
+
:class="{ 'uni-list-item--disabled': disabled }"
|
|
343
|
+
:style="{ 'background-color': customStyle.backgroundColor }"
|
|
344
|
+
:hover-class="(!clickable && !link) || disabled || showSwitch ? '' : 'uni-list-item--hover'"
|
|
345
|
+
class="uni-list-item"
|
|
346
|
+
@click="onClick"
|
|
347
|
+
>
|
|
348
|
+
<view v-if="!isFirstChild" class="border--left" :class="{ 'uni-list--border': border }"></view>
|
|
349
|
+
<view
|
|
350
|
+
class="uni-list-item__container"
|
|
351
|
+
:class="{ 'container--right': showArrow || link, 'flex--direction': direction === 'column' }"
|
|
352
|
+
:style="{
|
|
353
|
+
paddingTop: padding.top,
|
|
354
|
+
paddingLeft: padding.left,
|
|
355
|
+
paddingRight: padding.right,
|
|
356
|
+
paddingBottom: padding.bottom
|
|
357
|
+
}"
|
|
358
|
+
>
|
|
359
|
+
<slot name="header">
|
|
360
|
+
<view class="uni-list-item__header">
|
|
361
|
+
<view v-if="thumb" class="uni-list-item__icon">
|
|
362
|
+
<image :src="thumb" class="uni-list-item__icon-img" :class="['uni-list--' + thumbSize]" />
|
|
363
|
+
</view>
|
|
364
|
+
<view v-else-if="showExtraIcon" class="uni-list-item__icon">
|
|
365
|
+
<uni-icons
|
|
366
|
+
:customPrefix="extraIcon.customPrefix"
|
|
367
|
+
:color="extraIcon.color"
|
|
368
|
+
:size="extraIcon.size"
|
|
369
|
+
:type="extraIcon.type"
|
|
370
|
+
/>
|
|
371
|
+
</view>
|
|
372
|
+
</view>
|
|
373
|
+
</slot>
|
|
374
|
+
<slot name="body">
|
|
375
|
+
<view
|
|
376
|
+
class="uni-list-item__content"
|
|
377
|
+
:class="{ 'uni-list-item__content--center': thumb || showExtraIcon || showBadge || showSwitch }"
|
|
378
|
+
>
|
|
379
|
+
<text
|
|
380
|
+
v-if="title"
|
|
381
|
+
class="uni-list-item__content-title"
|
|
382
|
+
:class="[ellipsis !== 0 && ellipsis <= 2 ? 'uni-ellipsis-' + ellipsis : '']"
|
|
383
|
+
>
|
|
384
|
+
{{ title }}
|
|
385
|
+
</text>
|
|
386
|
+
<text v-if="note" class="uni-list-item__content-note">{{ note }}</text>
|
|
387
|
+
</view>
|
|
388
|
+
</slot>
|
|
389
|
+
<slot name="footer">
|
|
390
|
+
<view
|
|
391
|
+
v-if="rightText || showBadge || showSwitch"
|
|
392
|
+
class="uni-list-item__extra"
|
|
393
|
+
:class="{ 'flex--justify': direction === 'column' }"
|
|
394
|
+
>
|
|
395
|
+
<text v-if="rightText" class="uni-list-item__extra-text">{{ rightText }}</text>
|
|
396
|
+
<uni-badge v-if="showBadge" :type="badgeType" :text="badgeText" :custom-style="badgeStyle" />
|
|
397
|
+
<switch v-if="showSwitch" :disabled="disabled" :checked="switchChecked" @change="onSwitchChange" />
|
|
398
|
+
</view>
|
|
399
|
+
</slot>
|
|
400
|
+
</view>
|
|
401
|
+
<uni-icons v-if="showArrow || link" :size="16" class="uni-icon-wrapper" color="#bbb" type="arrowright" />
|
|
402
|
+
</view>
|
|
403
|
+
<!-- #ifdef APP-NVUE -->
|
|
404
|
+
</cell>
|
|
405
|
+
<!-- #endif -->
|
|
406
|
+
</template>
|
|
407
|
+
<script>
|
|
408
|
+
/**
|
|
409
|
+
* ListItem 列表子组件
|
|
410
|
+
* @description 列表子组件
|
|
411
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=24
|
|
412
|
+
* @property {String} title 标题
|
|
413
|
+
* @property {String} note 描述
|
|
414
|
+
* @property {String} thumb 左侧缩略图,若thumb有值,则不会显示扩展图标
|
|
415
|
+
* @property {String} thumbSize = [lg|base|sm] 略缩图大小
|
|
416
|
+
* @value lg 大图
|
|
417
|
+
* @value base 一般
|
|
418
|
+
* @value sm 小图
|
|
419
|
+
* @property {String} badgeText 数字角标内容
|
|
420
|
+
* @property {String} badgeType 数字角标类型,参考[uni-icons](https://ext.dcloud.net.cn/plugin?id=21)
|
|
421
|
+
* @property {Object} badgeStyle 数字角标样式
|
|
422
|
+
* @property {String} rightText 右侧文字内容
|
|
423
|
+
* @property {Boolean} disabled = [true|false] 是否禁用
|
|
424
|
+
* @property {Boolean} clickable = [true|false] 是否开启点击反馈
|
|
425
|
+
* @property {String} link = [navigateTo|redirectTo|reLaunch|switchTab] 是否展示右侧箭头并开启点击反馈
|
|
426
|
+
* @value navigateTo 同 uni.navigateTo()
|
|
427
|
+
* @value redirectTo 同 uni.redirectTo()
|
|
428
|
+
* @value reLaunch 同 uni.reLaunch()
|
|
429
|
+
* @value switchTab 同 uni.switchTab()
|
|
430
|
+
* @property {String | PageURIString} to 跳转目标页面
|
|
431
|
+
* @property {Boolean} showBadge = [true|false] 是否显示数字角标
|
|
432
|
+
* @property {Boolean} showSwitch = [true|false] 是否显示Switch
|
|
433
|
+
* @property {Boolean} switchChecked = [true|false] Switch是否被选中
|
|
434
|
+
* @property {Boolean} showExtraIcon = [true|false] 左侧是否显示扩展图标
|
|
435
|
+
* @property {Object} extraIcon 扩展图标参数,格式为 {color: '#4cd964',size: '22',type: 'spinner'}
|
|
436
|
+
* @property {String} direction = [row|column] 排版方向
|
|
437
|
+
* @value row 水平排列
|
|
438
|
+
* @value column 垂直排列
|
|
439
|
+
* @event {Function} click 点击 uniListItem 触发事件
|
|
440
|
+
* @event {Function} switchChange 点击切换 Switch 时触发
|
|
441
|
+
*/
|
|
442
|
+
export default {
|
|
443
|
+
name: 'UniListItem',
|
|
444
|
+
emits: ['click', 'switchChange'],
|
|
445
|
+
props: {
|
|
446
|
+
direction: {
|
|
447
|
+
type: String,
|
|
448
|
+
default: 'row'
|
|
449
|
+
},
|
|
450
|
+
title: {
|
|
451
|
+
type: String,
|
|
452
|
+
default: ''
|
|
453
|
+
},
|
|
454
|
+
note: {
|
|
455
|
+
type: String,
|
|
456
|
+
default: ''
|
|
457
|
+
},
|
|
458
|
+
ellipsis: {
|
|
459
|
+
type: [Number, String],
|
|
460
|
+
default: 0
|
|
461
|
+
},
|
|
462
|
+
disabled: {
|
|
463
|
+
type: [Boolean, String],
|
|
464
|
+
default: false
|
|
465
|
+
},
|
|
466
|
+
clickable: {
|
|
467
|
+
type: Boolean,
|
|
468
|
+
default: false
|
|
469
|
+
},
|
|
470
|
+
showArrow: {
|
|
471
|
+
type: [Boolean, String],
|
|
472
|
+
default: false
|
|
473
|
+
},
|
|
474
|
+
link: {
|
|
475
|
+
type: [Boolean, String],
|
|
476
|
+
default: false
|
|
477
|
+
},
|
|
478
|
+
to: {
|
|
479
|
+
type: String,
|
|
480
|
+
default: ''
|
|
481
|
+
},
|
|
482
|
+
showBadge: {
|
|
483
|
+
type: [Boolean, String],
|
|
484
|
+
default: false
|
|
485
|
+
},
|
|
486
|
+
showSwitch: {
|
|
487
|
+
type: [Boolean, String],
|
|
488
|
+
default: false
|
|
489
|
+
},
|
|
490
|
+
switchChecked: {
|
|
491
|
+
type: [Boolean, String],
|
|
492
|
+
default: false
|
|
493
|
+
},
|
|
494
|
+
badgeText: {
|
|
495
|
+
type: String,
|
|
496
|
+
default: ''
|
|
497
|
+
},
|
|
498
|
+
badgeType: {
|
|
499
|
+
type: String,
|
|
500
|
+
default: 'success'
|
|
501
|
+
},
|
|
502
|
+
badgeStyle: {
|
|
503
|
+
type: Object,
|
|
504
|
+
default() {
|
|
505
|
+
return {};
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
rightText: {
|
|
509
|
+
type: String,
|
|
510
|
+
default: ''
|
|
511
|
+
},
|
|
512
|
+
thumb: {
|
|
513
|
+
type: String,
|
|
514
|
+
default: ''
|
|
515
|
+
},
|
|
516
|
+
thumbSize: {
|
|
517
|
+
type: String,
|
|
518
|
+
default: 'base'
|
|
519
|
+
},
|
|
520
|
+
showExtraIcon: {
|
|
521
|
+
type: [Boolean, String],
|
|
522
|
+
default: false
|
|
523
|
+
},
|
|
524
|
+
extraIcon: {
|
|
525
|
+
type: Object,
|
|
526
|
+
default() {
|
|
527
|
+
return {
|
|
528
|
+
type: '',
|
|
529
|
+
color: '#000000',
|
|
530
|
+
size: 20,
|
|
531
|
+
customPrefix: ''
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
border: {
|
|
536
|
+
type: Boolean,
|
|
537
|
+
default: true
|
|
538
|
+
},
|
|
539
|
+
customStyle: {
|
|
540
|
+
type: Object,
|
|
541
|
+
default() {
|
|
542
|
+
return {
|
|
543
|
+
padding: '',
|
|
544
|
+
backgroundColor: '#FFFFFF'
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
keepScrollPosition: {
|
|
549
|
+
type: Boolean,
|
|
550
|
+
default: false
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
watch: {
|
|
554
|
+
'customStyle.padding': {
|
|
555
|
+
handler(padding) {
|
|
556
|
+
if (typeof padding == 'number') {
|
|
557
|
+
padding += '';
|
|
558
|
+
}
|
|
559
|
+
let paddingArr = padding.split(' ');
|
|
560
|
+
if (paddingArr.length === 1) {
|
|
561
|
+
const allPadding = paddingArr[0];
|
|
562
|
+
this.padding = {
|
|
563
|
+
top: allPadding,
|
|
564
|
+
right: allPadding,
|
|
565
|
+
bottom: allPadding,
|
|
566
|
+
left: allPadding
|
|
567
|
+
};
|
|
568
|
+
} else if (paddingArr.length === 2) {
|
|
569
|
+
const [verticalPadding, horizontalPadding] = paddingArr;
|
|
570
|
+
this.padding = {
|
|
571
|
+
top: verticalPadding,
|
|
572
|
+
right: horizontalPadding,
|
|
573
|
+
bottom: verticalPadding,
|
|
574
|
+
left: horizontalPadding
|
|
575
|
+
};
|
|
576
|
+
} else if (paddingArr.length === 4) {
|
|
577
|
+
const [topPadding, rightPadding, bottomPadding, leftPadding] = paddingArr;
|
|
578
|
+
this.padding = {
|
|
579
|
+
top: topPadding,
|
|
580
|
+
right: rightPadding,
|
|
581
|
+
bottom: bottomPadding,
|
|
582
|
+
left: leftPadding
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
immediate: true
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
// inject: ['list'],
|
|
590
|
+
data() {
|
|
591
|
+
return {
|
|
592
|
+
isFirstChild: false,
|
|
593
|
+
padding: {
|
|
594
|
+
top: '',
|
|
595
|
+
right: '',
|
|
596
|
+
bottom: '',
|
|
597
|
+
left: ''
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
},
|
|
601
|
+
mounted() {
|
|
602
|
+
this.list = this.getForm();
|
|
603
|
+
// 判断是否存在 uni-list 组件
|
|
604
|
+
if (this.list) {
|
|
605
|
+
if (!this.list.firstChildAppend) {
|
|
606
|
+
this.list.firstChildAppend = true;
|
|
607
|
+
this.isFirstChild = true;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
methods: {
|
|
612
|
+
/**
|
|
613
|
+
* 获取父元素实例
|
|
614
|
+
*/
|
|
615
|
+
getForm(name = 'uniList') {
|
|
616
|
+
let parent = this.$parent;
|
|
617
|
+
let parentName = parent.$options.name;
|
|
618
|
+
while (parentName !== name) {
|
|
619
|
+
parent = parent.$parent;
|
|
620
|
+
if (!parent) return false;
|
|
621
|
+
parentName = parent.$options.name;
|
|
622
|
+
}
|
|
623
|
+
return parent;
|
|
624
|
+
},
|
|
625
|
+
onClick() {
|
|
626
|
+
if (this.to !== '') {
|
|
627
|
+
this.openPage();
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
if (this.clickable || this.link) {
|
|
631
|
+
this.$emit('click', {
|
|
632
|
+
data: {}
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
onSwitchChange(e) {
|
|
637
|
+
this.$emit('switchChange', e.detail);
|
|
638
|
+
},
|
|
639
|
+
openPage() {
|
|
640
|
+
if (['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'].indexOf(this.link) !== -1) {
|
|
641
|
+
this.pageApi(this.link);
|
|
642
|
+
} else {
|
|
643
|
+
this.pageApi('navigateTo');
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
pageApi(api) {
|
|
647
|
+
let callback = {
|
|
648
|
+
url: this.to,
|
|
649
|
+
success: (res) => {
|
|
650
|
+
this.$emit('click', {
|
|
651
|
+
data: res
|
|
652
|
+
});
|
|
653
|
+
},
|
|
654
|
+
fail: (err) => {
|
|
655
|
+
this.$emit('click', {
|
|
656
|
+
data: err
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
switch (api) {
|
|
661
|
+
case 'navigateTo':
|
|
662
|
+
uni.navigateTo(callback);
|
|
663
|
+
break;
|
|
664
|
+
case 'redirectTo':
|
|
665
|
+
uni.redirectTo(callback);
|
|
666
|
+
break;
|
|
667
|
+
case 'reLaunch':
|
|
668
|
+
uni.reLaunch(callback);
|
|
669
|
+
break;
|
|
670
|
+
case 'switchTab':
|
|
671
|
+
uni.switchTab(callback);
|
|
672
|
+
break;
|
|
673
|
+
default:
|
|
674
|
+
uni.navigateTo(callback);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
</script>
|
|
680
|
+
<style>
|
|
681
|
+
@import 'style.css';
|
|
682
|
+
</style>
|