diff --git a/api/appUser.js b/api/appUser.js index 7274af0..b59a53d 100644 --- a/api/appUser.js +++ b/api/appUser.js @@ -399,8 +399,18 @@ export function getGamePassPackages(activity_id) { * @param {number} package_id - 套餐ID * @param {number} count - 购买数量 */ -export function purchaseGamePass(package_id, count = 1) { - return authRequest({ url: '/api/app/game-passes/purchase', method: 'POST', data: { package_id, count } }) +/** + * 购买次数卡套餐 + * @param {number} package_id - 套餐ID + * @param {number} count - 购买数量 + * @param {Array} coupon_ids - 优惠券ID列表 + */ +export function purchaseGamePass(package_id, count = 1, coupon_ids = []) { + const data = { package_id, count } + if (coupon_ids && coupon_ids.length > 0) { + data.coupon_ids = coupon_ids + } + return authRequest({ url: '/api/app/game-passes/purchase', method: 'POST', data }) } /** diff --git a/components/GamePassPurchasePopup.vue b/components/GamePassPurchasePopup.vue index 0768b4f..64b5541 100644 --- a/components/GamePassPurchasePopup.vue +++ b/components/GamePassPurchasePopup.vue @@ -3,7 +3,7 @@ - 使用次数(次数需使用完,剩余次数不可退) + 购买次数卡(次数需使用完,剩余次数不可退) × @@ -19,8 +19,8 @@ v-for="(pkg, index) in packages" :key="pkg.id" class="package-item" - :class="{ 'best-value': pkg.is_best_value }" - @tap="handlePurchase(pkg)" + :class="{ 'best-value': pkg.is_best_value, 'selected': selectedPkgId === pkg.id }" + @tap="selectPackage(pkg)" > {{ pkg.tag }} @@ -32,10 +32,10 @@ ¥ - {{ (pkg.price / 100).toFixed(2) }} + {{ (getTotalPrice(pkg) / 100).toFixed(2) }} - ¥{{ (pkg.original_price / 100).toFixed(2) }} + ¥{{ (pkg.original_price * (counts[pkg.id] || 1) / 100).toFixed(2) }} @@ -50,21 +50,63 @@ /> + - + + + + 优惠券 + + + + + {{ selectedCoupon.name }} + (-¥{{ effectiveCouponDiscount.toFixed(2) }}) + (最高抵扣50%) + + 暂无可用优惠券 + 请选择优惠券 + + + + + + + + + + + 合计: + ¥{{ finalPayAmount.toFixed(2) }} + 已优惠 ¥{{ effectiveCouponDiscount.toFixed(2) }} + + + + + +