123
dcc
2024-06-27 90d901daf17ba0644eb5c3096450262cfd76ef58
src/page/list/tradingList/data.list.vue
@@ -24,41 +24,24 @@
        </van-col>
      </van-row>
    </div>
    <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-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">
        <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 class="shu" :class="item.isOption == '1' ? 'shublue' : ''"></div>
                </div>
                <div
                  class="title_color"
                  style="
                  <div class="title_color" style="
                    width: 100%;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                  "
                >
                  ">
                  {{ item.name }}
                </div>
              </div>
@@ -88,10 +71,7 @@
          </van-col>
          <van-col span="6">
            <div style="text-align: right">
              <div
                class="tp right_bs"
                :class="`${item.color > 0 ? 'green' : 'red'}`"
              >
                <div class="tp right_bs" :class="`${item.color > 0 ? 'green' : 'red'}`">
                <span class="price_color">{{ item.hcrateP }}</span>
              </div>
            </div>
@@ -99,6 +79,7 @@
        </van-row>
      </div>
    </van-list>
    </van-pull-refresh>
    <dazy ref="dazy" />
  </div>
@@ -108,6 +89,7 @@
import * as api from "@/axios/api";
import handleDt from "@/utils/deTh";
import dazy from "./dazy.vue";
import { WhrWebSocket } from "@/utils/WhrWebSocket";
export default {
  components: { dazy },
@@ -163,7 +145,8 @@
      listArr: [],
      pageNumVal: 1,
      getInterval: null,
      num: 1
      num: 1,
      refreshing: false
    };
  },
@@ -171,9 +154,10 @@
    this.listArr = [];
    this.pageNumVal = 1;
    this.getStock(this.active, this.zxactive, 1);
    this.getInterval = setInterval(() => {
      this.getStock(this.active, this.zxactive, 1);
    }, 5000);
    this.initWebSocket()
    // this.getInterval = setInterval(() => {
    //   this.getStock(this.active, this.zxactive, 1);
    // }, 5000);
  },
  methods: {
    filterSH(val) {
@@ -277,6 +261,40 @@
        this.finished = true;
      }
    }, 500),
    onRefresh() {
      // 清空列表数据
      this.finished = false;
      // 重新加载数据
      // 将 loading 设置为 true,表示处于加载状态
      this.loading = true;
      if (this.refreshing) {
        // this.listArr = [];
        this.refreshing = false;
      }
      this.getStock();
    },
    initWebSocket() {
      this.Trade = new WhrWebSocket({
        path: `ws://ws.is4vc.com:8001/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)
      if (userToUpdate) {
        // 更新对象数据
        userToUpdate.nowPrice = result.last;
        userToUpdate.hcrateP = result.pcp;
      }
    },
    onLoads() {
      console.log('onLoads');
      // this.pageNumVal++;
@@ -312,6 +330,7 @@
  // display: flex;
  // justify-content: space-between;
  border-bottom: 1px solid #f0f2f3;
  .right_bs {
    text-align: center;
    border-radius: 0.05333rem;
@@ -331,10 +350,12 @@
  .green {
    background-color: rgb(3, 173, 143);
  }
  .red {
    background-color: rgb(208, 75, 100);
  }
}
.center_price {
  font-style: normal;
  font-weight: 500;
@@ -346,6 +367,7 @@
  flex: 1;
  margin-right: 20px;
}
.title_color {
  font-style: normal;
  font-weight: 500;