优惠券请求的问题: 小程序没有请求

This commit is contained in:
邹方成 2026-01-09 00:48:26 +08:00
parent 6da73a1955
commit 3b0bf07f77

View File

@ -159,7 +159,7 @@
<script setup> <script setup>
import { ref, computed, watch } from 'vue' import { ref, computed, watch } from 'vue'
import { onLoad, onUnload } from '@dcloudio/uni-app' 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' import { requestLotterySubscription } from '@/utils/subscribe'
// - uni-app.vue // - uni-app.vue
import ActivityPageLayout from '@/components/activity/ActivityPageLayout.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) const amount = (selectedChoices.value.length * Number(detail.value.price_draw || 0) / 100).toFixed(2)
paymentAmount.value = amount paymentAmount.value = amount
//
fetchCoupons()
console.log('[Yifanshang] Payment amount:', amount, 'Opening payment popup...') console.log('[Yifanshang] Payment amount:', amount, 'Opening payment popup...')
// //
@ -612,6 +615,28 @@ function handleRandomDraw() {
handlePayment() 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 gamePasses = ref(null)
const gamePassRemaining = computed(() => gamePasses.value?.total_remaining || 0) const gamePassRemaining = computed(() => gamePasses.value?.total_remaining || 0)