mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
fix: support preview video (#3594)
This commit is contained in:
parent
0bc07ecce1
commit
eca7dae310
@ -60,4 +60,4 @@
|
|||||||
<slot />
|
<slot />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
@ -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) {
|
onClickPreview(event) {
|
||||||
const { index } = event.currentTarget.dataset;
|
const { index } = event.currentTarget.dataset;
|
||||||
|
@ -21,6 +21,16 @@
|
|||||||
data-index="{{ index }}"
|
data-index="{{ index }}"
|
||||||
bind:tap="onPreviewImage"
|
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
|
<view
|
||||||
wx:else
|
wx:else
|
||||||
class="van-uploader__file"
|
class="van-uploader__file"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user