1
jhzh
2025-07-22 421087f05bbcee88211f2b95afd4843da521998b
src/page/list/tradingList/data.list.vue
@@ -1,6 +1,6 @@
<template>
  <div class="list-data">
    <div class="header-box">
    <!-- <div class="header-box">
      <van-row type="flex" align="center" gutter="20">
        <van-col span="8">
          <div>
@@ -12,71 +12,127 @@
            {{ $t("市场") }}
          </div>
        </van-col>
        <van-col span="7">
        <van-col :span="active == 'DZ' ? '12' : '7'">
          <div style="text-align: right">
            {{ $t("hj314") }}
          </div>
        </van-col>
        <van-col span="6">
        <van-col span="6" v-if="active == 3">
          <div style="text-align: right">
            {{ $t("hj315") }}
          </div>
        </van-col>
      </van-row>
    </div>
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
      <van-list style="margin-bottom: 50px" v-model="loadings" :finished="finished" :finished-text="$t('hj43')"
        :loading-text="$t('hj430')" @load="onLoads" :immediate-check="false">
        <div class="item" @click="handleGoToKlineDetail1(item, index)" v-for="(item, index) in listArr"
          :key="item.indexCode">
    </div> -->
    <van-pull-refresh
      v-model="refreshing"
      @refresh="onRefresh"
      :loosing-text="$t('hj430')"
      :pulling-text="$t('hj430')"
    >
      <van-list
        style="margin-bottom: 50px"
        v-model="loadings"
        :finished="finished"
        :finished-text="$t('hj43')"
        :loading-text="$t('hj430')"
        @load="onLoads"
        :immediate-check="false"
      >
        <div
          class="item"
          @click="handleGoToKlineDetail1(item, index)"
          v-for="(item, index) in listArr"
          :key="item.indexCode"
        >
          <van-row type="flex" align="center" gutter="20">
            <van-col span="8">
              <div>
                <div class="tp">
                  <div class="collection" @click="optionszx(item)">
                    <div class="shu" :class="item.isOption == '1' ? 'shublue' : ''"></div>
                  </div>
                  <div class="title_color" style="
                    width: 100%;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                  ">
                    {{ item.name }}
                  </div>
                </div>
                <div class="bt">
                  <span>{{ item.spell }}</span>
                </div>
              </div>
            </van-col>
            <!-- <van-col span="3"> -->
            <!-- </van-col> -->
            <van-col span="3">
              <div style="text-align: right">
                {{ item.gid }}
              <img style="width: 42px;height: 42px;border-radius: 50px;" src="@/assets/img/nologo.svg"/>
            </van-col>
            <van-col span="8">
              <div >
                <!-- <div> -->
                  <div class="tp">
                    <div class="collection" @click="optionszx(item)">
                      <div
                        class="shu"
                        :class="item.isOption == '1' ? 'shublue' : ''"
                      ></div>
                    </div>
                    <div
                      class="title_color"
                      style="
                        width: 100%;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                      "
                    >
                      {{ item.name || item.stockName }}
                    </div>
                <!-- </div> -->
                </div>
                <div class="bt" style="font-size: 12px;margin-top: 10px;">
                  <span>{{ item.spell || item.stockSpell }}</span>
                  <span style="padding: 3px 4px;background-color: #E8F4F0;color: #185546;font-size: 10px;">{{$t('日股')}}</span>
                </div>
              </div>
            </van-col>
            <van-col span="7">
            <!-- <van-col span="3">
              <div style="text-align: right">
                <div class="tp">
                  <span class="price_color">
                    {{ item.nowPrice | _toLocaleString(false) }}
                  </span>
                {{ (item.gid || item.stockGid).toUpperCase() }}
              </div>
            </van-col> -->
            <van-col :span="active == 'DZ' ? '12' : '7'">
              <div >
                <div class="tp" style="display: flex;flex-direction: column;">
                  <span style="margin-bottom: 10px;font-size: .32rem;color: #858093;">{{$t('最新价')}}</span>
                  <div style="display: flex;">
                    <span class="price_color" style="font-size: 16px;font-weight: bold;">
                      {{ item.nowPrice  }}
                    </span>
                    <img v-if="item.hcrateP.charAt(0) == '-'" style="width: 18px;" src="@/assets/home/greeensvg.png"/>
                    <img v-else style="width: 18px;" src="@/assets/home/R10OVD4.png"/>
                  </div>
                </div>
                <div class="bt">
                <div class="bt" v-if="active != 'DZ'">
                  <span>{{ item.addTime }}</span>
                </div>
              </div>
            </van-col>
            <van-col span="6">
            <van-col span="6" v-if="active != 'DZ'">
              <div style="text-align: right">
                <div class="tp right_bs" :class="`${item.color > 0 ? 'green' : 'red'}`">
                  <span class="price_color">{{ item.hcrateP }}</span>
               <!-- <div
                  class="tp right_bs"
                  :class="`${item.hcrateP.charAt(0) == '+' ? 'green' : 'red'}`"
                > -->
                <div
                  class="tp " style="display: flex;flex-direction: column;"
                >
                  <span :class="item.hcrateP.charAt(0) == '-'?'price_colorgree':'price_colorred'" style="margin-bottom: 10px;font-weight: bold;font-size: 12px;">{{ item.hcrate }}</span>
                  <span :class="item.hcrateP.charAt(0) == '-'?'price_colorgree':'price_colorred'" style="font-weight: bold;font-size: 12px;">{{ item.hcrateP }}</span>
                </div>
              </div>
            </van-col>
          </van-row>
          <div class="box-a" v-if="active == 'DZ'">
            <div class="box_a_left">
              {{ $t("kpsj") }}:{{
                $moment(item.startTime).format("DD-MM-YYYY hh:mm:ss A")
              }}
            </div>
            <div class="box_a_right">
              {{ $t("gbsj") }}:{{
                $moment(item.endTime).format("DD-MM-YYYY hh:mm:ss A")
              }}
            </div>
          </div>
        </div>
      </van-list>
    </van-pull-refresh>
@@ -146,15 +202,20 @@
      pageNumVal: 1,
      getInterval: null,
      num: 1,
      refreshing: false
      refreshing: false,
    };
  },
  beforeDestroy() {
      if (this.Trade) {
        this.Trade.close();
        console.log('WebSocket disconnected');
      }
    },
  mounted() {
    this.listArr = [];
    this.pageNumVal = 1;
    this.getStock(this.active, this.zxactive, 1);
    this.initWebSocket()
    this.initWebSocket();
    // this.getInterval = setInterval(() => {
    //   this.getStock(this.active, this.zxactive, 1);
    // }, 5000);
@@ -227,7 +288,15 @@
      // api.positionzx;
      let data;
      if (a !== "") {
        data = await api.getStockByType(opt);
        if (a == "JP") {
          //印股
          opt.stockType = "JP";
          data = await api.getStockByType(opt);
        } else {
          //大宗
          opt.stockType = "";
          data = await api.stockgetDzList(opt);
        }
      } else {
        // 自选
        data = await api.positionzx(opt);
@@ -245,12 +314,19 @@
              if (this.listArr.length % 20) {
                this.finished = true;
              }
            } else {
              this.listArr = data.data.list;
              this.loadings = false;
              // this.finished = true;
              if (this.listArr.length % 20) {
                this.finished = true;
              }
            }
          } else {
            if (this.zxactive === data.data.stockType) {
              this.listArr = data.data.list;
              this.loadings = false;
              // this.finished = true;
              this.finished = true;
              if (this.listArr.length % 20) {
                this.finished = true;
              }
@@ -277,17 +353,18 @@
    },
    initWebSocket() {
      console.log("initWebSocket");
      this.Trade = new WhrWebSocket({
        path: `ws://ws.is4vc.com:8001/websocket-server`,
        path: `wss://wss.yanshiz.com/websocket-server `,
        onmessage: this.getTradeMessage,
      });
      this.Trade.init();
    },
    getTradeMessage({ data }) {
      let result = JSON.parse(data)
      let pid = result.pid
      let userToUpdate = this.listArr.find(item => item.code == pid)
      let result = JSON.parse(data);
      let pid = result.pid;
      let userToUpdate = this.listArr.find((item) => item.code == pid);
      if (userToUpdate) {
        // 更新对象数据
        userToUpdate.nowPrice = result.last;
@@ -296,13 +373,13 @@
    },
    onLoads() {
      console.log('onLoads');
      console.log("onLoads");
      // this.pageNumVal++;
      this.loadings = true;
      this.num += 1
      this.num += 1;
      this.getStock();
    },
    optionszx() { },
    optionszx() {},
  },
  destroyed() {
    clearInterval(this.getInterval);
@@ -312,8 +389,25 @@
</script>
<style lang="less" scoped>
  .price_colorred {
    color: #C8302F;
    font-size: 0.4rem;
    font-weight: 600;
  }
  .price_colorgree {
    color: #0FAD60;
    font-size: 0.4rem;
    font-weight: 600;
  }
.box-a {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-top: 10px;
}
.list-data {
  width: 100%;
  height: 85vh;
  background-color: #fff;
  .header-box {
@@ -377,4 +471,4 @@
  text-align: left;
  color: #14181f;
}
</style>
</style>