feat(金币代理页面): 对接兑换比例数据
This commit is contained in:
parent
aee4293b15
commit
5c1450f64a
@ -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": "سجل البائع",
|
||||
|
||||
@ -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": "বিক্রেতা রেকর্ড",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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ı",
|
||||
|
||||
@ -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": "卖家记录",
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user