feat(marketing): implement recharge tiers and coupon management across admin, server, and uniapp

这个提交包含在:
xcbyy
2026-10-10 09:22:46 +08:00
父节点 51682fffea
当前提交 d9c8388711
共有 12 个文件被更改,包括 1494 次插入 和 7 次删除

查看文件

@@ -579,6 +579,37 @@ export async function getNavCategories() {
return null;
}
/**
* 获取钱包充值阶梯与赠送配置列表 (真实从 MySQL 读取)
*/
export async function getRechargeTiers() {
try {
const res = await http.get('/marketing/recharge-tiers');
if (Array.isArray(res) && res.length > 0) {
return res;
}
} catch (err) {
console.warn('[API] 获取充值阶梯异常:', err.message);
}
return null;
}
/**
* 获取可用优惠券列表 (支持品类过滤)
*/
export async function getMarketingCoupons(category) {
try {
const query = category ? `?category=${category}` : '';
const res = await http.get(`/marketing/coupons${query}`);
if (Array.isArray(res) && res.length > 0) {
return res;
}
} catch (err) {
console.warn('[API] 获取营销优惠券异常:', err.message);
}
return null;
}

查看文件

@@ -218,7 +218,7 @@ import { ICONS } from '@/common/icons.js';
import { getCurrentThemeKey, setTheme, THEME_KEYS, applyThemeToNativeUI } from '@/common/theme.js';
import { getCurrentRole, setCurrentRole, ROLE_TYPES, toggleRole as toggleUserRole, isExpertCertified, getExpertCertStatus, setExpertCertStatus, CERT_STATUS } from '@/common/role.js';
import { getNavBarInfo } from '@/common/nav.js';
import { getUserProfile, rechargeBalance, withdrawCommission, getUserFinanceRecords, updateUserProfile, uploadImage } from '@/common/api.js';
import { getUserProfile, rechargeBalance, withdrawCommission, getUserFinanceRecords, updateUserProfile, uploadImage, getRechargeTiers } from '@/common/api.js';
const user = ref({
id: 1001,
@@ -453,21 +453,45 @@ const viewWalletLog = async () => {
}
};
const handleRecharge = () => {
const handleRecharge = async () => {
let tiers = [];
try {
const list = await getRechargeTiers();
if (Array.isArray(list) && list.length > 0) {
tiers = list;
}
} catch (_) {}
if (tiers.length === 0) {
tiers = [
{ amount: 50, bonusAmount: 0, tag: '基础充值' },
{ amount: 100, bonusAmount: 5, tag: '热门畅享' },
{ amount: 200, bonusAmount: 15, tag: '超值加赠' },
{ amount: 500, bonusAmount: 50, tag: '尊享特惠' }
];
}
const itemList = tiers.map((t) => {
const bonus = Number(t.bonusAmount) > 0 ? ` (赠¥${Number(t.bonusAmount)})` : '';
const tag = t.tag ? ` [${t.tag}]` : '';
return `充值 ¥${Number(t.amount)}${bonus}${tag}`;
});
uni.showActionSheet({
itemList: ['快捷充值 ¥50', '快捷充值 ¥100', '快捷充值 ¥200', '快捷充值 ¥500'],
itemList,
success: async (res) => {
const amounts = [50, 100, 200, 500];
const amount = amounts[res.tapIndex] || 50;
const selected = tiers[res.tapIndex] || tiers[0];
const amount = Number(selected.amount);
try {
const result = await rechargeBalance(1001, amount);
if (result && result.balance) {
user.value.balance = result.balance;
}
const bonusMsg = Number(selected.bonusAmount) > 0 ? `,加赠 ¥${Number(selected.bonusAmount)} 已同步入账` : '';
uni.showToast({
title: `充值 ¥${amount} 成功!`,
title: `充值 ¥${amount} 成功${bonusMsg}!`,
icon: 'success',
duration: 1800
duration: 2000
});
} catch (err) {
uni.showToast({