From 9ddad348a549154e7b328f9d7dd9517d2abd330c Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Tue, 30 Sep 2025 09:47:25 +0800
Subject: [PATCH] 1

---
 src/page/trading/TradeNew.vue |   95 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 65 insertions(+), 30 deletions(-)

diff --git a/src/page/trading/TradeNew.vue b/src/page/trading/TradeNew.vue
index e1d7724..46b5c15 100644
--- a/src/page/trading/TradeNew.vue
+++ b/src/page/trading/TradeNew.vue
@@ -1,14 +1,20 @@
 <template>
   <div class="trade_new">
-    <tab-head></tab-head>
+    <tab-head>
+      <!-- <van-popover v-model="showPopover" trigger="click" :actions="actions" @select="onSelect" slot="left">
+        <template #reference>
+          <van-button type="primary">{{ $t("一键平仓") }}</van-button>
+        </template>
+      </van-popover> -->
+    </tab-head>
 
     <div class="order_tabs">
       <van-tabs v-model="active" swipe-threshold="1">
         <van-tab :title="$t('hj160')" name=""></van-tab>
-        <van-tab title="AI" name="4"></van-tab>
-        <van-tab :title="$t('hj621')" name="3"></van-tab>
-        <van-tab title="IPO" name="2"></van-tab>
-        <van-tab :title="$t('日内')" name="0"></van-tab>
+        <van-tab :title="$t('美股指数')" name="US"></van-tab>
+        <van-tab :title="$t('hksi')" name="HK"></van-tab>
+        <van-tab :title="$t('tsi')" name="TW"></van-tab>
+        <van-tab :title="$t('ni')" name="IN"></van-tab>
       </van-tabs>
     </div>
 
@@ -24,12 +30,7 @@
       </van-col>
     </van-row>
 
-    <van-row
-      class="list_item"
-      v-for="i in list"
-      :key="i.id"
-      @click="toDetails(i)"
-    >
+    <van-row class="list_item" v-for="i in list" :key="i.id" @click="toDetails(i)">
       <van-col span="8" class="item_n">
         <div class="flex-start">
           <span class="i_icon">{{ i.stockGid }}</span>
@@ -41,7 +42,10 @@
       </van-col>
       <van-col span="8" class="item_n">
         <p class="flex-start">{{ i.orderNum }}</p>
-        <p class="flex-start i_name">
+        <p class="flex-start i_name" :style="{
+          color:
+            i.profitAndLose > 0 ? 'green' : i.profitAndLose < 0 ? 'red' : ''
+        }">
           {{ i.profitAndLose }} ({{ i.profitAndLoseParent }})
         </p>
       </van-col>
@@ -56,11 +60,7 @@
       <van-col span="24" class="flex-start transaction_type">
         <span>{{ types[i.positionType] }}</span>
       </van-col>
-      <van-col
-        span="24"
-        class="flex-between-start item_card"
-        v-if="i.positionType == 4"
-      >
+      <van-col span="24" class="flex-between-start item_card" v-if="i.positionType == 4">
         <div class="card_label">
           <p>{{ $t("建仓成本") }}</p>
           <p>{{ i.orderTotalPrice }}</p>
@@ -81,18 +81,16 @@
       <img src="@/assets/img/zhaobudao2.png" alt="" />
     </div>
 
-    <n-pagination
-      :pageNo.sync="pageNum"
-      :pageSize="pageSize"
-      :total="total"
-    ></n-pagination>
+    <n-pagination :pageNo.sync="pageNum" :pageSize="pageSize" :total="total"></n-pagination>
   </div>
 </template>
 
 <script>
+let times = null; // 计时器
 import tabHead from "@/components/tabHead.vue";
 import * as api from "@/axios/api";
 import nPagination from "@/components/nPagination.vue";
+import { Notify } from "vant";
 
 export default {
   components: {
@@ -111,27 +109,35 @@
         2: "IPO",
         3: this.$t("hj621"),
         4: "AI"
-      }
+      },
+      actions: [{ text: '确定', key: '1' }, { text: '取消', key: '2' }],
+      showPopover: false,
     };
   },
   watch: {
     pageNum() {
       this.getList();
+      this.creatTimer();
     },
     active() {
       this.pageNum = 1;
       this.getList();
+      this.creatTimer();
     }
   },
   created() {
     this.getList();
+    this.creatTimer();
+  },
+  destroyed() {
+    this.stopTimer();
   },
   methods: {
     // 获取数据
     async getList() {
       let data = await api.getchicang({
         state: 0,
-        positionType: this.active,
+        stockType: this.active,
         pageNum: this.pageNum,
         pageSize: this.pageSize
       });
@@ -148,6 +154,32 @@
         path: "/Stockdetail",
         query: { codes: i.positionSn }
       });
+    },
+    // 
+    stopTimer() {
+      if (times) {
+        clearInterval(times);
+        times = null;
+      }
+    },
+    creatTimer() {
+      this.stopTimer()
+      times = setInterval(() => {
+        this.getList();
+      }, 3000);
+    },
+    // 一键平仓确认弹框
+    onSelect(action) {
+      if (action.key == 1) this.oneClose();
+    },
+    // 一键平仓
+    async oneClose() {
+      const res = await api.allsell();
+      if (res.status === 0) {
+        Notify({ type: "success", message: res.msg });
+      } else {
+        Notify({ type: "danger", message: res.msg });
+      }
     }
   }
 };
@@ -166,16 +198,20 @@
   background: #fff;
   font-size: 10vw;
   padding-bottom: 1.3rem;
+
   // padding-top: 1.4em;
   /deep/ .van-tabs--line .van-tabs__wrap {
     height: 1.2em;
   }
+
   /deep/ .van-tab__text--ellipsis {
     overflow: visible;
   }
+
   /deep/ .van-tab {
     font-size: 0.4em;
   }
+
   /deep/ .van-tabs__line {
     background-color: @green;
     height: 0.1em;
@@ -220,7 +256,7 @@
         color: #999;
         font-size: 0.35em;
 
-        & > p:last-child {
+        &>p:last-child {
           color: #333;
           margin-top: 0.15em;
         }
@@ -230,6 +266,7 @@
     .transaction_type {
       color: #fff;
       padding-top: 0.08em;
+
       span {
         font-size: 0.3em;
         background: @brown;
@@ -271,11 +308,9 @@
       position: absolute;
       top: 0;
       left: 0;
-      background: linear-gradient(
-        to right,
-        rgba(0, 0, 0, 0),
-        rgba(0, 0, 0, 0.8)
-      );
+      background: linear-gradient(to right,
+          rgba(0, 0, 0, 0),
+          rgba(0, 0, 0, 0.8));
       text-align: end;
       color: @red;
       padding-right: 0.25em;

--
Gitblit v1.9.3