|
|
@@ -1,16 +1,171 @@
|
|
|
<!-- 钱包-提现 -->
|
|
|
<template>
|
|
|
- <app-view class="wallet-deposit">
|
|
|
+ <app-view class="wallet-withdraw g-layout g-form">
|
|
|
<template #header>
|
|
|
<app-navbar title="提现" />
|
|
|
</template>
|
|
|
+ <Form ref="formRef" class="g-form__container g-layout-block" @submit="onSubmit">
|
|
|
+ <CellGroup inset>
|
|
|
+ <Field name="currenty" label="币种" label-align="top" :rules="formRules.currenty" arrow-direction="down"
|
|
|
+ is-link>
|
|
|
+ <template #input>
|
|
|
+ <app-select v-model="formData.CurrencyID" :options="digitalCurrentyList"
|
|
|
+ @confirm="onCurrentyChange" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ </CellGroup>
|
|
|
+ <CellGroup inset>
|
|
|
+ <Field name="token" label="网络" label-align="top" placeholder="请选择" :rules="formRules.token"
|
|
|
+ arrow-direction="down" is-link readonly @click="state.showSheet = true">
|
|
|
+ <template #input v-if="tokenItem">
|
|
|
+ {{ tokenItem.name }} ({{ tokenItem.chain_id }})
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ </CellGroup>
|
|
|
+ <CellGroup inset>
|
|
|
+ <Field name="Address" v-model="formData.Address" label="地址" label-align="top" placeholder="请输入"
|
|
|
+ :rules="formRules.Address" />
|
|
|
+ </CellGroup>
|
|
|
+ <CellGroup inset>
|
|
|
+ <Cell title="数量" :value="`可用 (${formatDecimal(balance, accountItem?.currencydecimalplace)})`" />
|
|
|
+ <Field name="Amount" label-align="top" :rules="formRules.Amount">
|
|
|
+ <template #input>
|
|
|
+ <app-stepper v-model="formData.Amount" :min="0" :max="balance" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ </CellGroup>
|
|
|
+ </Form>
|
|
|
+ <div class="g-form__footer inset">
|
|
|
+ <Button type="primary" block @click="formRef?.submit">提现</Button>
|
|
|
+ </div>
|
|
|
+ <ActionSheet v-model:show="state.showSheet" title="选择网络">
|
|
|
+ <CellGroup style="min-height: 200px;">
|
|
|
+ <RadioGroup v-model="state.tokenId" v-if="walletTokens.length">
|
|
|
+ <template v-for="(item, index) in walletTokens" :key="index">
|
|
|
+ <Cell :title="item.name" :label="item.chain_id" :border="false" clickable center
|
|
|
+ @click="onRadioClick(item.id)">
|
|
|
+ <!-- <template #icon>
|
|
|
+ <Image fit="contain" :src="item.icon_url" width="28" height="28" round style="margin-right: 10px;" />
|
|
|
+ </template> -->
|
|
|
+ <template #right-icon>
|
|
|
+ <Radio :name="item.id" />
|
|
|
+ </template>
|
|
|
+ </Cell>
|
|
|
+ </template>
|
|
|
+ </RadioGroup>
|
|
|
+ <Empty description="暂无数据" v-else />
|
|
|
+ </CellGroup>
|
|
|
+ </ActionSheet>
|
|
|
</app-view>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
+import { shallowRef, computed, reactive, onMounted } from 'vue'
|
|
|
+import { FormInstance, FieldRule, Form, Button, CellGroup, Field, Cell, ActionSheet, RadioGroup, Radio, Icon, showSuccessToast, showFailToast, Dialog, Empty } from 'vant'
|
|
|
+import { fullloading } from '@/utils/vant'
|
|
|
+import { formatDecimal } from '@/filters'
|
|
|
+import { getDigitalCurrencyList } from '@/constants/order'
|
|
|
+import { useRequest } from '@/hooks/request'
|
|
|
+import { queryWalletTokens, digitalAccountWithdrawApply } from '@/services/api/digital'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
|
+import { useSpotAccountStore } from '../components/spot/composables'
|
|
|
+import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
+import AppStepper from '@mobile/components/base/stepper/index.vue'
|
|
|
|
|
|
const { getQueryStringToNumber } = useNavigation()
|
|
|
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
const currencyId = getQueryStringToNumber('id')
|
|
|
+
|
|
|
+const spotAccountStore = useSpotAccountStore()
|
|
|
+const digitalCurrentyList = getDigitalCurrencyList()
|
|
|
+
|
|
|
+const state = reactive({
|
|
|
+ showSheet: false,
|
|
|
+ showDialog: false,
|
|
|
+ qrContent: '',
|
|
|
+ tokenId: 0
|
|
|
+})
|
|
|
+
|
|
|
+const formData = reactive<Partial<Proto.DigitalAccountWithdrawApplyReq>>({
|
|
|
+ CurrencyID: currencyId
|
|
|
+})
|
|
|
+
|
|
|
+const currentyItem = computed(() => digitalCurrentyList.find((e) => e.enumitemname === formData.CurrencyID))
|
|
|
+
|
|
|
+const tokenItem = computed(() => walletTokens.value.find((e) => e.id === state.tokenId))
|
|
|
+
|
|
|
+const accountItem = computed(() => spotAccountStore.getAccountItem({
|
|
|
+ currencyid: formData.CurrencyID
|
|
|
+}))
|
|
|
+
|
|
|
+// 可用余额
|
|
|
+const balance = computed(() => spotAccountStore.getAvailableBalance(accountItem.value))
|
|
|
+
|
|
|
+const { dataList: walletTokens, run: getWalletTokens } = useRequest(queryWalletTokens, {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: () => {
|
|
|
+ walletTokens.value.filter((e) => e.can_withdraw === 1)
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: { [key: string]: FieldRule[] } = {
|
|
|
+ currenty: [{
|
|
|
+ message: '请选择币种',
|
|
|
+ validator: () => !!formData.CurrencyID
|
|
|
+ }],
|
|
|
+ token: [{
|
|
|
+ message: '请选择网络',
|
|
|
+ validator: () => !!state.tokenId
|
|
|
+ }],
|
|
|
+ Address: [{
|
|
|
+ required:true,
|
|
|
+ message: '请输入地址'
|
|
|
+ }],
|
|
|
+ Amount: [{
|
|
|
+ message: '请输入数量',
|
|
|
+ validator: () => !!formData.Amount
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+const onCurrentyChange = () => {
|
|
|
+ state.tokenId = 0
|
|
|
+
|
|
|
+ if (currentyItem.value) {
|
|
|
+ getWalletTokens({
|
|
|
+ currency: currentyItem.value.label
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ walletTokens.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const onRadioClick = (value: number) => {
|
|
|
+ state.tokenId = value
|
|
|
+ state.showSheet = false
|
|
|
+}
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ fullloading((hideLoading) => {
|
|
|
+ digitalAccountWithdrawApply({
|
|
|
+ data: {
|
|
|
+ ...formData,
|
|
|
+ DigitalAccountID: Number(accountItem.value?.digitalaccountid),
|
|
|
+ ExtendInfo: JSON.stringify({
|
|
|
+ token_id: tokenItem.value?.token_id,
|
|
|
+ memo: ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).then(() => {
|
|
|
+ hideLoading('提现成功', 'success')
|
|
|
+ }).catch((err) => {
|
|
|
+ hideLoading(err, 'fail')
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ onCurrentyChange()
|
|
|
+})
|
|
|
</script>
|