Compare commits

..

No commits in common. "5cd4e77d07c1d91a114ce317817ed6ecf3b35795" and "e903ae2d93d7a9396715ee79cc38846ba02424a1" have entirely different histories.

3 changed files with 24 additions and 57 deletions

View File

@ -234,16 +234,8 @@ export function redeemItemCardByPoints(user_id, item_card_id, quantity = 1) {
return authRequest({ url: `/api/app/users/${user_id}/points/redeem-item-card`, method: 'POST', data: { item_card_id, quantity } }) return authRequest({ url: `/api/app/users/${user_id}/points/redeem-item-card`, method: 'POST', data: { item_card_id, quantity } })
} }
export function getStoreItems(kind = 'product', page = 1, page_size = 20, filters = {}) { export function getStoreItems(kind = 'product', page = 1, page_size = 20) {
const data = { kind, page, page_size } return authRequest({ url: '/api/app/store/items', method: 'GET', data: { kind, page, page_size } })
if (filters.keyword) data.keyword = filters.keyword
if (filters.price_min !== undefined && filters.price_min !== null && filters.price_min !== '') {
data.price_min = parseInt(filters.price_min)
}
if (filters.price_max !== undefined && filters.price_max !== null && filters.price_max !== '') {
data.price_max = parseInt(filters.price_max)
}
return authRequest({ url: '/api/app/store/items', method: 'GET', data })
} }
export function getTasks(page = 1, page_size = 20) { export function getTasks(page = 1, page_size = 20) {

View File

@ -776,10 +776,10 @@ export default {
return String(v || '').trim() return String(v || '').trim()
}, },
formatPoints(v) { formatPoints(v) {
// * rate / 100
const n = Number(v) || 0 const n = Number(v) || 0
if (n === 0) return '0.0' if (n === 0) return '0.0'
return n.toFixed(1) const f = n / 100
return f.toFixed(1)
}, },
copyInviteCode() { copyInviteCode() {
const code = this.getInviteCode() const code = this.getInviteCode()

View File

@ -290,19 +290,7 @@ async function loadItems(append = false) {
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true
try { try {
// const res = await getStoreItems(currentTab.value, page.value, pageSize)
const filters = {}
if (keyword.value && keyword.value.trim()) {
filters.keyword = keyword.value.trim()
}
if (priceMin.value !== '' && priceMin.value !== null) {
filters.price_min = priceMin.value
}
if (priceMax.value !== '' && priceMax.value !== null) {
filters.price_max = priceMax.value
}
const res = await getStoreItems(currentTab.value, page.value, pageSize, filters)
const list = res.list || res || [] const list = res.list || res || []
const total = res.total || 0 const total = res.total || 0
const newItems = normalizeItems(list, currentTab.value) const newItems = normalizeItems(list, currentTab.value)
@ -313,12 +301,21 @@ async function loadItems(append = false) {
allItems.value = newItems allItems.value = newItems
} }
// 使 // total
items.value = allItems.value
//
const totalPages = Math.ceil(total / pageSize) const totalPages = Math.ceil(total / pageSize)
hasMore.value = page.value < totalPages
//
if (page.value < totalPages) {
page.value++
//
loading.value = false // loading
await loadItems(true)
} else {
//
hasMore.value = false
}
applyFilters()
} catch (e) { } catch (e) {
console.error(e) console.error(e)
hasMore.value = false hasMore.value = false
@ -353,22 +350,14 @@ function applyFilters() {
function applyPriceFilter() { function applyPriceFilter() {
activePriceRange.value = 'custom' activePriceRange.value = 'custom'
// applyFilters()
page.value = 1
hasMore.value = true
allItems.value = []
loadItems()
} }
function resetPriceFilter() { function resetPriceFilter() {
priceMin.value = '' priceMin.value = ''
priceMax.value = '' priceMax.value = ''
activePriceRange.value = 'all' activePriceRange.value = 'all'
// applyFilters()
page.value = 1
hasMore.value = true
allItems.value = []
loadItems()
} }
function selectQuickPrice(range) { function selectQuickPrice(range) {
@ -383,24 +372,14 @@ function selectQuickPrice(range) {
} else { } else {
priceMax.value = '' priceMax.value = ''
} }
// applyFilters()
page.value = 1
hasMore.value = true
allItems.value = []
loadItems()
} }
function isRangeActive(range) { function isRangeActive(range) {
return activePriceRange.value === range.key return activePriceRange.value === range.key
} }
function onSearchConfirm() { function onSearchConfirm() { applyFilters() }
//
page.value = 1
hasMore.value = true
allItems.value = []
loadItems()
}
function onProductTap(p) { function onProductTap(p) {
if (p.kind === 'product') { if (p.kind === 'product') {
@ -479,11 +458,7 @@ onShow(() => {
}) })
onReachBottom(() => { onReachBottom(() => {
// //
if (hasMore.value && !loading.value) {
page.value++
loadItems(true)
}
}) })
watch(keyword, () => applyFilters()) watch(keyword, () => applyFilters())