|
|
@@ -6,22 +6,12 @@
|
|
|
</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"
|
|
|
- center is-link>
|
|
|
- <template #input>
|
|
|
- <image-icon :url="getCurrencyIconUrl(currentyItem.label)" size="small" v-if="currentyItem" />
|
|
|
- <app-select v-model="state.currentyId" :options="digitalCurrentyList"
|
|
|
- @confirm="onCurrentyChange" />
|
|
|
- </template>
|
|
|
- </Field>
|
|
|
+ <app-field-currency name="currency" label="币种" label-align="top" :rules="formRules.currency"
|
|
|
+ v-model="state.currencyId" @change="onCurrencyChange" />
|
|
|
</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>
|
|
|
+ <app-field-token name="token" label="存款网络" label-align="top" :rules="formRules.token"
|
|
|
+ v-model="state.tokenId" :currency="state.currencyName" @change="onTokenChange" />
|
|
|
</CellGroup>
|
|
|
</Form>
|
|
|
<CellGroup inset v-if="tokenItem">
|
|
|
@@ -30,7 +20,7 @@
|
|
|
<dl class="g-layout-block g-layout-block--inset">
|
|
|
<dt>
|
|
|
<h3>存款地址</h3>
|
|
|
- <span>*仅将 {{ currentyItem?.label }} 存入此地址</span>
|
|
|
+ <span>*仅将 {{ state.currencyName }} 存入此地址</span>
|
|
|
</dt>
|
|
|
<dd v-for="(item, index) in addressList" :key="index">
|
|
|
<span>{{ item.address }}</span>
|
|
|
@@ -43,24 +33,6 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</CellGroup>
|
|
|
- <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-icon :url="item.icon_url" style="margin-right: 8px;" />
|
|
|
- </template> -->
|
|
|
- <template #right-icon>
|
|
|
- <Radio :name="item.id" />
|
|
|
- </template>
|
|
|
- </Cell>
|
|
|
- </template>
|
|
|
- </RadioGroup>
|
|
|
- <Empty description="暂无数据" v-else />
|
|
|
- </CellGroup>
|
|
|
- </ActionSheet>
|
|
|
<Dialog v-model:show="state.showDialog" :show-confirm-button="false" cancel-button-text="关闭" show-cancel-button
|
|
|
destroy-on-close>
|
|
|
<div class="wallet-deposit__qrcode">
|
|
|
@@ -71,44 +43,40 @@
|
|
|
</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 { shallowRef, computed, reactive } from 'vue'
|
|
|
+import { FormInstance, FieldRule, Form, Button, CellGroup, Cell, Icon, showSuccessToast, showFailToast, Dialog } from 'vant'
|
|
|
import { dialog, fullloading } from '@/utils/vant'
|
|
|
-import { formatDecimal, getCurrencyIconUrl } from '@/filters'
|
|
|
-import { getDigitalCurrencyList } from '@/constants/order'
|
|
|
+import { formatDecimal } from '@/filters'
|
|
|
import { useRequest } from '@/hooks/request'
|
|
|
-import { queryWalletAddress, queryWalletTokens, createDigitalWalletAddress } from '@/services/api/digital'
|
|
|
+import { queryWalletAddress, createDigitalWalletAddress } from '@/services/api/digital'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
|
import { useSpotAccountStore } from '../components/spot/composables'
|
|
|
import AppQrcode from '@/components/base/qrcode/index.vue'
|
|
|
-import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
-import ImageIcon from '@mobile/components/base/image-icon/index.vue'
|
|
|
+import AppFieldCurrency from '@/packages/digital/components/field-currency/index.vue'
|
|
|
+import AppFieldToken from '@/packages/digital/components/field-token/index.vue'
|
|
|
|
|
|
const { getQueryStringToNumber } = useNavigation()
|
|
|
|
|
|
+const spotAccountStore = useSpotAccountStore()
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
const currencyId = getQueryStringToNumber('id')
|
|
|
|
|
|
-const spotAccountStore = useSpotAccountStore()
|
|
|
-const digitalCurrentyList = getDigitalCurrencyList()
|
|
|
-
|
|
|
const state = reactive({
|
|
|
showSheet: false,
|
|
|
showDialog: false,
|
|
|
qrContent: '',
|
|
|
- currentyId: currencyId,
|
|
|
+ currencyId: currencyId,
|
|
|
+ currencyName: '',
|
|
|
tokenId: 0
|
|
|
})
|
|
|
|
|
|
-const addressList = computed(() => walletAddress.value.filter((e) => e.chain_id === tokenItem.value?.chain_id))
|
|
|
+const { dataList: walletAddress, run: getWalletAddress } = useRequest(queryWalletAddress)
|
|
|
|
|
|
-const currentyItem = computed(() => digitalCurrentyList.find((e) => e.enumitemname === state.currentyId))
|
|
|
+const tokenItem = shallowRef<Model.WalletTokensRsp>()
|
|
|
|
|
|
-const tokenItem = computed(() => walletTokens.value.find((e) => e.id === state.tokenId))
|
|
|
+const addressList = computed(() => walletAddress.value.filter((e) => e.chain_id === tokenItem.value?.chain_id))
|
|
|
|
|
|
-const accountItem = computed(() => spotAccountStore.getAccountItem({
|
|
|
- currencyid: currencyId
|
|
|
-}))
|
|
|
+const accountItem = computed(() => spotAccountStore.getAccountItem({ currencyid: currencyId }))
|
|
|
|
|
|
// 可用余额
|
|
|
const balance = computed(() => {
|
|
|
@@ -116,20 +84,11 @@ const balance = computed(() => {
|
|
|
return formatDecimal(balance, accountItem.value?.currencydecimalplace)
|
|
|
})
|
|
|
|
|
|
-const { dataList: walletAddress, run: getWalletAddress } = useRequest(queryWalletAddress)
|
|
|
-
|
|
|
-const { dataList: walletTokens, run: getWalletTokens } = useRequest(queryWalletTokens, {
|
|
|
- manual: true,
|
|
|
- onSuccess: () => {
|
|
|
- walletTokens.value.filter((e) => e.can_deposit === 1)
|
|
|
- }
|
|
|
-})
|
|
|
-
|
|
|
// 表单验证规则
|
|
|
const formRules: { [key: string]: FieldRule[] } = {
|
|
|
- currenty: [{
|
|
|
+ currency: [{
|
|
|
message: '请选择币种',
|
|
|
- validator: () => !!state.currentyId
|
|
|
+ validator: () => !!state.currencyId
|
|
|
}],
|
|
|
token: [{
|
|
|
message: '请选择网络',
|
|
|
@@ -137,21 +96,15 @@ const formRules: { [key: string]: FieldRule[] } = {
|
|
|
}],
|
|
|
}
|
|
|
|
|
|
-const onCurrentyChange = () => {
|
|
|
+const onCurrencyChange = (item: { label: string; }) => {
|
|
|
state.tokenId = 0
|
|
|
-
|
|
|
- if (currentyItem.value) {
|
|
|
- getWalletTokens({
|
|
|
- currency: currentyItem.value.label
|
|
|
- })
|
|
|
- } else {
|
|
|
- walletTokens.value = []
|
|
|
- }
|
|
|
+ state.currencyName = item.label
|
|
|
+ tokenItem.value = undefined
|
|
|
}
|
|
|
|
|
|
-const onRadioClick = (value: number) => {
|
|
|
- state.tokenId = value
|
|
|
- state.showSheet = false
|
|
|
+const onTokenChange = (item: Model.WalletTokensRsp) => {
|
|
|
+ tokenItem.value = item
|
|
|
+ formRef.value?.validate('token')
|
|
|
}
|
|
|
|
|
|
const openQRcode = (address: string) => {
|
|
|
@@ -190,10 +143,6 @@ const onSubmit = () => {
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
-onMounted(() => {
|
|
|
- onCurrentyChange()
|
|
|
-})
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|