|
|
@@ -92,10 +92,10 @@
|
|
|
<ion-input
|
|
|
v-model="withdrawAmount"
|
|
|
:placeholder="$t('balance.withdrawInputTip')"
|
|
|
+ type="number"
|
|
|
inputmode="decimal"
|
|
|
:size="36"
|
|
|
clearInput
|
|
|
- @ionBlur="formatAmount"
|
|
|
></ion-input>
|
|
|
</div>
|
|
|
<div class="item">
|
|
|
@@ -131,8 +131,22 @@ import { modalController } from '@ionic/vue'
|
|
|
import WebViewPage from './WebViewPage.vue'
|
|
|
import { closeOutline } from 'ionicons/icons'
|
|
|
import { showConfirmDialog } from 'vant'
|
|
|
-
|
|
|
+import { watchDebounced } from '@vueuse/core'
|
|
|
+import { ref } from 'vue'
|
|
|
export default {
|
|
|
+ setup() {
|
|
|
+ const withdrawAmount = ref(null)
|
|
|
+ const formatAmount = () => {
|
|
|
+ console.log('formatAmount', withdrawAmount)
|
|
|
+ if (withdrawAmount.value && Number(withdrawAmount.value)) {
|
|
|
+ withdrawAmount.value = Math.floor(Number(withdrawAmount.value) / 100) * 100
|
|
|
+ } else {
|
|
|
+ withdrawAmount.value = null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ watchDebounced(withdrawAmount, formatAmount, { debounce: 800, maxWait: 1000000 })
|
|
|
+ return { withdrawAmount, formatAmount }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
balance: {
|
|
|
@@ -144,7 +158,6 @@ export default {
|
|
|
amountOptions: [50, 100, 200, 500, 1000, 2000, 3000, 5000, 10000],
|
|
|
customAmount: null,
|
|
|
showWithdrawModal: false,
|
|
|
- withdrawAmount: null,
|
|
|
withdrawFeeRate: 0.08,
|
|
|
withdrawFeeLowRate: 0.01,
|
|
|
windowSize: useWindowSize(),
|
|
|
@@ -192,7 +205,7 @@ export default {
|
|
|
}
|
|
|
return {
|
|
|
fee: fee.toFixed(2),
|
|
|
- realReceipt: (amount - fee).toFixed(2)
|
|
|
+ realReceipt: amount.toFixed(2)
|
|
|
}
|
|
|
},
|
|
|
breakpoint() {
|
|
|
@@ -248,26 +261,24 @@ export default {
|
|
|
this.$toast.error(e.error)
|
|
|
})
|
|
|
},
|
|
|
- formatAmount() {
|
|
|
- console.log('formatAmount', this.withdrawAmount)
|
|
|
- if (this.withdrawAmount && Number(this.withdrawAmount)) {
|
|
|
- let amount = Math.floor(this.withdrawAmount / 100) * 100
|
|
|
- if (amount === 100) {
|
|
|
- amount = 120
|
|
|
- }
|
|
|
- this.withdrawAmount = amount
|
|
|
- }
|
|
|
- },
|
|
|
withdraw() {
|
|
|
this.formatAmount()
|
|
|
const amount = Number(this.withdrawAmount)
|
|
|
- if (!amount || this.withdrawAmount <= 0 || this.withdrawAmount > this.balance.balance) {
|
|
|
+ if (!amount) {
|
|
|
this.$toast.error(this.$t('balance.withdrawAmountError'))
|
|
|
return
|
|
|
}
|
|
|
+ if (amount < 100) {
|
|
|
+ this.$toast.error(this.$t('balance.withdrawMin', { value: 100 }))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (amount + Number(this.fee.fee) > this.balance.balance) {
|
|
|
+ this.$toast.error(this.$t('balance.insufficientBalance'))
|
|
|
+ return
|
|
|
+ }
|
|
|
this.$toast.loading(this.$t('balance.withdrawing'))
|
|
|
this.$http
|
|
|
- .post('/withdrawApply/apply', { amount })
|
|
|
+ .post('/withdrawApply/apply', { amount, separateFee: true })
|
|
|
.then(res => {
|
|
|
this.$toast.dismiss()
|
|
|
this.getBalance()
|