
<template>
    <view class="evalOne">
        <image v-if="current.type==1" mode="aspectFill" :src="current.url" 
        @click="previewImage(current.url)"/>
        <video v-else :id="`myVideo_${index}`"
        :src="current.url" 
        :controls="true"
        :show-fullscreen-btn="true"></video>
    </view>
</template>

<script>
export default {
    props:['item','current'],
    data() {
        return {
            allImageSrc: []
        }
    },
    watch: {
        item: {
            handler(val, oldval) {
                for (let i = 0; i < val.images.length; i++) {
                    if(val.images[i].type==1){
                        this.allImageSrc.push(val.images[i].url)
                    }
                }
            },
            deep: true,
            immediate: true
        },
    },
    methods: {
        openPicture() {
            let imgObj = [];
            let msg = "&Evaluation=1"
            uni.navigateTo({
                url: `/pages/hotel/picture?imgObj=${encodeURIComponent(imgObj)}${msg}`,
            });
        },
        previewImage(src) {
            uni.previewImage({
                urls: this.allImageSrc,
                current: src,
                longPressActions: {
                    itemList: ["发送给朋友", "保存图片", "收藏"],
                    success: function(data) {
                        
                    },
                    fail: function(err) {
                        console.log(err.errMsg);
                    },
                },
            });
        },
    }
}
</script>
<style>
	.evalOne{
        height: 332rpx;
        width: 332rpx;
        border-radius: 14rpx;
        background: #eee;
        overflow: hidden;
    }
    .evalOne image,.evalOne video{
        width: 100%;
        height: 100%;
    }
</style>