refactor: 项目架构清理 — 删除调试页面/冗余store/H5降级代码/无用文件
This commit is contained in:
@@ -18,12 +18,12 @@
|
||||
</view>
|
||||
<!-- 年卡列表 -->
|
||||
<view class="card-list">
|
||||
<view v-if="cardStore.loading" class="loading"><text>加载中...</text></view>
|
||||
<view v-else-if="cardStore.cardList.length === 0">
|
||||
<view v-if="loading" class="loading"><text>加载中...</text></view>
|
||||
<view v-else-if="cardList.length === 0">
|
||||
<empty-state icon="🎫" text="暂无符合条件的年卡" />
|
||||
</view>
|
||||
<view v-else>
|
||||
<card-item v-for="card in cardStore.cardList" :key="card.id" :card="card" @click="goDetail" />
|
||||
<card-item v-for="card in cardList" :key="card.id" :card="card" @click="goDetail" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -32,12 +32,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { useCardStore } from '../../../../store/card'
|
||||
import { getCardList } from '../../../../api/card'
|
||||
import CardItem from '../../../../components/card-item.vue'
|
||||
import EmptyState from '../../../../components/empty-state.vue'
|
||||
import type { CardInfo } from '../../../../api/types'
|
||||
|
||||
const cardStore = useCardStore()
|
||||
const cardList = ref<CardInfo[]>([])
|
||||
const loading = ref(false)
|
||||
const keyword = ref('')
|
||||
const currentCategory = ref('')
|
||||
|
||||
@@ -49,14 +50,24 @@ const categories = [
|
||||
{ label: '情侣年卡', value: 'couple' }
|
||||
]
|
||||
|
||||
/** 获取年卡列表 */
|
||||
async function fetchCardList(params?: { keyword?: string; category?: string }) {
|
||||
loading.value = true
|
||||
try {
|
||||
cardList.value = await getCardList(params)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 页面加载时获取年卡列表 */
|
||||
onLoad(() => {
|
||||
cardStore.fetchCardList()
|
||||
fetchCardList()
|
||||
})
|
||||
|
||||
/** 执行搜索 */
|
||||
function handleSearch() {
|
||||
cardStore.fetchCardList({ keyword: keyword.value, category: currentCategory.value })
|
||||
fetchCardList({ keyword: keyword.value, category: currentCategory.value })
|
||||
}
|
||||
|
||||
/** 选择分类 */
|
||||
|
||||
Reference in New Issue
Block a user