li.shaoyi 1 год назад
Родитель
Сommit
b3194b9eb2

+ 17 - 0
src/filters/index.ts

@@ -168,6 +168,23 @@ export function round(value: number, precision = 2) {
 }
 
 /**
+ * 乘方函数,处理计算精度问题
+ * @param base 
+ * @param exponent 
+ * @returns 
+ */
+export function pow(base:number, exponent:number) {  
+    let result = 1;  
+    for (let i = 0; i < Math.abs(exponent); i++) {  
+        result *= base
+    }  
+    if (exponent < 0) {  
+        return 1 / result
+    }  
+    return result
+}
+
+/**
  * 强制保留小数位,不足位数自动补零
  * @param value 
  * @param decimal 保留小数位

+ 2 - 2
src/hooks/hqchart/candlestick/dataset.ts

@@ -168,8 +168,8 @@ export function useDataset(goodsCode: string, cycleType = ChartCycleType.Minutes
                     record.h = last // 更新最高价
                 }
                 record.c = last // 更新收盘价
-                record.tv = q.lastvolume ?? record.tv
-                record.tt = q.Lastturnover ?? record.tt
+                record.tv += q.lastvolume ?? 0 // 累计数量
+                record.tt += q.Lastturnover ?? 0 // 累计金额
                 record.hv = q.holdvolume ?? record.hv
                 record.s = q.settle ?? record.s
             }

+ 2 - 2
src/hooks/hqchart/timeline/dataset.ts

@@ -171,8 +171,8 @@ export function useDataset(goodsCode: string) {
                     record.h = last // 更新最高价
                 }
                 record.c = last // 更新收盘价
-                record.tv = q.lastvolume ?? record.tv
-                record.tt = q.Lastturnover ?? record.tt
+                record.tv += q.lastvolume ?? 0 // 累计数量
+                record.tt += q.Lastturnover ?? 0 // 累计金额
                 record.hv = q.holdvolume ?? record.hv
                 record.s = q.settle ?? record.s
             }

+ 2 - 1
src/packages/mobile/views/goods/detail/components/listing/Index.vue

@@ -80,6 +80,7 @@
 import { shallowRef, defineAsyncComponent, onMounted, computed } from 'vue'
 import { Form, FormInstance, Button, CellGroup, FieldRule, Field, Stepper, RadioGroup, Radio } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
+import { pow } from '@/filters'
 import { BuyOrSell } from '@/constants/order'
 import { useOrder } from '@/business/trade'
 import { usePosition } from '@/business/position'
@@ -119,7 +120,7 @@ const isTrademode16 = computed(() => quote.value?.trademode === 16)
 const priceStep = computed(() => {
     const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
     if (quoteminunit) {
-        return quoteminunit * Math.pow(10, decimalplace * -1)
+        return quoteminunit * pow(10, decimalplace * -1)
     }
     return 1
 })

+ 2 - 2
src/packages/mobile/views/order/position/components/goods/close/Index.vue

@@ -50,7 +50,7 @@ import { shallowRef, PropType, onMounted, computed } from 'vue'
 import AppModal from '@/components/base/modal/index.vue'
 import { CellGroup, Cell, Button, FieldRule, Form, Field, Stepper, FormInstance } from 'vant'
 import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
-import { formatDecimal, handleNumberValue } from '@/filters'
+import { formatDecimal, handleNumberValue, pow } from '@/filters'
 import { useOrder } from '@/business/trade'
 import { dialog, fullloading } from '@/utils/vant'
 import { useFuturesStore } from '@/stores'
@@ -78,7 +78,7 @@ const { formSubmit, formData } = useOrder()
 const priceStep = computed(() => {
     const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
     if (quoteminunit) {
-        return quoteminunit * Math.pow(10, decimalplace * -1)
+        return quoteminunit * pow(10, decimalplace * -1)
     }
     return 1
 })

+ 2 - 2
src/packages/mobile/views/order/position/components/goods/detail/components/transfer/Index.vue

@@ -51,7 +51,7 @@ import { shallowRef, PropType, onMounted, computed } from 'vue'
 import AppModal from '@/components/base/modal/index.vue'
 import { CellGroup, Cell, Button, FieldRule, Form, Field, Stepper, FormInstance } from 'vant'
 import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
-import { formatDecimal, handleNumberValue, handleRequestBigNumber, handlePriceColor } from '@/filters'
+import { formatDecimal, handleNumberValue, handleRequestBigNumber, handlePriceColor, pow } from '@/filters'
 import { useOrder } from '@/business/trade'
 import { dialog, fullloading } from '@/utils/vant'
 import { useFuturesStore, usePositionStore } from '@/stores'
@@ -72,7 +72,7 @@ const quote = futuresStore.getGoodsQuote(props.selectedRow.goodscode)
 const priceStep = computed(() => {
     const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
     if (quoteminunit) {
-        return quoteminunit * Math.pow(10, decimalplace * -1)
+        return quoteminunit * pow(10, decimalplace * -1)
     }
     return 1
 })

+ 2 - 1
src/packages/mobile/views/transfer/listing/Index.vue

@@ -56,6 +56,7 @@
 import { shallowRef, defineAsyncComponent, computed, onMounted } from 'vue'
 import { CellGroup, Form, Field, Stepper, Button, FieldRule, FormInstance, RadioGroup, Radio } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
+import { pow } from '@/filters'
 import { useRequest } from '@/hooks/request'
 import { queryMineTradePositionExs } from '@/services/api/transfer'
 import { useOrder } from '@/business/trade'
@@ -106,7 +107,7 @@ const { dataList, run: getMineTradePositionExs } = useRequest(queryMineTradePosi
 const priceStep = computed(() => {
     const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
     if (quoteminunit) {
-        return quoteminunit * Math.pow(10, decimalplace * -1)
+        return quoteminunit * pow(10, decimalplace * -1)
     }
     return 1
 })

+ 0 - 6
src/packages/pc/components/modules/hqchart/timeline/index.vue

@@ -69,12 +69,6 @@ const chartOption = {
                     { Text: '价:' + handleNumberValue(Close), Color: paint.GetColor(Open, YClose) },
                     { Text: '幅:' + Increase.toFixed(2) + '%', Color: paint.GetColor(Increase, 0) }
                 ]
-                if (goods.value?.trademode !== 99) {
-                    AryText.push(
-                        { Text: '量:' + changeUnit(Vol), Color: paint.VolColor },
-                        { Text: '额:' + changeUnit(Amount), Color: paint.AmountColor }
-                    )
-                }
                 return {
                     AryText
                 }

+ 2 - 2
src/packages/pc/views/footer/goods/detail/components/transfer/index.vue

@@ -48,7 +48,7 @@
 import { ref, PropType, computed, onMounted } from 'vue'
 import { ElMessage, FormInstance, FormRules } from 'element-plus'
 import { useOrder } from '@/business/trade'
-import { formatDecimal, handlePriceColor, handleRequestBigNumber } from '@/filters'
+import { formatDecimal, handlePriceColor, handleRequestBigNumber, pow } from '@/filters'
 import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
 import { useFuturesStore, usePositionStore } from '@/stores'
 import { EBuildType, EDelistingType, EListingSelectType, EPriceMode, EValidType } from '@/constants/client'
@@ -76,7 +76,7 @@ const maxQty = computed(() => {
 const priceStep = computed(() => {
     const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
     if (quoteminunit) {
-        return quoteminunit * Math.pow(10, decimalplace * -1)
+        return quoteminunit * pow(10, decimalplace * -1)
     }
     return 1
 })

+ 2 - 2
src/packages/pc/views/footer/goods/position/components/transfer/index.vue

@@ -56,7 +56,7 @@
 import { ref, PropType, onMounted, computed } from 'vue'
 import { ElMessage, FormInstance, FormRules } from 'element-plus'
 import { useOrder } from '@/business/trade'
-import { formatDecimal, parsePercent } from '@/filters'
+import { formatDecimal, parsePercent, pow } from '@/filters'
 import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
 import { useFuturesStore } from '@/stores'
 import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
@@ -86,7 +86,7 @@ const qtyStep = ref<number>() // 数量步长
 const priceStep = computed(() => {
     const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
     if (quoteminunit) {
-        return quoteminunit * Math.pow(10, decimalplace * -1)
+        return quoteminunit * pow(10, decimalplace * -1)
     }
     return 1
 })

+ 2 - 1
src/packages/pc/views/market/trade/goods/list/listing/index.vue

@@ -85,6 +85,7 @@
 <script lang="ts" setup>
 import { shallowRef, computed, watch, onMounted } from 'vue'
 import { ElMessage, ElMessageBox, FormInstance, FormRules } from 'element-plus'
+import { pow } from '@/filters'
 import { EPriceMode, EListingSelectType, EDelistingType, EBuildType, EValidType, EOrderOperateType } from '@/constants/client'
 import { BuyOrSell, getBuyOrSellList } from '@/constants/order'
 import { useOrder } from '@/business/trade'
@@ -114,7 +115,7 @@ const isTrademode16 = computed(() => selectedGoods.value?.trademode === 16)
 const priceStep = computed(() => {
     const { quoteminunit = 0, decimalplace = 0 } = selectedGoods.value ?? {}
     if (quoteminunit) {
-        return quoteminunit * Math.pow(10, decimalplace * -1)
+        return quoteminunit * pow(10, decimalplace * -1)
     }
     return 1
 })

+ 2 - 1
src/packages/pc/views/market/trade/presell/transfer/listing/index.vue

@@ -64,6 +64,7 @@
 <script lang="ts" setup>
 import { shallowRef, computed, watch, onMounted } from 'vue'
 import { ElMessage, ElMessageBox, FormInstance, FormRules } from 'element-plus'
+import { pow } from '@/filters'
 import { EPriceMode, EListingSelectType, EDelistingType, EBuildType, EValidType } from '@/constants/client'
 import { BuyOrSell, getBuyOrSellList } from '@/constants/order'
 import { useRequest } from '@/hooks/request'
@@ -106,7 +107,7 @@ const enableqty = computed(() => {
 const priceStep = computed(() => {
     const { quoteminunit = 0, decimalplace = 0 } = selectedGoods.value ?? {}
     if (quoteminunit) {
-        return quoteminunit * Math.pow(10, decimalplace * -1)
+        return quoteminunit * pow(10, decimalplace * -1)
     }
     return 1
 })

+ 3 - 0
src/services/websocket/package/package40/decode.ts

@@ -145,6 +145,9 @@ function setQuoteTikFieldByByte(quote: Proto.Quote, key: number, value: Uint8Arr
         case 0x25:
             quote.lastvolume = Number(strValue);
             break;
+        case 0x26:
+            quote.lastturnover = Number(strValue);
+            break;
         case 0x3c:
             quote.preholdvolume = Number(strValue);
             break;

+ 2 - 0
src/stores/modules/futures.ts

@@ -259,6 +259,7 @@ export const useFuturesStore = defineStore(() => {
             askvolume4: quote.askvolume4 ?? 0,
             askvolume5: quote.askvolume5 ?? 0,
             lastvolume: quote.lastvolume ?? 0,
+            lastturnover: quote.Lastturnover ?? 0,
             presettle: quote.presettle ?? 0,
             preclose: quote.preclose ?? 0,
             opened: quote.opened ?? 0,
@@ -425,6 +426,7 @@ export const useFuturesStore = defineStore(() => {
             holdvolume: quote.holdvolume,
             inventory: quote.inventory,
             lastvolume: quote.lastvolume,
+            Lastturnover: handleDeimalplace(quote.lastturnover),
             limitdown: handleDeimalplace(quote.limitlow),
             limitup: handleDeimalplace(quote.limithigh),
             lowest: handleDeimalplace(quote.lowest),

+ 2 - 1
src/types/model/market.d.ts

@@ -100,7 +100,8 @@ declare namespace Model {
         askvolume3: number; // 卖量3
         askvolume4: number; // 卖量4
         askvolume5: number; // 卖量5
-        lastvolume: number; // 现量
+        lastvolume: number; // 最新成交量
+        lastturnover: number; // 最新成交金额
         presettle: number; // 昨结价
         preclose: number; // 昨收
         opened: number; // 开盘

+ 1 - 0
src/types/proto/quote.d.ts

@@ -39,6 +39,7 @@ declare namespace Proto {
         totalturnover?: number;
         totalvolume?: number;
         lastvolume?: number;
+        lastturnover?: number;
         preholdvolume?: number;
         exerciseprice?: number;
         inventory?: number;