Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 解决 accept 为 video 时不能展示视频 #3594

Merged
merged 8 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/tabs/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
<slot />
</view>
</view>
</view>
</view>
21 changes: 21 additions & 0 deletions packages/uploader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,27 @@ VantComponent({
},
});
},
// fix: accept 为 video 时不能展示视频
onPreviewVideo: function (event) {
if (!this.data.previewFullImage) return;
var index = event.currentTarget.dataset.index;
var lists = this.data.lists;
wx.previewMedia({
sources: lists
.filter(function (item) {
return item.isVideo;
})
.map(function (item) {
item.type = 'video';
item.url = item.url || item.path;
return item;
}),
current: index,
fail: function () {
wx.showToast({ title: '预览视频失败', icon: 'none' });
},
});
},

onClickPreview(event) {
const { index } = event.currentTarget.dataset;
Expand Down
10 changes: 10 additions & 0 deletions packages/uploader/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
data-index="{{ index }}"
bind:tap="onPreviewImage"
/>
<video
wx:elif="{{ item.isVideo }}"
src="{{item.url || item.path}}"
autoplay="{{item.autoplay}}"
class="van-uploader__preview-image"
style="width: {{ utils.addUnit(previewSize) }}; height: {{ utils.addUnit(previewSize) }};"
data-index="{{ index }}"
bind:tap="onPreviewVideo"
>
</video>
<view
wx:else
class="van-uploader__file"
Expand Down