237 lines
8.2 KiB
Vue
237 lines
8.2 KiB
Vue
<script setup lang="ts">
|
|
import { ElMessage } from 'element-plus'
|
|
import { ref, watch } from 'vue'
|
|
|
|
import { updateSystemConfig, type SystemConfig } from '@/features/admin/api/systemConfigs'
|
|
import type { ListingPublishAgreements } from '@/features/listings/api/listingOptions'
|
|
import { safeParseJSON } from '@/utils/json'
|
|
|
|
const defaultListingPublishAgreements: ListingPublishAgreements = {
|
|
virtual_asset_sale: {
|
|
title: '虚拟资产出售协议',
|
|
content: `请您在发布账号前仔细阅读并确认以下内容:
|
|
|
|
一、发布性质
|
|
1. 您发布的账号、哈夫币、皮肤、装备、消耗品等均属于游戏内虚拟资产或使用权益展示。
|
|
2. 虚拟资产受游戏厂商规则、版本更新、风控策略和账号状态影响,平台不承诺其具备现实货币价值或永久可用性。
|
|
3. 您应确保发布信息真实、完整、可交接,且与截图材料和账号实际资产一致。
|
|
|
|
二、风险告知
|
|
1. 发布账号后,买家下单前后可能因游戏环境变化、资产变动、封禁记录、登录限制等产生交易风险。
|
|
2. 若您隐瞒账号异常、资产缺失、封禁记录、不可用物资或其他影响交易的信息,平台可依据证据处理赔付、退款或下架。
|
|
3. 请勿绕过平台私下收款、私下交接或诱导用户脱离平台沟通,否则平台可能限制账号发布权限。
|
|
|
|
三、费用与结算
|
|
1. 发布价格、押金、额外消耗品价值以平台发布页和订单页面展示为准。
|
|
2. 订单完成后,平台将按订单记录、结账结果和相关规则进行结算。
|
|
3. 若发生争议,平台将依据订单记录、资产快照、聊天记录、截图证据和双方说明进行处理。`,
|
|
},
|
|
seller_agreement: {
|
|
title: '号主协议',
|
|
content: `请您作为号主在发布账号前确认并遵守以下约定:
|
|
|
|
一、账号发布义务
|
|
1. 您应如实填写区服、段位、哈夫币数量、保险、体力、负重、登录方式、封禁记录、常用地区和备注信息。
|
|
2. 您应上传真实、清晰、可核验的账号截图材料,不得使用伪造、过期或与账号不一致的截图。
|
|
3. 您不得发布盗号、黑号、纠纷账号、已被限制使用账号或无法完成正常交接的账号。
|
|
|
|
二、交接与协作
|
|
1. 买家下单后,您应在平台要求时间内完成交接,及时响应扫码、人脸冻结、登录验证等流程。
|
|
2. 您应在租用期间保持可联系状态,不得无故拒绝交接、恶意拖延或私下更改交易条件。
|
|
3. 租用结束后,请按平台流程确认归还和结账,配合核验资产状态。
|
|
|
|
三、责任承担
|
|
1. 因您发布信息不实、交接不及时、账号异常隐瞒或私下交易造成的损失,平台可依据规则处理退款、赔付、下架或限制发布。
|
|
2. 因租客违规使用造成的损失,您应通过平台流程提交证据并配合争议处理。
|
|
3. 您同意平台依据订单记录、资产快照、聊天记录、截图证据和相关规则处理结算、赔付及争议。`,
|
|
},
|
|
}
|
|
|
|
const props = defineProps<{
|
|
modelValue: boolean
|
|
config: SystemConfig
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'update:modelValue', val: boolean): void
|
|
(e: 'saved'): void
|
|
}>()
|
|
|
|
const submitting = ref(false)
|
|
const description = ref('')
|
|
const draft = ref<ListingPublishAgreements>(cloneAgreements(defaultListingPublishAgreements))
|
|
|
|
watch(
|
|
() => props.modelValue,
|
|
(val) => {
|
|
if (val) {
|
|
draft.value = parseListingPublishAgreements(props.config.value)
|
|
description.value = props.config.description || ''
|
|
}
|
|
},
|
|
{ immediate: true },
|
|
)
|
|
|
|
function parseListingPublishAgreements(raw: string) {
|
|
const parsed = safeParseJSON(raw, defaultListingPublishAgreements)
|
|
return cloneAgreements({
|
|
virtual_asset_sale: {
|
|
title: readText(parsed?.virtual_asset_sale?.title, defaultListingPublishAgreements.virtual_asset_sale.title),
|
|
content: readText(parsed?.virtual_asset_sale?.content, defaultListingPublishAgreements.virtual_asset_sale.content),
|
|
},
|
|
seller_agreement: {
|
|
title: readText(parsed?.seller_agreement?.title, defaultListingPublishAgreements.seller_agreement.title),
|
|
content: readText(parsed?.seller_agreement?.content, defaultListingPublishAgreements.seller_agreement.content),
|
|
},
|
|
})
|
|
}
|
|
|
|
function readText(value: unknown, fallback: string) {
|
|
return typeof value === 'string' && value.trim() ? value : fallback
|
|
}
|
|
|
|
function cloneAgreements(value: ListingPublishAgreements) {
|
|
return JSON.parse(JSON.stringify(value)) as ListingPublishAgreements
|
|
}
|
|
|
|
function resetDefaults() {
|
|
draft.value = cloneAgreements(defaultListingPublishAgreements)
|
|
}
|
|
|
|
async function handleSave() {
|
|
submitting.value = true
|
|
try {
|
|
await updateSystemConfig(props.config.key, {
|
|
value: JSON.stringify(draft.value, null, 2),
|
|
description: description.value,
|
|
})
|
|
ElMessage.success('发布协议配置已更新')
|
|
emit('saved')
|
|
emit('update:modelValue', false)
|
|
} catch (error) {
|
|
ElMessage.error(readError(error, '保存失败'))
|
|
} finally {
|
|
submitting.value = false
|
|
}
|
|
}
|
|
|
|
function readError(error: unknown, fallback: string) {
|
|
if (typeof error === 'object' && error && 'response' in error) {
|
|
const response = (error as { response?: { data?: { message?: string } } }).response
|
|
return response?.data?.message || fallback
|
|
}
|
|
return fallback
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<el-dialog
|
|
:model-value="modelValue"
|
|
title="编辑发布协议"
|
|
width="860px"
|
|
@update:model-value="emit('update:modelValue', $event)"
|
|
>
|
|
<div class="dialog-body">
|
|
<div class="dialog-header">
|
|
<p class="config-key-label"><strong>{{ config.key }}</strong></p>
|
|
<el-button size="small" @click="resetDefaults">恢复默认文本</el-button>
|
|
</div>
|
|
|
|
<div class="agreement-editor-grid">
|
|
<section class="agreement-editor-card">
|
|
<div class="agreement-card-title">虚拟资产出售协议</div>
|
|
<el-form-item label="协议标题" class="full-control">
|
|
<el-input v-model="draft.virtual_asset_sale.title" placeholder="请输入协议标题" />
|
|
</el-form-item>
|
|
<el-form-item label="协议正文" class="full-control">
|
|
<el-input
|
|
v-model="draft.virtual_asset_sale.content"
|
|
type="textarea"
|
|
:rows="14"
|
|
resize="vertical"
|
|
placeholder="请输入协议正文"
|
|
/>
|
|
</el-form-item>
|
|
</section>
|
|
|
|
<section class="agreement-editor-card">
|
|
<div class="agreement-card-title">号主协议</div>
|
|
<el-form-item label="协议标题" class="full-control">
|
|
<el-input v-model="draft.seller_agreement.title" placeholder="请输入协议标题" />
|
|
</el-form-item>
|
|
<el-form-item label="协议正文" class="full-control">
|
|
<el-input
|
|
v-model="draft.seller_agreement.content"
|
|
type="textarea"
|
|
:rows="14"
|
|
resize="vertical"
|
|
placeholder="请输入协议正文"
|
|
/>
|
|
</el-form-item>
|
|
</section>
|
|
</div>
|
|
|
|
<el-form-item label="配置说明" class="desc-item">
|
|
<el-input v-model="description" type="textarea" :rows="3" placeholder="配置说明" />
|
|
</el-form-item>
|
|
</div>
|
|
<template #footer>
|
|
<el-button @click="emit('update:modelValue', false)">取消</el-button>
|
|
<el-button type="primary" :loading="submitting" @click="handleSave">保存</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.dialog-body {
|
|
display: grid;
|
|
gap: 16px;
|
|
max-height: 68vh;
|
|
overflow-y: auto;
|
|
padding-right: 8px;
|
|
}
|
|
|
|
.dialog-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 12px;
|
|
}
|
|
|
|
.config-key-label {
|
|
margin: 0;
|
|
color: #374151;
|
|
}
|
|
|
|
.agreement-editor-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
gap: 14px;
|
|
}
|
|
|
|
.agreement-editor-card {
|
|
display: grid;
|
|
gap: 12px;
|
|
padding: 14px;
|
|
border: 1px solid #e5e7eb;
|
|
border-radius: 8px;
|
|
background: #f9fafb;
|
|
}
|
|
|
|
.agreement-card-title {
|
|
color: #111827;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.full-control,
|
|
.desc-item {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
@media (max-width: 900px) {
|
|
.agreement-editor-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
</style>
|