liyaozhi
2025-10-28 1320688354fd168c51cf2e05f29a2253f4ed9c00
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
<template>
    <view v-if="show" class="preview-container">
        <swiper ref="mySwiper" class="preview-swiper" :current="current" @change="onSwiperChange">
            <swiper-item v-for="(item, index) in images" :key="index">
                <view class="swiper-item">
                    <image class="preview-image" :src="item.file_path" mode="aspectFit" @click="handleClose"></image>
                </view>
            </swiper-item>
        </swiper>
 
        <!-- 顶部栏 -->
        <view class="preview-header">
            <text class="preview-index">{{ current + 1 }}/{{ images.length }}</text>
            <view class="preview-actions">
                <text class="close-btn" @click="handleClose">×</text>
            </view>
        </view>
        
        <!-- 底部栏 -->
        <!-- <view class="preview-footer d-c-c">
            <view class="preview-actions">
                <button class="delete-btn" @click="handleDelete">删除</button>
            </view>
        </view> -->
    </view>
</template>
 
<script>
    import { ActivityFile } from '@/common/activityFile.js';
    export default {
        data() {
            return {
                current: 0,
            };
        },
        props: {
            show: {
                type: Boolean,
                default: false
            },
            images: {
                type: Array,
                default: () => []
            }
        },
        created() {
        },
        methods: {
            onSwiperChange(e) {
                this.current = e.detail.current;
            },
 
            handleClose() {
                if (this.loading) return;
                this.$emit('close')
            },
 
            handleDelete() {
                let self = this;
                let file_id = self.images[self.current].file_id;
                uni.showLoading({
                    title: '正在删除...'
                });
                self._post(
                    'branch.admin.activityFile/delete', {
                        fileIds: file_id
                    },
                    function(res) {
                        uni.hideLoading();
                        uni.showToast({
                            title: '已删除',
                            duration: 1000,
                            icon: 'none'
                        });
                        self.images.splice(self.current, 1);
                        if (self.current > self.images.length - 1) {
                            self.current = 0;
                        }
                    }
                );
            },
 
        }
    }
</script>
 
<style scoped>
    .preview-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #000;
        z-index: 130;
    }
 
    .preview-swiper {
        height: 100%;
    }
 
    .swiper-item {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
    }
 
    .preview-image {
        width: 100%;
        height: 100%;
    }
 
    .preview-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 100rpx;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent);
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 30rpx;
        color: #fff;
    }
 
    .preview-index {
        font-size: 28rpx;
    }
 
    .close-btn {
        font-size: 50rpx;
        width: 60rpx;
        height: 60rpx;
        text-align: center;
        line-height: 60rpx;
    }
    
    .preview-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 200rpx;
        padding: 0 30rpx;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    }
    
    .delete-btn {
        background: rgba(255, 255, 255, 0.5);
        color: #ffffff;
        border-radius: 50rpx;
        padding: 6rpx 50rpx;
        font-size: 28rpx;
    }
</style>