deploy: auto commit repo-root changes 2026-07-13 22:38:58
This commit is contained in:
@@ -15,6 +15,11 @@
|
||||
<text>赔率加载中...</text>
|
||||
</view>
|
||||
|
||||
<view v-else-if="loadError" class="match-odds-detail__state">
|
||||
<text>{{ loadError }}</text>
|
||||
<u-button size="mini" type="primary" @click="retryFetch">重新加载</u-button>
|
||||
</view>
|
||||
|
||||
<view v-else-if="platforms.length" class="match-odds-detail__list">
|
||||
<view v-for="platform in platforms"
|
||||
:key="`${platform.platform_key}-${platform.source_match_id || platform.update_time || 0}`"
|
||||
@@ -79,7 +84,7 @@ const props = withDefaults(defineProps<{
|
||||
|
||||
const defaultPlatformOptions: PlatformOption[] = [
|
||||
{ key: '', label: '全部平台' },
|
||||
{ key: 'hg', label: '滚球' },
|
||||
{ key: 'hg', label: '皇冠' },
|
||||
{ key: 'titan007', label: '球探' },
|
||||
]
|
||||
|
||||
@@ -88,8 +93,13 @@ const platformOptions = ref<PlatformOption[]>([...defaultPlatformOptions])
|
||||
const sourceSite = ref('')
|
||||
const loading = ref(false)
|
||||
const loaded = ref(false)
|
||||
const loadError = ref('')
|
||||
const requestSeq = ref(0)
|
||||
|
||||
const normalizePlatformLabel = (key: string, label: string) => {
|
||||
return key === 'hg' ? '皇冠' : label
|
||||
}
|
||||
|
||||
const platforms = computed<WorldCupOddsPlatform[]>(() => {
|
||||
const result: WorldCupOddsPlatform[] = []
|
||||
const seen = new Set<string>()
|
||||
@@ -99,7 +109,10 @@ const platforms = computed<WorldCupOddsPlatform[]>(() => {
|
||||
const key = `${platform.platform_key}-${platform.source_match_id || ''}`
|
||||
if (seen.has(key)) return
|
||||
seen.add(key)
|
||||
result.push(platform)
|
||||
result.push({
|
||||
...platform,
|
||||
platform_name: normalizePlatformLabel(platform.platform_key, platform.platform_name),
|
||||
})
|
||||
})
|
||||
})
|
||||
return result
|
||||
@@ -124,7 +137,7 @@ const mergePlatformOptions = (options: unknown) => {
|
||||
options.forEach((item: any) => {
|
||||
const key = String(item?.key || '').trim()
|
||||
const label = String(item?.label || '').trim()
|
||||
if (key && label) map.set(key, { key, label })
|
||||
if (key && label) map.set(key, { key, label: normalizePlatformLabel(key, label) })
|
||||
})
|
||||
}
|
||||
platformOptions.value = Array.from(map.values())
|
||||
@@ -141,6 +154,7 @@ const fetchOdds = async (force = false) => {
|
||||
const seq = requestSeq.value + 1
|
||||
requestSeq.value = seq
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
const data = await getMatchOdds({
|
||||
home_team: props.homeTeam.trim(),
|
||||
@@ -157,6 +171,8 @@ const fetchOdds = async (force = false) => {
|
||||
if (seq !== requestSeq.value) return
|
||||
console.error('获取比赛赔率失败', error)
|
||||
oddsList.value = []
|
||||
loaded.value = true
|
||||
loadError.value = '赔率加载失败,请稍后重试'
|
||||
} finally {
|
||||
if (seq === requestSeq.value) loading.value = false
|
||||
}
|
||||
@@ -169,6 +185,11 @@ const switchPlatform = (platformKey: string) => {
|
||||
void fetchOdds(true)
|
||||
}
|
||||
|
||||
const retryFetch = () => {
|
||||
loaded.value = false
|
||||
void fetchOdds(true)
|
||||
}
|
||||
|
||||
const formatUpdateTime = (timestamp?: number) => {
|
||||
const value = Number(timestamp || 0)
|
||||
if (!value) return ''
|
||||
@@ -185,6 +206,7 @@ watch(
|
||||
() => {
|
||||
loaded.value = false
|
||||
oddsList.value = []
|
||||
loadError.value = ''
|
||||
void fetchOdds(true)
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user