li.shaoyi 2 hari lalu
induk
melakukan
dd560f67cb

+ 21 - 21
src/packages/digital/views/listing/goods/detail/spread/index.vue

@@ -2,28 +2,28 @@
     <app-block class="listing-quote-spread">
         <dl>
             <dt>
-                <span>{{ $t('tabbar.pricing') }}</span>
                 <span>{{ $t('tss.qty') }}</span>
+                <span>{{ $t('tabbar.pricing') }}</span>
             </dt>
             <dd>
-                <span class="g-price-up">{{ handleNumberValue(quote.ask5.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.askvolume5) }}</span>
+                <span>{{ handleNumberValue(quote.bidvolume) }}</span>
+                <span class="g-price-up">{{ handleNumberValue(quote.bid.toFixed(quote.decimalplace)) }}</span>
             </dd>
             <dd>
-                <span class="g-price-up">{{ handleNumberValue(quote.ask4.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.askvolume4) }}</span>
+                <span>{{ handleNumberValue(quote.bidvolume2) }}</span>
+                <span class="g-price-up">{{ handleNumberValue(quote.bid2.toFixed(quote.decimalplace)) }}</span>
             </dd>
             <dd>
-                <span class="g-price-up">{{ handleNumberValue(quote.ask3.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.askvolume3) }}</span>
+                <span>{{ handleNumberValue(quote.bidvolume3) }}</span>
+                <span class="g-price-up">{{ handleNumberValue(quote.bid3.toFixed(quote.decimalplace)) }}</span>
             </dd>
             <dd>
-                <span class="g-price-up">{{ handleNumberValue(quote.ask2.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.askvolume2) }}</span>
+                <span>{{ handleNumberValue(quote.bidvolume4) }}</span>
+                <span class="g-price-up">{{ handleNumberValue(quote.bid4.toFixed(quote.decimalplace)) }}</span>
             </dd>
             <dd>
-                <span class="g-price-up">{{ handleNumberValue(quote.ask.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.askvolume) }}</span>
+                <span>{{ handleNumberValue(quote.bidvolume5) }}</span>
+                <span class="g-price-up">{{ handleNumberValue(quote.bid5.toFixed(quote.decimalplace)) }}</span>
             </dd>
         </dl>
         <dl>
@@ -32,24 +32,24 @@
                 <span>{{ $t('tss.qty') }}</span>
             </dt>
             <dd>
-                <span class="g-price-down">{{ handleNumberValue(quote.bid.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.bidvolume) }}</span>
+                <span class="g-price-down">{{ handleNumberValue(quote.ask.toFixed(quote.decimalplace)) }}</span>
+                <span>{{ handleNumberValue(quote.askvolume) }}</span>
             </dd>
             <dd>
-                <span class="g-price-down">{{ handleNumberValue(quote.bid2.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.bidvolume2) }}</span>
+                <span class="g-price-down">{{ handleNumberValue(quote.ask2.toFixed(quote.decimalplace)) }}</span>
+                <span>{{ handleNumberValue(quote.askvolume2) }}</span>
             </dd>
             <dd>
-                <span class="g-price-down">{{ handleNumberValue(quote.bid3.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.bidvolume3) }}</span>
+                <span class="g-price-down">{{ handleNumberValue(quote.ask3.toFixed(quote.decimalplace)) }}</span>
+                <span>{{ handleNumberValue(quote.askvolume3) }}</span>
             </dd>
             <dd>
-                <span class="g-price-down">{{ handleNumberValue(quote.bid4.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.bidvolume4) }}</span>
+                <span class="g-price-down">{{ handleNumberValue(quote.ask4.toFixed(quote.decimalplace)) }}</span>
+                <span>{{ handleNumberValue(quote.askvolume4) }}</span>
             </dd>
             <dd>
-                <span class="g-price-down">{{ handleNumberValue(quote.bid5.toFixed(quote.decimalplace)) }}</span>
-                <span>{{ handleNumberValue(quote.bidvolume5) }}</span>
+                <span class="g-price-down">{{ handleNumberValue(quote.ask5.toFixed(quote.decimalplace)) }}</span>
+                <span>{{ handleNumberValue(quote.askvolume5) }}</span>
             </dd>
         </dl>
     </app-block>

+ 5 - 3
src/services/websocket/build/index.ts

@@ -106,9 +106,11 @@ export class MTP2WebSocket<T extends Package40 | Package50> {
                     // 接收数据
                     this.ws.onmessage = (e) => {
                         // 接收数据
-                        new Response(e.data).arrayBuffer().then((res) => {
-                            this.disposeReceiveDatas(new Uint8Array(res));
-                        })
+                        if (e.data instanceof Blob) {
+                            e.data.arrayBuffer().then((res) => {
+                                this.disposeReceiveDatas(new Uint8Array(res));
+                            })
+                        }
                     }
                 } catch {
                     reject(errMsg);

+ 55 - 29
src/stores/modules/futures.ts

@@ -387,6 +387,8 @@ export const useFuturesStore = defineStore(() => {
             sellslpoint: 0,
             selltppoint: 0,
             riskcontrolmode: 1,
+            basedecimalplace: 0,
+            quotedecimalplace: 0,
             traderules: [],
             tradefees: []
         }
@@ -445,7 +447,9 @@ export const useFuturesStore = defineStore(() => {
                     buytppoint: item.buytppoint,
                     sellslpoint: item.sellslpoint,
                     selltppoint: item.selltppoint,
-                    riskcontrolmode: item.riskcontrolmode
+                    riskcontrolmode: item.riskcontrolmode,
+                    basedecimalplace: item.basedecimalplace,
+                    quotedecimalplace: item.quotedecimalplace
                 } = goods)
 
                 item.iscannotbuy = goods.iscannotbuy ?? 0
@@ -499,38 +503,60 @@ export const useFuturesStore = defineStore(() => {
         item.openedColor = handleColor(item.opened)
         item.highestColor = handleColor(item.highest)
         item.lowestColor = handleColor(item.lowest)
+
+        if (item?.trademode === 80 || item?.trademode === 81) {
+            // 处理数量小数位
+            const handleDecimalPlace = (value: number) => {
+                if (value) {
+                    const decimal = Math.pow(10, item.basedecimalplace)
+                    return value / decimal
+                }
+                return value
+            }
+
+            item.askvolume = handleDecimalPlace(item.askvolume)
+            item.askvolume2 = handleDecimalPlace(item.askvolume2)
+            item.askvolume3 = handleDecimalPlace(item.askvolume3)
+            item.askvolume4 = handleDecimalPlace(item.askvolume4)
+            item.askvolume5 = handleDecimalPlace(item.askvolume5)
+            item.bidvolume = handleDecimalPlace(item.bidvolume)
+            item.bidvolume2 = handleDecimalPlace(item.bidvolume2)
+            item.bidvolume3 = handleDecimalPlace(item.bidvolume3)
+            item.bidvolume4 = handleDecimalPlace(item.bidvolume4)
+            item.bidvolume5 = handleDecimalPlace(item.bidvolume5)
+        }
     }
 
     // 处理行情数据
     const handleQuotation = (quote: Proto.Quote): Partial<Model.QuoteDayRsp> => {
         const goods = state.goodsList.find((e) => e.goodscode.toUpperCase() === quote.goodscode?.toUpperCase())
         // 处理报价小数位
-        const handleDeimalplace = (value?: number) => {
+        const handleDecimalPlace = (value?: number, decimals?: number) => {
             if (goods && value) {
-                const decimal = Math.pow(10, goods.decimalplace)
+                const decimal = Math.pow(10, decimals ?? goods.decimalplace)
                 return value / decimal
             }
             return value
         }
         return {
             goodscode: quote.goodscode,
-            last: handleDeimalplace(quote.last),
+            last: handleDecimalPlace(quote.last),
             lasttime: (quote.date && quote.time) ? moment(quote.date + quote.time, 'YYYYMMDDHHmmss').toISOString(true) : undefined,
-            ask: handleDeimalplace(quote.ask),
-            ask2: handleDeimalplace(quote.ask2),
-            ask3: handleDeimalplace(quote.ask3),
-            ask4: handleDeimalplace(quote.ask4),
-            ask5: handleDeimalplace(quote.ask5),
+            ask: handleDecimalPlace(quote.ask),
+            ask2: handleDecimalPlace(quote.ask2),
+            ask3: handleDecimalPlace(quote.ask3),
+            ask4: handleDecimalPlace(quote.ask4),
+            ask5: handleDecimalPlace(quote.ask5),
             askvolume: quote.askvolume,
             askvolume2: quote.askvolume2,
             askvolume3: quote.askvolume3,
             askvolume4: quote.askvolume4,
             askvolume5: quote.askvolume5,
-            bid: handleDeimalplace(quote.bid),
-            bid2: handleDeimalplace(quote.bid2),
-            bid3: handleDeimalplace(quote.bid3),
-            bid4: handleDeimalplace(quote.bid4),
-            bid5: handleDeimalplace(quote.bid5),
+            bid: handleDecimalPlace(quote.bid),
+            bid2: handleDecimalPlace(quote.bid2),
+            bid3: handleDecimalPlace(quote.bid3),
+            bid4: handleDecimalPlace(quote.bid4),
+            bid5: handleDecimalPlace(quote.bid5),
             bidvolume: quote.bidvolume,
             bidvolume2: quote.bidvolume2,
             bidvolume3: quote.bidvolume3,
@@ -543,25 +569,25 @@ export const useFuturesStore = defineStore(() => {
             calloptionpremiums5: quote.calloptionpremiums5,
             exchangecode: quote.exchangecode,
             exchangedate: quote.exchangedate,
-            highest: handleDeimalplace(quote.highest),
+            highest: handleDecimalPlace(quote.highest),
             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),
-            opened: handleDeimalplace(quote.opened),
-            preclose: handleDeimalplace(quote.preclose),
+            Lastturnover: handleDecimalPlace(quote.lastturnover),
+            limitdown: handleDecimalPlace(quote.limitlow),
+            limitup: handleDecimalPlace(quote.limithigh),
+            lowest: handleDecimalPlace(quote.lowest),
+            opened: handleDecimalPlace(quote.opened),
+            preclose: handleDecimalPlace(quote.preclose),
             preholdvolume: quote.preholdvolume,
-            presettle: handleDeimalplace(quote.presettle),
-            putoptionpremiums: handleDeimalplace(quote.putoptionpremiums),
-            putoptionpremiums2: handleDeimalplace(quote.putoptionpremiums2),
-            putoptionpremiums3: handleDeimalplace(quote.putoptionpremiums3),
-            putoptionpremiums4: handleDeimalplace(quote.putoptionpremiums4),
-            putoptionpremiums5: handleDeimalplace(quote.putoptionpremiums5),
-            settle: handleDeimalplace(quote.settle),
-            totalturnover: handleDeimalplace(quote.totalturnover),
+            presettle: handleDecimalPlace(quote.presettle),
+            putoptionpremiums: handleDecimalPlace(quote.putoptionpremiums),
+            putoptionpremiums2: handleDecimalPlace(quote.putoptionpremiums2),
+            putoptionpremiums3: handleDecimalPlace(quote.putoptionpremiums3),
+            putoptionpremiums4: handleDecimalPlace(quote.putoptionpremiums4),
+            putoptionpremiums5: handleDecimalPlace(quote.putoptionpremiums5),
+            settle: handleDecimalPlace(quote.settle),
+            totalturnover: handleDecimalPlace(quote.totalturnover),
             totalvolume: quote.totalvolume,
         }
     }

+ 2 - 0
src/types/model/goods.d.ts

@@ -12,6 +12,7 @@ declare namespace Model {
         areauserid: number; // 所属机构
         bannerurls: string; // Banner图片(2:1)(逗号分隔)
         basecurrencycode: string; // 基础货币代码(80:Goodscurrencyid)
+        basedecimalplace: number; // 基础货币小数位(80,81:Goodscurrencyid)
         buyotherfeealgorithm: number; // 买交收其它费用算法
         buyotherfeevalue: number; // 买交收其它费用值
         buypricemovealgorithm: number; // 买交收升贴水算法
@@ -62,6 +63,7 @@ declare namespace Model {
         provideruserid: number; // 发售方用户ID(49)\供货商(50)
         qtydecimalplace: number; // 成交量小数位
         quotecurrencycode: string; // 计价货币代码(80:currencyid)
+        quotedecimalplace: number; // 计价货币小数位(80,81:currencyid)
         quotegear: number; // 行情档位(1-10)
         quoteminunit: number; // 行情最小变动单位 [整数,报价小数位一起使用]
         relatedgoodsid: number; // 关联参考商品ID

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

@@ -162,6 +162,8 @@ declare namespace Model {
         sellslpoint: number; // 卖止损点差(按账户风控)
         selltppoint: number; // 卖止盈点差(按账户风控)
         riskcontrolmode: number; // 风控方式(52、10模式) 1:按单风控 2:按账户风控
+        basedecimalplace: number; // 基础货币小数位(80,81:Goodscurrencyid)
+        quotedecimalplace: number; // 计价货币小数位(80,81:currencyid)
         traderules: Proto.TradeRuleInfoStruct['TradeRules'] // 交易规则
         tradefees: Proto.TradeFeeInfoStruct['TradeFees'] // 交易费用
     }