fix: 充值体验修复——回调写星尘流水(明细页有记录)+重推幂等+退款回调写流水+充值成功返回我的+我的页onShow刷新余额

This commit is contained in:
Hermes Agent
2026-09-14 15:21:24 +08:00
parent e6cb577305
commit c7d4158aca
3 changed files with 67 additions and 30 deletions
+8 -2
View File
@@ -108,7 +108,7 @@
</template>
<script setup>
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { onShow, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { ref, computed, onMounted } from 'vue'
import { useUserStore } from '@/stores/user'
import { knowledgeApi, aiChatApi, request } from '@/utils/api'
@@ -174,9 +174,15 @@ const quotaPercent = computed(() => {
onMounted(() => {
loadStats()
if (userStore.isLoggedIn) {
loadVpayInfo()
userStore.fetchMe()
loadCollected()
}
})
// 每次进入/返回本页都刷新余额与额度(充值页支付成功后返回时余额同步)
onShow(() => {
if (userStore.isLoggedIn) {
loadVpayInfo()
loadQuota()
}
})
+10 -2
View File
@@ -120,8 +120,16 @@ async function recharge() {
// #endif
uni.showToast({ title: '充值成功!', icon: 'success' })
// 刷新余额
info.value = await request('GET', '/api/vpay/info', null, userStore.token)
// 刷新余额后返回"我的"(该页 onShow 会重新拉取余额与额度)
try {
info.value = await request('GET', '/api/vpay/info', null, userStore.token)
} catch (e) {}
setTimeout(() => {
uni.navigateBack({
delta: 1,
fail: () => uni.switchTab({ url: '/pages/profile/profile' }),
})
}, 1200)
} catch (e) {
const msg = e.message || '支付未完成'
if (msg.includes('cancel')) {