From 7c4de2cb1422f6f4748928df5bbcc802d85dd820 Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Sat, 23 Aug 2025 14:47:15 +0800
Subject: [PATCH] 1
---
src/page/list/tradingList/data.list.vue | 342 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 250 insertions(+), 92 deletions(-)
diff --git a/src/page/list/tradingList/data.list.vue b/src/page/list/tradingList/data.list.vue
index 0329c97..3c0a911 100644
--- a/src/page/list/tradingList/data.list.vue
+++ b/src/page/list/tradingList/data.list.vue
@@ -5,92 +5,131 @@
<van-col span="8">
<div>
{{ $t("hj313") }}
- </div></van-col
- >
- <van-col span="10"
- ><div style="text-align: right">
+ </div>
+ </van-col>
+ <van-col span="3">
+ <div style="text-align: right">
+ {{ $t("市场") }}
+ </div>
+ </van-col>
+ <van-col :span="active == 'DZ' ? '12' : '7'">
+ <div style="text-align: right">
{{ $t("hj314") }}
- </div></van-col
- >
- <van-col span="6">
+ </div>
+ </van-col>
+ <van-col span="6" v-if="active == 3">
<div style="text-align: right">
{{ $t("hj315") }}
- </div></van-col
- >
+ </div>
+ </van-col>
</van-row>
</div>
-
- <van-list
- v-model="loadings"
- :finished="finished"
- :finished-text="$t('hj43')"
- @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">
- <span class="collection" @click="optionszx(item)">
- <span
- class="shu"
- :class="item.isOption == '1' ? 'shublue' : ''"
- ></span>
- </span>
- <span
- class="title_color"
- style="
- overflow: hidden;
- -webkit-line-clamp: 1;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- "
- >{{ item.name }}</span
- >
+ <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 || item.stockName }}
+ </div>
+ </div>
+ <div class="bt">
+ <span>{{ item.spell || item.stockSpell }}</span>
+ </div>
</div>
- <div class="bt">
- <span>{{ item.spell }}</span>
- </div>
- </div></van-col
- >
+ </van-col>
- <van-col span="10">
- <div style="text-align: right">
- <div class="tp">
- <span class="price_color">{{ item.nowPrice }}</span>
+ <van-col span="3">
+ <div style="text-align: right">
+ {{ (item.gid || item.stockGid).toUpperCase() }}
</div>
- <div class="bt">
- <span>{{ item.addTime }}</span>
+ </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="tp right_bs"
+ :class="`${item.hcrateP.charAt(0) == '+' ? 'green' : 'red'}`"
+ >
+ <span class="price_color">{{ 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>
- </van-col>
- <van-col span="6">
- <div style="text-align: right">
- <div
- class="tp right_bs"
- :class="`${item.hcrate > 0 ? 'green' : 'red'}`"
- >
- <span class="price_color">{{ item.hcrate }}</span>
- </div>
+ <div class="box_a_right">
+ {{ $t("gbsj") }}:{{
+ $moment(item.endTime).format("DD-MM-YYYY hh:mm:ss A")
+ }}
</div>
- </van-col>
- </van-row>
- </div>
- </van-list>
+ </div>
+ </div>
+ </van-list>
+ </van-pull-refresh>
+
+ <dazy ref="dazy" />
</div>
</template>
<script>
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 },
props: {
active: {
type: String,
@@ -108,25 +147,32 @@
type: Array,
default: [],
},
+ zxtabsList: {
+ type: Array,
+ default: [],
+ },
},
watch: {
active(e) {
this.finished = false;
this.listArr = [];
this.pageNumVal = 1;
- this.getStock(e, this.zxactive);
+ this.loadings = true;
+ this.getStock(e, this.zxactive, 1);
},
zxactive(e) {
this.finished = false;
this.listArr = [];
this.pageNumVal = 1;
- this.getStock(this.active, e);
+ this.loadings = true;
+ this.getStock(this.active, e, 1);
},
sousuo(e) {
this.finished = false;
this.listArr = [];
this.pageNumVal = 1;
- this.getStock(this.active, this.zxactive);
+ this.loadings = true;
+ this.getStock(this.active, this.zxactive, 1);
},
},
data() {
@@ -135,13 +181,25 @@
finished: false,
listArr: [],
pageNumVal: 1,
+ getInterval: null,
+ 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);
+ this.getStock(this.active, this.zxactive, 1);
+ this.initWebSocket();
+ // this.getInterval = setInterval(() => {
+ // this.getStock(this.active, this.zxactive, 1);
+ // }, 5000);
},
methods: {
filterSH(val) {
@@ -151,14 +209,21 @@
return 0;
}
},
- // 点击进入详情
+
handleGoToKlineDetail1(item) {
+ // 如果是大宗交易。不需要进入详情
+ if (this.active === "DZ") {
+ this.$refs.dazy.currentItem = item;
+ this.$refs.dazy.show = true;
+ return;
+ }
+
+ // 点击进入详情
const obj = {
pid: item.code || "",
type: item.stock_type || "",
};
window.localStorage.setItem("kLine", JSON.stringify(obj));
- // return;
var codes = item.code;
var names = item.name;
var ifZhishu = "0";
@@ -176,53 +241,142 @@
},
});
},
+
// 获取列表
- getStock: handleDt.debounce(async function (a, b) {
+ getStock: handleDt.debounce(async function (a, b, c) {
a = this.active;
let stockType = "";
if (a !== "") {
let array = this.tabsList.filter((item) => item.key === a);
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: this.pageNumVal,
- pageSize: 15,
+ pageNum: pageNumVal,
+ pageSize: 20 * this.num,
stockPlate: "",
keyWords: this.sousuo,
stockType: stockType,
orderBy: "",
};
- let data = await api.getStockByType(opt);
- this.loading = false;
- if (data.status === 0) {
- if (this.listArr.length >= data.data.total) {
- this.finished = true;
- }
- if (this.pageNumVal !== 1) {
- this.listArr = [...this.listArr, ...data.data.list];
+
+ // console.log();
+ // api.positionzx;
+ let data;
+ if (a !== "") {
+ if (a == "IN") {
+ //印股
+ data = await api.getStockByType(opt);
} else {
- this.listArr = data.data.list;
+ //大宗
+ opt.stockType = "";
+ data = await api.stockgetDzList(opt);
}
} else {
- this.loading = false;
+ // 自选
+ data = await api.positionzx(opt);
+ }
+
+ if (data.status === 0) {
+ if (pageNumVal !== 1) {
+ this.listArr = [...this.listArr, ...data.data.list];
+ } else {
+ 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) {
+ 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;
+ if (this.listArr.length % 20) {
+ this.finished = true;
+ }
+ }
+ }
+ }
+ } else {
this.finished = true;
}
}, 500),
- onLoads() {
- if (!this.loading) {
- this.pageNumVal++;
- this.loading = true;
- this.getStock();
+
+ 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.acapl.net/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.getStock();
+ },
optionszx() {},
+ },
+ destroyed() {
+ clearInterval(this.getInterval);
+ this.getInterval = null;
},
};
</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 {
@@ -239,6 +393,7 @@
// display: flex;
// justify-content: space-between;
border-bottom: 1px solid #f0f2f3;
+
.right_bs {
text-align: center;
border-radius: 0.05333rem;
@@ -258,10 +413,12 @@
.green {
background-color: rgb(3, 173, 143);
}
+
.red {
background-color: rgb(208, 75, 100);
}
}
+
.center_price {
font-style: normal;
font-weight: 500;
@@ -273,6 +430,7 @@
flex: 1;
margin-right: 20px;
}
+
.title_color {
font-style: normal;
font-weight: 500;
@@ -282,4 +440,4 @@
text-align: left;
color: #14181f;
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.3