后端(补齐前端已入口但无接口的模块): - Coupon 控制器:center 领券中心 / my 我的券(未使用·已使用·已过期+计数)/ receive 领取 含库存与过期校验、重复领取拦截、领券后自动发消息 - Message 控制器:index 列表(分类筛选)/ read 单条已读 / readAll 全部已读 / unread 角标 支持 user 与 master 两种归属 前端(对应页面,全部接真接口): - pages/address/list 服务地址:列表 / 新增·编辑弹层 / 设为默认 / 删除 - pages/coupon/coupon 领券中心 + 我的券(双 Tab + 状态筛选 + 计数) - pages/message/message 消息中心:分类 / 未读圆点 / 点开自动已读 / 全部已读 / 跳订单 - mine.vue 三个入口(地址·优惠券·消息)由「开发中」改为真实路由 - merchant/workbench 服务地址入口接真实路由 - 首页 TabBar「消息」接入消息中心 - api.js 新增 coupon/message 共 7 个接口 后台登录页(UI 与前端主色调统一): - 左侧橙金渐变品牌区:logo 徽标 + 「优匠优服」立体字 + slogan + 460万+/99.9%/1762万 平台实力 + 保障条 - 右侧白色登录卡:橙色渐变按钮、圆角输入框、错误提示条 - 保留 FastAdmin 全部挂钩(token/验证码/keeplogin/@AdminLoginFormBegin 等 14 项) 验证:5 套用例 178 项断言全通过(47+65+27+24+15),配置自检 8/8
133 行
5.1 KiB
Vue
133 行
5.1 KiB
Vue
<template>
|
|
<view class="page">
|
|
<view class="tabs">
|
|
<view class="tab" :class="{ on: tab === 'center' }" @tap="switchTab('center')">领券中心</view>
|
|
<view class="tab" :class="{ on: tab === 'mine' }" @tap="switchTab('mine')">我的券{{ counts.unused ? '(' + counts.unused + ')' : '' }}</view>
|
|
</view>
|
|
|
|
<view class="list" v-if="tab === 'center'">
|
|
<view class="cp" v-for="c in center" :key="c.id">
|
|
<view class="cp-l">
|
|
<text class="cp-val">{{ c.value_text }}</text>
|
|
<text class="cp-rule">{{ c.rule_text }}</text>
|
|
</view>
|
|
<view class="cp-m">
|
|
<text class="cp-name">{{ c.name }}</text>
|
|
<text class="cp-time">{{ c.time_text }}</text>
|
|
</view>
|
|
<view class="cp-btn" :class="{ done: c.received_by_me || c.sold_out }" @tap="receive(c)">
|
|
{{ c.received_by_me ? '已领取' : (c.sold_out ? '已领完' : '领取') }}
|
|
</view>
|
|
</view>
|
|
<view class="empty" v-if="!loading && !center.length">暂无可领取的优惠券</view>
|
|
</view>
|
|
|
|
<view class="list" v-else>
|
|
<view class="tabs2">
|
|
<view v-for="t in statusTabs" :key="t.key" class="tab2" :class="{ on: status === t.key }" @tap="switchStatus(t.key)">
|
|
{{ t.name }}{{ counts[t.key] ? ' ' + counts[t.key] : '' }}
|
|
</view>
|
|
</view>
|
|
<view class="cp" :class="{ dim: status !== 'unused' }" v-for="c in mine" :key="c.id">
|
|
<view class="cp-l">
|
|
<text class="cp-val">{{ c.value_text }}</text>
|
|
<text class="cp-rule">{{ c.rule_text }}</text>
|
|
</view>
|
|
<view class="cp-m">
|
|
<text class="cp-name">{{ c.name }}</text>
|
|
<text class="cp-time">{{ c.time_text }}</text>
|
|
</view>
|
|
<view class="cp-btn use" v-if="status === 'unused'" @tap="goOrder">去使用</view>
|
|
</view>
|
|
<view class="empty" v-if="!loading && !mine.length">暂无优惠券</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue';
|
|
import { onShow } from '@dcloudio/uni-app';
|
|
import api from '@/utils/api.js';
|
|
import { isLogin, toLogin } from '@/utils/request.js';
|
|
|
|
const tab = ref('center');
|
|
const status = ref('unused');
|
|
const center = ref([]);
|
|
const mine = ref([]);
|
|
const counts = ref({ unused: 0, used: 0, expired: 0 });
|
|
const loading = ref(false);
|
|
|
|
const statusTabs = [
|
|
{ key: 'unused', name: '未使用' },
|
|
{ key: 'used', name: '已使用' },
|
|
{ key: 'expired', name: '已过期' }
|
|
];
|
|
|
|
function switchTab(t) {
|
|
tab.value = t;
|
|
if (t === 'center') loadCenter(); else loadMine();
|
|
}
|
|
function switchStatus(s) { status.value = s; loadMine(); }
|
|
function goOrder() { uni.reLaunch({ url: '/YJYF/YJYF' }); }
|
|
|
|
async function loadCenter() {
|
|
if (!isLogin()) { toLogin(); return; }
|
|
loading.value = true;
|
|
try {
|
|
const res = await api.couponCenter();
|
|
center.value = res.list || [];
|
|
} catch (e) {
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
async function loadMine() {
|
|
if (!isLogin()) { toLogin(); return; }
|
|
loading.value = true;
|
|
try {
|
|
const res = await api.couponMy({ status: status.value });
|
|
mine.value = res.list || [];
|
|
if (res.counts) counts.value = res.counts;
|
|
} catch (e) {
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
async function receive(c) {
|
|
if (c.received_by_me) { uni.showToast({ title: '已领取过了', icon: 'none' }); return; }
|
|
if (c.sold_out) { uni.showToast({ title: '已被领完', icon: 'none' }); return; }
|
|
try {
|
|
await api.couponReceive({ coupon_id: c.id });
|
|
uni.showToast({ title: '领取成功' });
|
|
loadCenter();
|
|
} catch (e) {}
|
|
}
|
|
|
|
onShow(() => loadCenter());
|
|
</script>
|
|
|
|
<style scoped>
|
|
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 40rpx; }
|
|
.tabs { display: flex; background: #fff; box-shadow: 0 4rpx 12rpx rgba(0,0,0,.03); }
|
|
.tab { flex: 1; text-align: center; padding: 26rpx 0; font-size: 28rpx; color: #666; }
|
|
.tab.on { color: #F0710D; font-weight: 700; }
|
|
.tabs2 { display: flex; padding: 0 0 16rpx; }
|
|
.tab2 { margin-right: 16rpx; padding: 0 24rpx; line-height: 56rpx; border-radius: 28rpx; background: #fff; font-size: 24rpx; color: #666; }
|
|
.tab2.on { background: #FFF3E6; color: #E36B0C; font-weight: 600; }
|
|
.list { padding: 22rpx 28rpx; }
|
|
.cp { display: flex; align-items: center; background: #fff; border-radius: 20rpx; padding: 24rpx; margin-bottom: 18rpx; box-shadow: 0 6rpx 20rpx rgba(240,129,31,.06); }
|
|
.cp.dim { opacity: .6; }
|
|
.cp-l { width: 150rpx; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; padding-right: 18rpx; border-right: 1rpx dashed #F0DCC8; }
|
|
.cp-val { font-size: 40rpx; font-weight: 800; color: #F0710D; }
|
|
.cp-rule { margin-top: 4rpx; font-size: 18rpx; color: #B5B5B5; }
|
|
.cp-m { flex: 1; min-width: 0; padding-left: 18rpx; display: flex; flex-direction: column; }
|
|
.cp-name { font-size: 28rpx; font-weight: 600; color: #1F1F1F; }
|
|
.cp-time { margin-top: 6rpx; font-size: 20rpx; color: #9A9A9A; }
|
|
.cp-btn { flex-shrink: 0; margin-left: 12rpx; padding: 0 26rpx; line-height: 60rpx; border-radius: 30rpx; color: #fff; font-size: 24rpx; font-weight: 600; background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%); }
|
|
.cp-btn.done { background: #EEE; color: #9A9A9A; }
|
|
.cp-btn.use { background: #FFF3E6; color: #E36B0C; }
|
|
.empty { padding: 100rpx 0; text-align: center; font-size: 24rpx; color: #9A9A9A; }
|
|
</style>
|