liuyg
2021-07-02 ef1b3b4c73bb1b30e945ec1c8b1ec0f342f790f9
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
166
167
168
169
170
171
172
173
174
175
176
177
<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'],
        // props: [{
        //     imgs:{
        //         type: Array,
        //         default: []
        //     },
        //     videos:{
        //         type: Object,
        //         default: []
        //     },
        //     type:{
        //         type: String,
        //         default: null
        //     },
        // }],
        data() {
            return {
 
            }
        },
        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: 10rem;
        // border: 1px solid #0000FF;
        white-space: nowrap;
        box-sizing: border-box;
        overflow: scroll;
 
        .imgs {
            display: inline-block;
            padding-top: 0.5rem;
            width: 9rem;
            height: 9rem;
            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;
 
            image {
                width: 100%;
                height: 100%;
            }
 
            .close {
                background-color: #fff;
                width: 1.6rem;
                height: 1.6rem;
                text-align: center;
                line-height: 1.6rem;
                position: absolute;
                top: 0.2rem;
                right: 0.5rem;
                font-size: 1.5rem;
                color: red;
                border-radius: 1.5rem;
                border: 1px solid red;
 
                &:hover {
                    color: red;
                    border: 1px solid red;
                }
            }
        }
 
        .videos {
            display: inline-block;
            padding-top: 0.5rem;
            width: 9rem;
            height: 9rem;
            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;
 
            video {
                width: 100%;
                height: 100%;
            }
 
            .close {
                background-color: #fff;
                width: 1.6rem;
                height: 1.6rem;
                text-align: center;
                line-height: 1.6rem;
                position: absolute;
                top: 0.2rem;
                right: 0.5rem;
                font-size: 1.5rem;
                color: red;
                border-radius: 1.5rem;
                border: 1px solid red;
 
                &:hover {
                    color: red;
                    border: 1px solid red;
                }
            }
        }
    }
</style>