lxf
2025-04-30 5724853bb254ca29e3c095a6f2f987cf551c44ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<template>
  <div class="ware">
    <div style="padding: 0 0.4rem 0.4rem">
      <van-tabs v-model="active" color="#0066ed" @change="handleTabChange">
        <van-tab :title="$t('hj52')" name="2"></van-tab>
        <van-tab :title="$t('黄金原油')" name="1"></van-tab>
      </van-tabs>
 
      <itemCard
        @closingPosition="closingPosition"
        :activeObj="activeObj"
        :itemClick="itemClick"
      />
      <div>
        <dataList
          ref="dataListref"
          :activeObj="activeObj"
          @closingPosition="closingPosition"
        />
      </div>
    </div>
  </div>
</template>
 
<script>
import card from "./Warehouse/card.vue";
import itemCard from "./Warehouse/item.card.vue";
import dataList from "./Warehouse/data.list.vue";
import { getMoney } from "../../axios/api";
 
export default {
  components: { card, itemCard, dataList },
  data() {
    return {
      actives: "2",
      active: "2",
      activeObj: {},
      tabsArr: [
        // {
        //   title: this.$t("hometips"),
        //   name: "1",
        //   bgc: "rgb(8, 82, 196)",
        //   laber: "ALL",
        //   symbolCode: "USD",
        //   symbol: "$",
        // },
        {
          title: this.$t("hj52"),
          assname: this.$t("沙特股总资产"),
          name: "2",
          bgc: "rgb(12, 175, 226)",
          laber: "ST",
          symbolCode: "INR",
          symbol: " ﷼"
        },
        {
          title: this.$t("黄金原油"),
          assname: this.$t("黄金原油"),
          name: "1",
          bgc: "rgb(12, 175, 226)",
          laber: "USD",
          symbolCode: "USD",
          symbol: "RM"
        }
        // {
        //   title: this.$t("黄金原油"),
        //   assname: this.$t("黄金原油"),
        //   name: "2",
        //   bgc: "rgb(12, 175, 226)",
        //   laber: "IN",
        //   symbolCode: "INR",
        //   symbol: " ﷼"
        // }
        // {
        //   title: this.$t("马来西亚"),
        //   assname: this.$t("馬股总资产"),
        //   name: "4",
        //   bgc: "rgb(163, 91, 255)",
        //   laber: "MAS",
        //   symbolCode: "MYR",
        //   symbol: "RM",
        // },
        // {
        //   title: this.$t("港股"),
        //   assname: this.$t("港股总资产"),
        //   name: "5",
        //   bgc: "rgb(255 91 230)",
        //   laber: "HK",
        //   symbolCode: "HKD",
        //   symbol: "HK$",
        // },
      ],
      getMoneyList: []
    };
  },
  created() {
    this.getMoneys();
  },
  mounted() {
    if (this.$route.query.buyType) {
      let arr = this.tabsArr.filter(
        item => item.laber == this.$route.query.buyType
      )[0];
      // this.onClick(arr);
    }
  },
  methods: {
    closingPosition() {
      this.getMoneys();
    },
    itemClick() {
      this.$refs.dataListref.getList(this.activeObj.laber);
      this.getMoneys();
    },
    async getMoneys() {
      const res = await getMoney();
      if (res.status === 0) {
        let arr = [];
        this.tabsArr.map(item => {
          res.data.map(items => {
            if (items.accectType === item.laber) {
              item = { ...item, ...items, laber: items.accectType };
              arr.push(item);
            }
          });
        });
        let obj = arr.filter(item => item.name == this.active)[0];
        console.log("getMoneys: ", arr, obj);
        this.activeObj = obj;
        this.tabsArr = arr;
        this.$forceUpdate(); // 强制Vue重新渲染
      }
    },
    onClick(e) {
      this.active = e.name;
      this.activeObj = e;
      this.getMoneys();
      if (e.name !== "1") {
        this.$refs.dataListref.getList(e.laber);
      }
    },
    handleTabChange(name) {
      const arr = this.tabsArr.filter(item => item.name === name);
      if (arr.length > 0) {
        this.activeObj = arr[0];
        this.$refs.dataListref.getList(this.activeObj.laber);
      }
    }
  }
};
</script>
 
<style lang="less" scoped>
.ware {
  overflow: hidden;
  min-height: 100vh;
  // padding: 0 0.4rem 0.4rem;
  background-color: #fff;
  padding-bottom: 100px;
}
.tabs-box {
  display: flex;
  overflow-x: auto;
  width: 100%; /* Ensures it takes full width of the container */
  white-space: nowrap; /* Prevents text wrapping */
  background: rgb(247, 247, 250);
  margin-top: 20px;
  border-radius: 20px;
  padding-right: 20px;
}
.tabs-box::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}
.tabs-item {
  cursor: pointer;
  flex: 0 0 auto; /* Ensures items do not grow or shrink */
  padding: 15px; /* Adjust padding as needed */
  // border: 1px solid #ccc; /* Just for demonstration, you can style as needed */
  margin-right: 10px; /* Adjust margin as needed */
  min-width: 100px; /* Minimum width for each item */
  text-align: center;
  color: rgb(140, 159, 173);
  font-size: 16px;
  // padding: 0.10667rem 0.34667rem;
}
.tabs-item-active {
  border-radius: 20px;
  background: #39a08e;
  // padding: 0.10667rem 0.34667rem;
  color: #fff;
}
</style>