修复卖家商品价格展示

This commit is contained in:
yml
2026-05-25 15:12:40 +08:00
parent 7e7e6dc166
commit e270ce8bfc
5 changed files with 78 additions and 23 deletions
+9
View File
@@ -30,6 +30,15 @@ export function getListingDisplayPrice(item: Listing) {
return Number(item.price || 0);
}
export function getListingSellerPrice(item: Listing) {
const priceBreakdown = item.asset_summary?.price_breakdown;
if (typeof priceBreakdown === "object" && priceBreakdown !== null) {
const price = readUnknownNumber((priceBreakdown as Record<string, unknown>).seller_total_price);
if (price > 0) return price;
}
return getListingDisplayPrice(item);
}
export function getRatioValue(item: Listing) {
const ratio = readAssetNumber(item, "publish_ratio");
if (ratio > 0) return ratio;
@@ -4,11 +4,11 @@ import { useRouter } from 'vue-router'
import { showToast, showDialog } from 'vant'
import { fetchSellerListings, offlineListing, submitListingReview, type Listing } from '@/api/listings'
import { fetchFileBlobByURL } from '@/api/files'
import { listingReviewStatusLabel, listingStatusLabel } from '@/utils/statusLabels'
import { listingStatusLabel } from '@/utils/statusLabels'
import { getListingSellerPrice } from '@/utils/listingDisplay'
const router = useRouter()
const loading = ref(false)
const rawListings = ref<Listing[]>([])
const activeTab = ref('all')
interface DisplayListing extends Listing {
@@ -128,12 +128,8 @@ function getStatusText(item: Listing) {
return listingStatusLabel(item.status)
}
function goDetail(item: Listing) {
if (item.status === 'published' && item.review_status === 'approved') {
router.push(`/m/listings/${item.id}`)
} else {
showToast('该商品当前状态不支持预览')
}
function listingPrice(item: Listing) {
return getListingSellerPrice(item).toFixed(2)
}
function goBack() {
@@ -178,7 +174,6 @@ function goBack() {
v-for="item in filteredListings"
:key="item.id"
class="listing-card"
@click="goDetail(item)"
>
<div class="card-content">
<!-- 封面图 -->
@@ -201,7 +196,7 @@ function goBack() {
<p class="listing-meta">{{ item.server_region }} · {{ item.login_platform }}</p>
<div class="price-row">
<span class="price-val">¥{{ item.price.toFixed(2) }}<small>/小时</small></span>
<span class="price-val">¥{{ listingPrice(item) }}</span>
<span class="deposit-val">押金: ¥{{ item.deposit_amount.toFixed(2) }}</span>
</div>
</div>
@@ -352,7 +347,6 @@ function goBack() {
padding: 14px;
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.02), 0 1px 4px rgba(0, 0, 0, 0.02);
border: 1px solid rgba(243, 244, 246, 0.9);
cursor: pointer;
display: flex;
flex-direction: column;
}
@@ -4,6 +4,7 @@ import { onMounted, ref } from 'vue'
import { fetchSellerListings, offlineListing, submitListingReview, type Listing } from '@/api/listings'
import { listingReviewStatusLabel, listingStatusLabel } from '@/utils/statusLabels'
import { getListingSellerPrice } from '@/utils/listingDisplay'
const loading = ref(false)
const listings = ref<Listing[]>([])
@@ -36,16 +37,7 @@ async function offline(id: number) {
}
function listingPrice(row: Listing) {
return `¥${readSellerPrice(row).toFixed(2)}`
}
function readSellerPrice(row: Listing) {
const breakdown = row.asset_summary?.price_breakdown
if (typeof breakdown === 'object' && breakdown !== null) {
const price = Number((breakdown as Record<string, unknown>).seller_total_price)
if (Number.isFinite(price) && price > 0) return price
}
return Number(row.price || 0)
return `¥${getListingSellerPrice(row).toFixed(2)}`
}
</script>