From 9c71fa12acfa3331152092def6a8063bc5f8bf18 Mon Sep 17 00:00:00 2001
From: jhzh <1628036192@qq.com>
Date: Fri, 15 Aug 2025 15:36:09 +0800
Subject: [PATCH] 1
---
src/page/list/tradingList/data.list.vue | 318 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 231 insertions(+), 87 deletions(-)
diff --git a/src/page/list/tradingList/data.list.vue b/src/page/list/tradingList/data.list.vue
index da4ef60..a85b335 100644
--- a/src/page/list/tradingList/data.list.vue
+++ b/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,93 +12,132 @@
{{ $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"
+ </div> -->
+ <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="shu"
- :class="item.isOption == '1' ? 'shublue' : ''"
- ></div>
+ <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="3"> -->
+ <!-- </van-col> -->
+
+ <van-col span="3">
+ <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="3">
+ <div style="text-align: right">
+ {{ (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('hj40')}}</span>
+ <div style="display: flex;">
+ <span class="price_color" style="font-size: 16px;font-weight: bold;">
+ {{ item.nowPrice }}
+ </span>
+ <div v-if="active != 'DZ'">
+ <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>
+ <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="tp right_bs"
+ :class="`${item.hcrateP.charAt(0) == '+' ? 'green' : 'red'}`"
+ > -->
<div
- class="title_color"
- style="
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- "
+ class="tp " style="display: flex;flex-direction: column;"
>
- {{ item.name }}
+ <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>
- <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") }}:{{
+ formatTimestamp(item.startTime)
+ }}
</div>
- </van-col>
-
- <van-col span="3">
- <div style="text-align: right">
- {{ item.gid }}
+ <div class="box_a_right">
+ {{ $t("gbsj") }}:{{
+ formatTimestamp(item.endTime)
+ }}
</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 +147,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 },
@@ -149,9 +189,11 @@
this.getStock(this.active, e, 1);
},
sousuo(e) {
+ // if (this.loadings) return; // 避免重复触发
this.finished = false;
this.listArr = [];
this.pageNumVal = 1;
+ this.num = 1
this.loadings = true;
this.getStock(this.active, this.zxactive, 1);
},
@@ -163,19 +205,40 @@
listArr: [],
pageNumVal: 1,
getInterval: null,
- num: 1
+ num: 1,
+ 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.getInterval = setInterval(() => {
- this.getStock(this.active, this.zxactive, 1);
- }, 5000);
+ this.initWebSocket();
+ // this.getInterval = setInterval(() => {
+ // this.getStock(this.active, this.zxactive, 1);
+ // }, 5000);
},
methods: {
+ formatTimestamp(timestamp) {
+ const date = new Date(timestamp); // 将时间戳转换为 Date 对象
+
+ const day = date.getDate(); // 日期
+ const month = date.getMonth() + 1; // 月份(从 0 开始,所以下标要加 1)
+ const year = date.getFullYear(); // 年份
+ const hours = date.getHours(); // 小时
+ const minutes = date.getMinutes(); // 分钟
+ const seconds = date.getSeconds(); // 秒钟
+
+ // 格式化为 "日月年/时分秒" 格式
+ return `${year}${this.$t('年')}${month}${this.$t('月')}${day}${this.$t('日')}/${hours}:${minutes}:${seconds}`;
+ // return `${month}`;
+ },
filterSH(val) {
if (val === "sh") {
return 1;
@@ -219,6 +282,7 @@
// 获取列表
getStock: handleDt.debounce(async function (a, b, c) {
+ console.log(a,b,c);
a = this.active;
let stockType = "";
if (a !== "") {
@@ -226,24 +290,29 @@
stockType = array[0].name;
} else {
let array = this.zxtabsList.filter((item) => item.key === b);
- console.log(this.zxtabsList, b);
stockType = array[0].name;
}
let pageNumVal = c || this.pageNumVal;
let opt = {
pageNum: pageNumVal,
- pageSize: 20*this.num,
+ // pageSize: 15 * this.num,
+ pageSize: 15 ,
stockPlate: "",
keyWords: this.sousuo,
stockType: stockType,
orderBy: "",
};
-
- // console.log();
- // 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);
@@ -252,13 +321,27 @@
if (data.status === 0) {
if (pageNumVal !== 1) {
this.listArr = [...this.listArr, ...data.data.list];
+ this.loadings = false;
+ // this.finished = true;
+ if (this.listArr.length < 15) {
+ this.finished = true;
+ }
} else {
+ this.listArr = []
if (this.active) {
if (this.active === data.data.stockType) {
this.listArr = data.data.list;
this.loadings = false;
// this.finished = true;
- if(this.listArr.length % 20 ){
+ console.log(this.listArr.length%15);
+ if (this.listArr.length < 15) {
+ this.finished = true;
+ }
+ } else {
+ this.listArr = data.data.list;
+ this.loadings = false;
+ // this.finished = true;
+ if (this.listArr.length < 15) {
this.finished = true;
}
}
@@ -267,7 +350,7 @@
this.listArr = data.data.list;
this.loadings = false;
// this.finished = true;
- if(this.listArr.length % 20 ){
+ if (this.listArr.length < 15) {
this.finished = true;
}
}
@@ -277,11 +360,51 @@
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.stcarlyle.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++;
+ console.log("onLoads");
this.loadings = true;
- this.num+=1
+ // this.finished = true;
+ this.pageNumVal++;
+ if(this.listArr.length==0){
+ this.num = 1
+ }else{
+ this.num += 1;
+ }
this.getStock();
},
optionszx() {},
@@ -294,8 +417,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 {
@@ -312,6 +452,7 @@
// display: flex;
// justify-content: space-between;
border-bottom: 1px solid #f0f2f3;
+
.right_bs {
text-align: center;
border-radius: 0.05333rem;
@@ -331,10 +472,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 +489,7 @@
flex: 1;
margin-right: 20px;
}
+
.title_color {
font-style: normal;
font-weight: 500;
@@ -355,4 +499,4 @@
text-align: left;
color: #14181f;
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.3