From 3fe222593adba91eb9d015d5fa052be0d9b7c350 Mon Sep 17 00:00:00 2001
From: dcc <dcc@163.com>
Date: Mon, 08 Jul 2024 16:19:02 +0800
Subject: [PATCH] Trade里面价格和涨跌幅升序降序

---
 src/page/list/tradingList/data.list.vue |  124 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 102 insertions(+), 22 deletions(-)

diff --git a/src/page/list/tradingList/data.list.vue b/src/page/list/tradingList/data.list.vue
index 7bb82fe..8714d9c 100644
--- a/src/page/list/tradingList/data.list.vue
+++ b/src/page/list/tradingList/data.list.vue
@@ -15,33 +15,78 @@
         <van-col span="7">
           <div style="text-align: right">
             {{ $t("hj314") }}
+            <span class="caret-wrapper">
+              <i
+                class="el-icon-caret-top"
+                style="font-size: 0.3rem"
+                @click="priceAscending"
+                :style="{color: Ascend == 1?'#409eff':'#8c9fad'}"
+              ></i>
+              <i
+                class="el-icon-caret-bottom"
+                style="font-size: 0.3rem"
+                @click="priceDescending"
+                 :style="{color: Ascend == 2?'#409eff':'#8c9fad'}"
+              ></i>
+            </span>
           </div>
         </van-col>
         <van-col span="6">
           <div style="text-align: right">
             {{ $t("hj315") }}
+            <span class="caret-wrapper">
+              <i
+                class="el-icon-caret-top"
+                style="font-size: 0.3rem"
+                @click="riseFallAscending"
+                 :style="{color: riseFallAscend == 1?'#409eff':'#8c9fad'}"
+              ></i>
+              <i
+                class="el-icon-caret-bottom"
+                style="font-size: 0.3rem"
+                @click="riseFallDescending"
+                 :style="{color: riseFallAscend == 2?'#409eff':'#8c9fad'}"
+              ></i>
+            </span>
           </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">
+      <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="
-                    width: 100%;
-                    overflow: hidden;
-                    text-overflow: ellipsis;
-                    white-space: nowrap;
-                  ">
+                  <div
+                    class="title_color"
+                    style="
+                      width: 100%;
+                      overflow: hidden;
+                      text-overflow: ellipsis;
+                      white-space: nowrap;
+                    "
+                  >
                     {{ item.name }}
                   </div>
                 </div>
@@ -71,7 +116,10 @@
             </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>
@@ -90,6 +138,7 @@
 import handleDt from "@/utils/deTh";
 import dazy from "./dazy.vue";
 import { WhrWebSocket } from "@/utils/WhrWebSocket";
+import { color } from "echarts/lib/export";
 
 export default {
   components: { dazy },
@@ -146,20 +195,39 @@
       pageNumVal: 1,
       getInterval: null,
       num: 1,
-      refreshing: false
-    };
+      refreshing: false,
+      Ascend: 0,
+      riseFallAscend: 0
+    }
   },
 
   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);
   },
   methods: {
+    priceAscending() {
+      this.Ascend = 1
+      this.listArr.sort((a, b) => a.nowPrice - b.nowPrice);
+    },
+    priceDescending() {
+      this.Ascend = 2
+      this.listArr.sort((a, b) => b.nowPrice - a.nowPrice);
+    },
+    riseFallAscending() {
+      this.riseFallAscend = 1
+      this.listArr.sort((a, b) => a.hcrate - b.hcrate);
+    },
+    riseFallDescending() {
+      this.riseFallAscend = 2
+      this.listArr.sort((a, b) => b.hcrate - a.hcrate);
+    },
+
     filterSH(val) {
       if (val === "sh") {
         return 1;
@@ -277,7 +345,7 @@
     },
 
     initWebSocket() {
-      console.log('initWebSocket');
+      console.log("initWebSocket");
       this.Trade = new WhrWebSocket({
         path: `wss://ws.is4vc.com/websocket-server`,
         onmessage: this.getTradeMessage,
@@ -286,9 +354,9 @@
       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;
@@ -297,13 +365,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);
@@ -378,4 +446,16 @@
   text-align: left;
   color: #14181f;
 }
+
+.caret-wrapper {
+  display: inline-flex;
+  flex-direction: column;
+  align-items: center;
+  height: 0.6rem;
+  width: 0.5rem;
+  vertical-align: middle;
+  cursor: pointer;
+  overflow: initial;
+  position: relative;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3