|
@@ -1,20 +1,74 @@
|
|
|
<template>
|
|
|
- <div class="photocopy">
|
|
|
- <div class="photocopy-left">
|
|
|
- <el-image src="" fit="contain" />
|
|
|
+ <div v-loading="loading" class="photocopy">
|
|
|
+ <template v-if="!noData">
|
|
|
+ <div class="photocopy-left">
|
|
|
+ <el-image :src="baseUrl + list[curIndex]?.thumb" fit="contain" />
|
|
|
|
|
|
- <div class="photocopy-left__prev" />
|
|
|
- <div class="photocopy-left__next" />
|
|
|
+ <div class="photocopy-left__prev" @click="handlePrev" />
|
|
|
+ <div class="photocopy-left__next" @click="handleNext" />
|
|
|
|
|
|
- <div class="photocopy-left__magnify" />
|
|
|
+ <div class="photocopy-left__magnify" @click="viewerVisible = true" />
|
|
|
|
|
|
- <div class="photocopy-left__pagination">12/24</div>
|
|
|
- </div>
|
|
|
+ <div class="photocopy-left__pagination">
|
|
|
+ {{ curIndex + 1 }}/{{ total }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class="photocopy-right"></div>
|
|
|
+ <div class="photocopy-right" v-html="list[curIndex]?.description" />
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <el-empty v-else description="暂无数据" style="width: 100%" />
|
|
|
</div>
|
|
|
+
|
|
|
+ <el-image-viewer
|
|
|
+ v-if="viewerVisible"
|
|
|
+ :url-list="list.map((i) => `${baseUrl}${i.thumb}`)"
|
|
|
+ :initial-index="curIndex"
|
|
|
+ @close="viewerVisible = false"
|
|
|
+ />
|
|
|
</template>
|
|
|
|
|
|
+<script setup>
|
|
|
+import { watch, ref } from "vue";
|
|
|
+import { usePagination } from "@lsq/base";
|
|
|
+import { getMediaListApi } from "@/api";
|
|
|
+import { getBaseUrl } from "@/utils";
|
|
|
+
|
|
|
+const props = defineProps(["detail", "isLogin"]);
|
|
|
+const curIndex = ref(0);
|
|
|
+const viewerVisible = ref(false);
|
|
|
+const baseUrl = getBaseUrl();
|
|
|
+
|
|
|
+const { total, loading, list, noData, getList } = usePagination(
|
|
|
+ async (params) => {
|
|
|
+ return getMediaListApi({
|
|
|
+ ...params,
|
|
|
+ pageSize: 999,
|
|
|
+ bookId: props.detail.id,
|
|
|
+ type: "img",
|
|
|
+ });
|
|
|
+ }
|
|
|
+);
|
|
|
+
|
|
|
+const handlePrev = () => {
|
|
|
+ curIndex.value = Math.max(curIndex.value - 1, 0);
|
|
|
+};
|
|
|
+
|
|
|
+const handleNext = () => {
|
|
|
+ curIndex.value = Math.min(curIndex.value + 1, list.value.length - 1);
|
|
|
+};
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => props.detail,
|
|
|
+ () => {
|
|
|
+ props.detail && getList();
|
|
|
+ },
|
|
|
+ {
|
|
|
+ immediate: true,
|
|
|
+ }
|
|
|
+);
|
|
|
+</script>
|
|
|
+
|
|
|
<style lang="scss" scoped>
|
|
|
@import "./index.scss";
|
|
|
</style>
|