feat: fetch subscription prices from server settings

- Add GET /api/v1/subscription/plans public endpoint (no auth needed)
  that reads prices from system_settings table
- Subscribe-plans page now loads prices from server on show
- Falls back to hardcoded defaults if API fails
- Add api.getPlans() to miniprogram API module
这个提交包含在:
Guoguo
2026-04-29 08:07:47 -07:00
父节点 71e4a487a5
当前提交 e8f076c914
修改 3 个文件,包含 47 行新增4 行删除
+12
查看文件
@@ -13,6 +13,18 @@ const PLANS = {
yearly: { amount: 899, days: 365 }
}
router.get('/subscription/plans', wrap(async (req, res) => {
const settingsDao = require('../dao/settings.dao')
const settings = await settingsDao.getAll()
res.json(ok({
plans: [
{ key: 'monthly', name: '月卡', price: Number(settings.monthly_price) || PLANS.monthly.amount, days: 30 },
{ key: 'yearly', name: '年卡', price: Number(settings.yearly_price) || PLANS.yearly.amount, days: 365 },
{ key: 'trial', name: '试用', price: 0, days: Number(settings.trial_days) || 7 }
]
}))
}))
router.get('/subscription', requireUser, wrap(async (req, res) => {
const sub = await subscriptionDao.findActive(req.user.user_id)
if (!sub) return res.json(ok({ status: 'inactive', plan: 'none', remaining_days: 0 }))