新版本更改中

This commit is contained in:
2025-11-21 16:23:46 +08:00
parent a02c287715
commit 868632400a
4 changed files with 366 additions and 374 deletions

View File

@@ -39,10 +39,9 @@
</el-tag>
</div>
<div class="desc">{{ shop.description || '这家店还没有描述~' }}</div>
<!-- <div class="meta">
<span>店铺ID{{ shop.id || '-' }}</span>
<span>可删除{{ shop.del ? '是' : '否' }}</span>
</div> -->
<div class="meta">
<span>手续费率{{ formatFeeRate(shop.feeRate) }}</span>
</div>
<div class="actions">
<el-button size="small" type="primary" @click="handleOpenEdit">修改店铺</el-button>
<el-button size="small" type="warning" @click="handleToggleShop">
@@ -124,6 +123,14 @@
<label class="label">店铺描述</label>
<el-input type="textarea" :rows="3" v-model="editForm.description" placeholder="请输入描述" :maxlength="300" show-word-limit />
</div>
<div class="row">
<label class="label">手续费比例</label>
<el-input
v-model="editForm.feeRate"
placeholder="比例区间 0.01 - 0.1 之间最多6位小数"
@input="handleEditFeeRateInput"
/>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visibleEdit=false">取消</el-button>
@@ -200,11 +207,12 @@ export default {
name: '',
image: '',
description: '',
feeRate: '',
del: true,
state: 0
},
visibleEdit: false,
editForm: { id: '', name: '', image: '', description: '' },
editForm: { id: '', name: '', image: '', description: '', feeRate: '' },
// 店铺配置列表
shopConfigs: [],
visibleConfigEdit: false,
@@ -259,6 +267,38 @@ export default {
this.fetchMyShop()
},
methods: {
/**
* 手续费率显示最多6位小数去除多余的0空值显示为 '-'
*/
formatFeeRate(value) {
if (value === null || value === undefined || value === '') return '-'
const num = Number(value)
if (!Number.isFinite(num)) return '-'
const fixed = num.toFixed(6)
return fixed.replace(/\.?0+$/, '')
},
/**
* 修改弹窗 - 手续费输入允许一个小数点最多6位小数允许尾随点
*/
handleEditFeeRateInput(value) {
let v = String(value ?? this.editForm.feeRate ?? '')
v = v.replace(/[^0-9.]/g, '')
const firstDot = v.indexOf('.')
if (firstDot !== -1) {
v = v.slice(0, firstDot + 1) + v.slice(firstDot + 1).replace(/\./g, '')
}
const endsWithDot = v.endsWith('.')
const parts = v.split('.')
let intPart = parts[0] || ''
let decPart = parts[1] || ''
if (decPart.length > 6) decPart = decPart.slice(0, 6)
if (intPart && intPart !== '0') intPart = String(Number(intPart))
if (endsWithDot && firstDot !== -1) {
this.editForm.feeRate = `${intPart || '0'}.`
return
}
this.editForm.feeRate = decPart ? `${intPart || '0'}.${decPart}` : (intPart || '')
},
// 简单的emoji检测覆盖常见表情平面与符号范围
hasEmoji(str) {
if (!str || typeof str !== 'string') return false
@@ -291,6 +331,7 @@ export default {
name: res.data.name,
image: res.data.image,
description: res.data.description,
feeRate: res.data.feeRate,
del: !!res.data.del,
state: Number(res.data.state || 0)
}
@@ -429,7 +470,8 @@ export default {
id: res.data.id,
name: res.data.name,
image: res.data.image,
description: res.data.description
description: res.data.description,
feeRate: res.data.feeRate
}
@@ -439,7 +481,8 @@ export default {
id: this.shop.id,
name: this.shop.name,
image: this.shop.image,
description: this.shop.description
description: this.shop.description,
feeRate: this.shop.feeRate
}
this.$message.warning(res && res.msg ? res.msg : '未获取到店铺详情')
}
@@ -449,7 +492,8 @@ export default {
id: this.shop.id,
name: this.shop.name,
image: this.shop.image,
description: this.shop.description
description: this.shop.description,
feeRate: this.shop.feeRate
}
console.error('查询店铺详情失败:', error)
@@ -492,7 +536,19 @@ export default {
this.$message.warning('店铺描述不能超过300个字符')
return
}
// 手续费比例必填、0.01-0.1、最多6位小数
const rateRaw = String(this.editForm.feeRate || '').trim()
if (!rateRaw) {
this.$message.warning('请填写店铺手续费比例0.01 - 0.1最多6位小数')
return
}
const rateNum = Number(rateRaw)
const decOk = rateRaw.includes('.') ? ((rateRaw.split('.')[1] || '').length <= 6) : true
if (!Number.isFinite(rateNum) || rateNum < 0.01 || rateNum > 0.1 || !decOk) {
this.$message.warning('手续费比例需在 0.01 - 0.1 之间且小数位不超过6位')
return
}
this.editForm.feeRate = rateNum.toString()
const payload = { ...this.editForm }
const res = await updateShop(payload)
@@ -585,9 +641,9 @@ export default {
})
return
}
// 跳转到新增商品页面并传递店铺ID
// 直接跳转到“添加出售机器”页面并传递店铺ID(供后续扩展使用)
this.$router.push({
path: '/account/product-new',
path: '/account/product-machine-add',
query: { shopId: this.shop.id }
})
},