126 lines
2.7 KiB
Vue
126 lines
2.7 KiB
Vue
<template>
|
|
<view class="preview-container" v-if="show">
|
|
<view class="header" @tap.stop :style="{ 'padding-top': statusBarHeight }">
|
|
<image class="icon-back" src="/static/image/phone-message/oppo/back-white.png" @tap="close"></image>
|
|
<image class="icon-download" src="/static/image/phone-message/oppo/save-white.png"></image>
|
|
</view>
|
|
<!-- 图片显示 -->
|
|
<swiper class="preview-swiper" :current="current" @change="onChange">
|
|
<swiper-item v-for="(imgSrc, index) in images" :key="index">
|
|
<image class="preview-img" :src="imgSrc" mode="aspectFit"></image>
|
|
</swiper-item>
|
|
</swiper>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, watch } from 'vue';
|
|
|
|
const statusBarHeight = (uni.getSystemInfoSync().statusBarHeight || 44) + 'px';
|
|
|
|
const props = defineProps({
|
|
show: Boolean,
|
|
images: {
|
|
type: Array,
|
|
default: () => []
|
|
},
|
|
currentIndex: {
|
|
type: Number,
|
|
default: 0
|
|
}
|
|
});
|
|
const emit = defineEmits(['update:show']);
|
|
|
|
const current = ref(0);
|
|
|
|
watch(() => props.currentIndex, (val) => {
|
|
current.value = val;
|
|
});
|
|
|
|
const onChange = (e) => {
|
|
current.value = e.detail.current;
|
|
};
|
|
|
|
const close = () => {
|
|
emit('update:show', false);
|
|
};
|
|
|
|
// const download = () => {
|
|
// const currentSrc = props.images[current.value];
|
|
// if (!currentSrc) return;
|
|
|
|
// // 触发下载逻辑
|
|
// uni.saveImageToPhotosAlbum({
|
|
// filePath: currentSrc,
|
|
// success: function () {
|
|
// uni.showToast({
|
|
// title: '保存成功',
|
|
// icon: 'success'
|
|
// });
|
|
// },
|
|
// fail: function () {
|
|
// uni.showToast({
|
|
// title: '保存失败',
|
|
// icon: 'none'
|
|
// });
|
|
// }
|
|
// });
|
|
// };
|
|
</script>
|
|
|
|
<style scoped>
|
|
.preview-container {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
background-color: #000000;
|
|
z-index: 999999;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.header {
|
|
box-sizing: content-box;
|
|
width: 100%;
|
|
/* 预留状态栏高度 */
|
|
height: 98rpx;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
z-index: 2;
|
|
background-color: rgba(0, 0, 0, 0.6);
|
|
}
|
|
|
|
.icon-back {
|
|
width: 48rpx;
|
|
height: 48rpx;
|
|
margin: 0 34rpx;
|
|
}
|
|
|
|
.icon-download {
|
|
width: 48rpx;
|
|
height: 48rpx;
|
|
margin: 0 34rpx;
|
|
}
|
|
|
|
.preview-swiper {
|
|
width: 100vw;
|
|
height: 100vh;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
z-index: 1;
|
|
}
|
|
|
|
.preview-img {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: block;
|
|
}
|
|
</style>
|