feat(金币代理页面): 做两种模式的兼容

This commit is contained in:
hzj 2026-04-15 20:28:39 +08:00
parent 435e67316b
commit 223c331985
6 changed files with 68 additions and 16 deletions

View File

@ -96,7 +96,8 @@
"search_user": "البحث عن المستخدم",
"enter_user_id": "يرجى إدخال id المستخدم",
"recharge": "شحن",
"enter_recharge_amount": "أدخل مبلغ الدولارات المراد شحنه للمستخدم.",
"enter_recharge_amount": "أدخل عدد القطع النقدية التي تريد إيداعها على المستخدم.",
"enter_recharge_dollar_amount": "أدخل مبلغ الدولارات المراد شحنه للمستخدم.",
"recharge_auto_convert_tip": "تحويل تلقائي لعدد العملات الذهبية المطلوبة للشحن.",
"recharge_ratio_text": "*$1={ratio} عملة",
"recharge_now": "شحن الآن",

View File

@ -96,7 +96,8 @@
"search_user": "ব্যবহারকারী অনুসন্ধান",
"enter_user_id": "দয়া করে ব্যবহারকারী আইডি লিখুন",
"recharge": "রিচার্জ",
"enter_recharge_amount": "ব্যবহারকারীকে রিচার্জ করার ডলারের পরিমাণ লিখুন।",
"enter_recharge_amount": "ব্যবহারকারীকে রিচার্জ করার মুদ্রার পরিমাণ লিখুন।",
"enter_recharge_dollar_amount": "ব্যবহারকারীকে রিচার্জ করার ডলারের পরিমাণ লিখুন।",
"recharge_auto_convert_tip": "রিচার্জের জন্য প্রয়োজনীয় গোল্ড কয়েন স্বয়ংক্রিয়ভাবে রূপান্তর করা হবে।",
"recharge_ratio_text": "*$1={ratio} কয়েন",
"recharge_now": "এখন রিচার্জ করুন",

View File

@ -96,7 +96,8 @@
"search_user": "Search user",
"enter_user_id": "Please enter the user ID",
"recharge": "Recharge",
"enter_recharge_amount": "Enter the amount of Dollars to be recharged to the user.",
"enter_recharge_amount": "Enter the amount of coins to be recharged to the user.",
"enter_recharge_dollar_amount": "Enter the amount of Dollars to be recharged to the user.",
"recharge_auto_convert_tip": "Autoconvert the gold coins needed for recharge.",
"recharge_ratio_text": "*$1={ratio}coins",
"recharge_now": "Recharge now",

View File

@ -96,7 +96,8 @@
"search_user": "Kullanıcı ara",
"enter_user_id": "Lütfen kullanıcı ID'sini girin",
"recharge": "Yükle",
"enter_recharge_amount": "Kullanıcıya yüklenecek Dolar miktarını girin.",
"enter_recharge_amount": "Kullanıcıya yüklenecek coin miktarını girin.",
"enter_recharge_dollar_amount": "Kullanıcıya yüklenecek Dolar miktarını girin.",
"recharge_auto_convert_tip": "Yükleme için gereken altın coin miktarı otomatik olarak dönüştürülür.",
"recharge_ratio_text": "*$1={ratio} coin",
"recharge_now": "Şimdi yükle",

View File

@ -96,7 +96,8 @@
"search_user": "搜索用户",
"enter_user_id": "请输入用户id",
"recharge": "充值",
"enter_recharge_amount": "请输入要向用户充值的美元金额。",
"enter_recharge_amount": "请输入要向用户充值的硬币数量。",
"enter_recharge_dollar_amount": "请输入要向用户充值的美元金额。",
"recharge_auto_convert_tip": "自动换算本次充值所需的金币数量。",
"recharge_ratio_text": "*$1={ratio}金币",
"recharge_now": "现在充值",

View File

@ -198,12 +198,15 @@
background-color: white;
padding: 10px 16px;
border-radius: 12px;
margin-bottom: 16px;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25);
"
>
<input
v-model="rechargeAmount"
:placeholder="t('enter_recharge_amount')"
:placeholder="
t(hasRechargeRatio ? 'enter_recharge_dollar_amount' : 'enter_recharge_amount')
"
class="amount-input"
@input="preventDecimalInput"
@keydown="onKeyDown"
@ -212,7 +215,10 @@
/>
</div>
<div style="margin: 10px 0 16px; display: flex; flex-direction: column; gap: 4px">
<div
v-if="hasRechargeRatio"
style="margin: 0 0 16px; display: flex; flex-direction: column; gap: 4px"
>
<div
v-if="rechargeCoinsNeeded == 0"
style="color: rgba(0, 0, 0, 0.4); font-weight: 600; font-size: 0.9em"
@ -411,6 +417,12 @@ const selectedAmount = ref({})
const isAbleSelect = ref(false) //
const rechargeRatio = ref(0) // 1
const hasRechargeRatio = computed(() => {
return (
freightThreshold.value &&
Object.prototype.hasOwnProperty.call(freightThreshold.value, 'rechargeRatio')
)
})
//
const amountStyle = (amountItem) => {
@ -561,12 +573,29 @@ const currentCoinBalance = computed(() => {
const rechargeDollarAmount = computed(() => {
return Number(rechargeAmount.value) || 0
})
const maxRechargeDollarAmount = computed(() => {
const ratio = Number(rechargeRatio.value) || 0
if (ratio <= 0) {
return 0
}
return Math.floor(currentCoinBalance.value / ratio)
})
const rechargeCoinsNeeded = computed(() => {
return rechargeDollarAmount.value * (Number(rechargeRatio.value) || 0)
})
//
const canRecharge = computed(() => {
if (!hasRechargeRatio.value) {
return (
selectedUser.value.id &&
rechargeAmount.value &&
rechargeDollarAmount.value > 0 &&
!isRecharging.value
)
}
return (
selectedUser.value.id &&
rechargeAmount.value &&
@ -590,6 +619,19 @@ const preventDecimalInput = (event) => {
value = ''
}
//
if (value !== '') {
const numericValue = parseInt(value)
if (hasRechargeRatio.value) {
if (numericValue > maxRechargeDollarAmount.value) {
value = maxRechargeDollarAmount.value > 0 ? String(maxRechargeDollarAmount.value) : ''
}
} else if (numericValue > currentCoinBalance.value) {
value = currentCoinBalance.value > 0 ? String(currentCoinBalance.value) : ''
}
}
//
event.target.value = value
@ -617,7 +659,7 @@ const rechargeNow = useThrottle(async () => {
return
}
if (quantity <= 0 || quantity > currentCoinBalance.value) {
if (hasRechargeRatio.value && (quantity <= 0 || quantity > currentCoinBalance.value)) {
return
}
@ -631,11 +673,16 @@ const rechargeNow = useThrottle(async () => {
try {
isRecharging.value = true
const rechargeData = {
acceptUserId: acceptUserId,
quantity: quantity,
amount: amount,
}
const rechargeData = hasRechargeRatio.value
? {
acceptUserId: acceptUserId,
quantity: amount,
amount: quantity,
}
: {
acceptUserId: acceptUserId,
quantity: amount,
}
const response = await freightRecharge(rechargeData)
@ -647,7 +694,7 @@ const rechargeNow = useThrottle(async () => {
showSuccess(
t('transfer_coin_success', {
amount: quantity,
amount: hasRechargeRatio.value ? quantity : amount,
name: selectedUser.value.name,
}),
)
@ -657,7 +704,7 @@ const rechargeNow = useThrottle(async () => {
} else {
showError(
t('transfer_coin_failed', {
amount: quantity,
amount: hasRechargeRatio.value ? quantity : amount,
}),
)
}
@ -666,7 +713,7 @@ const rechargeNow = useThrottle(async () => {
showError(
error.response.errorMsg ||
t('transfer_coin_failed', {
amount: quantity,
amount: hasRechargeRatio.value ? quantity : amount,
}),
)
} finally {