fix: 需要资格的商品每个订单消耗1个资格

- 移除后台商品管理的资格消耗设置
- 修改后端资格检查和扣除逻辑为每个订单项消耗1个资格
- 修改前端显示为需要1个资格

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 18:08:26 +08:00
parent 057244d4b3
commit ec0a30c43d
4 changed files with 16 additions and 23 deletions
+3 -5
View File
@@ -34,7 +34,7 @@
<p class="description">{{ product.description }}</p>
<div class="meta">
<el-tag v-if="product.require_credit" :type="hasEnoughCredit() ? 'warning' : 'danger'">
{{ $t('product.requireCredit') }}: {{ product.credit_cost * quantity }}
{{ $t('product.requireCredit') }}: 1
<span v-if="!hasEnoughCredit()"> (资格不足)</span>
</el-tag>
<el-tag v-if="product.credit_reward > 0" type="success">+{{ product.credit_reward * quantity }} {{ $t('product.creditReward') }}</el-tag>
@@ -88,8 +88,7 @@ const productImages = computed(() => {
// 检查用户是否有足够资格购买
function hasEnoughCredit(): boolean {
if (!product.value || !product.value.require_credit) return true
const totalCost = product.value.credit_cost * quantity.value
return userCredits.value >= totalCost
return userCredits.value >= 1
}
// 获取用户资格信息
@@ -114,8 +113,7 @@ onMounted(async () => {
async function addToCart() {
// 检查购物资格
if (!hasEnoughCredit()) {
const totalCost = product.value.credit_cost * quantity.value
ElMessage.warning(`资格不足!需要 ${totalCost} 资格,您当前只有 ${userCredits.value} 资格`)
ElMessage.warning(`资格不足!该商品需要1个资格,您当前只有 ${userCredits.value} 资格`)
return
}