1
李凌
5 days ago 349c48e168b9f2580334422228acde7d1b21bede
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
<template>
  <div id="cryptos">
    <assets-head :title="$t('资金账户')" :back-func="backFunc" />
    <div class="funds-page pb-120">
      <div class="funds-tabs-wrap">
        <div class="funds-tabs">
          <div
            v-for="(item, index) in typeList"
            :key="'type' + index"
            class="funds-tab-item"
            :class="{ active: tab === index }"
            @click="onTabs(index)"
          >
            {{ item.type }}
          </div>
        </div>
      </div>
      <div class="funds-content">
        <over-view v-if="tab === 0" :funds="funds" :key="'tab0'" />
        <as-sets v-if="tab === 1" :funds="funds" :key="'tab1'" />
        <contract v-if="tab === 2" :funds="funds" :index="index" :key="'tab2'" />
        <financial v-if="tab === 3" :funds="funds" :index="index" :key="'tab3'" />
      </div>
    </div>
  </div>
</template>
 
<script>
import AsSets from '@/components/Transform/assetsCenter/assets.vue'
import OverView from '@/components/Transform/assetsCenter/overview.vue'
import Contract from '@/components/Transform/assetsCenter/contract.vue'
import Financial from '@/components/Transform/assetsCenter/financial.vue'
import { _getAllAssets } from '@/service/user.api.js'
 
export default {
  name: 'assets-index',
  components: {
    AsSets,
    OverView,
    Contract,
    Financial
  },
  data() {
    return {
      tab: 0,
      index: 0,
      funds: {},
      typeList: [
        { type: this.$t('总览') },
        { type: this.$t('现货账户') },
        { type: this.$t('合约') },
        { type: this.$t('理财') }
      ]
    }
  },
  methods: {
    backFunc() {
      this.$router.push({
        path: '/quotes/index',
        query: { tabActive: 1 }
      })
    },
    onTabs(val) {
      this.tab = val
    },
    getAssets() {
      _getAllAssets().then((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
  },
  beforeUnmount() {
    clearInterval(this.timer)
    this.timer = null
  }
}
</script>
 
<style lang="scss">
@import '@/assets/init.scss';
 
#cryptos {
  .funds-page {
    min-height: 100vh;
    box-sizing: border-box;
  }
 
  .funds-tabs-wrap {
    padding: 20px 32px 8px;
    position: sticky;
    top: 96px;
    z-index: 10;
    @include themify() {
      background: themed('main_background');
    }
  }
 
  .funds-tabs {
    display: flex;
    gap: 12px;
    padding: 8px;
    border-radius: 20px;
    @include themify() {
      background: themed('cont_background');
    }
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  }
 
  .funds-tab-item {
    flex: 1;
    text-align: center;
    padding: 18px 8px;
    border-radius: 14px;
    font-size: 26px;
    line-height: 1.2;
    transition: all 0.2s ease;
    @include themify() {
      color: themed('text_color1');
    }
 
    &.active {
      color: #fff;
      background: linear-gradient(135deg, #1a6dff 0%, #004aee 100%);
      font-weight: 600;
      box-shadow: 0 6px 16px rgba(0, 74, 238, 0.28);
    }
  }
 
  .funds-content {
    padding: 0 32px;
  }
}
</style>