优惠券请求的问题: 小程序没有请求
This commit is contained in:
parent
6da73a1955
commit
3b0bf07f77
@ -159,7 +159,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { onLoad, onUnload } from '@dcloudio/uni-app'
|
||||
import { getIssueChoices, joinLottery, createWechatOrder, getLotteryResult } from '@/api/appUser'
|
||||
import { getIssueChoices, joinLottery, createWechatOrder, getLotteryResult, getUserCoupons } from '@/api/appUser'
|
||||
import { requestLotterySubscription } from '@/utils/subscribe'
|
||||
// 公共组件 - uni-app需要直接导入.vue文件
|
||||
import ActivityPageLayout from '@/components/activity/ActivityPageLayout.vue'
|
||||
@ -579,6 +579,9 @@ function handlePayment() {
|
||||
const amount = (selectedChoices.value.length * Number(detail.value.price_draw || 0) / 100).toFixed(2)
|
||||
paymentAmount.value = amount
|
||||
|
||||
// 获取优惠券
|
||||
fetchCoupons()
|
||||
|
||||
console.log('[Yifanshang] Payment amount:', amount, 'Opening payment popup...')
|
||||
|
||||
// 显示支付弹窗
|
||||
@ -612,6 +615,28 @@ function handleRandomDraw() {
|
||||
handlePayment()
|
||||
}
|
||||
|
||||
// ============ 优惠券逻辑 (Fix BUG 5) ============
|
||||
async function fetchCoupons() {
|
||||
const userId = uni.getStorageSync('user_id')
|
||||
if (!userId) return
|
||||
|
||||
try {
|
||||
// 获取未使用(status=1)的优惠券
|
||||
const res = await getUserCoupons(userId, 1, 1, 100)
|
||||
if (res && Array.isArray(res.list)) {
|
||||
// 简单过滤:只显示未过期的(虽然接口可能已过滤)
|
||||
// TODO: 如果需要根据活动ID过滤适用券,需后端支持或在此处根据规则过滤
|
||||
paymentCoupons.value = res.list
|
||||
} else {
|
||||
paymentCoupons.value = []
|
||||
}
|
||||
console.log('[Yifanshang] Fetched coupons:', paymentCoupons.value.length)
|
||||
} catch (e) {
|
||||
console.error('[Yifanshang] Failed to fetch coupons:', e)
|
||||
paymentCoupons.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// ============ 次数卡逻辑 ============
|
||||
const gamePasses = ref(null)
|
||||
const gamePassRemaining = computed(() => gamePasses.value?.total_remaining || 0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user