feat: 图片相册与图片浏览
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<view class="custom-indicator">
|
<view class="custom-indicator" @click="handlePreviewClick">
|
||||||
<uni-icons fontFamily="znicons" size="10" color="#fff">{{
|
<uni-icons fontFamily="znicons" size="10" color="#fff">{{
|
||||||
zniconsMap["zn-camera"]
|
zniconsMap["zn-camera"]
|
||||||
}}</uni-icons>
|
}}</uni-icons>
|
||||||
@@ -68,6 +68,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, nextTick } from "vue";
|
import { ref, computed, nextTick } from "vue";
|
||||||
import { zniconsMap } from "@/static/fonts/znicons.js";
|
import { zniconsMap } from "@/static/fonts/znicons.js";
|
||||||
|
import { useAppStore } from "@/store";
|
||||||
|
const appStore = useAppStore();
|
||||||
|
|
||||||
// Props定义
|
// Props定义
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -166,6 +168,13 @@ const handleSwiperChange = (e) => {
|
|||||||
active.value = currentIndex;
|
active.value = currentIndex;
|
||||||
scrollToActiveItem(currentIndex);
|
scrollToActiveItem(currentIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handlePreviewClick = () => {
|
||||||
|
appStore.setPreviewImageData(thumbnails.value);
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/goods/album/index`,
|
||||||
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -17,6 +17,12 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/goods/album/index",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"subPackages": [
|
"subPackages": [
|
||||||
|
|||||||
87
src/pages/goods/album/index.vue
Normal file
87
src/pages/goods/album/index.vue
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<template>
|
||||||
|
<view class="bg-F5F7FA flex flex-col h-screen overflow-hidden">
|
||||||
|
<TopNavBar title="房间相册" backgroundColor="transparent" />
|
||||||
|
<view class="p-8">
|
||||||
|
<text class="ml-4 font-size-18 color-171717 font-500"
|
||||||
|
>全部({{ albumList.length }})</text
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<scroll-view scroll-y class="scroll-container overflow-auto">
|
||||||
|
<view class="pl-8 pr-8 pb-24">
|
||||||
|
<view class="flex flex-wrap">
|
||||||
|
<view
|
||||||
|
class="album-item"
|
||||||
|
v-for="(item, index) in albumList"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<image
|
||||||
|
class="album-image"
|
||||||
|
:src="item.photoUrl"
|
||||||
|
mode="aspectFill"
|
||||||
|
@click="handlePreview(item.photoUrl)"
|
||||||
|
></image>
|
||||||
|
<view class="album-title">{{ item.title }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from "vue";
|
||||||
|
import TopNavBar from "@/components/TopNavBar/index.vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import { useAppStore } from "@/store";
|
||||||
|
const appStore = useAppStore();
|
||||||
|
|
||||||
|
const albumList = ref([]);
|
||||||
|
|
||||||
|
onLoad(() => {
|
||||||
|
albumList.value = appStore.previewImageData;
|
||||||
|
appStore.setPreviewImageData([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 处理图片预览
|
||||||
|
const handlePreview = (photoUrl) => {
|
||||||
|
uni.previewImage({
|
||||||
|
current: photoUrl,
|
||||||
|
urls: albumList.value.map((item) => item.photoUrl),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.scroll-container {
|
||||||
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.album-item {
|
||||||
|
position: relative;
|
||||||
|
width: calc(50% - 8px);
|
||||||
|
margin: 4px;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.album-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 150px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.album-title {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
background: linear-gradient(180deg, rgba(144, 144, 144, 0) 0%, #000000 100%);
|
||||||
|
border-radius: 0 0 8px 8px;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -37,3 +37,7 @@
|
|||||||
.bg-button {
|
.bg-button {
|
||||||
background: linear-gradient(90deg, #2d91ff 0%, #4de4ff 100%);
|
background: linear-gradient(90deg, #2d91ff 0%, #4de4ff 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bg-transparent {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,3 +2,7 @@
|
|||||||
.overflow-hidden {
|
.overflow-hidden {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.overflow-auto {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|||||||
@@ -103,6 +103,14 @@
|
|||||||
padding: 24px;
|
padding: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pt-24 {
|
||||||
|
padding-top: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pb-24 {
|
||||||
|
padding-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.pb-safe-area {
|
.pb-safe-area {
|
||||||
padding-bottom: Max(env(safe-area-inset-bottom), 12px);
|
padding-bottom: Max(env(safe-area-inset-bottom), 12px);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ export const useAppStore = defineStore("app", {
|
|||||||
state() {
|
state() {
|
||||||
return {
|
return {
|
||||||
title: "",
|
title: "",
|
||||||
sceneId: "",
|
sceneId: "", /// 分身场景id
|
||||||
hasToken: false,
|
hasToken: false, /// 是否有token
|
||||||
tokenExpired: false,
|
tokenExpired: false, /// token是否过期
|
||||||
|
previewImageData: [], /// 预览图片数据
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getters: {},
|
getters: {},
|
||||||
@@ -24,6 +25,9 @@ export const useAppStore = defineStore("app", {
|
|||||||
setTokenExpired(status) {
|
setTokenExpired(status) {
|
||||||
this.tokenExpired = status;
|
this.tokenExpired = status;
|
||||||
},
|
},
|
||||||
|
setPreviewImageData(data) {
|
||||||
|
this.previewImageData = data;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
unistorage: true,
|
unistorage: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user