zengh
2022-05-09 52c39f5e2711e5535b689b66dfa5e100c7882b7f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<template>
    <view class="seeImgs" v-if="imgs.length != 0 || videos.length != 0 ">
        <view class="imgs" v-for="(item, index) in imgs" :key="index" v-if="type == 'imgs'">
            <image :src="item.src" mode="scaleToFill" @click="previewImage(index)"></image>
            <view class="close" @click="delelteImg(index)">
                X
            </view>
        </view>
        <view class="videos" v-for="(item, index) in videos" :key="index" v-if="type == 'videos'">
 
            <!-- <image :src="item.src" mode="scaleToFill" @click="previewImage(index)"></image> -->
            <video :src="item.src" controls></video>
 
            <view class="close" @click="deleltevideo(index)">
                X
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        props: ['imgs', 'videos', 'type'],
        data() {
            return {
                // uesVideodata: []
            }
        },
        // watch: {
        //     "videos"() {
        //         // console.log(this.videos)
        //         if (this.videos != []) {
        //             setTimeout(res=>{
        //                 this.uesVideodata = this.videos;
        //             },500)
        //         } else []
        //     }
        // },
        methods: {
            //图片删除
            delelteImg(index) {
                var that = this;
                wx.showModal({
                    title: '提示',
                    content: '确定要删除该照片吗?',
                    cancelText: '取消',
                    confirmText: '确定',
                    success: res => {
                        if (res.confirm) {
                            // console.log(index)
                            // that.imgs.splice(index, 1);
                            that.$emit('del', index);
                        }
                    }
                });
            },
 
            //图片预览
            previewImage(index) {
                let photoList = this.imgs.map(item => {
                    return item.src;
                });
                // console.log(index)
                // console.log(photoList)
                wx.previewImage({
                    current: photoList[index],
                    urls: photoList
                });
            },
 
            //视频删除
            deleltevideo(index) {
                var that = this;
                wx.showModal({
                    title: '提示',
                    content: '确定要删除该视频吗?',
                    cancelText: '取消',
                    confirmText: '确定',
                    success: res => {
                        if (res.confirm) {
                            // console.log(index)
                            // that.imgs.splice(index, 1);
                            that.$emit('del', index);
                        }
                    }
                });
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    .seeImgs {
        width: 100%;
        height: 4.3rem;
        // border: 1px solid #0000FF;
        white-space: nowrap;
        box-sizing: border-box;
        overflow: auto;
        // display: flex;
        // align-items: center;
        // position: absolute;
        // right: 0;
        // z-index: 110;
 
        .imgs {
            display: inline-block;
            padding-top: 0.5rem;
            width: 4rem;
            height: 4rem;
            padding: 0 0.2rem 0 0.2rem;
            margin: 0 0.2rem 0 0.2rem;
            // border-right: 1px solid rgba($color: #000000, $alpha: 0.5);
            position: relative;
            // border: 1px solid #0000FF;
            top: 0.22rem;
 
            image {
                width: 100%;
                height: 100%;
            }
 
 
        }
 
        .videos {
            display: inline-block;
            padding-top: 0.5rem;
            width: 4.2rem;
            height: 4.2rem;
            padding: 0 0.2rem 0 0.2rem;
            margin: 0 0.2rem 0 0.2rem;
            // border-right: 1px solid rgba($color: #000000, $alpha: 0.5);
            position: relative;
            // border: 1px solid #0000FF;
            top: 0.22rem;
 
            video {
                width: 100%;
                height: 100%;
            }
        }
    }
 
    .close {
        background-color: #fff;
        width: 0.9rem;
        height: 0.9rem;
        text-align: center;
        line-height: 0.8rem;
        position: absolute;
        top: 0.1rem;
        right: 0.2rem;
        font-size: 0.5rem;
        color: red;
        border-radius: 1.5rem;
        border: 1px solid red;
        z-index: 111;
 
        &:hover {
            color: red;
            border: 1px solid red;
        }
    }
</style>