refactor(store): 重构 home store 并改名为 goods store
- 将 home store 重命名为 goods store,以更准确地反映其用途 - 更新了相关文件中的导入路径和引用 -调整了首页布局和组件以适应新的 goods store 结构 - 新增了 goods store 中的 actionDetails 和 itemList 属性
This commit is contained in:
parent
fbbb30040e
commit
6f67273a9a
16
app/api/goods/index.js
Normal file
16
app/api/goods/index.js
Normal file
@ -0,0 +1,16 @@
|
||||
import { getHttp } from '~/api/http.js'
|
||||
|
||||
export async function artworkList(data) {
|
||||
const http = getHttp()
|
||||
return await http('/api/v1/m/auction/default/artwork/list', {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
})
|
||||
}
|
||||
export async function defaultDetail(data) {
|
||||
const http = getHttp()
|
||||
return await http('/api/v1/m/auction/default/detail', {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
})
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
import { useRuntimeConfig } from '#app'
|
||||
import { ofetch } from 'ofetch'
|
||||
import {message} from '@/components/x-message/useMessage.js'
|
||||
import {authStore} from "@/stores/auth/index.js";
|
||||
let httpStatusErrorHandler
|
||||
|
||||
let http
|
||||
@ -12,15 +13,14 @@ export function setupHttp() {
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const baseURL = config.public.NUXT_PUBLIC_API_BASE
|
||||
|
||||
const {token}= authStore()
|
||||
http = ofetch.create({
|
||||
baseURL,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
async onRequest({ options }) {
|
||||
const token = localStorage.getItem('token')
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
...(token && { Authorization: token }),
|
||||
Authorization:token.value
|
||||
}
|
||||
},
|
||||
async onResponse({ response }) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { useAppHeaderRouteNames as routeWhiteList } from '~/config'
|
||||
import { homeStore } from "@/stores/home/index.js";
|
||||
import { homeStore } from "@/stores/goods/index.js";
|
||||
const { fullLive } = homeStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@ -40,7 +40,7 @@ const showLeftArrow = computed(() => route.name && routeWhiteList.includes(route
|
||||
placeholder clickable fixed
|
||||
@click-left="onBack"
|
||||
>
|
||||
<template #title v-if="route.meta.i18n==='menu.home'">
|
||||
<template #title v-if="route.meta.i18n==='menu.goods'">
|
||||
|
||||
<div class="flex flex-col items-center justify-center">
|
||||
<div class="text-#000000 text-17px mb-5px font-600">{{ title }}</div>
|
||||
|
@ -7,7 +7,7 @@ By default, `default.vue` will be used unless an alternative is specified in the
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
definePageMeta({
|
||||
layout: 'home',
|
||||
layout: 'goods',
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
@ -8,6 +8,6 @@
|
||||
</main>
|
||||
</template>
|
||||
<script setup >
|
||||
import { homeStore } from "@/stores/home/index.js";
|
||||
import { homeStore } from "@/stores/goods/index.js";
|
||||
const { fullLive } = homeStore()
|
||||
</script>
|
15
app/pages/home/components/Cescribe/index.vue
Normal file
15
app/pages/home/components/Cescribe/index.vue
Normal file
@ -0,0 +1,15 @@
|
||||
<script setup>
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="px-16px pt-14px">
|
||||
<div class="text-#575757 text-14px">
|
||||
这里是后台富文本配置的说明,啊即可打开三等奖撒度老师的湿答答是快乐的阿四大皆空
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -16,7 +16,7 @@
|
||||
<div
|
||||
class="absolute left-[8px] top-[8px] h-[17px] w-[45px] flex items-center justify-center bg-[#2b53ac] text-[12px] text-[#fff]"
|
||||
>
|
||||
LOT{{ index + 1 }}
|
||||
LOT{{ item.index+1 }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="pt-[8px]">
|
||||
@ -39,7 +39,11 @@
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
items: Array
|
||||
items: Array,
|
||||
colIndex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits(['openShow']);
|
||||
|
@ -27,7 +27,7 @@ const openShow = () => {
|
||||
<div
|
||||
class="absolute left-[8px] top-[8px] h-[17px] w-[45px] flex items-center justify-center bg-[#2b53ac] text-[12px] text-[#fff]"
|
||||
>
|
||||
LOT{{ index + 1 }}
|
||||
LOT{{ item.index + 1 }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="pt-[8px]">
|
||||
|
@ -2,12 +2,10 @@
|
||||
import {useRect} from '@vant/use';
|
||||
import LiveRoom from '@/pages/LiveRoom/index.client.vue';
|
||||
import itemDetail from '@/components/itemDetail/index.vue';
|
||||
import {homeStore} from "@/stores/home/index.js";
|
||||
import {homeStore} from "@/stores/goods/index.js";
|
||||
import Column from './components/Column/index.vue'
|
||||
|
||||
const {fullLive} = homeStore();
|
||||
|
||||
|
||||
definePageMeta({
|
||||
layout: 'default',
|
||||
i18n: 'menu.home',
|
||||
@ -21,17 +19,17 @@ const show = ref(false);
|
||||
const showHeight = ref('');
|
||||
const list = ref([{
|
||||
image: 'https://e-cdn.fontree.cn/fonchain-main/prod/file/default/setting/637d95b4-2ae9-4a74-bd60-a3a9d2ca2ca0.png',
|
||||
title: '张天赐 | 日出而作,日落而息',
|
||||
title: '张天赐 | 日出而作,日落而息1',
|
||||
startingPrice: 'RMB 1,000',
|
||||
transactionPrice: 'RMB 10,000',
|
||||
}, {
|
||||
image: 'https://e-cdn.fontree.cn/fonchain-main/prod/file/default/setting/f7b65e23-ce21-41b4-8e58-9e6dc6950727.png',
|
||||
title: '张天赐 | 日出而作,日落而息',
|
||||
title: '张天赐 | 日出而作,日落而息2',
|
||||
startingPrice: 'RMB 1,000',
|
||||
transactionPrice: '',
|
||||
}, {
|
||||
image: 'https://e-cdn.fontree.cn/fonchain-main/prod/file/default/setting/41eceb23-d168-4049-ae8e-48c5328b192f.png',
|
||||
title: '张天赐 | 日出而作,日落而息',
|
||||
title: '张天赐 | 日出而作,日落而息3',
|
||||
startingPrice: 'RMB 1,000',
|
||||
transactionPrice: '',
|
||||
}, {
|
||||
@ -75,7 +73,8 @@ const onRefresh = () => {
|
||||
const columns = computed(() => {
|
||||
const result = [[], []];
|
||||
list.value.forEach((item, index) => {
|
||||
result[index % 2].push(item);
|
||||
// 为每个项目添加一个 index 属性
|
||||
result[index % 2].push({ ...item, index });
|
||||
});
|
||||
return result;
|
||||
});
|
||||
@ -108,7 +107,7 @@ const changeLive = () => {
|
||||
<van-pull-refresh>
|
||||
<van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="loadData">
|
||||
<div class="w-full flex gap-[16px]">
|
||||
<Column v-for="(column, colIndex) in columns" :key="colIndex" :items="column" @openShow="openShow"/>
|
||||
<Column v-for="(column, colIndex) in columns" :key="colIndex" :colIndex="colIndex" :items="column" @openShow="openShow"/>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { createGlobalState } from '@vueuse/core'
|
||||
export const homeStore = createGlobalState(() => {
|
||||
const actionDetails=ref({})
|
||||
const fullLive=ref(false)
|
||||
const list = ref([{
|
||||
const itemList = ref([{
|
||||
image: 'https://e-cdn.fontree.cn/fonchain-main/prod/file/default/setting/637d95b4-2ae9-4a74-bd60-a3a9d2ca2ca0.png',
|
||||
title: '张天赐 | 日出而作,日落而息',
|
||||
startingPrice: 'RMB 1,000',
|
||||
@ -42,8 +43,10 @@ export const homeStore = createGlobalState(() => {
|
||||
startingPrice: 'RMB 1,000',
|
||||
transactionPrice: 'RMB 10,000',
|
||||
}])
|
||||
|
||||
return{
|
||||
list,
|
||||
actionDetails,
|
||||
itemList,
|
||||
fullLive
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user