增加发布协议确认配置

This commit is contained in:
yml2213
2026-06-07 21:14:49 +08:00
parent 954c3d6be3
commit eebd2d3b04
19 changed files with 760 additions and 13 deletions
@@ -3,11 +3,14 @@ import { useRouter } from 'vue-router'
import { fetchFileBlobByURL, uploadFile } from '@/shared/api/files'
import {
emptyListingPublishAgreements,
emptyListingPublishOptions,
emptyListingSalePriceConfig,
fetchListingPublishAgreements,
fetchListingPublishOptions,
fetchListingSalePriceConfig,
type ChargeMode,
type ListingPublishAgreements,
type ListingPublishOptions,
type PublishSalePriceConfig,
type ScreenshotKey,
@@ -45,6 +48,9 @@ export function usePublishForm(options: UsePublishFormOptions) {
const draftReady = ref(false)
const publishOptions = ref<ListingPublishOptions>(emptyListingPublishOptions)
const salePriceConfig = ref<PublishSalePriceConfig>(emptyListingSalePriceConfig)
const publishAgreements = ref<ListingPublishAgreements>(emptyListingPublishAgreements)
const virtualAssetSaleAgreementChecked = ref(false)
const sellerAgreementChecked = ref(false)
const fileInput = ref<HTMLInputElement | null>(null)
const activeUploadKey = ref<ScreenshotKey>('coin')
const form = reactive<PublishForm>(defaultPublishForm())
@@ -66,6 +72,9 @@ export function usePublishForm(options: UsePublishFormOptions) {
})
const uploadedScreenshotCount = computed(() => pricing.screenshotUrls.value.length)
const requiredScreenshotCount = ref(0)
const canPublishAfterAgreements = computed(
() => virtualAssetSaleAgreementChecked.value && sellerAgreementChecked.value,
)
onMounted(() => {
restoreDraft()
@@ -114,12 +123,14 @@ export function usePublishForm(options: UsePublishFormOptions) {
async function loadPublishOptions() {
try {
const [nextPublishOptions, nextSalePriceConfig] = await Promise.all([
const [nextPublishOptions, nextSalePriceConfig, nextPublishAgreements] = await Promise.all([
fetchListingPublishOptions(),
fetchListingSalePriceConfig(),
fetchListingPublishAgreements(),
])
publishOptions.value = nextPublishOptions
salePriceConfig.value = nextSalePriceConfig
publishAgreements.value = nextPublishAgreements
// 默认数字都是0
for (const item of nextPublishOptions.quantity_items) {
@@ -130,6 +141,7 @@ export function usePublishForm(options: UsePublishFormOptions) {
} catch {
publishOptions.value = emptyListingPublishOptions
salePriceConfig.value = emptyListingSalePriceConfig
publishAgreements.value = emptyListingPublishAgreements
}
}
@@ -205,6 +217,8 @@ export function usePublishForm(options: UsePublishFormOptions) {
clearRecord(screenshotFiles)
revokeAllScreenshotPreviews()
selectedSkins.value = []
virtualAssetSaleAgreementChecked.value = false
sellerAgreementChecked.value = false
activeUploadKey.value = 'coin'
// Also re-initialize quantityValues to 0
@@ -397,6 +411,8 @@ export function usePublishForm(options: UsePublishFormOptions) {
screenshot_urls: pricing.screenshotUrls.value,
price: pricing.calculatedFinalPrice.value,
deposit_amount: Number(form.deposit_amount),
agreed_virtual_asset_sale: virtualAssetSaleAgreementChecked.value,
agreed_seller_agreement: sellerAgreementChecked.value,
})
removePublishDraft(options.draftKey)
suppressDraftSave.value = true
@@ -445,6 +461,7 @@ export function usePublishForm(options: UsePublishFormOptions) {
}
if (!pricing.calculatedFinalPrice.value) return '请完善币数、保险、体力和负重后再发布'
if (!Number.isFinite(pricing.calculatedFinalPrice.value)) return '发布价格计算异常,请检查填写内容'
if (!canPublishAfterAgreements.value) return '请先阅读并勾选两份发布协议'
for (const item of pricing.screenshotSlots.value) {
if (isScreenshotRequired(item) && !screenshotFiles[item.key]) return `请上传${item.label}`
}
@@ -530,6 +547,10 @@ export function usePublishForm(options: UsePublishFormOptions) {
router,
loading,
uploading,
publishAgreements,
virtualAssetSaleAgreementChecked,
sellerAgreementChecked,
canPublishAfterAgreements,
fileInput,
activeUploadKey,
form,