zj
2024-06-03 96140d8eb2531144828dffe2ad8c19d0d9431009
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
<template>
  <div class="pb-120 assetsCenter">
    <div class="flex justify-between px-52 pt-31  box-border">
      <div class="flex-1 items-center text-center textColor1" v-for="(item, index) in typeList " :key="'type' + index"
        @click="onTabs(index)">
        <div class="font-32  text-center lh-53">{{ item.type }}</div>
      </div>
    </div>
    <div class="flex mx-52 mt-17">
      <span class="flex-1 border-b-color " :class="{ active_color: tab === 0 }"></span>
      <span class="flex-1 border-b-color" :class="{ active_color: tab === 1 }"></span>
      <span class="flex-1 border-b-color" :class="{ active_color: tab === 2 }"></span>
      <span class="flex-1 border-b-color" :class="{ active_color: tab === 3 }"></span>
    </div>
    <over-view v-if="tab === 0" :funds="funds" :key="tab"></over-view>
    <as-sets v-if="tab === 1" :funds="funds" :key="tab"></as-sets>
    <contract v-if="tab === 2" :funds="funds" :index="index" :key="tab"></contract>
    <financial v-if="tab === 3" :funds="funds" :index="index" :key="tab"></financial>
 
  </div>
</template>
 
<script>
 
import AsSets from "@/components/assetsCenter/assets"
import OverView from "@/components/assetsCenter/overview"
import Contract from "@/components/assetsCenter/contract"
import Financial from "@/components/assetsCenter/financial"
import Axios from "@/API/assets"
export default {
  name: "assets-index",
  components: {
    AsSets,
    OverView,
    Contract,
    Financial
  },
  data() {
    return {
      type: 'left', //left 从左往右 right 从有王座
      list: [],
      timer: null,
      tab: 0,
      index: 0, // 每个组件的二级tab
      funds: {},
      typeList: [
        {
          type: this.$t('总览'),
        },
        {
          type: this.$t('现货账户'),
        },
        {
          type: this.$t('合约'),
 
        },
        {
          type: this.$t('理财'),
        },
      ]
    }
  },
  methods: {
    onTabs(val) {
      if (this.tab < val) {
        this.type = 'right'
      } else {
        this.type = 'left'
      }
      console.log(val)
      this.tab = val
    },
    getAssets() {
      Axios.GetAllAssets().then((res) => {
        const { code, data } = res
        if (code) {
          //console.log('总资产数据',data)
          this.funds = data
        }
      })
    },
  },
  created() {
    this.getAssets()
    this.timer = setInterval(() => {
      this.getAssets()
    }, 5000)
    if (Object.hasOwnProperty.call(this.$route.query, 'tab')) {
      this.tab = this.$route.query.tab / 1
      this.index = this.$route.query.index ? this.$route.query.index * 1 : 0
    }
  },
  activated() {
    clearInterval(this.timer)
    this.timer = setInterval(() => {
      this.getAssets()
    }, 5000)
    this.index = 0
  },
  deactivated() {
    clearInterval(this.timer)
    this.timer = null
  },
  beforeDestroy() {
    clearInterval(this.timer)
    this.timer = null
  }
}
</script>
 
<style lang="scss" scoped>
.assetsCenter {
  width: 100%;
  box-sizing: border-box;
}
 
.active_color {
  @include themify() {
    border-bottom: 5px solid themed("color_main") !important;
  }
 
  border-radius: 2.208px;
}
 
.left-enter-active,
.left-leave-active,
.right-enter-active,
.right-leave-active {
  will-change: transform;
  transition: all 500ms;
}
 
.left-leave-active,
.right-leave-active {
  display: none;
}
 
.left-enter {
  opacity: 0;
  transform: translate3d(-100%, 0, 0);
}
 
.left-leave {
  opacity: 0;
  transform: translate3d(100%, 0, 0)
}
 
.right-enter {
  opacity: 0;
  transform: translate3d(100%, 0, 0);
}
 
.right-leave {
  opacity: 0;
  transform: translate3d(-100%, 0, 0)
}
</style>