Skip to content

Commit da8456a

Browse files
committed
uview fix:search
1 parent 5ddd427 commit da8456a

4 files changed

Lines changed: 32 additions & 15 deletions

File tree

‎uni_modules/uview-ui/components/u-form/u-form.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
props = [].concat(props);
113113
this.children.map((child) => {
114114
// 如果u-form-item的prop在props数组中,则清除对应的校验结果信息
115-
if (props.includes(child.props)) {
115+
if (props.includes(child.prop)) {
116116
child.message = null;
117117
}
118118
});

‎uni_modules/uview-ui/components/u-search/u-search.vue‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
</template>
2323
<view class="u-search__content__icon">
2424
<u-icon
25+
@tap="clickIcon"
2526
:size="22"
2627
:name="searchIcon"
2728
:color="searchIconColor ? searchIconColor : color"
@@ -100,7 +101,7 @@
100101
* @property {String | Number} height 输入框高度,单位px(默认 64 )
101102
* @property {String | Number} label 搜索框左边显示内容
102103
* @property {Object} customStyle 定义需要用到的外部样式
103-
*
104+
*
104105
* @event {Function} change 输入框内容发生变化时触发
105106
* @event {Function} search 用户确定搜索时触发,用户按回车键,或者手机键盘右下角的"搜索"键时触发
106107
* @event {Function} custom 用户点击右侧控件时触发
@@ -190,6 +191,10 @@
190191
// 点击搜索框,只有disabled=true时才发出事件,因为禁止了输入,意味着是想跳转真正的搜索页
191192
clickHandler() {
192193
if (this.disabled) this.$emit('click');
194+
},
195+
// 点击左边图标
196+
clickIcon() {
197+
this.$emit('clickIcon');
193198
}
194199
}
195200
}
@@ -217,8 +222,8 @@ $u-search-action-margin-left: 5px !default;
217222
218223
/* #ifdef H5 */
219224
// iOS15在H5下,hx的某些版本,input type=search时,会多了一个搜索图标,进行移除
220-
[type="search"]::-webkit-search-decoration {
221-
display: none;
225+
[type="search"]::-webkit-search-decoration {
226+
display: none;
222227
}
223228
/* #endif */
224229

‎uni_modules/uview-ui/components/u-upload/u-upload.vue‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@
188188
} = this;
189189
const lists = fileList.map((item) =>
190190
Object.assign(Object.assign({}, item), {
191-
isImage: uni.$u.test.image(item.url),
192-
isVideo: uni.$u.test.video(item.url),
191+
// 如果item.url为本地选择的blob文件的话,无法判断其为video还是image,此处优先通过accept做判断处理
192+
isImage: this.accept === 'image' || uni.$u.test.image(item.url || item.thumb),
193+
isVideo: this.accept === 'video' || uni.$u.test.video(item.url || item.thumb),
193194
deletable: typeof(item.deletable) === 'boolean' ? item.deletable : this.deletable,
194195
})
195196
);
@@ -299,8 +300,8 @@
299300
if (!item.isImage || !this.previewFullImage) return
300301
uni.previewImage({
301302
// 先filter找出为图片的item,再返回filter结果中的图片url
302-
urls: this.lists.filter((item) => uni.$u.test.image(item.url)).map((item) => item.url),
303-
current: item.url,
303+
urls: this.lists.filter((item) => this.accept === 'image' || uni.$u.test.image(item.url || item.thumb)).map((item) => item.url || item.thumb),
304+
current: item.url || item.thumb,
304305
fail() {
305306
uni.$u.toast('预览图片失败')
306307
},
@@ -324,10 +325,7 @@
324325
),
325326
current: index,
326327
fail() {
327-
wx.showToast({
328-
title: '预览视频失败',
329-
icon: 'none'
330-
});
328+
uni.$u.toast('预览视频失败')
331329
},
332330
});
333331
},

‎uni_modules/uview-ui/components/u-upload/utils.js‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ function formatImage(res) {
1717
type: 'image',
1818
url: item.path,
1919
thumb: item.path,
20-
size: item.size
20+
size: item.size,
21+
// #ifdef H5
22+
name: item.name
23+
// #endif
2124
}))
2225
}
2326

@@ -28,7 +31,10 @@ function formatVideo(res) {
2831
type: 'video',
2932
url: res.tempFilePath,
3033
thumb: res.thumbTempFilePath,
31-
size: res.size
34+
size: res.size,
35+
// #ifdef H5
36+
name: res.name
37+
// #endif
3238
}
3339
]
3440
}
@@ -44,7 +50,15 @@ function formatMedia(res) {
4450
}
4551

4652
function formatFile(res) {
47-
return res.tempFiles.map((item) => ({ ...pickExclude(item, ['path']), url: item.path, size:item.size }))
53+
return res.tempFiles.map((item) => ({
54+
...pickExclude(item, ['path']),
55+
url: item.path,
56+
size:item.size,
57+
// #ifdef H5
58+
name: item.name,
59+
type: item.type
60+
// #endif
61+
}))
4862
}
4963
export function chooseFile({
5064
accept,

0 commit comments

Comments
 (0)