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