|
@@ -1,5 +1,5 @@
|
|
|
<script setup>
|
|
|
-import { onMounted, inject } from 'vue'
|
|
|
+import { onMounted, inject, computed } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import PaintingDetailBox from '@/components/PaintingDetailBox.vue'
|
|
|
import paintingInfoBox from '@/components/PaintingInfoBox.vue'
|
|
@@ -7,6 +7,30 @@ import paintingInfoBox from '@/components/PaintingInfoBox.vue'
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
|
|
|
+// 可当普通组件传入或者当作路由界面使用
|
|
|
+const usageState = computed(() =>{
|
|
|
+ if (route.query.idx) {
|
|
|
+ return 'newPage'
|
|
|
+ }
|
|
|
+ return 'component'
|
|
|
+})
|
|
|
+
|
|
|
+// 当组件使用时需要传入的参数
|
|
|
+const props = defineProps({
|
|
|
+ // 画作id(和路由参数一样)
|
|
|
+ idx: {
|
|
|
+ type: String,
|
|
|
+ default: '0',
|
|
|
+ },
|
|
|
+ // 状态
|
|
|
+ state: {
|
|
|
+ type: String,
|
|
|
+ default: '1',
|
|
|
+ },
|
|
|
+})
|
|
|
+
|
|
|
+// 返回按钮触发的行为
|
|
|
+const emit = defineEmits(['close'])
|
|
|
|
|
|
const $env = inject("$env")
|
|
|
|
|
@@ -23,10 +47,23 @@ const getPaintingSize = (raw) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const realState = computed(() => {
|
|
|
+ if (props.state === '2' || route.query.state === '2') {
|
|
|
+ return 2
|
|
|
+ }
|
|
|
+ return 1
|
|
|
+})
|
|
|
+
|
|
|
// idx 传入下标index
|
|
|
-const paintingInfo = route.query.idx == 'home' ? configExcel['首页画作'][0] : configExcel['画作'][route.query.idx]
|
|
|
+const paintingInfo = route.query.idx == 'home' || props.idx == 'home' ? configExcel['首页画作'][0] : configExcel['画作'][usageState.value == 'newPage' ? route.query.idx : props.idx]
|
|
|
+// const paintingInfo = route.query.idx == 'home' ? configExcel['首页画作'][0] : configExcel['画作'][route.query.idx]
|
|
|
onMounted(() => {
|
|
|
- console.log(paintingInfo)
|
|
|
+ // if (usageState.value == 'newPage') {
|
|
|
+ // paintingInfo = route.query.idx == 'home' ? configExcel['首页画作'][0] : configExcel['画作'][route.query.idx]
|
|
|
+ // } else if (usageState.value == 'component') {
|
|
|
+ // paintingInfo = props.idx == 'home' ? configExcel['首页画作'][0] : configExcel['画作'][props.idx]
|
|
|
+ // }
|
|
|
+ console.log('看看检索', props.state == '2', realState.value)
|
|
|
})
|
|
|
</script>
|
|
|
|
|
@@ -47,9 +84,9 @@ onMounted(() => {
|
|
|
:painting-desc="paintingInfo['简介']"
|
|
|
:author-desc="paintingInfo['作者简介']"
|
|
|
:size="paintingInfo['尺寸'] ? getPaintingSize(paintingInfo['尺寸']) : ''"
|
|
|
- :state="route.query.state ? Number(route.query.state) : 1"
|
|
|
+ :state="realState"
|
|
|
/>
|
|
|
- <BtnBack @click="() => route.query.idx == 'home' ? router.replace('/?page=4'):router.back()" />
|
|
|
+ <BtnBack @click="() => usageState ==='component' ? emit('close'):router.back()" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|