feat: 资料更新
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
<div
|
||||
class="assets-toolbar__download flex flex-center"
|
||||
:class="{ disabled: selectedCount < 1 }"
|
||||
v-loading="downloadingSelected"
|
||||
@click="handleDownloadSelected"
|
||||
>
|
||||
<SvgIcon name="downloadBtn" color="#fff" />
|
||||
@@ -66,6 +67,7 @@
|
||||
download
|
||||
:url="item.thumbnailUrl"
|
||||
:name="item.listingName"
|
||||
@download.stop="handleDownloadSelected(item)"
|
||||
:showPrice="false"
|
||||
></CommodityItem>
|
||||
</div>
|
||||
@@ -92,7 +94,7 @@
|
||||
import { useClothesCategories } from '@/utils/ClothesCategory'
|
||||
import Empty from './Empty.vue'
|
||||
import FilterSidebar from './FilterSidebar.vue'
|
||||
import { fetchMyWardrobe } from '@/api/user'
|
||||
import { fetchMyWardrobe, fetchDownloadItemsByGet } from '@/api/user'
|
||||
import { useUserInfoStore } from '@/stores'
|
||||
|
||||
import { debounce } from 'lodash-es'
|
||||
@@ -320,9 +322,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
const handleDownloadSelected = () => {
|
||||
const items = dataList.value.filter((item) => item.checked)
|
||||
console.log(items)
|
||||
const downloadingSelected = ref(false)
|
||||
const handleDownloadSelected = (assets) => {
|
||||
const items = assets ? [assets] : dataList.value.filter((item) => item.checked)
|
||||
|
||||
downloadingSelected.value = true
|
||||
const ids = items.map((item) => item.listingId)
|
||||
fetchDownloadItemsByGet({ ids })
|
||||
.then((res) => {
|
||||
const disposition = res.headers['content-disposition']
|
||||
const fileName =
|
||||
disposition?.split('filename=')[1]?.replace(/"/g, '') || 'download.zip'
|
||||
const blob = res.data
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
|
||||
const timestamp = new Date().getTime()
|
||||
link.download = fileName || `wardrobe_download_${timestamp}.zip`
|
||||
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
|
||||
document.body.removeChild(link)
|
||||
window.URL.revokeObjectURL(url)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Download failed:', error)
|
||||
}).finally(() => {
|
||||
downloadingSelected.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const handleAssetsScroll = () => {
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
:show-brand="false"
|
||||
is-order
|
||||
order-actions-layout
|
||||
@download="handleDownload(order)"
|
||||
/>
|
||||
</div>
|
||||
</article>
|
||||
@@ -96,7 +97,7 @@
|
||||
import { computed, onMounted, ref, shallowRef } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { fetchMyOrders } from '@/api/user'
|
||||
import { fetchMyOrders ,fetchDownloadItemsByGet} from '@/api/user'
|
||||
import ScItem from '@/views/shoppingCart/sc-item.vue'
|
||||
import Empty from './Empty.vue'
|
||||
|
||||
@@ -181,14 +182,10 @@
|
||||
return t('Wardrobe.orders.actions.buyAgain')
|
||||
}
|
||||
|
||||
const getOrderStatusValue = (status: unknown): ActualOrderStatus => {
|
||||
if (status === 0 || status === '0' || status === 'unpaid') return 'unpaid'
|
||||
if (status === 2 || status === '2' || status === 'cancelled') return 'cancelled'
|
||||
return 'paid'
|
||||
}
|
||||
|
||||
const getOrderStatus = (order: OrderRecord) => {
|
||||
return getOrderStatusValue(order.status)
|
||||
if (Number(order.status) === 0) return 'unpaid'
|
||||
if (Number(order.status) === 2) return 'cancelled'
|
||||
if (Number(order.status) === 1) return 'paid'
|
||||
}
|
||||
|
||||
const formatOrderUpdateTime = (dateStr: string) => {
|
||||
@@ -221,7 +218,7 @@
|
||||
}
|
||||
|
||||
const getOrderItemInfo = (item: OrderItem, order: OrderRecord) => ({
|
||||
status: item.status,
|
||||
status: order.status,
|
||||
title: item.listingName,
|
||||
brand: order.shopName,
|
||||
tags: item.productCategory,
|
||||
@@ -230,6 +227,43 @@
|
||||
cover: item.thumbnailUrl
|
||||
})
|
||||
|
||||
const resetOrders = () => {
|
||||
ordersRequestId.value += 1
|
||||
orders.value = []
|
||||
expandedOrderId.value = ''
|
||||
isLoadingOrders.value = false
|
||||
hasMoreOrders.value = true
|
||||
orderParams.value.page = 1
|
||||
|
||||
if (ordersScrollRef.value) {
|
||||
ordersScrollRef.value.scrollTop = 0
|
||||
}
|
||||
}
|
||||
|
||||
const setActiveStatus = (status: OrderStatus) => {
|
||||
activeStatus.value = status
|
||||
resetOrders()
|
||||
fetchAllOrders()
|
||||
}
|
||||
|
||||
const handleOrdersScroll = () => {
|
||||
const el = ordersScrollRef.value
|
||||
if (!el) return
|
||||
|
||||
const reachBottom = el.scrollTop + el.clientHeight >= el.scrollHeight - 120
|
||||
if (reachBottom) {
|
||||
fetchAllOrders()
|
||||
}
|
||||
}
|
||||
|
||||
const handleDownload = (order) => {
|
||||
console.log(order)
|
||||
}
|
||||
|
||||
const handleRouteBrand = (order: OrderRecord) => {
|
||||
ROUTER.push(`/brand/${order.sellerId}`)
|
||||
}
|
||||
|
||||
const fetchAllOrders = async () => {
|
||||
if (isLoadingOrders.value || !hasMoreOrders.value) return
|
||||
|
||||
@@ -267,39 +301,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
const resetOrders = () => {
|
||||
ordersRequestId.value += 1
|
||||
orders.value = []
|
||||
expandedOrderId.value = ''
|
||||
isLoadingOrders.value = false
|
||||
hasMoreOrders.value = true
|
||||
orderParams.value.page = 1
|
||||
|
||||
if (ordersScrollRef.value) {
|
||||
ordersScrollRef.value.scrollTop = 0
|
||||
}
|
||||
}
|
||||
|
||||
const setActiveStatus = (status: OrderStatus) => {
|
||||
activeStatus.value = status
|
||||
resetOrders()
|
||||
fetchAllOrders()
|
||||
}
|
||||
|
||||
const handleOrdersScroll = () => {
|
||||
const el = ordersScrollRef.value
|
||||
if (!el) return
|
||||
|
||||
const reachBottom = el.scrollTop + el.clientHeight >= el.scrollHeight - 120
|
||||
if (reachBottom) {
|
||||
fetchAllOrders()
|
||||
}
|
||||
}
|
||||
|
||||
const handleRouteBrand = (order: OrderRecord) => {
|
||||
ROUTER.push(`/brand/${order.sellerId}`)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchAllOrders()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user