@10yun/cv-mobile-ui 0.5.20 → 0.5.21
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/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,294 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<!-- #ifdef APP-NVUE -->
|
|
3
2
|
<cell>
|
|
4
3
|
<!-- #endif -->
|
|
5
4
|
<view :hover-class="!clickable && !link ? '' : 'uni-list-chat--hover'" class="uni-list-chat" @click.stop="onClick">
|
|
6
5
|
<view :class="{ 'uni-list--border': border, 'uni-list-chat--first': isFirstChild }"></view>
|
|
7
6
|
<view class="uni-list-chat__container">
|
|
8
7
|
<view class="uni-list-chat__header-warp">
|
|
9
8
|
<view
|
|
10
9
|
v-if="avatarCircle || avatarList.length === 0"
|
|
11
10
|
class="uni-list-chat__header"
|
|
12
11
|
:class="{ 'header--circle': avatarCircle }"
|
|
13
12
|
>
|
|
14
13
|
<image
|
|
15
14
|
class="uni-list-chat__header-image"
|
|
16
15
|
:class="{ 'header--circle': avatarCircle }"
|
|
17
16
|
:src="avatarUrl"
|
|
18
17
|
mode="aspectFill"
|
|
19
18
|
></image>
|
|
20
19
|
</view>
|
|
21
20
|
<!-- 头像组 -->
|
|
22
21
|
<view v-else class="uni-list-chat__header">
|
|
23
22
|
<view
|
|
24
23
|
v-for="(item, index) in avatarList"
|
|
25
24
|
:key="index"
|
|
26
25
|
class="uni-list-chat__header-box"
|
|
27
26
|
:class="computedAvatar"
|
|
28
27
|
:style="{ width: imageWidth + 'px', height: imageWidth + 'px' }"
|
|
29
28
|
>
|
|
30
29
|
<image
|
|
31
30
|
class="uni-list-chat__header-image"
|
|
32
31
|
:style="{ width: imageWidth + 'px', height: imageWidth + 'px' }"
|
|
33
32
|
:src="item.url"
|
|
34
33
|
mode="aspectFill"
|
|
35
34
|
></image>
|
|
36
35
|
</view>
|
|
37
36
|
</view>
|
|
38
37
|
</view>
|
|
39
38
|
<!-- #ifndef APP -->
|
|
40
39
|
<view class="slot-header">
|
|
41
40
|
<!-- #endif -->
|
|
42
41
|
<slot name="header"></slot>
|
|
43
42
|
<!-- #ifndef APP -->
|
|
44
43
|
</view>
|
|
45
44
|
<!-- #endif -->
|
|
46
45
|
<view
|
|
47
46
|
v-if="badgeText && badgePositon === 'left'"
|
|
48
47
|
class="uni-list-chat__badge uni-list-chat__badge-pos"
|
|
49
48
|
:class="[isSingle]"
|
|
50
49
|
>
|
|
51
50
|
<text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text>
|
|
52
51
|
</view>
|
|
53
52
|
<view class="uni-list-chat__content">
|
|
54
53
|
<view class="uni-list-chat__content-main">
|
|
55
54
|
<text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text>
|
|
56
55
|
<view style="flex-direction: row">
|
|
57
56
|
<text class="draft" v-if="isDraft">[草稿]</text>
|
|
58
57
|
<text class="uni-list-chat__content-note uni-ellipsis">{{ isDraft ? note.slice(14) : note }}</text>
|
|
59
58
|
</view>
|
|
60
59
|
</view>
|
|
61
60
|
<view class="uni-list-chat__content-extra">
|
|
62
61
|
<slot>
|
|
63
62
|
<text class="uni-list-chat__content-extra-text">{{ time }}</text>
|
|
64
63
|
<view
|
|
65
64
|
v-if="badgeText && badgePositon === 'right'"
|
|
66
65
|
class="uni-list-chat__badge"
|
|
67
66
|
:class="[isSingle, badgePositon === 'right' ? 'uni-list-chat--right' : '']"
|
|
68
67
|
>
|
|
69
68
|
<text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text>
|
|
70
69
|
</view>
|
|
71
70
|
</slot>
|
|
72
71
|
</view>
|
|
73
72
|
</view>
|
|
74
73
|
</view>
|
|
75
74
|
</view>
|
|
76
75
|
<!-- #ifdef APP-NVUE -->
|
|
77
76
|
</cell>
|
|
78
77
|
<!-- #endif -->
|
|
79
78
|
* ListChat 聊天列表
|
|
80
79
|
* @description 聊天列表,用于创建聊天类列表
|
|
81
80
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=24
|
|
82
81
|
* @property {String} title 标题
|
|
83
82
|
* @property {String} note 描述
|
|
84
83
|
* @property {Boolean} clickable = [true|false] 是否开启点击反馈,默认为false
|
|
85
84
|
* @property {String} badgeText 数字角标内容
|
|
86
85
|
* @property {String} badgePositon = [left|right] 角标位置,默认为 right
|
|
87
86
|
* @property {String} link = [false|navigateTo|redirectTo|reLaunch|switchTab] 是否展示右侧箭头并开启点击反馈,默认为false
|
|
88
87
|
* @value false 不开启
|
|
89
88
|
* @value navigateTo 同 uni.navigateTo()
|
|
90
89
|
* @value redirectTo 同 uni.redirectTo()
|
|
91
90
|
* @value reLaunch 同 uni.reLaunch()
|
|
92
91
|
* @value switchTab 同 uni.switchTab()
|
|
93
92
|
* @property {String | PageURIString} to 跳转目标页面
|
|
94
93
|
* @property {String} time 右侧时间显示
|
|
95
94
|
* @property {Boolean} avatarCircle = [true|false] 是否显示圆形头像,默认为false
|
|
96
95
|
* @property {String} avatar 头像地址,avatarCircle 不填时生效
|
|
97
96
|
* @property {Array} avatarList 头像组,格式为 [{url:''}]
|
|
98
97
|
* @event {Function} click 点击 uniListChat 触发事件
|
|
99
98
|
*/
|
|
100
99
|
name: 'UniListChat',
|
|
101
100
|
emits: ['click'],
|
|
102
101
|
props: {
|
|
103
102
|
title: {
|
|
104
103
|
type: String,
|
|
105
104
|
default: ''
|
|
106
105
|
},
|
|
107
106
|
note: {
|
|
108
107
|
type: String,
|
|
109
108
|
default: ''
|
|
110
109
|
},
|
|
111
110
|
clickable: {
|
|
112
111
|
type: Boolean,
|
|
113
112
|
default: false
|
|
114
113
|
},
|
|
115
114
|
link: {
|
|
116
115
|
type: [Boolean, String],
|
|
117
116
|
default: false
|
|
118
117
|
},
|
|
119
118
|
to: {
|
|
120
119
|
type: String,
|
|
121
120
|
default: ''
|
|
122
121
|
},
|
|
123
122
|
badgeText: {
|
|
124
123
|
type: [String, Number],
|
|
125
124
|
default: ''
|
|
126
125
|
},
|
|
127
126
|
badgePositon: {
|
|
128
127
|
type: String,
|
|
129
128
|
default: 'right'
|
|
130
129
|
},
|
|
131
130
|
time: {
|
|
132
131
|
type: String,
|
|
133
132
|
default: ''
|
|
134
133
|
},
|
|
135
134
|
avatarCircle: {
|
|
136
135
|
type: Boolean,
|
|
137
136
|
default: false
|
|
138
137
|
},
|
|
139
138
|
avatar: {
|
|
140
139
|
type: String,
|
|
141
140
|
default: ''
|
|
142
141
|
},
|
|
143
142
|
avatarList: {
|
|
144
143
|
type: Array,
|
|
145
144
|
default() {
|
|
146
145
|
return [];
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
},
|
|
150
149
|
// inject: ['list'],
|
|
151
150
|
computed: {
|
|
152
151
|
isDraft() {
|
|
153
152
|
return this.note.slice(0, 14) == '[uni-im-draft]';
|
|
154
153
|
},
|
|
155
154
|
isSingle() {
|
|
156
155
|
if (this.badgeText === 'dot') {
|
|
157
156
|
return 'uni-badge--dot';
|
|
158
157
|
} else {
|
|
159
158
|
const badgeText = this.badgeText.toString();
|
|
160
159
|
if (badgeText.length > 1) {
|
|
161
160
|
return 'uni-badge--complex';
|
|
162
161
|
} else {
|
|
163
162
|
return 'uni-badge--single';
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
165
|
},
|
|
167
166
|
computedAvatar() {
|
|
168
167
|
if (this.avatarList.length > 4) {
|
|
169
168
|
this.imageWidth = avatarWidth * 0.31;
|
|
170
169
|
return 'avatarItem--3';
|
|
171
170
|
} else if (this.avatarList.length > 1) {
|
|
172
171
|
this.imageWidth = avatarWidth * 0.47;
|
|
173
172
|
return 'avatarItem--2';
|
|
174
173
|
} else {
|
|
175
174
|
this.imageWidth = avatarWidth;
|
|
176
175
|
return 'avatarItem--1';
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
178
|
},
|
|
180
179
|
watch: {
|
|
181
180
|
avatar: {
|
|
182
181
|
handler(avatar) {
|
|
183
182
|
if (avatar.substr(0, 8) == 'cloud://') {
|
|
184
183
|
uniCloud
|
|
185
184
|
.getTempFileURL({
|
|
186
185
|
fileList: [avatar]
|
|
187
186
|
})
|
|
188
187
|
.then((res) => {
|
|
189
188
|
// console.log(res);
|
|
190
189
|
// 兼容uniCloud私有化部署
|
|
191
190
|
let fileList = res.fileList || res.result.fileList;
|
|
192
191
|
this.avatarUrl = fileList[0].tempFileURL;
|
|
193
192
|
});
|
|
194
193
|
} else {
|
|
195
194
|
this.avatarUrl = avatar;
|
|
196
195
|
}
|
|
197
196
|
},
|
|
198
197
|
immediate: true
|
|
199
198
|
}
|
|
200
199
|
},
|
|
201
200
|
data() {
|
|
202
201
|
return {
|
|
203
202
|
isFirstChild: false,
|
|
204
203
|
border: true,
|
|
205
204
|
// avatarList: 3,
|
|
206
205
|
imageWidth: 50,
|
|
207
206
|
avatarUrl: ''
|
|
208
207
|
};
|
|
209
208
|
},
|
|
210
209
|
mounted() {
|
|
211
210
|
this.list = this.getForm();
|
|
212
211
|
if (this.list) {
|
|
213
212
|
if (!this.list.firstChildAppend) {
|
|
214
213
|
this.list.firstChildAppend = true;
|
|
215
214
|
this.isFirstChild = true;
|
|
216
215
|
}
|
|
217
216
|
this.border = this.list.border;
|
|
218
217
|
}
|
|
219
218
|
},
|
|
220
219
|
methods: {
|
|
221
220
|
/**
|
|
222
221
|
* 获取父元素实例
|
|
223
222
|
*/
|
|
224
223
|
getForm(name = 'uniList') {
|
|
225
224
|
let parent = this.$parent;
|
|
226
225
|
let parentName = parent.$options.name;
|
|
227
226
|
while (parentName !== name) {
|
|
228
227
|
parent = parent.$parent;
|
|
229
228
|
if (!parent) return false;
|
|
230
229
|
parentName = parent.$options.name;
|
|
231
230
|
}
|
|
232
231
|
return parent;
|
|
233
232
|
},
|
|
234
233
|
onClick() {
|
|
235
234
|
if (this.to !== '') {
|
|
236
235
|
this.openPage();
|
|
237
236
|
return;
|
|
238
237
|
}
|
|
239
238
|
if (this.clickable || this.link) {
|
|
240
239
|
this.$emit('click', {
|
|
241
240
|
data: {}
|
|
242
241
|
});
|
|
243
242
|
}
|
|
244
243
|
},
|
|
245
244
|
openPage() {
|
|
246
245
|
if (['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'].indexOf(this.link) !== -1) {
|
|
247
246
|
this.pageApi(this.link);
|
|
248
247
|
} else {
|
|
249
248
|
this.pageApi('navigateTo');
|
|
250
249
|
}
|
|
251
250
|
},
|
|
252
251
|
pageApi(api) {
|
|
253
252
|
let callback = {
|
|
254
253
|
url: this.to,
|
|
255
254
|
success: (res) => {
|
|
256
255
|
this.$emit('click', {
|
|
257
256
|
data: res
|
|
258
257
|
});
|
|
259
258
|
},
|
|
260
259
|
fail: (err) => {
|
|
261
260
|
this.$emit('click', {
|
|
262
261
|
data: err
|
|
263
262
|
});
|
|
264
263
|
}
|
|
265
264
|
};
|
|
266
265
|
switch (api) {
|
|
267
266
|
case 'navigateTo':
|
|
268
267
|
uni.navigateTo(callback);
|
|
269
268
|
break;
|
|
270
269
|
case 'redirectTo':
|
|
271
270
|
uni.redirectTo(callback);
|
|
272
271
|
break;
|
|
273
272
|
case 'reLaunch':
|
|
274
273
|
uni.reLaunch(callback);
|
|
275
274
|
break;
|
|
276
275
|
case 'switchTab':
|
|
277
276
|
uni.switchTab(callback);
|
|
278
277
|
break;
|
|
279
278
|
default:
|
|
280
279
|
uni.navigateTo(callback);
|
|
281
280
|
}
|
|
282
281
|
}
|
|
283
282
|
}
|
|
283
|
+
<template>
|
|
284
|
+
<!-- #ifdef APP-NVUE -->
|
|
285
|
+
<cell>
|
|
286
|
+
<!-- #endif -->
|
|
287
|
+
<view :hover-class="!clickable && !link ? '' : 'uni-list-chat--hover'" class="uni-list-chat" @click.stop="onClick">
|
|
288
|
+
<view :class="{ 'uni-list--border': border, 'uni-list-chat--first': isFirstChild }"></view>
|
|
289
|
+
<view class="uni-list-chat__container">
|
|
290
|
+
<view class="uni-list-chat__header-warp">
|
|
291
|
+
<view
|
|
292
|
+
v-if="avatarCircle || avatarList.length === 0"
|
|
293
|
+
class="uni-list-chat__header"
|
|
294
|
+
:class="{ 'header--circle': avatarCircle }"
|
|
295
|
+
>
|
|
296
|
+
<image
|
|
297
|
+
class="uni-list-chat__header-image"
|
|
298
|
+
:class="{ 'header--circle': avatarCircle }"
|
|
299
|
+
:src="avatarUrl"
|
|
300
|
+
mode="aspectFill"
|
|
301
|
+
></image>
|
|
302
|
+
</view>
|
|
303
|
+
<!-- 头像组 -->
|
|
304
|
+
<view v-else class="uni-list-chat__header">
|
|
305
|
+
<view
|
|
306
|
+
v-for="(item, index) in avatarList"
|
|
307
|
+
:key="index"
|
|
308
|
+
class="uni-list-chat__header-box"
|
|
309
|
+
:class="computedAvatar"
|
|
310
|
+
:style="{ width: imageWidth + 'px', height: imageWidth + 'px' }"
|
|
311
|
+
>
|
|
312
|
+
<image
|
|
313
|
+
class="uni-list-chat__header-image"
|
|
314
|
+
:style="{ width: imageWidth + 'px', height: imageWidth + 'px' }"
|
|
315
|
+
:src="item.url"
|
|
316
|
+
mode="aspectFill"
|
|
317
|
+
></image>
|
|
318
|
+
</view>
|
|
319
|
+
</view>
|
|
320
|
+
</view>
|
|
321
|
+
<!-- #ifndef APP -->
|
|
322
|
+
<view class="slot-header">
|
|
323
|
+
<!-- #endif -->
|
|
324
|
+
<slot name="header"></slot>
|
|
325
|
+
<!-- #ifndef APP -->
|
|
326
|
+
</view>
|
|
327
|
+
<!-- #endif -->
|
|
328
|
+
<view
|
|
329
|
+
v-if="badgeText && badgePositon === 'left'"
|
|
330
|
+
class="uni-list-chat__badge uni-list-chat__badge-pos"
|
|
331
|
+
:class="[isSingle]"
|
|
332
|
+
>
|
|
333
|
+
<text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text>
|
|
334
|
+
</view>
|
|
335
|
+
<view class="uni-list-chat__content">
|
|
336
|
+
<view class="uni-list-chat__content-main">
|
|
337
|
+
<text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text>
|
|
338
|
+
<view style="flex-direction: row">
|
|
339
|
+
<text class="draft" v-if="isDraft">[草稿]</text>
|
|
340
|
+
<text class="uni-list-chat__content-note uni-ellipsis">{{ isDraft ? note.slice(14) : note }}</text>
|
|
341
|
+
</view>
|
|
342
|
+
</view>
|
|
343
|
+
<view class="uni-list-chat__content-extra">
|
|
344
|
+
<slot>
|
|
345
|
+
<text class="uni-list-chat__content-extra-text">{{ time }}</text>
|
|
346
|
+
<view
|
|
347
|
+
v-if="badgeText && badgePositon === 'right'"
|
|
348
|
+
class="uni-list-chat__badge"
|
|
349
|
+
:class="[isSingle, badgePositon === 'right' ? 'uni-list-chat--right' : '']"
|
|
350
|
+
>
|
|
351
|
+
<text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text>
|
|
352
|
+
</view>
|
|
353
|
+
</slot>
|
|
354
|
+
</view>
|
|
355
|
+
</view>
|
|
356
|
+
</view>
|
|
357
|
+
</view>
|
|
358
|
+
<!-- #ifdef APP-NVUE -->
|
|
359
|
+
</cell>
|
|
360
|
+
<!-- #endif -->
|
|
361
|
+
</template>
|
|
362
|
+
<script>
|
|
363
|
+
// 头像大小
|
|
364
|
+
const avatarWidth = 45;
|
|
365
|
+
/**
|
|
366
|
+
* ListChat 聊天列表
|
|
367
|
+
* @description 聊天列表,用于创建聊天类列表
|
|
368
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=24
|
|
369
|
+
* @property {String} title 标题
|
|
370
|
+
* @property {String} note 描述
|
|
371
|
+
* @property {Boolean} clickable = [true|false] 是否开启点击反馈,默认为false
|
|
372
|
+
* @property {String} badgeText 数字角标内容
|
|
373
|
+
* @property {String} badgePositon = [left|right] 角标位置,默认为 right
|
|
374
|
+
* @property {String} link = [false|navigateTo|redirectTo|reLaunch|switchTab] 是否展示右侧箭头并开启点击反馈,默认为false
|
|
375
|
+
* @value false 不开启
|
|
376
|
+
* @value navigateTo 同 uni.navigateTo()
|
|
377
|
+
* @value redirectTo 同 uni.redirectTo()
|
|
378
|
+
* @value reLaunch 同 uni.reLaunch()
|
|
379
|
+
* @value switchTab 同 uni.switchTab()
|
|
380
|
+
* @property {String | PageURIString} to 跳转目标页面
|
|
381
|
+
* @property {String} time 右侧时间显示
|
|
382
|
+
* @property {Boolean} avatarCircle = [true|false] 是否显示圆形头像,默认为false
|
|
383
|
+
* @property {String} avatar 头像地址,avatarCircle 不填时生效
|
|
384
|
+
* @property {Array} avatarList 头像组,格式为 [{url:''}]
|
|
385
|
+
* @event {Function} click 点击 uniListChat 触发事件
|
|
386
|
+
*/
|
|
387
|
+
export default {
|
|
388
|
+
name: 'UniListChat',
|
|
389
|
+
emits: ['click'],
|
|
390
|
+
props: {
|
|
391
|
+
title: {
|
|
392
|
+
type: String,
|
|
393
|
+
default: ''
|
|
394
|
+
},
|
|
395
|
+
note: {
|
|
396
|
+
type: String,
|
|
397
|
+
default: ''
|
|
398
|
+
},
|
|
399
|
+
clickable: {
|
|
400
|
+
type: Boolean,
|
|
401
|
+
default: false
|
|
402
|
+
},
|
|
403
|
+
link: {
|
|
404
|
+
type: [Boolean, String],
|
|
405
|
+
default: false
|
|
406
|
+
},
|
|
407
|
+
to: {
|
|
408
|
+
type: String,
|
|
409
|
+
default: ''
|
|
410
|
+
},
|
|
411
|
+
badgeText: {
|
|
412
|
+
type: [String, Number],
|
|
413
|
+
default: ''
|
|
414
|
+
},
|
|
415
|
+
badgePositon: {
|
|
416
|
+
type: String,
|
|
417
|
+
default: 'right'
|
|
418
|
+
},
|
|
419
|
+
time: {
|
|
420
|
+
type: String,
|
|
421
|
+
default: ''
|
|
422
|
+
},
|
|
423
|
+
avatarCircle: {
|
|
424
|
+
type: Boolean,
|
|
425
|
+
default: false
|
|
426
|
+
},
|
|
427
|
+
avatar: {
|
|
428
|
+
type: String,
|
|
429
|
+
default: ''
|
|
430
|
+
},
|
|
431
|
+
avatarList: {
|
|
432
|
+
type: Array,
|
|
433
|
+
default() {
|
|
434
|
+
return [];
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
// inject: ['list'],
|
|
439
|
+
computed: {
|
|
440
|
+
isDraft() {
|
|
441
|
+
return this.note.slice(0, 14) == '[uni-im-draft]';
|
|
442
|
+
},
|
|
443
|
+
isSingle() {
|
|
444
|
+
if (this.badgeText === 'dot') {
|
|
445
|
+
return 'uni-badge--dot';
|
|
446
|
+
} else {
|
|
447
|
+
const badgeText = this.badgeText.toString();
|
|
448
|
+
if (badgeText.length > 1) {
|
|
449
|
+
return 'uni-badge--complex';
|
|
450
|
+
} else {
|
|
451
|
+
return 'uni-badge--single';
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
computedAvatar() {
|
|
456
|
+
if (this.avatarList.length > 4) {
|
|
457
|
+
this.imageWidth = avatarWidth * 0.31;
|
|
458
|
+
return 'avatarItem--3';
|
|
459
|
+
} else if (this.avatarList.length > 1) {
|
|
460
|
+
this.imageWidth = avatarWidth * 0.47;
|
|
461
|
+
return 'avatarItem--2';
|
|
462
|
+
} else {
|
|
463
|
+
this.imageWidth = avatarWidth;
|
|
464
|
+
return 'avatarItem--1';
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
watch: {
|
|
469
|
+
avatar: {
|
|
470
|
+
handler(avatar) {
|
|
471
|
+
if (avatar.substr(0, 8) == 'cloud://') {
|
|
472
|
+
uniCloud
|
|
473
|
+
.getTempFileURL({
|
|
474
|
+
fileList: [avatar]
|
|
475
|
+
})
|
|
476
|
+
.then((res) => {
|
|
477
|
+
// console.log(res);
|
|
478
|
+
// 兼容uniCloud私有化部署
|
|
479
|
+
let fileList = res.fileList || res.result.fileList;
|
|
480
|
+
this.avatarUrl = fileList[0].tempFileURL;
|
|
481
|
+
});
|
|
482
|
+
} else {
|
|
483
|
+
this.avatarUrl = avatar;
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
immediate: true
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
data() {
|
|
490
|
+
return {
|
|
491
|
+
isFirstChild: false,
|
|
492
|
+
border: true,
|
|
493
|
+
// avatarList: 3,
|
|
494
|
+
imageWidth: 50,
|
|
495
|
+
avatarUrl: ''
|
|
496
|
+
};
|
|
497
|
+
},
|
|
498
|
+
mounted() {
|
|
499
|
+
this.list = this.getForm();
|
|
500
|
+
if (this.list) {
|
|
501
|
+
if (!this.list.firstChildAppend) {
|
|
502
|
+
this.list.firstChildAppend = true;
|
|
503
|
+
this.isFirstChild = true;
|
|
504
|
+
}
|
|
505
|
+
this.border = this.list.border;
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
methods: {
|
|
509
|
+
/**
|
|
510
|
+
* 获取父元素实例
|
|
511
|
+
*/
|
|
512
|
+
getForm(name = 'uniList') {
|
|
513
|
+
let parent = this.$parent;
|
|
514
|
+
let parentName = parent.$options.name;
|
|
515
|
+
while (parentName !== name) {
|
|
516
|
+
parent = parent.$parent;
|
|
517
|
+
if (!parent) return false;
|
|
518
|
+
parentName = parent.$options.name;
|
|
519
|
+
}
|
|
520
|
+
return parent;
|
|
521
|
+
},
|
|
522
|
+
onClick() {
|
|
523
|
+
if (this.to !== '') {
|
|
524
|
+
this.openPage();
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
if (this.clickable || this.link) {
|
|
528
|
+
this.$emit('click', {
|
|
529
|
+
data: {}
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
openPage() {
|
|
534
|
+
if (['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'].indexOf(this.link) !== -1) {
|
|
535
|
+
this.pageApi(this.link);
|
|
536
|
+
} else {
|
|
537
|
+
this.pageApi('navigateTo');
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
pageApi(api) {
|
|
541
|
+
let callback = {
|
|
542
|
+
url: this.to,
|
|
543
|
+
success: (res) => {
|
|
544
|
+
this.$emit('click', {
|
|
545
|
+
data: res
|
|
546
|
+
});
|
|
547
|
+
},
|
|
548
|
+
fail: (err) => {
|
|
549
|
+
this.$emit('click', {
|
|
550
|
+
data: err
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
switch (api) {
|
|
555
|
+
case 'navigateTo':
|
|
556
|
+
uni.navigateTo(callback);
|
|
557
|
+
break;
|
|
558
|
+
case 'redirectTo':
|
|
559
|
+
uni.redirectTo(callback);
|
|
560
|
+
break;
|
|
561
|
+
case 'reLaunch':
|
|
562
|
+
uni.reLaunch(callback);
|
|
563
|
+
break;
|
|
564
|
+
case 'switchTab':
|
|
565
|
+
uni.switchTab(callback);
|
|
566
|
+
break;
|
|
567
|
+
default:
|
|
568
|
+
uni.navigateTo(callback);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
</script>
|
|
574
|
+
<style>
|
|
575
|
+
@import 'style.css';
|
|
576
|
+
</style>
|