Handy_Cao 1 月之前
父節點
當前提交
a11c501b87

+ 1 - 1
src/packages/digital/views/contract/components/position/index.vue

@@ -19,7 +19,7 @@
                             <time class="text-small">{{ formatDate(item.tHDetailEx.tradeTime) }}</time>
                         </th>
                         <th>
-                            <span :class="!item.buyorsell ? 'g-price-up' : 'g-price-down'">
+                            <span :class="item.tHDetailEx.buyorsell === 0 ? 'g-price-up' : 'g-price-down'">
                                 {{ getBuyOrSellName(item.tHDetailEx.buyOrSell) }}
                             </span>
                         </th>

+ 4 - 4
src/packages/digital/views/contract/goods/detail/index.vue

@@ -10,7 +10,7 @@
                         <template #label>
                             <span>{{ quote?.presettle }}</span>
                             <span>{{ parsePercent(quote?.change) }}</span>
-                            <span>{{ getGoodsCurrencyName(goods.currencyid) }}</span>
+                            <span>{{ getGoodsCurrencyName(goods?.currencyid) }}</span>
                         </template>
                         <template #right-icon>
                             <span @click="routerToChart">图表</span>
@@ -21,10 +21,10 @@
         </template>
         <Row class="g-layout-block g-layout-block--inset" gutter="10">
             <Col span="12">
-            <span :class="quote.askColor">{{ quote.ask }}</span>
+            <span :class="quote?.askColor">{{ quote?.ask }}</span>
             </Col>
             <Col span="12">
-            <span :class="quote.bidColor">{{ quote.bid }}</span>
+            <span :class="quote?.bidColor">{{ quote?.bid }}</span>
             </Col>
         </Row>
         <Row class="g-layout-block g-layout-block--inset" gutter="10">
@@ -64,7 +64,7 @@
         </Form>
         <Row class="g-layout-block g-layout-block--inset">
             <Col span="24">
-            <Button :type="formData.BuyOrSell === BuyOrSell.Buy ? 'success' : 'danger' " block @click="onSubmit">{{ formData.BuyOrSell === BuyOrSell.Buy ? '开多' : '开空' }}{{ goods.goodscode }}</Button>
+            <Button :type="formData.BuyOrSell === BuyOrSell.Buy ? 'success' : 'danger' " block @click="onSubmit">{{ formData.BuyOrSell === BuyOrSell.Buy ? '开多' : '开空' }}{{ goods?.goodscode }}</Button>
             </Col>
         </Row>
         <Tabs v-model:active="tabIndex">

+ 29 - 52
src/packages/digital/views/spot/goods/detail/index.vue

@@ -8,10 +8,8 @@
                             <b>{{ quote?.goodscode }}</b>
                         </template>
                         <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 #right-icon>
                             <span @click="navigateToGoodsChart">图表</span>
@@ -46,24 +44,20 @@
                     v-if="formData.PriceMode === PriceMode.Market" />
                 <Field label="数量">
                     <template #input>
-                        <app-stepper v-model="formData.OrderQty" :min="0" />
+                        <app-stepper v-model="formData.OrderQty" />
                     </template>
                 </Field>
-                <Cell :title="formData.BuyOrSell === BuyOrSell.Buy ? '预估支付' : '预估获取'"
-                    :value="formatDecimal(calculations.estimatedAmount, quoteAccount?.currencydecimalplace)" />
+                <Cell :title="formData.BuyOrSell === BuyOrSell.Buy ? '预估支付' : '预估获取'" :value="calculations.estimatedAmount" />
             </CellGroup>
             <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 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>
         </Form>
         <Row class="g-layout-block g-layout-block--inset">
@@ -86,25 +80,22 @@
 </template>
 
 <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 { fullloading } from '@/utils/vant'
 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 { 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()
@@ -115,7 +106,7 @@ const formRef = shallowRef<FormInstance>()
 
 const formData = reactive<Partial<Proto.DigitalOrderReq>>({
     BuyOrSell: BuyOrSell.Buy,
-    PriceMode: PriceMode.Market,
+    PriceMode: PriceMode.Limit,
     OperateType: EOrderOperateType.ORDEROPERATETYPE_NORMAL,
     ListingSelectType: EListingSelectType.LISTINGSELECTTYPE_DELISTING,
     DelistingType: EDelistingType.DELISTINGTYPE_SELECTED,
@@ -130,39 +121,35 @@ 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 * 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 {
         estimatedAmount,
-        maxBalance,
-        maxBuyQty,
+        availableBalance,
+        availableQty,
         buyEstimatedFee,
-        maxAmount,
-        maxSellQty,
+        availableAmount,
+        sellQty,
         sellEstimatedFee
     }
 })
@@ -178,12 +165,9 @@ const navigateToGoodsChart = () => {
 
 const onSubmit = () => {
     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.MarketID = quote.value?.marketid
 
@@ -208,14 +192,7 @@ const onSubmit = () => {
 }
 
 onMounted(() => {
-    if (quote.value) {
-        subscribe.start(quote.value.goodscode)
-        formData.OrderPrice = quote.value.last
-    }
-})
-
-onUnmounted(() => {
-    subscribe.stop()
+    formData.OrderPrice = quote.value?.last
 })
 </script>