refactor: 项目架构清理 — 删除调试页面/冗余store/H5降级代码/无用文件
This commit is contained in:
@@ -32,10 +32,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { useCardStore } from '../../../../store/card'
|
||||
import { activateCard } from '../../../../api/card'
|
||||
import { showToast } from '../../../../utils'
|
||||
|
||||
const cardStore = useCardStore()
|
||||
const cardId = ref('')
|
||||
const cardName = ref('')
|
||||
const activating = ref(false)
|
||||
@@ -76,7 +75,7 @@ async function handleActivate() {
|
||||
if (!cardId.value) return
|
||||
activating.value = true
|
||||
try {
|
||||
await cardStore.activateCard(cardId.value, form)
|
||||
await activateCard(cardId.value, form)
|
||||
showToast('激活成功', 'success')
|
||||
// 激活成功后跳转入园码页
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -23,10 +23,9 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useCardStore } from '../../../../store/card'
|
||||
import { bindCard } from '../../../../api/card'
|
||||
import { showToast } from '../../../../utils'
|
||||
|
||||
const cardStore = useCardStore()
|
||||
const cardNo = ref('')
|
||||
const binding = ref(false)
|
||||
|
||||
@@ -38,7 +37,7 @@ async function handleBind() {
|
||||
}
|
||||
binding.value = true
|
||||
try {
|
||||
await cardStore.bindCard(cardNo.value.trim())
|
||||
await bindCard(cardNo.value.trim())
|
||||
showToast('绑定成功', 'success')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
|
||||
@@ -54,10 +54,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { useCardStore } from '../../../../store/card'
|
||||
import { getCardDetail } from '../../../../api/card'
|
||||
import type { CardDetail } from '../../../../api/types'
|
||||
|
||||
const cardStore = useCardStore()
|
||||
const card = ref<CardDetail | null>(null)
|
||||
|
||||
/** 页面加载时获取年卡详情 */
|
||||
@@ -70,8 +69,7 @@ onLoad((options) => {
|
||||
/** 加载年卡详情数据 */
|
||||
async function loadDetail(id: string) {
|
||||
try {
|
||||
await cardStore.fetchCardDetail(id)
|
||||
card.value = cardStore.currentCard
|
||||
card.value = await getCardDetail(id)
|
||||
} catch (err) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
}
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
|
||||
/** 选择分类 */
|
||||
|
||||
@@ -25,11 +25,10 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onBeforeUnmount } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { useCardStore } from '../../../../store/card'
|
||||
import { getEntryQrCode } from '../../../../api/card'
|
||||
import { showToast } from '../../../../utils'
|
||||
import type { QrCodeInfo } from '../../../../api/types'
|
||||
|
||||
const cardStore = useCardStore()
|
||||
const cardId = ref('')
|
||||
const qrInfo = ref<QrCodeInfo | null>(null)
|
||||
let refreshTimer: ReturnType<typeof setInterval> | null = null
|
||||
@@ -54,7 +53,7 @@ onBeforeUnmount(() => {
|
||||
/** 加载入园码 */
|
||||
async function loadQrCode() {
|
||||
try {
|
||||
qrInfo.value = await cardStore.getEntryQrCode(cardId.value)
|
||||
qrInfo.value = await getEntryQrCode(cardId.value)
|
||||
} catch (err: any) {
|
||||
showToast(err.message || '获取入园码失败')
|
||||
}
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 顶部标题区 -->
|
||||
<view class="header">
|
||||
<text class="header-title">湖南12301文旅专区</text>
|
||||
</view>
|
||||
|
||||
<!-- 宫格功能入口 -->
|
||||
<view class="grid">
|
||||
<view class="grid-item" @click="goTo('/packages/user/pages/card/list')">
|
||||
<view class="grid-icon" style="background: #E8F0FE;">
|
||||
<text class="emoji">🎫</text>
|
||||
</view>
|
||||
<text class="grid-label">购买年卡</text>
|
||||
<text class="grid-desc">多种卡种可选</text>
|
||||
</view>
|
||||
|
||||
<view class="grid-item" @click="goTo('/packages/user/pages/card/bind')">
|
||||
<view class="grid-icon" style="background: #FFF3E0;">
|
||||
<text class="emoji">📱</text>
|
||||
</view>
|
||||
<text class="grid-label">激活/绑定</text>
|
||||
<text class="grid-desc">激活已购年卡</text>
|
||||
</view>
|
||||
|
||||
<view class="grid-item" @click="showComingSoon">
|
||||
<view class="grid-icon" style="background: #E8F8F0;">
|
||||
<text class="emoji">🏔️</text>
|
||||
</view>
|
||||
<text class="grid-label">景区预约</text>
|
||||
<text class="grid-desc">预约入园时间</text>
|
||||
</view>
|
||||
|
||||
<view class="grid-item" @click="showComingSoon">
|
||||
<view class="grid-icon" style="background: #FCE4EC;">
|
||||
<text class="emoji">📋</text>
|
||||
</view>
|
||||
<text class="grid-label">我的记录</text>
|
||||
<text class="grid-desc">预约/使用记录</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 推荐年卡 -->
|
||||
<view class="section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">推荐年卡</text>
|
||||
<text class="section-more" @click="goTo('/packages/user/pages/card/list')">查看全部 ›</text>
|
||||
</view>
|
||||
|
||||
<view v-if="cardStore.loading" class="loading">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
|
||||
<view v-else-if="cardStore.cardList.length === 0" class="empty">
|
||||
<empty-state icon="🎫" text="暂无年卡" />
|
||||
</view>
|
||||
|
||||
<view v-else>
|
||||
<card-item
|
||||
v-for="card in displayCards"
|
||||
:key="card.id"
|
||||
:card="card"
|
||||
@click="goToDetail"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { useCardStore } from '../../../../store/card'
|
||||
import CardItem from '../../../../components/card-item.vue'
|
||||
import EmptyState from '../../../../components/empty-state.vue'
|
||||
import type { CardInfo } from '../../../../api/types'
|
||||
|
||||
const cardStore = useCardStore()
|
||||
|
||||
// 首页最多展示 3 张年卡
|
||||
const displayCards = computed(() => cardStore.cardList.slice(0, 3))
|
||||
|
||||
onShow(() => {
|
||||
cardStore.fetchCardList()
|
||||
})
|
||||
|
||||
function goTo(url: string) {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
function goToDetail(card: CardInfo) {
|
||||
uni.navigateTo({ url: `/packages/user/pages/card/detail?id=${card.id}` })
|
||||
}
|
||||
|
||||
function showComingSoon() {
|
||||
uni.showToast({ title: '即将上线,敬请期待', icon: 'none' })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: #4A90D9;
|
||||
padding: 40rpx 30rpx 30rpx;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
padding: 20rpx;
|
||||
margin: -20rpx 16rpx 0;
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.grid-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
|
||||
.grid-icon {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.emoji {
|
||||
font-size: 44rpx;
|
||||
}
|
||||
|
||||
.grid-label {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
|
||||
.grid-desc {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.section {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.section-more {
|
||||
font-size: 24rpx;
|
||||
color: #4A90D9;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 60rpx;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -1,85 +0,0 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="user-card">
|
||||
<view class="avatar-wrap">
|
||||
<image class="avatar" :src="userStore.userInfo?.avatarUrl || defaultAvatar" mode="aspectFill" />
|
||||
</view>
|
||||
<view class="user-info">
|
||||
<text class="nickname">{{ userStore.userInfo?.nickname || '未登录' }}</text>
|
||||
<text class="user-desc" v-if="userStore.isLogin">欢迎使用湖南12301文旅专区</text>
|
||||
<text class="user-desc" v-else @click="goLogin">点击登录</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="menu-card">
|
||||
<view class="menu-item" @click="goTo('/packages/user/pages/card/bind')">
|
||||
<text class="menu-icon">🎫</text>
|
||||
<text class="menu-text">我的年卡</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
<view class="menu-item" @click="showComingSoon">
|
||||
<text class="menu-icon">📦</text>
|
||||
<text class="menu-text">订单管理</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
<view class="menu-item" @click="showComingSoon">
|
||||
<text class="menu-icon">📋</text>
|
||||
<text class="menu-text">使用记录</text>
|
||||
<text class="menu-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn-area" v-if="userStore.isLogin">
|
||||
<button class="btn-logout" @click="handleLogout">退出登录</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useUserStore } from '../../../../store/user'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const defaultAvatar = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
||||
|
||||
/** 跳转登录页 */
|
||||
function goLogin() { uni.navigateTo({ url: '/pages/login/login' }) }
|
||||
|
||||
/** 需要登录的页面跳转 */
|
||||
function goTo(url: string) {
|
||||
if (!userStore.isLogin) { uni.navigateTo({ url: '/pages/login/login' }); return }
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
/** 退出登录 */
|
||||
function handleLogout() {
|
||||
uni.showModal({
|
||||
title: '提示', content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
userStore.logout()
|
||||
uni.showToast({ title: '已退出', icon: 'success' })
|
||||
setTimeout(() => { uni.navigateTo({ url: '/pages/login/login' }) }, 1000)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 即将上线提示 */
|
||||
function showComingSoon() { uni.showToast({ title: '即将上线,敬请期待', icon: 'none' }) }
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page { min-height: 100vh; background: #f5f5f5; }
|
||||
.user-card { background: linear-gradient(135deg, #4A90D9, #357ABD); padding: 50rpx 30rpx 40rpx; display: flex; align-items: center; }
|
||||
.avatar-wrap { margin-right: 24rpx; }
|
||||
.avatar { width: 120rpx; height: 120rpx; border-radius: 50%; border: 4rpx solid rgba(255,255,255,0.5); background: #eee; }
|
||||
.user-info { display: flex; flex-direction: column; }
|
||||
.nickname { font-size: 34rpx; font-weight: bold; color: #fff; margin-bottom: 8rpx; }
|
||||
.user-desc { font-size: 24rpx; color: rgba(255,255,255,0.8); }
|
||||
.menu-card { background: #fff; border-radius: 16rpx; margin: 20rpx; overflow: hidden; }
|
||||
.menu-item { display: flex; align-items: center; padding: 30rpx; border-bottom: 1rpx solid #f0f0f0; }
|
||||
.menu-item:last-child { border-bottom: none; }
|
||||
.menu-icon { font-size: 36rpx; margin-right: 20rpx; }
|
||||
.menu-text { flex: 1; font-size: 28rpx; color: #333; }
|
||||
.menu-arrow { font-size: 36rpx; color: #ccc; }
|
||||
.btn-area { padding: 40rpx 20rpx; }
|
||||
.btn-logout { width: 100%; height: 88rpx; line-height: 88rpx; background: #fff; color: #E74C3C; border-radius: 44rpx; font-size: 30rpx; border: 1rpx solid #f0f0f0; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user