查询扭蛋碎片+点券
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { computed } from 'vue'
|
||||
import { useAccounts } from '@/composables/useAccounts'
|
||||
import { useProducts } from '@/composables/useProducts'
|
||||
import { useActivity } from '@/composables/useActivity'
|
||||
|
||||
const {
|
||||
accounts,
|
||||
@@ -9,10 +10,13 @@ const {
|
||||
statusMap,
|
||||
toggleAccount,
|
||||
toggleAll,
|
||||
getScore
|
||||
getScore,
|
||||
getXiaodianAssets
|
||||
} = useAccounts()
|
||||
|
||||
const { selectedProductName } = useProducts()
|
||||
const { currentActivity } = useActivity()
|
||||
const isXiaodian = computed(() => currentActivity.value?.id === 'xiaodian')
|
||||
|
||||
const allSelected = computed(() =>
|
||||
accounts.value.length > 0 && selectedIndices.value.size === accounts.value.length
|
||||
@@ -81,14 +85,15 @@ const getResultMessage = (name: string) => {
|
||||
<th>账号</th>
|
||||
<th>凭据</th>
|
||||
<th>商品</th>
|
||||
<th>积分</th>
|
||||
<th>{{ isXiaodian ? '点券' : '积分' }}</th>
|
||||
<th v-if="isXiaodian">扭蛋碎片</th>
|
||||
<th class="status-col">状态</th>
|
||||
<th>最后结果</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="accounts.length === 0">
|
||||
<td colspan="7" class="empty-state">暂无账号,请加载账号</td>
|
||||
<td :colspan="isXiaodian ? 8 : 7" class="empty-state">暂无账号,请加载账号</td>
|
||||
</tr>
|
||||
<template v-else>
|
||||
<tr
|
||||
@@ -121,7 +126,15 @@ const getResultMessage = (name: string) => {
|
||||
</span>
|
||||
<span v-else>-</span>
|
||||
</td>
|
||||
<td>{{ getScore(account.name) }}</td>
|
||||
<td>
|
||||
<template v-if="isXiaodian">
|
||||
{{ getXiaodianAssets(account.name)?.success ? getXiaodianAssets(account.name)?.coupons : (getXiaodianAssets(account.name)?.error || '-') }}
|
||||
</template>
|
||||
<template v-else>{{ getScore(account.name) }}</template>
|
||||
</td>
|
||||
<td v-if="isXiaodian">
|
||||
{{ getXiaodianAssets(account.name)?.success ? getXiaodianAssets(account.name)?.fragments : '-' }}
|
||||
</td>
|
||||
<td class="status-td">
|
||||
<span
|
||||
class="status-badge"
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useScheduler } from '@/composables/useScheduler'
|
||||
import { useAccounts } from '@/composables/useAccounts'
|
||||
import { useActivity } from '@/composables/useActivity'
|
||||
|
||||
const { scheduleActive, startNow, startSchedule, cancelSchedule, restoreSchedule } = useScheduler()
|
||||
const { reloadAccounts, queryAllScore } = useAccounts()
|
||||
const { reloadAccounts, queryAllScore, queryAllXiaodianAssets } = useAccounts()
|
||||
const { currentActivity } = useActivity()
|
||||
const isXiaodian = computed(() => currentActivity.value?.id === 'xiaodian')
|
||||
|
||||
// 从本地缓存恢复定时设置
|
||||
const { savedTime } = restoreSchedule()
|
||||
@@ -13,6 +16,14 @@ const targetTime = ref(savedTime || '18:00:00')
|
||||
const handleSchedule = () => {
|
||||
startSchedule(targetTime.value)
|
||||
}
|
||||
|
||||
const queryAssets = () => {
|
||||
if (isXiaodian.value) {
|
||||
queryAllXiaodianAssets()
|
||||
return
|
||||
}
|
||||
queryAllScore()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -34,7 +45,7 @@ const handleSchedule = () => {
|
||||
停止定时
|
||||
</button>
|
||||
<button class="btn" @click="reloadAccounts">加载账号</button>
|
||||
<button class="btn" @click="queryAllScore">查询积分</button>
|
||||
<button class="btn" @click="queryAssets">{{ isXiaodian ? '查询点券/碎片' : '查询积分' }}</button>
|
||||
</div>
|
||||
|
||||
<div class="schedule-bar">
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useProducts } from '@/composables/useProducts'
|
||||
import { useActivity } from '@/composables/useActivity'
|
||||
|
||||
const { selectedProductId, selectedProductName, selectedProduct } = useProducts()
|
||||
const { currentActivity } = useActivity()
|
||||
const priceLabel = computed(() => currentActivity.value?.id === 'xiaodian' ? '点券' : '积分')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -10,7 +14,7 @@ const { selectedProductId, selectedProductName, selectedProduct } = useProducts(
|
||||
<div class="selected-product-name">{{ selectedProductName || '未选' }}</div>
|
||||
<div class="selected-product-meta">
|
||||
<template v-if="selectedProduct">
|
||||
<span class="chip chip-score">{{ selectedProduct.score }} 积分</span>
|
||||
<span class="chip chip-score">{{ selectedProduct.score }} {{ priceLabel }}</span>
|
||||
<span class="chip chip-stock" :class="{ low: selectedProduct.count < 500 }">
|
||||
库存 {{ selectedProduct.count }}
|
||||
</span>
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
import { useVirtualizer } from '@tanstack/vue-virtual'
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useProducts } from '@/composables/useProducts'
|
||||
import { useActivity } from '@/composables/useActivity'
|
||||
|
||||
const { filteredProducts, selectedProductId, selectProduct, searchQuery } = useProducts()
|
||||
const { currentActivity } = useActivity()
|
||||
const priceLabel = computed(() => currentActivity.value?.id === 'xiaodian' ? '点券' : '积分')
|
||||
|
||||
const parentRef = ref<HTMLElement | null>(null)
|
||||
|
||||
@@ -56,7 +59,7 @@ const handleSelect = (commodityId: string, commodityName: string) => {
|
||||
<div class="pinfo">
|
||||
<div class="pname">{{ filteredProducts[item.index].commodityName }}</div>
|
||||
<div class="pmeta">
|
||||
<span class="chip chip-score">{{ filteredProducts[item.index].score }} 积分</span>
|
||||
<span class="chip chip-score">{{ filteredProducts[item.index].score }} {{ priceLabel }}</span>
|
||||
<span
|
||||
class="chip chip-stock"
|
||||
:class="{ low: filteredProducts[item.index].count < 500 }"
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ref } from 'vue'
|
||||
import { useToast } from './useToast'
|
||||
import {
|
||||
GetAccounts,
|
||||
QueryXiaodianAssets,
|
||||
QueryScore,
|
||||
ReloadAccounts,
|
||||
VerifyAllExchange,
|
||||
@@ -24,6 +25,13 @@ const accounts = ref<Account[]>([])
|
||||
const selectedIndices = ref<Set<number>>(new Set())
|
||||
const statusMap = ref<Record<string, AccountStatus | boolean>>({})
|
||||
const scoreMap = ref<Record<string, string>>({})
|
||||
export interface XiaodianAssets {
|
||||
success: boolean
|
||||
coupons: number
|
||||
fragments: number
|
||||
error?: string
|
||||
}
|
||||
const xiaodianAssetsMap = ref<Record<string, XiaodianAssets>>({})
|
||||
|
||||
export function useAccounts() {
|
||||
const { showToast } = useToast()
|
||||
@@ -96,10 +104,24 @@ export function useAccounts() {
|
||||
showToast('积分查询完成', '', 'success')
|
||||
}
|
||||
|
||||
const queryAllXiaodianAssets = async () => {
|
||||
showToast('查询点券和碎片', '正在查询账号资产...', 'info')
|
||||
try {
|
||||
const data = await QueryXiaodianAssets()
|
||||
xiaodianAssetsMap.value = data?.results || {}
|
||||
const successCount = Object.values(xiaodianAssetsMap.value).filter(item => item.success).length
|
||||
showToast('资产查询完成', `成功 ${successCount}/${accounts.value.length} 个账号`, successCount > 0 ? 'success' : 'warn')
|
||||
} catch (e: any) {
|
||||
showToast('资产查询失败', e?.message || '', 'error')
|
||||
}
|
||||
}
|
||||
|
||||
const getScore = (name: string): string => {
|
||||
return scoreMap.value[name] || localStorage.getItem('accScore_' + name) || '-'
|
||||
}
|
||||
|
||||
const getXiaodianAssets = (name: string): XiaodianAssets | undefined => xiaodianAssetsMap.value[name]
|
||||
|
||||
const resetStatus = () => {
|
||||
statusMap.value = {}
|
||||
localStorage.removeItem('statusMap')
|
||||
@@ -173,13 +195,16 @@ export function useAccounts() {
|
||||
selectedIndices,
|
||||
statusMap,
|
||||
scoreMap,
|
||||
xiaodianAssetsMap,
|
||||
loadAccounts,
|
||||
reloadAccounts,
|
||||
toggleAccount,
|
||||
toggleAll,
|
||||
restoreSelection,
|
||||
queryAllScore,
|
||||
queryAllXiaodianAssets,
|
||||
getScore,
|
||||
getXiaodianAssets,
|
||||
resetStatus,
|
||||
setStatuses,
|
||||
mergeStatuses,
|
||||
|
||||
Reference in New Issue
Block a user