li.shaoyi 2 weeks ago
parent
commit
7a5139cc63

+ 6 - 4
src/packages/digital/views/contract/components/position/detail/index.vue

@@ -16,7 +16,7 @@
                 <tr>
                     <td colspan="3">
                         <span class="text-small">{{ $t('account.profitLoss') + `(${currency(item.currencyid)})`
-                        }}</span>
+                            }}</span>
                         <span :class="item.profitLossClass">
                             {{ item.profitLoss.toFixed(item.decimalplace) }}
                         </span>
@@ -41,12 +41,12 @@
                 <tr>
                     <td>
                         <span class="text-small">{{ $t('position.goods.holderprice') + `(${currency(item.currencyid)})`
-                            }}</span>
+                        }}</span>
                         <span>{{ item.holderprice }}</span>
                     </td>
                     <td>
                         <span class="text-small">{{ $t('position.goods.holderamount') + `(${currency(item.currencyid)})`
-                            }}</span>
+                        }}</span>
                         <span>{{ item.holderamount }}</span>
                     </td>
                     <td></td>
@@ -108,7 +108,9 @@ const currency = (id: number) => {
     return getGoodsCurrencyItemName(id)
 }
 
-const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => onRefresh())
+const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => {
+    pullRefreshRef.value?.refresh()
+})
 
 const { dataList, loading, run } = useRequest(queryTradeHolderDetail, {
     defaultParams: props.params

+ 4 - 1
src/packages/digital/views/wallet/deposit/index.vue

@@ -117,7 +117,10 @@ const balance = computed(() => {
 const { dataList: walletAddress, run: getWalletAddress } = useRequest(queryWalletAddress)
 
 const { dataList: walletTokens, run: getWalletTokens } = useRequest(queryWalletTokens, {
-    manual: true
+    manual: true,
+    onSuccess: () => {
+        walletTokens.value.filter((e) => e.can_deposit === 1)
+    }
 })
 
 // 表单验证规则

+ 156 - 1
src/packages/digital/views/wallet/withdraw/index.vue

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