|
@@ -8,10 +8,8 @@
|
|
|
<b>{{ quote?.goodscode }}</b>
|
|
<b>{{ quote?.goodscode }}</b>
|
|
|
</template>
|
|
</template>
|
|
|
<template #label>
|
|
<template #label>
|
|
|
- <div style="display: flex; align-items: center; gap: 10px;">
|
|
|
|
|
- <h2 :class="quote?.lastColor">{{ quote?.last }}</h2>
|
|
|
|
|
- <span>{{ parsePercent(quote?.change) }}</span>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <span :class="quote?.lastColor">{{ quote?.last }}</span>
|
|
|
|
|
+ <span>{{ parsePercent(quote?.change) }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template #right-icon>
|
|
<template #right-icon>
|
|
|
<span @click="navigateToGoodsChart">图表</span>
|
|
<span @click="navigateToGoodsChart">图表</span>
|
|
@@ -46,24 +44,20 @@
|
|
|
v-if="formData.PriceMode === PriceMode.Market" />
|
|
v-if="formData.PriceMode === PriceMode.Market" />
|
|
|
<Field label="数量">
|
|
<Field label="数量">
|
|
|
<template #input>
|
|
<template #input>
|
|
|
- <app-stepper v-model="formData.OrderQty" :min="0" />
|
|
|
|
|
|
|
+ <app-stepper v-model="formData.OrderQty" />
|
|
|
</template>
|
|
</template>
|
|
|
</Field>
|
|
</Field>
|
|
|
- <Cell :title="formData.BuyOrSell === BuyOrSell.Buy ? '预估支付' : '预估获取'"
|
|
|
|
|
- :value="formatDecimal(calculations.estimatedAmount, quoteAccount?.currencydecimalplace)" />
|
|
|
|
|
|
|
+ <Cell :title="formData.BuyOrSell === BuyOrSell.Buy ? '预估支付' : '预估获取'" :value="calculations.estimatedAmount" />
|
|
|
</CellGroup>
|
|
</CellGroup>
|
|
|
<CellGroup inset v-if="formData.BuyOrSell === BuyOrSell.Buy">
|
|
<CellGroup inset v-if="formData.BuyOrSell === BuyOrSell.Buy">
|
|
|
- <Cell title="预估手续费"
|
|
|
|
|
- :value="formatDecimal(calculations.buyEstimatedFee, quoteAccount?.currencydecimalplace)" />
|
|
|
|
|
- <Cell title="可用余额"
|
|
|
|
|
- :value="formatDecimal(calculations.maxBalance, quoteAccount?.currencydecimalplace)" />
|
|
|
|
|
- <Cell title="可买数量" :value="formatDecimal(calculations.maxBuyQty, baseAccount?.currencydecimalplace)" />
|
|
|
|
|
|
|
+ <Cell title="可用余额" :value="calculations.availableBalance" />
|
|
|
|
|
+ <Cell title="可开数量" :value="calculations.availableQty" />
|
|
|
|
|
+ <Cell title="预估手续费" :value="calculations.buyEstimatedFee" />
|
|
|
</CellGroup>
|
|
</CellGroup>
|
|
|
<CellGroup inset v-if="formData.BuyOrSell === BuyOrSell.Sell">
|
|
<CellGroup inset v-if="formData.BuyOrSell === BuyOrSell.Sell">
|
|
|
- <Cell title="预估手续费"
|
|
|
|
|
- :value="formatDecimal(calculations.sellEstimatedFee, quoteAccount?.currencydecimalplace)" />
|
|
|
|
|
- <Cell title="可获金额" :value="formatDecimal(calculations.maxAmount, quoteAccount?.currencydecimalplace)" />
|
|
|
|
|
- <Cell title="可卖数量" :value="formatDecimal(calculations.maxSellQty, baseAccount?.currencydecimalplace)" />
|
|
|
|
|
|
|
+ <Cell title="可获金额" :value="calculations.availableAmount" />
|
|
|
|
|
+ <Cell title="可卖数量" :value="calculations.sellQty" />
|
|
|
|
|
+ <Cell title="预估手续费" :value="calculations.sellEstimatedFee" />
|
|
|
</CellGroup>
|
|
</CellGroup>
|
|
|
</Form>
|
|
</Form>
|
|
|
<Row class="g-layout-block g-layout-block--inset">
|
|
<Row class="g-layout-block g-layout-block--inset">
|
|
@@ -86,25 +80,22 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, reactive, computed, onMounted, onUnmounted } from 'vue'
|
|
|
|
|
|
|
+import { shallowRef, reactive, computed, onMounted } from 'vue'
|
|
|
import { Form, Button, CellGroup, Field, Cell, Tab, Tabs, Col, Row, FormInstance } from 'vant'
|
|
import { Form, Button, CellGroup, Field, Cell, Tab, Tabs, Col, Row, FormInstance } from 'vant'
|
|
|
import { fullloading } from '@/utils/vant'
|
|
import { fullloading } from '@/utils/vant'
|
|
|
import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EValidType } from '@/constants/client'
|
|
import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EValidType } from '@/constants/client'
|
|
|
-import { parsePercent, handleNumberValue, formatDecimal } from '@/filters'
|
|
|
|
|
|
|
+import { parsePercent, handleNumberValue } from '@/filters'
|
|
|
import { BuyOrSell, PriceMode, getPricemode2List } from '@/constants/order'
|
|
import { BuyOrSell, PriceMode, getPricemode2List } from '@/constants/order'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
|
import { digitalOrder } from '@/services/api/digital'
|
|
import { digitalOrder } from '@/services/api/digital'
|
|
|
import { useFuturesStore, useUserStore } from '@/stores'
|
|
import { useFuturesStore, useUserStore } from '@/stores'
|
|
|
import { useSpotAccountStore } from '../../../wallet/components/spot/composables'
|
|
import { useSpotAccountStore } from '../../../wallet/components/spot/composables'
|
|
|
-import quoteSocket from '@/services/websocket/quote'
|
|
|
|
|
import Long from 'long'
|
|
import Long from 'long'
|
|
|
import AppSelect from '@mobile/components/base/select/index.vue'
|
|
import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
import AppStepper from '@mobile/components/base/stepper/index.vue'
|
|
import AppStepper from '@mobile/components/base/stepper/index.vue'
|
|
|
import SpotOrder from '../../components/order/index.vue'
|
|
import SpotOrder from '../../components/order/index.vue'
|
|
|
import SpotAccount from '../../components/account/index.vue'
|
|
import SpotAccount from '../../components/account/index.vue'
|
|
|
|
|
|
|
|
-const subscribe = quoteSocket.createSubscribe()
|
|
|
|
|
-
|
|
|
|
|
const { router, getQueryStringToNumber } = useNavigation()
|
|
const { router, getQueryStringToNumber } = useNavigation()
|
|
|
const goodsId = getQueryStringToNumber('id')
|
|
const goodsId = getQueryStringToNumber('id')
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
@@ -115,7 +106,7 @@ const formRef = shallowRef<FormInstance>()
|
|
|
|
|
|
|
|
const formData = reactive<Partial<Proto.DigitalOrderReq>>({
|
|
const formData = reactive<Partial<Proto.DigitalOrderReq>>({
|
|
|
BuyOrSell: BuyOrSell.Buy,
|
|
BuyOrSell: BuyOrSell.Buy,
|
|
|
- PriceMode: PriceMode.Market,
|
|
|
|
|
|
|
+ PriceMode: PriceMode.Limit,
|
|
|
OperateType: EOrderOperateType.ORDEROPERATETYPE_NORMAL,
|
|
OperateType: EOrderOperateType.ORDEROPERATETYPE_NORMAL,
|
|
|
ListingSelectType: EListingSelectType.LISTINGSELECTTYPE_DELISTING,
|
|
ListingSelectType: EListingSelectType.LISTINGSELECTTYPE_DELISTING,
|
|
|
DelistingType: EDelistingType.DELISTINGTYPE_SELECTED,
|
|
DelistingType: EDelistingType.DELISTINGTYPE_SELECTED,
|
|
@@ -130,39 +121,35 @@ const baseAccount = computed(() => spotAccountStore.getAccountItem({ currencyid:
|
|
|
const quoteAccount = computed(() => spotAccountStore.getAccountItem({ currencyid: quote.value?.currencyid })) // 计价货币账户
|
|
const quoteAccount = computed(() => spotAccountStore.getAccountItem({ currencyid: quote.value?.currencyid })) // 计价货币账户
|
|
|
|
|
|
|
|
const calculations = computed(() => {
|
|
const calculations = computed(() => {
|
|
|
- const buyFeeValue = futuresStore.getFeeValue(quote.value, 101)
|
|
|
|
|
- const sellFeeValue = futuresStore.getFeeValue(quote.value, 102)
|
|
|
|
|
-
|
|
|
|
|
const { last = 0, agreeunit = 0 } = quote.value ?? {}
|
|
const { last = 0, agreeunit = 0 } = quote.value ?? {}
|
|
|
const { OrderPrice = 0, OrderQty = 0 } = formData
|
|
const { OrderPrice = 0, OrderQty = 0 } = formData
|
|
|
|
|
|
|
|
const price = formData.PriceMode === PriceMode.Market ? last : OrderPrice
|
|
const price = formData.PriceMode === PriceMode.Market ? last : OrderPrice
|
|
|
- const amount = OrderQty * agreeunit
|
|
|
|
|
|
|
|
|
|
// 预估金额
|
|
// 预估金额
|
|
|
- const estimatedAmount = price * amount
|
|
|
|
|
|
|
+ const estimatedAmount = price * OrderQty * agreeunit
|
|
|
|
|
|
|
|
// 可用余额
|
|
// 可用余额
|
|
|
- const maxBalance = spotAccountStore.getAvailableBalance(quoteAccount.value)
|
|
|
|
|
- // 可买数量
|
|
|
|
|
- const maxBuyQty = price ? maxBalance / (price * agreeunit) : 0
|
|
|
|
|
|
|
+ const availableBalance = spotAccountStore.getAvailableBalance(quoteAccount.value)
|
|
|
|
|
+ // 可用数量
|
|
|
|
|
+ const availableQty = availableBalance / agreeunit
|
|
|
// 预估手续费
|
|
// 预估手续费
|
|
|
- const buyEstimatedFee = (buyFeeValue.FeeAlgorithm === 2 ? amount : estimatedAmount) * buyFeeValue.feeValue
|
|
|
|
|
|
|
+ const buyEstimatedFee = 0
|
|
|
|
|
|
|
|
// 可卖数量
|
|
// 可卖数量
|
|
|
- const maxSellQty = spotAccountStore.getAvailableBalance(baseAccount.value)
|
|
|
|
|
|
|
+ const sellQty = spotAccountStore.getAvailableBalance(baseAccount.value)
|
|
|
// 可获金额
|
|
// 可获金额
|
|
|
- const maxAmount = price * maxSellQty * agreeunit
|
|
|
|
|
|
|
+ const availableAmount = price * sellQty * agreeunit
|
|
|
// 预估手续费
|
|
// 预估手续费
|
|
|
- const sellEstimatedFee = (sellFeeValue.FeeAlgorithm === 2 ? amount : estimatedAmount) * sellFeeValue.feeValue
|
|
|
|
|
|
|
+ const sellEstimatedFee = 0
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
estimatedAmount,
|
|
estimatedAmount,
|
|
|
- maxBalance,
|
|
|
|
|
- maxBuyQty,
|
|
|
|
|
|
|
+ availableBalance,
|
|
|
|
|
+ availableQty,
|
|
|
buyEstimatedFee,
|
|
buyEstimatedFee,
|
|
|
- maxAmount,
|
|
|
|
|
- maxSellQty,
|
|
|
|
|
|
|
+ availableAmount,
|
|
|
|
|
+ sellQty,
|
|
|
sellEstimatedFee
|
|
sellEstimatedFee
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
@@ -178,12 +165,9 @@ const navigateToGoodsChart = () => {
|
|
|
|
|
|
|
|
const onSubmit = () => {
|
|
const onSubmit = () => {
|
|
|
fullloading((hideLoading) => {
|
|
fullloading((hideLoading) => {
|
|
|
- const baseAccountId = baseAccount.value?.digitalaccountid
|
|
|
|
|
- const quoteAccountId = quoteAccount.value?.digitalaccountid
|
|
|
|
|
-
|
|
|
|
|
- if (baseAccountId && quoteAccountId) {
|
|
|
|
|
- formData.BaseAccountID = Long.fromString(baseAccountId)
|
|
|
|
|
- formData.QuoteAccountID = Long.fromString(quoteAccountId)
|
|
|
|
|
|
|
+ if (baseAccount.value && quoteAccount.value) {
|
|
|
|
|
+ formData.BaseAccountID = Long.fromString(baseAccount.value.digitalaccountid)
|
|
|
|
|
+ formData.QuoteAccountID = Long.fromString(quoteAccount.value.digitalaccountid)
|
|
|
formData.GoodsID = quote.value?.goodsid
|
|
formData.GoodsID = quote.value?.goodsid
|
|
|
formData.MarketID = quote.value?.marketid
|
|
formData.MarketID = quote.value?.marketid
|
|
|
|
|
|
|
@@ -208,14 +192,7 @@ const onSubmit = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
- if (quote.value) {
|
|
|
|
|
- subscribe.start(quote.value.goodscode)
|
|
|
|
|
- formData.OrderPrice = quote.value.last
|
|
|
|
|
- }
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
-onUnmounted(() => {
|
|
|
|
|
- subscribe.stop()
|
|
|
|
|
|
|
+ formData.OrderPrice = quote.value?.last
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|