feat: 景区详情页优化 + 代码质量修复 + 首页适配

- 详情页:地图按钮改为复制地址,电话点击直接拨号
- 详情页:移除免X次/年徽章,增加信息卡片与卡种卡片间距
- 详情页:运营状态实时判断(根据营业时间自动显示营业中/已闭园)
- 详情页:轮播圆点仅多图时显示,加大尺寸+投影,z-index置顶
- 详情页:景区电话箭头靠右对齐
- 首页:热门景点两列布局改用padding方案,修复小屏手机单列显示
- 代码质量:card/order API移入分包,消除主包未使用JS文件
- 代码质量:manifest启用minified和lazyCodeLoading
- 构建:vite配置静默Sass弃用警告

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
jacobxu666
2026-06-25 19:19:40 +08:00
co-authored by Claude
parent ee2fd39dcd
commit 5524d78229
14 changed files with 8682 additions and 64 deletions
+3 -2
View File
@@ -6,7 +6,8 @@
"urlCheck": false,
"es6": true,
"postcss": false,
"minified": false
}
"minified": true
},
"lazyCodeLoading": "requiredComponents"
}
}
@@ -1,5 +1,5 @@
import { get, post } from './request'
import type { CardInfo, CardDetail, MyCard, ActivateParams, QrCodeInfo } from './types'
import { get, post } from '../../../api/request'
import type { CardInfo, CardDetail, MyCard, ActivateParams, QrCodeInfo } from '../../../api/types'
/** 获取年卡列表 */
export function getCardList(params?: { keyword?: string; category?: string }): Promise<CardInfo[]> {
@@ -1,5 +1,5 @@
import { get, post } from './request'
import type { OrderInfo, CreateOrderParams, MockPayResult } from './types'
import { get, post } from '../../../api/request'
import type { OrderInfo, CreateOrderParams, MockPayResult } from '../../../api/types'
/** 创建订单 */
export function createOrder(data: CreateOrderParams): Promise<OrderInfo> {
+1 -1
View File
@@ -32,7 +32,7 @@
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { activateCard } from '../../../../api/card'
import { activateCard } from '../../api/card'
import { showToast } from '../../../../utils'
const cardId = ref('')
+1 -1
View File
@@ -23,7 +23,7 @@
<script setup lang="ts">
import { ref } from 'vue'
import { bindCard } from '../../../../api/card'
import { bindCard } from '../../api/card'
import { showToast } from '../../../../utils'
const cardNo = ref('')
+1 -1
View File
@@ -41,7 +41,7 @@
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { createOrder, mockPay } from '../../../../api/order'
import { createOrder, mockPay } from '../../api/order'
import { showToast } from '../../../../utils'
const cardId = ref('')
+1 -1
View File
@@ -66,7 +66,7 @@
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getCardDetail } from '../../../../api/card'
import { getCardDetail } from '../../api/card'
import type { CardDetail } from '../../../../api/types'
const card = ref<CardDetail | null>(null)
+1 -1
View File
@@ -55,7 +55,7 @@
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getCardList } from '../../../../api/card'
import { getCardList } from '../../api/card'
import CardItem from '../../../../components/card-item.vue'
import type { CardInfo } from '../../../../api/types'
+1 -1
View File
@@ -25,7 +25,7 @@
<script setup lang="ts">
import { ref, onBeforeUnmount } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getEntryQrCode } from '../../../../api/card'
import { getEntryQrCode } from '../../api/card'
import { showToast } from '../../../../utils'
import type { QrCodeInfo } from '../../../../api/types'
+22 -16
View File
@@ -107,21 +107,22 @@
:key="spot.id"
class="spot animate-fade-in-up"
:class="`stagger-${Math.min(idx + 4, 10)}`"
@click="goSpot(spot)"
>
<view class="spot-cover">
<image class="spot-img" :src="spot.image" mode="aspectFill" />
<view class="spot-region">
<view class="pin-dot" />
<text>{{ spot.region }}</text>
<view class="spot-inner" @click="goSpot(spot)">
<view class="spot-cover">
<image class="spot-img" :src="spot.image" mode="aspectFill" />
<view class="spot-region">
<view class="pin-dot" />
<text>{{ spot.region }}</text>
</view>
</view>
</view>
<view class="spot-body">
<text class="spot-name">{{ spot.name }}</text>
<view class="spot-meta">
<text class="spot-price">¥{{ spot.price }}</text>
<view class="spot-benefit">
<text>{{ spot.benefit }}</text>
<view class="spot-body">
<text class="spot-name">{{ spot.name }}</text>
<view class="spot-meta">
<text class="spot-price">¥{{ spot.price }}</text>
<view class="spot-benefit">
<text>{{ spot.benefit }}</text>
</view>
</view>
</view>
</view>
@@ -588,15 +589,20 @@ function goMore() {
color: $color-muted-foreground;
}
/* Spots grid — 2 column */
/* Spots grid — 2 column (避免 gap 兼容问题,用 padding 模拟间距) */
.spots-grid {
display: flex;
flex-wrap: wrap;
gap: $spacing-2;
margin: 0 (-$spacing-1);
}
.spot {
width: calc(50% - #{$spacing-1});
width: 50%;
padding: $spacing-1;
box-sizing: border-box;
}
.spot-inner {
background: $color-card;
border-radius: $radius-lg;
overflow: hidden;
+79 -34
View File
@@ -3,10 +3,10 @@
<!-- 模块1:轮播大图 -->
<swiper
class="hero-swiper"
:indicator-dots="true"
:indicator-dots="scenic.images.length > 1"
indicator-color="rgba(255,255,255,0.4)"
indicator-active-color="#ffffff"
autoplay
:autoplay="scenic.images.length > 1"
circular
:interval="4000"
>
@@ -20,9 +20,6 @@
<!-- 标题行 -->
<view class="title-row">
<text class="scenic-name">{{ scenic.name }}</text>
<view v-if="scenic.freeCount > 0" class="free-badge">
<text>免{{ scenic.freeCount }}次/年</text>
</view>
</view>
<!-- 预约提醒横幅 -->
@@ -43,25 +40,29 @@
<text class="text-assist">{{ scenic.bookingDeadline }}</text>
</view>
<!-- 开放时间 -->
<!-- 开放时间 + 运营状态 -->
<view class="info-line" @click="onHoursClick">
<view class="icon-wrap icon-clock" />
<text class="text-body">{{ scenic.hours }}</text>
<view class="status-tag" :class="isOpen ? 'open' : 'closed'">
<view class="status-dot" />
<text>{{ isOpen ? '营业中' : '已闭园' }}</text>
</view>
</view>
<!-- 联系电话 -->
<view class="info-line clickable" @click="onPhoneClick">
<view class="icon-wrap icon-phone" />
<text class="text-body">{{ scenic.phone }}</text>
<view class="icon-wrap icon-chevron" />
<view class="icon-wrap icon-chevron chevron-right" />
</view>
<!-- 地址 -->
<view class="info-line clickable" @click="onMapClick">
<view class="info-line clickable" @click="onCopyAddress">
<view class="icon-wrap icon-map-pin" />
<text class="text-body address-text">{{ scenic.address }}</text>
<view class="map-btn" @click.stop="onMapClick">
<text>地图</text>
<view class="map-btn" @click.stop="onCopyAddress">
<text>复制</text>
</view>
</view>
</view>
@@ -131,7 +132,7 @@
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
interface NoticeItem { title: string; content: string }
@@ -146,6 +147,19 @@ interface ScenicDetail {
const scenic = ref<ScenicDetail>({ tags: [], images: [], cards: [], bookingNotice: [] } as unknown as ScenicDetail)
const activeTab = ref<'notice' | 'intro'>('notice')
/** 根据营业时间判断运营状态 */
const isOpen = computed(() => {
const h = scenic.value.hours
if (!h || h.includes('暂停') || h.includes('闭')) return false
const match = h.match(/(\d{2}):(\d{2})\s*-\s*(\d{2}):(\d{2})/)
if (!match) return true
const now = new Date()
const current = now.getHours() * 60 + now.getMinutes()
const open = parseInt(match[1]) * 60 + parseInt(match[2])
const close = parseInt(match[3]) * 60 + parseInt(match[4])
return current >= open && current <= close
})
// 双卡种数据:超级玩家卡 remaining 与 freeCount 一致,年卡 remaining 稍多
function buildCards(freeCount: number): CardBenefit[] {
if (freeCount <= 0) return []
@@ -182,10 +196,15 @@ function onHoursClick() {
uni.showToast({ title: '营业时间仅供参考', icon: 'none' })
}
function onPhoneClick() {
uni.showToast({ title: '联系电话功能开发中', icon: 'none' })
uni.makePhoneCall({ phoneNumber: scenic.value.phone })
}
function onMapClick() {
uni.showToast({ title: '地图导航开发中', icon: 'none' })
function onCopyAddress() {
uni.setClipboardData({
data: scenic.value.address,
success: () => {
uni.showToast({ title: '地址已复制', icon: 'success' })
}
})
}
function onBookClick(cardType: string) {
const label = cardType === 'super' ? '超级玩家卡' : '赣湘全域旅游年卡'
@@ -221,6 +240,7 @@ $icon-crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' w
.icon-clock { background-image: $icon-clock; }
.icon-phone { background-image: $icon-phone; }
.icon-chevron { background-image: $icon-chevron; }
.chevron-right { margin-left: auto; }
.icon-map-pin { background-image: $icon-map-pin; }
.icon-crown { background-image: $icon-crown; }
@@ -251,6 +271,24 @@ $icon-crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' w
.hero-swiper {
width: 100%;
height: 480rpx;
:deep(.uni-swiper-dots) {
z-index: 10;
bottom: 64rpx !important;
}
:deep(.uni-swiper-dot) {
width: 16rpx;
height: 16rpx;
border-radius: 50%;
margin: 0 8rpx !important;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.3);
}
:deep(.uni-swiper-dot-active) {
width: 32rpx;
border-radius: 8rpx;
}
}
.hero-img {
width: 100%;
@@ -278,25 +316,6 @@ $icon-crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' w
.scenic-name {
@extend .text-title;
flex: 1;
margin-right: $spacing-2;
}
.free-badge {
display: flex;
align-items: center;
justify-content: center;
padding: 6rpx 16rpx;
background: $uv-primary;
border-radius: $radius-sm;
flex-shrink: 0;
min-height: 40rpx;
text {
font-size: 22rpx;
color: #fff;
font-weight: $font-weight-semibold;
line-height: 1;
}
}
.notice-banner {
@@ -363,6 +382,32 @@ $icon-crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' w
line-height: 1.5;
}
/* 运营状态标签 */
.status-tag {
display: flex;
align-items: center;
gap: 8rpx;
margin-left: auto;
flex-shrink: 0;
text {
font-size: 24rpx;
font-weight: $font-weight-medium;
}
&.open text { color: $uv-success; }
&.closed text { color: $uv-error; }
}
.status-dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
.open & { background: $uv-success; }
.closed & { background: $uv-error; }
}
.map-btn {
padding: 8rpx 20rpx;
background: $uv-primary-light;
@@ -381,7 +426,7 @@ $icon-crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' w
/* ====== 模块3:卡种权益卡片 ====== */
.benefit-card {
background: $color-card;
margin: 0 $spacing-3 $spacing-2;
margin: $spacing-3 $spacing-3 $spacing-2;
padding: $spacing-3;
border-radius: $radius-lg;
box-shadow: $shadow-sm;
+2 -2
View File
@@ -197,8 +197,8 @@ const stickyHeaderHeight = ref(96) // 预估,onMounted 后精确测量
// 页面加载时获取系统信息
;(function initNavBar() {
try {
const sysInfo = uni.getSystemInfoSync()
statusBarHeight.value = sysInfo.statusBarHeight || 20
const windowInfo = uni.getWindowInfo()
statusBarHeight.value = windowInfo.statusBarHeight || 20
} catch {
statusBarHeight.value = 20
}