x1ongzhu преди 2 години
родител
ревизия
56bfefb48a
променени са 3 файла, в които са добавени 31 реда и са изтрити 16 реда
  1. 2 0
      src/locales/en.json
  2. 2 0
      src/locales/zh.json
  3. 27 16
      src/views/WalletPage.vue

+ 2 - 0
src/locales/en.json

@@ -27,6 +27,8 @@
         "withdraw": "Withdraw",
         "withdrawAmount": "Withdrawal Amount",
         "withdrawAmountError": "Enter the correct withdrawal amount",
+        "insufficientBalance": "Insufficient balance",
+        "withdrawMin": "The minimum withdrawal amount is {value}",
         "withdrawFee": "Withdrawal fee",
         "withdrawFeeTip": "Note: The rate is <span class=\"rate1\">{rate1}</span> for 1/3 of the total purchase volume and <span class=\"rate2\">{rate2}</span> for the excess.",
         "withdrawing": "Withdrawing",

+ 2 - 0
src/locales/zh.json

@@ -27,6 +27,8 @@
         "withdraw": "提现",
         "withdrawAmount": "提现金额",
         "withdrawAmountError": "请输入正确的提现金额",
+        "insufficientBalance": "余额不足",
+        "withdrawMin": "最低提现金额为{value}",
         "withdrawFee": "提现手续费",
         "withdrawFeeTip": "注: 购买总流水的1/3手续费为 <span class=\"rate1\">{rate1}</span>,超出部分手续费为 <span class=\"rate2\">{rate2}</span>",
         "withdrawing": "提现中",

+ 27 - 16
src/views/WalletPage.vue

@@ -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()