周五定时更新

This commit is contained in:
2025-10-31 14:09:58 +08:00
parent a60603acd0
commit a2fc94b402
28 changed files with 830 additions and 265 deletions

View File

@@ -134,17 +134,17 @@
<el-dialog title="修改配置" :visible.sync="visibleConfigEdit" width="560px">
<div class="row">
<label class="label">支付链</label>
<el-select v-model="configForm.chain" placeholder="请选择链">
<el-option v-for="c in chainOptions" :key="c.value" :value="c.value" :label="c.label" />
</el-select>
<el-input v-model="configForm.chainLabel" placeholder="-" disabled />
</div>
<div class="row">
<label class="label">支付币种</label>
<el-select
class="input"
size="middle"
ref="screen"
v-model="configForm.payCoin"
v-model="configForm.payCoins"
multiple
collapse-tags
filterable
placeholder="请选择币种"
>
<el-option
@@ -152,20 +152,22 @@
:key="item.value"
:label="item.label"
:value="item.value"
>
<div style="display: flex; align-items: center">
<img v-if="item.imgUrl" :src="item.imgUrl" style="float: left; width: 20px" />
<span style="float: left; margin-left: 5px">{{ item.label }}</span>
</div>
</el-option>
/>
</el-select>
</div>
<div class="row">
<label class="label">币种类型</label>
<el-radio-group v-model="configForm.payType">
<el-radio :label="0">虚拟币</el-radio>
<el-radio :label="1">稳定币</el-radio>
</el-radio-group>
<label class="label">已选择币种</label>
<div class="selected-coin-list">
<el-tag
v-for="c in selectedCoinLabels"
:key="c"
type="warning"
effect="light"
closable
@close="removeSelectedCoin(c)"
>{{ c }}</el-tag>
<span v-if="!selectedCoinLabels.length" style="color:#c0c4cc">未选择</span>
</div>
</div>
<div class="row">
<label class="label">钱包地址</label>
@@ -173,7 +175,7 @@
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visibleConfigEdit=false">取消</el-button>
<el-button type="primary" @click="submitConfigEdit">保存</el-button>
<el-button type="primary" @click="submitConfigEdit">确认修改</el-button>
</span>
</el-dialog>
</div>
@@ -181,7 +183,7 @@
</template>
<script>
import { getMyShop, updateShop, deleteShop, queryShop, closeShop ,updateShopConfig,deleteShopConfig} from '@/api/shops'
import { getMyShop, updateShop, deleteShop, queryShop, closeShop ,updateShopConfig,deleteShopConfig,getChainAndCoin} from '@/api/shops'
import { coinList } from '@/utils/coinList'
import { getShopConfig } from '@/api/wallet'
@@ -206,9 +208,10 @@ export default {
// 店铺配置列表
shopConfigs: [],
visibleConfigEdit: false,
configForm: { id: '', chain: '', payAddress: '', payCoin: '', payType: 0 },
configForm: { id: '', chainLabel: '', chainValue: '', payAddress: '', payCoins: [], payCoin: '' },
productOptions: [],
coinOptions: coinList || [],
editCoinOptionsApi: [],
// 支付链选项(可与后端接口对齐后替换为动态)
chainOptions: [
{ label: 'Tron (TRC20)', value: 'tron' },
@@ -244,14 +247,12 @@ export default {
* 弹窗可选币种:稳定币/虚拟币分流
*/
editCoinOptions() {
if (Number(this.configForm.payType) === 1) {
return [
{ label: 'USDT', value: 'usdt' },
{ label: 'USDC', value: 'usdc' },
{ label: 'BUSD', value: 'busd' },
]
}
if (Array.isArray(this.editCoinOptionsApi) && this.editCoinOptionsApi.length) return this.editCoinOptionsApi
return this.coinOptions
},
selectedCoinLabels() {
const map = new Map((this.editCoinOptions || []).map(o => [String(o.value), String(o.label).toUpperCase()]))
return (this.configForm.payCoins || []).map(v => map.get(String(v)) || String(v).toUpperCase())
}
},
created() {
@@ -338,8 +339,6 @@ export default {
this.$message.success('保存成功')
this.visibleConfigEdit = false
this.fetchShopConfigs(this.shop.id)
} else {
this.$message.error(res && res.msg ? res.msg : '保存失败')
}
},
async deleteShopConfig(params) {
@@ -349,16 +348,41 @@ export default {
this.fetchShopConfigs(this.shop.id)
}
},
handleEditConfig(row) {
this.configForm = {
id: row.id,
chain: row.chain || '',
payCoin: row.payCoin || '',
payType: typeof row.payType === 'number' ? row.payType : Number(row.payType || 0),
payAddress: row.payAddress || '',
async handleEditConfig(row) {
try {
const res = await getChainAndCoin({ id: row.id })
if (res && (res.code === 0 || res.code === 200) && res.data) {
const d = res.data || {}
const children = Array.isArray(d.children) ? d.children : []
this.editCoinOptionsApi = children.map(c => ({ label: c.label, value: c.value }))
const preSelected = children.filter(c => Number(c.hasBind) === 1).map(c => c.value)
this.configForm = {
id: row.id,
chainLabel: d.label || '',
chainValue: d.value || '',
payAddress: d.address || '',
payCoins: preSelected,
payCoin: preSelected.join(',')
}
} else {
// 回退:使用行内已有数据
this.editCoinOptionsApi = []
const chainLabel = row.chain || ''
const payCoinStr = String(row.payCoin || '')
const payCoins = payCoinStr ? payCoinStr.split(',') : []
this.configForm = {
id: row.id,
chainLabel,
chainValue: row.chain || '',
payAddress: row.payAddress || '',
payCoins,
payCoin: payCoins.join(',')
}
}
this.visibleConfigEdit = true
} catch (e) {
this.visibleConfigEdit = true
}
this.visibleConfigEdit = true
},
async handleDeleteConfig(row) {
this.deleteShopConfig({id:row.id})
@@ -366,11 +390,11 @@ export default {
submitConfigEdit() {
// 基础校验
if (!this.configForm.chain) {
if (!this.configForm.chainLabel && !this.configForm.chainValue) {
this.$message.warning('请选择支付链')
return
}
if (!this.configForm.payCoin) {
if (!this.configForm.payCoins || this.configForm.payCoins.length === 0) {
this.$message.warning('请选择支付币种')
return
}
@@ -379,10 +403,21 @@ export default {
this.$message.warning('请输入钱包地址')
return
}
const { productId, ...rest } = this.configForm
const payload = { ...rest, payType: Number(this.configForm.payType || 0) }
const payload = {
id: this.configForm.id,
chain: this.configForm.chainValue || this.configForm.chainLabel,
payCoin: (this.configForm.payCoins || []).join(','),
payAddress: this.configForm.payAddress
}
this.updateShopConfig(payload)
},
removeSelectedCoin(labelUpper) {
const label = String(labelUpper || '').toLowerCase()
const map = new Map((this.editCoinOptions || []).map(o => [String(o.label).toLowerCase(), String(o.value)]))
const value = map.get(label)
if (!value) return
this.configForm.payCoins = (this.configForm.payCoins || []).filter(v => String(v) !== String(value))
},
async handleOpenEdit() {
try {
// 先打开弹窗,提供更快的视觉反馈
@@ -627,5 +662,9 @@ export default {
.el-dialog__footer {
padding-top: 4px;
}
/* 已选择币种 - 靠左对齐且换行友好 */
.selected-coin-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
.selected-coin-list .el-tag { margin-right: 0; }
</style>