jhzh
2024-09-19 e3097587828362e34352cf4f378c8f5a260ea700
src/page/list/tradingList/data.list.vue
@@ -12,93 +12,111 @@
            {{ $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-list
      style="margin-bottom: 50px"
      v-model="loadings"
      :finished="finished"
      :finished-text="$t('hj43')"
      :loading-text="$t('hj430')"
      @load="onLoads"
      :immediate-check="false"
    <van-pull-refresh
      v-model="refreshing"
      @refresh="onRefresh"
      :loosing-text="$t('hj430')"
      :pulling-text="$t('hj430')"
    >
      <div
        class="item"
        @click="handleGoToKlineDetail1(item, index)"
        v-for="(item, index) in listArr"
        :key="item.indexCode"
      <van-list
        style="margin-bottom: 50px"
        v-model="loadings"
        :finished="finished"
        :finished-text="$t('hj43')"
        :loading-text="$t('hj430')"
        @load="onLoads"
        :immediate-check="false"
      >
        <van-row type="flex" align="center" gutter="20">
          <van-col span="8">
            <div>
              <div class="tp">
                <div class="collection" @click="optionszx(item)">
        <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="shu"
                    :class="item.isOption == '1' ? 'shublue' : ''"
                  ></div>
                    class="title_color"
                    style="
                      width: 100%;
                      overflow: hidden;
                      text-overflow: ellipsis;
                      white-space: nowrap;
                    "
                  >
                    {{ item.name || item.stockName }}
                  </div>
                </div>
                <div class="bt">
                  <span>{{ item.spell || item.stockSpell }}</span>
                </div>
              </div>
            </van-col>
            <van-col span="3">
              <div style="text-align: right">
                {{ (item.gid || item.stockGid) == "nse" ? "NSE" : "BSE" }}
              </div>
            </van-col>
            <van-col :span="active == 'DZ' ? '12' : '7'">
              <div style="text-align: right">
                <div class="tp">
                  <span class="price_color">
                    {{ item.nowPrice | _toLocaleString(false) }}
                  </span>
                </div>
                <div class="bt" v-if="active != 'DZ'">
                  <span>{{ item.addTime }}</span>
                </div>
              </div>
            </van-col>
            <van-col span="6" v-if="active != 'DZ'">
              <div style="text-align: right">
                <div
                  class="title_color"
                  style="
                    width: 100%;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                  "
                  class="tp right_bs"
                  :class="`${item.hcrateP.charAt(0) == '+' ? 'green' : 'red'}`"
                >
                  {{ item.name }}
                  <span class="price_color">{{ item.hcrateP }}</span>
                </div>
              </div>
              <div class="bt">
                <span>{{ item.spell }}</span>
              </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>
          </van-col>
          <van-col span="3">
            <div style="text-align: right">
              {{ item.gid }}
            <div class="box_a_right">
              {{ $t("gbsj") }}:{{
                $moment(item.endTime).format("DD-MM-YYYY hh:mm:ss A")
              }}
            </div>
          </van-col>
          <van-col span="7">
            <div style="text-align: right">
              <div class="tp">
                <span class="price_color">
                  {{ item.nowPrice | _toLocaleString(false) }}
                </span>
              </div>
              <div class="bt">
                <span>{{ item.addTime }}</span>
              </div>
            </div>
          </van-col>
          <van-col span="6">
            <div style="text-align: right">
              <div
                class="tp right_bs"
                :class="`${item.color > 0 ? 'green' : 'red'}`"
              >
                <span class="price_color">{{ item.hcrateP }}</span>
              </div>
            </div>
          </van-col>
        </van-row>
      </div>
    </van-list>
          </div>
        </div>
      </van-list>
    </van-pull-refresh>
    <dazy ref="dazy" />
  </div>
@@ -108,6 +126,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 +182,8 @@
      listArr: [],
      pageNumVal: 1,
      getInterval: null,
      num: 1
      num: 1,
      refreshing: false,
    };
  },
@@ -171,9 +191,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) {
@@ -232,7 +253,7 @@
      let pageNumVal = c || this.pageNumVal;
      let opt = {
        pageNum: pageNumVal,
        pageSize: 50*this.num,
        pageSize: 20 * this.num,
        stockPlate: "",
        keyWords: this.sousuo,
        stockType: stockType,
@@ -243,7 +264,14 @@
      // api.positionzx;
      let data;
      if (a !== "") {
        data = await api.getStockByType(opt);
        if (a == "IN") {
          //印股
          data = await api.getStockByType(opt);
        } else {
          //大宗
          opt.stockType = "";
          data = await api.stockgetDzList(opt);
        }
      } else {
        // 自选
        data = await api.positionzx(opt);
@@ -258,12 +286,25 @@
              this.listArr = data.data.list;
              this.loadings = false;
              // this.finished = true;
              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;
              }
            }
          }
        }
@@ -271,10 +312,46 @@
        this.finished = true;
      }
    }, 500),
    onRefresh() {
      // 清空列表数据
      this.finished = false;
      // 重新加载数据
      // 将 loading 设置为 true,表示处于加载状态
      this.loading = true;
      if (this.refreshing) {
        // this.listArr = [];
        this.refreshing = false;
      }
      this.getStock();
    },
    initWebSocket() {
      console.log("initWebSocket");
      this.Trade = new WhrWebSocket({
        path: `wss://ws.ispentagon-institution.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);
      if (userToUpdate) {
        // 更新对象数据
        userToUpdate.nowPrice = result.last;
        userToUpdate.hcrateP = result.pcp;
      }
    },
    onLoads() {
      console.log("onLoads");
      // this.pageNumVal++;
      this.loadings = true;
      this.num+=1
      this.num += 1;
      this.getStock();
    },
    optionszx() {},
@@ -287,8 +364,15 @@
</script>
<style lang="less" scoped>
.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 {
@@ -305,6 +389,7 @@
  // display: flex;
  // justify-content: space-between;
  border-bottom: 1px solid #f0f2f3;
  .right_bs {
    text-align: center;
    border-radius: 0.05333rem;
@@ -324,10 +409,12 @@
  .green {
    background-color: rgb(3, 173, 143);
  }
  .red {
    background-color: rgb(208, 75, 100);
  }
}
.center_price {
  font-style: normal;
  font-weight: 500;
@@ -339,6 +426,7 @@
  flex: 1;
  margin-right: 20px;
}
.title_color {
  font-style: normal;
  font-weight: 500;
@@ -348,4 +436,4 @@
  text-align: left;
  color: #14181f;
}
</style>
</style>