feat(金币代理页面): 对接兑换比例数据

This commit is contained in:
hzj 2026-04-15 19:49:02 +08:00
parent aee4293b15
commit 5c1450f64a
6 changed files with 71 additions and 32 deletions

View File

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

View File

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

View File

@ -96,7 +96,9 @@
"search_user": "Search user",
"enter_user_id": "Please enter the user ID",
"recharge": "Recharge",
"enter_recharge_amount": "Enter the amount of coins to be recharged to the user.",
"enter_recharge_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",
"succeed": "Succeed",
"seller_records": "Seller Records",

View File

@ -96,7 +96,9 @@
"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 coin miktarını girin.",
"enter_recharge_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",
"succeed": "Başarılı",
"seller_records": "Satıcı Kayıtları",

View File

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

View File

@ -191,10 +191,10 @@
<div style="margin-bottom: 12px; font-weight: 600; color: #333">
{{ t('recharge') }}
</div>
<div></div>
<!-- 输入金额 -->
<div
style="
margin-bottom: 16px;
background-color: white;
padding: 10px 16px;
border-radius: 12px;
@ -212,6 +212,15 @@
/>
</div>
<div style="margin: 10px 0 16px">
<div style="color: rgba(0, 0, 0, 0.4); font-weight: 600; font-size: 0.9em">
{{ t('recharge_auto_convert_tip') }}
</div>
<div style="color: rgba(0, 0, 0, 0.4); font-weight: 600; font-size: 0.9em">
{{ t('recharge_ratio_text', { ratio: rechargeRatio }) }}
</div>
</div>
<!-- 按钮 -->
<div style="display: flex; justify-content: center">
<button
@ -385,8 +394,9 @@ const AmountList = computed(() => {
})
const selectedAmount = ref({})
//
const isAbleSelect = ref(false)
const isAbleSelect = ref(false) //
const rechargeRatio = ref(0) // 1
//
const amountStyle = (amountItem) => {
@ -446,24 +456,6 @@ const Confirm = () => {
closedPopup()
}
//
const preventDecimalInput = (event) => {
let value = event.target.value
//
value = value.replace(/[^0-9]/g, '')
// 1
if (value === '' || parseInt(value) < 1) {
value = ''
}
//
event.target.value = value
rechargeAmount.value = parseFloat(value) || 0
}
//
const onKeyDown = (event) => {
// e+-
@ -520,6 +512,7 @@ const getFreightThreshold = async () => {
if (resFreightThreshold.status && resFreightThreshold.body) {
freightThreshold.value = resFreightThreshold.body
isAbleSelect.value = !resFreightThreshold.body?.settinged //
rechargeRatio.value = resFreightThreshold.body?.rechargeRatio || 0 //
}
}
@ -548,17 +541,47 @@ const initializeUser = () => {
//
const rechargeAmount = ref('')
const isRecharging = ref(false)
const currentCoinBalance = computed(() => {
return Number(coinsAmount.value) || 0
})
const rechargeDollarAmount = computed(() => {
return Number(rechargeAmount.value) || 0
})
const rechargeCoinsNeeded = computed(() => {
return rechargeDollarAmount.value * (Number(rechargeRatio.value) || 0)
})
//
const canRecharge = computed(() => {
return (
selectedUser.value.id &&
rechargeAmount.value &&
parseFloat(rechargeAmount.value) > 0 &&
rechargeDollarAmount.value > 0 &&
Number(rechargeRatio.value) > 0 &&
rechargeCoinsNeeded.value > 0 &&
rechargeCoinsNeeded.value <= currentCoinBalance.value &&
!isRecharging.value
)
})
//
const preventDecimalInput = (event) => {
let value = event.target.value
//
value = value.replace(/[^0-9]/g, '')
// 1
if (value === '' || parseInt(value) < 1) {
value = ''
}
//
event.target.value = value
rechargeAmount.value = parseFloat(value) || 0
}
//
const goToRecords = () => {
router.push('/seller-records')
@ -573,12 +596,17 @@ const searchUser = () => {
const rechargeNow = useThrottle(async () => {
if (!canRecharge.value || isRecharging.value) return
const amount = parseFloat(rechargeAmount.value)
const amount = rechargeDollarAmount.value
const quantity = rechargeCoinsNeeded.value
if (amount <= 0) {
showError(t('please_enter_valid_amount'))
return
}
if (quantity <= 0 || quantity > currentCoinBalance.value) {
return
}
// ID
const acceptUserId = selectedUser.value.id
if (!acceptUserId) {
@ -591,7 +619,8 @@ const rechargeNow = useThrottle(async () => {
const rechargeData = {
acceptUserId: acceptUserId,
quantity: amount,
quantity: quantity,
amount: amount,
}
const response = await freightRecharge(rechargeData)
@ -604,7 +633,7 @@ const rechargeNow = useThrottle(async () => {
showSuccess(
t('transfer_coin_success', {
amount: amount,
amount: quantity,
name: selectedUser.value.name,
}),
)
@ -614,7 +643,7 @@ const rechargeNow = useThrottle(async () => {
} else {
showError(
t('transfer_coin_failed', {
amount: amount,
amount: quantity,
}),
)
}
@ -623,7 +652,7 @@ const rechargeNow = useThrottle(async () => {
showError(
error.response.errorMsg ||
t('transfer_coin_failed', {
amount: amount,
amount: quantity,
}),
)
} finally {