feat(金币代理页面): 做两种模式的兼容
This commit is contained in:
parent
435e67316b
commit
223c331985
@ -96,7 +96,8 @@
|
|||||||
"search_user": "البحث عن المستخدم",
|
"search_user": "البحث عن المستخدم",
|
||||||
"enter_user_id": "يرجى إدخال id المستخدم",
|
"enter_user_id": "يرجى إدخال id المستخدم",
|
||||||
"recharge": "شحن",
|
"recharge": "شحن",
|
||||||
"enter_recharge_amount": "أدخل مبلغ الدولارات المراد شحنه للمستخدم.",
|
"enter_recharge_amount": "أدخل عدد القطع النقدية التي تريد إيداعها على المستخدم.",
|
||||||
|
"enter_recharge_dollar_amount": "أدخل مبلغ الدولارات المراد شحنه للمستخدم.",
|
||||||
"recharge_auto_convert_tip": "تحويل تلقائي لعدد العملات الذهبية المطلوبة للشحن.",
|
"recharge_auto_convert_tip": "تحويل تلقائي لعدد العملات الذهبية المطلوبة للشحن.",
|
||||||
"recharge_ratio_text": "*$1={ratio} عملة",
|
"recharge_ratio_text": "*$1={ratio} عملة",
|
||||||
"recharge_now": "شحن الآن",
|
"recharge_now": "شحن الآن",
|
||||||
|
|||||||
@ -96,7 +96,8 @@
|
|||||||
"search_user": "ব্যবহারকারী অনুসন্ধান",
|
"search_user": "ব্যবহারকারী অনুসন্ধান",
|
||||||
"enter_user_id": "দয়া করে ব্যবহারকারী আইডি লিখুন",
|
"enter_user_id": "দয়া করে ব্যবহারকারী আইডি লিখুন",
|
||||||
"recharge": "রিচার্জ",
|
"recharge": "রিচার্জ",
|
||||||
"enter_recharge_amount": "ব্যবহারকারীকে রিচার্জ করার ডলারের পরিমাণ লিখুন।",
|
"enter_recharge_amount": "ব্যবহারকারীকে রিচার্জ করার মুদ্রার পরিমাণ লিখুন।",
|
||||||
|
"enter_recharge_dollar_amount": "ব্যবহারকারীকে রিচার্জ করার ডলারের পরিমাণ লিখুন।",
|
||||||
"recharge_auto_convert_tip": "রিচার্জের জন্য প্রয়োজনীয় গোল্ড কয়েন স্বয়ংক্রিয়ভাবে রূপান্তর করা হবে।",
|
"recharge_auto_convert_tip": "রিচার্জের জন্য প্রয়োজনীয় গোল্ড কয়েন স্বয়ংক্রিয়ভাবে রূপান্তর করা হবে।",
|
||||||
"recharge_ratio_text": "*$1={ratio} কয়েন",
|
"recharge_ratio_text": "*$1={ratio} কয়েন",
|
||||||
"recharge_now": "এখন রিচার্জ করুন",
|
"recharge_now": "এখন রিচার্জ করুন",
|
||||||
|
|||||||
@ -96,7 +96,8 @@
|
|||||||
"search_user": "Search user",
|
"search_user": "Search user",
|
||||||
"enter_user_id": "Please enter the user ID",
|
"enter_user_id": "Please enter the user ID",
|
||||||
"recharge": "Recharge",
|
"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_auto_convert_tip": "Autoconvert the gold coins needed for recharge.",
|
||||||
"recharge_ratio_text": "*$1={ratio}coins",
|
"recharge_ratio_text": "*$1={ratio}coins",
|
||||||
"recharge_now": "Recharge now",
|
"recharge_now": "Recharge now",
|
||||||
|
|||||||
@ -96,7 +96,8 @@
|
|||||||
"search_user": "Kullanıcı ara",
|
"search_user": "Kullanıcı ara",
|
||||||
"enter_user_id": "Lütfen kullanıcı ID'sini girin",
|
"enter_user_id": "Lütfen kullanıcı ID'sini girin",
|
||||||
"recharge": "Yükle",
|
"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_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_ratio_text": "*$1={ratio} coin",
|
||||||
"recharge_now": "Şimdi yükle",
|
"recharge_now": "Şimdi yükle",
|
||||||
|
|||||||
@ -96,7 +96,8 @@
|
|||||||
"search_user": "搜索用户",
|
"search_user": "搜索用户",
|
||||||
"enter_user_id": "请输入用户id",
|
"enter_user_id": "请输入用户id",
|
||||||
"recharge": "充值",
|
"recharge": "充值",
|
||||||
"enter_recharge_amount": "请输入要向用户充值的美元金额。",
|
"enter_recharge_amount": "请输入要向用户充值的硬币数量。",
|
||||||
|
"enter_recharge_dollar_amount": "请输入要向用户充值的美元金额。",
|
||||||
"recharge_auto_convert_tip": "自动换算本次充值所需的金币数量。",
|
"recharge_auto_convert_tip": "自动换算本次充值所需的金币数量。",
|
||||||
"recharge_ratio_text": "*$1={ratio}金币",
|
"recharge_ratio_text": "*$1={ratio}金币",
|
||||||
"recharge_now": "现在充值",
|
"recharge_now": "现在充值",
|
||||||
|
|||||||
@ -198,12 +198,15 @@
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
padding: 10px 16px;
|
padding: 10px 16px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25);
|
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25);
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
v-model="rechargeAmount"
|
v-model="rechargeAmount"
|
||||||
:placeholder="t('enter_recharge_amount')"
|
:placeholder="
|
||||||
|
t(hasRechargeRatio ? 'enter_recharge_dollar_amount' : 'enter_recharge_amount')
|
||||||
|
"
|
||||||
class="amount-input"
|
class="amount-input"
|
||||||
@input="preventDecimalInput"
|
@input="preventDecimalInput"
|
||||||
@keydown="onKeyDown"
|
@keydown="onKeyDown"
|
||||||
@ -212,7 +215,10 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</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
|
<div
|
||||||
v-if="rechargeCoinsNeeded == 0"
|
v-if="rechargeCoinsNeeded == 0"
|
||||||
style="color: rgba(0, 0, 0, 0.4); font-weight: 600; font-size: 0.9em"
|
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 isAbleSelect = ref(false) // 是否可以设置
|
||||||
const rechargeRatio = ref(0) // 充值比例,1美元兑换多少金币
|
const rechargeRatio = ref(0) // 充值比例,1美元兑换多少金币
|
||||||
|
const hasRechargeRatio = computed(() => {
|
||||||
|
return (
|
||||||
|
freightThreshold.value &&
|
||||||
|
Object.prototype.hasOwnProperty.call(freightThreshold.value, 'rechargeRatio')
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// 选项样式
|
// 选项样式
|
||||||
const amountStyle = (amountItem) => {
|
const amountStyle = (amountItem) => {
|
||||||
@ -561,12 +573,29 @@ const currentCoinBalance = computed(() => {
|
|||||||
const rechargeDollarAmount = computed(() => {
|
const rechargeDollarAmount = computed(() => {
|
||||||
return Number(rechargeAmount.value) || 0
|
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(() => {
|
const rechargeCoinsNeeded = computed(() => {
|
||||||
return rechargeDollarAmount.value * (Number(rechargeRatio.value) || 0)
|
return rechargeDollarAmount.value * (Number(rechargeRatio.value) || 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 是否可以充值
|
// 是否可以充值
|
||||||
const canRecharge = computed(() => {
|
const canRecharge = computed(() => {
|
||||||
|
if (!hasRechargeRatio.value) {
|
||||||
|
return (
|
||||||
|
selectedUser.value.id &&
|
||||||
|
rechargeAmount.value &&
|
||||||
|
rechargeDollarAmount.value > 0 &&
|
||||||
|
!isRecharging.value
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
selectedUser.value.id &&
|
selectedUser.value.id &&
|
||||||
rechargeAmount.value &&
|
rechargeAmount.value &&
|
||||||
@ -590,6 +619,19 @@ const preventDecimalInput = (event) => {
|
|||||||
value = ''
|
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
|
event.target.value = value
|
||||||
|
|
||||||
@ -617,7 +659,7 @@ const rechargeNow = useThrottle(async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quantity <= 0 || quantity > currentCoinBalance.value) {
|
if (hasRechargeRatio.value && (quantity <= 0 || quantity > currentCoinBalance.value)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,11 +673,16 @@ const rechargeNow = useThrottle(async () => {
|
|||||||
try {
|
try {
|
||||||
isRecharging.value = true
|
isRecharging.value = true
|
||||||
|
|
||||||
const rechargeData = {
|
const rechargeData = hasRechargeRatio.value
|
||||||
acceptUserId: acceptUserId,
|
? {
|
||||||
quantity: quantity,
|
acceptUserId: acceptUserId,
|
||||||
amount: amount,
|
quantity: amount,
|
||||||
}
|
amount: quantity,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
acceptUserId: acceptUserId,
|
||||||
|
quantity: amount,
|
||||||
|
}
|
||||||
|
|
||||||
const response = await freightRecharge(rechargeData)
|
const response = await freightRecharge(rechargeData)
|
||||||
|
|
||||||
@ -647,7 +694,7 @@ const rechargeNow = useThrottle(async () => {
|
|||||||
|
|
||||||
showSuccess(
|
showSuccess(
|
||||||
t('transfer_coin_success', {
|
t('transfer_coin_success', {
|
||||||
amount: quantity,
|
amount: hasRechargeRatio.value ? quantity : amount,
|
||||||
name: selectedUser.value.name,
|
name: selectedUser.value.name,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -657,7 +704,7 @@ const rechargeNow = useThrottle(async () => {
|
|||||||
} else {
|
} else {
|
||||||
showError(
|
showError(
|
||||||
t('transfer_coin_failed', {
|
t('transfer_coin_failed', {
|
||||||
amount: quantity,
|
amount: hasRechargeRatio.value ? quantity : amount,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -666,7 +713,7 @@ const rechargeNow = useThrottle(async () => {
|
|||||||
showError(
|
showError(
|
||||||
error.response.errorMsg ||
|
error.response.errorMsg ||
|
||||||
t('transfer_coin_failed', {
|
t('transfer_coin_failed', {
|
||||||
amount: quantity,
|
amount: hasRechargeRatio.value ? quantity : amount,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user