交易所前端蓝色ui, 4.5 jiem
lxf
2025-04-18 66a33e936d39ec4db7fdffed5d646e044ccc43e9
src/page/deliveryContract/hold.vue
@@ -35,7 +35,9 @@
                <div>
                    <div class="text-grey text-right">{{ $t('现价') }}</div>
                    <div class="mt-20 text-right" :class="item.close_price > item.open_price ? 'text-green' : 'text-red'">
                        {{ item.close_price }}</div>
                        <!-- {{ item.close_price }} -->
                  {{newprice}}
                  </div>
                </div>
            </div>
            <div class="flex pt-40 pb-40">
@@ -75,20 +77,26 @@
            $t('您目前没有持仓') }}</div>
        <van-popup v-model="show">
            <popup-delivery :showBtns="true" :price="price" :detailData="detailData" :key="detailData.order_no"
                @close="onClose" />
                @close="onClose" :symbol="symbol" />
        </van-popup>
    </div>
</template>
<script>
import PopupDelivery from '@/components/popup-delivery'
import { WS_URL } from '@/config'
import { Popup } from 'vant';
import { _futrueOrderDetail } from "@/API/trade.api";
export default {
    name: "deliveryHoldList",
    data() {
        return {
         sockets: {
             quotes: null, // 行情
             deep: null /// 深度
         },
            show: false,
         newprice:"",
            iconShow: false,
            detailData: {},
        }
@@ -104,12 +112,42 @@
                return []
            }
        },
      symbol: {
          type: String,
          default: ''
      },
        price: {
            type: [Number, String],
            default: '0.00'
        },
    },
   deactivated(){
        this.closeSocket()
   },
   mounted (){
        this.fetchDeepData()
   },
    methods: {
      closeSocket() {
              this.sockets.deep.close()
          // this.sockets.quotes && this.sockets.quotes.close()
          // this.sockets.deep && this.sockets.deep.close()
          this.sockets.quotes = null
          this.sockets.deep = null
      },
      fetchDeepData() {
              this.startDeepSocket() // socket
      },
      startDeepSocket() {
          this.sockets.deep = new WebSocket(`${WS_URL}/3/${this.symbol}`)
          this.sockets.deep.onmessage = (evt) => {
              const { data } = evt
              const { code, data: _data } = JSON.parse(data)
               // console.log(_data.bids[0].price);
               this.newprice = _data.asks[0].price
          }
      },
        clearTimeout() {
            clearTimeout(this.timeout)
            this.timeout = null