This commit is contained in:
18631081161 2026-04-11 16:31:36 +08:00
parent bf989067c1
commit 2635edda7b
13 changed files with 241 additions and 73 deletions

View File

@ -41,7 +41,13 @@ builder.Services.AddAuthentication(options =>
builder.Services.AddAuthorization();
// Controllers
builder.Services.AddControllers();
builder.Services.AddControllers()
.AddJsonOptions(options =>
{
// 支持枚举字符串序列化/反序列化
options.JsonSerializerOptions.Converters.Add(new System.Text.Json.Serialization.JsonStringEnumConverter());
options.JsonSerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
});
// CORS 配置(支持移动端和管理后台跨域请求)
builder.Services.AddCors(options =>

View File

@ -37,6 +37,7 @@ export default {
stamps: 'Stamps',
qrcode: 'QR Code',
guide: 'Guide',
redeemableCoupons: 'Redeemable Coupons',
redeemBtn: 'Redeem',
redeemSuccess: 'Redeemed successfully',
redeemFail: 'Insufficient points',

View File

@ -37,6 +37,7 @@ export default {
stamps: '节日印花',
qrcode: '会员二维码',
guide: '使用说明',
redeemableCoupons: '可兑换优惠券',
redeemBtn: '兑换',
redeemSuccess: '兑换成功',
redeemFail: '积分不足,无法兑换',

View File

@ -37,6 +37,7 @@ export default {
stamps: '節日印花',
qrcode: '會員二維碼',
guide: '使用說明',
redeemableCoupons: '可兌換優惠券',
redeemBtn: '兌換',
redeemSuccess: '兌換成功',
redeemFail: '積分不足,無法兌換',

View File

@ -76,14 +76,14 @@
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "static/tab-home.png",
"selectedIconPath": "static/tab-home-active.png"
"iconPath": "static/tab/ic_home.png",
"selectedIconPath": "static/tab/ic_home_s.png"
},
{
"pagePath": "pages/mine/mine",
"text": "我的",
"iconPath": "static/tab-mine.png",
"selectedIconPath": "static/tab-mine-active.png"
"iconPath": "static/tab/ic_me.png",
"selectedIconPath": "static/tab/ic_me_s.png"
}
]
}

View File

@ -1,33 +1,70 @@
<template>
<view class="home-page">
<!-- Banner轮播图 -->
<swiper class="banner-swiper" autoplay circular indicator-dots>
<swiper-item v-for="banner in banners" :key="banner.id" @click="onBannerClick(banner)">
<image class="banner-image" :src="resolveImageUrl(banner.imageUrl)" mode="aspectFill" />
</swiper-item>
</swiper>
<view class="banner-wrap">
<swiper class="banner-swiper" autoplay circular indicator-dots indicator-color="rgba(255,255,255,0.4)" indicator-active-color="#ffffff">
<swiper-item v-for="banner in banners" :key="banner.id" @click="onBannerClick(banner)">
<image class="banner-image" :src="resolveImageUrl(banner.imageUrl)" mode="aspectFill" />
</swiper-item>
</swiper>
</view>
<!-- 功能入口网格 -->
<view class="entry-grid">
<view
v-for="entry in entries"
:key="entry.id"
class="entry-item"
@click="onEntryClick(entry)"
>
<image class="entry-image" :src="resolveImageUrl(entry.imageUrl)" mode="aspectFit" />
<text class="entry-label">{{ getEntryLabel(entry.key) }}</text>
<!-- 成为会员入口 -->
<view class="membership-entry" @click="onEntryClick({ key: 'membership' })">
<view class="membership-entry-left">
<view class="membership-icon-wrap">
<image class="membership-icon-img" src="/static/ic_vip.png" mode="aspectFit" />
</view>
<view class="membership-text">
<text class="membership-title">{{ t('home.membership') }}</text>
<text class="membership-sub">Unlock VIP Benefits</text>
</view>
</view>
<text class="membership-arrow"></text>
</view>
<!-- 功能入口节日印花 + 会员二维码 -->
<view class="entry-row">
<view class="entry-card" @click="onEntryClick({ key: 'stamps' })">
<image class="entry-icon" src="/static/ic_stamp.png" mode="aspectFit" />
<text class="entry-label">{{ t('home.stamps') }}</text>
</view>
<view class="entry-card" @click="onEntryClick({ key: 'qrcode' })">
<image class="entry-icon" src="/static/ic_qrcode.png" mode="aspectFit" />
<text class="entry-label">{{ t('home.qrcode') }}</text>
</view>
</view>
<!-- 可兑换优惠券列表 -->
<view class="coupon-section">
<CouponCard
v-for="coupon in coupons"
:key="coupon.couponId"
:coupon="coupon"
@redeem="onRedeemClick"
/>
<!-- 可兑换优惠券 -->
<view class="coupon-header">
<text class="coupon-title">{{ t('home.redeemableCoupons') || '可兑换优惠券' }}</text>
<view class="coupon-guide-link" @click="handleGuideEntry">
<text class="guide-icon"></text>
<text class="guide-text">{{ t('home.guide') }}</text>
</view>
</view>
<view class="coupon-list">
<view class="coupon-card" v-for="coupon in coupons" :key="coupon.couponId">
<view class="coupon-info">
<text class="coupon-name">{{ coupon.name }}</text>
<view class="coupon-detail-row">
<text class="coupon-dot"></text>
<text class="coupon-detail-label">到期时间</text>
<text class="coupon-detail-value highlight">{{ formatExpire(coupon.expireAt) }}</text>
</view>
<view class="coupon-detail-row">
<text class="coupon-dot"></text>
<text class="coupon-detail-label">兑换条件</text>
<text class="coupon-detail-value highlight">{{ coupon.requiredPoints }}积分</text>
</view>
</view>
<view class="coupon-action">
<view class="redeem-btn" @click="onRedeemClick(coupon)">
<text class="redeem-btn-text">兑换</text>
</view>
</view>
</view>
</view>
<!-- 使用说明弹窗 -->
@ -44,9 +81,6 @@
@confirm="onRedeemConfirm"
@cancel="showRedeem = false"
/>
<!-- 会员二维码弹窗占位由任务6实现 -->
<!-- <QrcodePopup :visible="showQrcode" @close="showQrcode = false" /> -->
</view>
</template>
@ -58,7 +92,6 @@ import { getRedeemableCoupons, redeemCoupon } from '../../api/coupon.js'
import { useUserStore } from '../../stores/user.js'
import { navigateBanner } from '../../utils/navigation.js'
import { resolveImageUrl } from '../../utils/image.js'
import CouponCard from '../../components/CouponCard.vue'
import RedeemPopup from '../../components/RedeemPopup.vue'
import CouponGuidePopup from '../../components/CouponGuidePopup.vue'
@ -77,17 +110,6 @@ const showRedeem = ref(false)
const selectedCoupon = ref(null)
const showQrcode = ref(false)
//
function getEntryLabel(key) {
const map = {
membership: t('home.membership'),
stamps: t('home.stamps'),
qrcode: t('home.qrcode'),
guide: t('home.guide')
}
return map[key] || key
}
// Banner
function onBannerClick(banner) {
navigateBanner(banner)
@ -124,9 +146,7 @@ async function handleQrcodeEntry() {
} else {
uni.navigateTo({ url: '/pages/membership/membership' })
}
} catch (e) {
//
}
} catch (e) {}
}
// 使
@ -135,9 +155,14 @@ async function handleGuideEntry() {
const res = await getCouponGuide()
guideContent.value = res.data?.content || res.data || ''
showGuide.value = true
} catch (e) {
//
}
} catch (e) {}
}
//
function formatExpire(dateStr) {
if (!dateStr) return '无限制'
const d = new Date(dateStr)
return `${d.getFullYear()}${d.getMonth() + 1}${d.getDate()}`
}
//
@ -154,11 +179,9 @@ async function onRedeemConfirm() {
showRedeem.value = false
selectedCoupon.value = null
uni.showToast({ title: t('home.redeemSuccess'), icon: 'none' })
//
await loadCoupons()
} catch (e) {
showRedeem.value = false
// message
}
}
@ -167,21 +190,21 @@ async function loadBanners() {
try {
const res = await getBanners()
banners.value = res.data || []
} catch (e) { /* 错误已统一处理 */ }
} catch (e) {}
}
async function loadEntries() {
try {
const res = await getEntries()
entries.value = res.data || []
} catch (e) { /* 错误已统一处理 */ }
} catch (e) {}
}
async function loadCoupons() {
try {
const res = await getRedeemableCoupons()
coupons.value = res.data || []
} catch (e) { /* 错误已统一处理 */ }
} catch (e) {}
}
onMounted(() => {
@ -194,47 +217,183 @@ onMounted(() => {
<style scoped>
.home-page {
min-height: 100vh;
background-color: #f5f5f5;
background-color: #f5f0e8;
}
/* Banner */
.banner-wrap {
padding: 24rpx 24rpx 0;
}
.banner-swiper {
width: 100%;
height: 360rpx;
height: 340rpx;
border-radius: 20rpx;
overflow: hidden;
}
.banner-image {
width: 100%;
height: 100%;
border-radius: 20rpx;
}
.entry-grid {
/* 成为会员入口 */
.membership-entry {
margin: 24rpx 24rpx 0;
background: linear-gradient(135deg, #4a5d4a, #3d4f3d);
border-radius: 20rpx;
padding: 30rpx 32rpx;
display: flex;
flex-wrap: wrap;
padding: 30rpx 20rpx;
background-color: #ffffff;
margin-bottom: 20rpx;
align-items: center;
justify-content: space-between;
}
.membership-entry-left {
display: flex;
align-items: center;
}
.membership-icon-wrap {
width: 64rpx;
height: 64rpx;
background: rgba(255, 255, 255, 0.15);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 20rpx;
}
.membership-icon-img {
width: 40rpx;
height: 40rpx;
}
.membership-text {
display: flex;
flex-direction: column;
}
.membership-title {
font-size: 30rpx;
color: #ffffff;
font-weight: 600;
margin-bottom: 4rpx;
}
.membership-sub {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.7);
}
.membership-arrow {
font-size: 40rpx;
color: rgba(255, 255, 255, 0.6);
}
.entry-item {
width: 25%;
/* 功能入口行 */
.entry-row {
display: flex;
padding: 24rpx 24rpx 0;
gap: 24rpx;
}
.entry-card {
flex: 1;
background-color: #ffffff;
border-radius: 20rpx;
padding: 36rpx 0;
display: flex;
flex-direction: column;
align-items: center;
padding: 16rpx 0;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
}
.entry-image {
width: 96rpx;
height: 96rpx;
margin-bottom: 12rpx;
.entry-icon {
width: 72rpx;
height: 72rpx;
margin-bottom: 16rpx;
}
.entry-label {
font-size: 24rpx;
font-size: 26rpx;
color: #333;
}
.coupon-section {
/* 优惠券标题行 */
.coupon-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 36rpx 24rpx 16rpx;
}
.coupon-title {
font-size: 32rpx;
color: #333;
font-weight: 600;
}
.coupon-guide-link {
display: flex;
align-items: center;
}
.guide-icon {
font-size: 28rpx;
color: #999;
margin-right: 6rpx;
}
.guide-text {
font-size: 24rpx;
color: #999;
}
/* 优惠券列表 */
.coupon-list {
padding: 0 24rpx 24rpx;
}
.coupon-card {
background-color: #ffffff;
border-radius: 20rpx;
padding: 32rpx;
margin-bottom: 20rpx;
display: flex;
align-items: flex-end;
justify-content: space-between;
}
.coupon-info {
flex: 1;
margin-right: 20rpx;
}
.coupon-name {
font-size: 34rpx;
color: #333;
font-weight: 600;
display: block;
margin-bottom: 16rpx;
}
.coupon-detail-row {
display: flex;
align-items: center;
margin-bottom: 8rpx;
}
.coupon-dot {
font-size: 14rpx;
color: #c9a96e;
margin-right: 10rpx;
}
.coupon-detail-label {
font-size: 24rpx;
color: #666;
}
.coupon-detail-value {
font-size: 24rpx;
color: #666;
}
.coupon-detail-value.highlight {
color: #c9a96e;
font-weight: 500;
}
/* 兑换按钮 */
.coupon-action {
flex-shrink: 0;
}
.redeem-btn {
background: linear-gradient(135deg, #d4a855, #c9a96e);
border-radius: 36rpx;
padding: 16rpx 40rpx;
}
.redeem-btn-text {
font-size: 26rpx;
color: #ffffff;
white-space: nowrap;
}
</style>

BIN
mobile/static/ic_qrcode.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
mobile/static/ic_stamp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
mobile/static/ic_vip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
mobile/static/tab/ic_me.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB