lxf
2025-07-16 c6ccd498aa419327de7c64e03f989964eeb5d278
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
<template>
  <div id="#cryptos">
    <div class="exchangeRate">
      <assets-head :title="$t('汇率设置')" />
      <div v-for="(item, index) in exchangeratelist_get_data" :key="index"
        class="flex justify-between items-center lang-padding font-35 box-border h-127 px-35 "
        @click="handleSetLang(item)">
        <div class="lang-title flex items-center font-26 textColor">
          <img class="w-12 h-12 mr-5" :src="item.url" alt="">
          {{ item.currency }}
        </div>
 
        <img class="w-12 h-12" v-if="item.currency == show_ex" src="../../../assets/image/public/checked.png" />
      </div>
    </div>
  </div>
</template>
<script>
import { _exchangeratelist, _exchangerateuserconfig } from "@/service/trade.api";
import { _getExchangeRate } from '@/service/cryptos.api'
import assetsHead from "@/components/Transform/assets-head/index.vue";
import { mapActions } from "vuex";
import { SET_CURRENCY } from "@/store/const.store";
 
export default {
  data() {
    return {
      show_ex: {},
      list: [
        { title: 'USD', key: 'USD' },
        { title: 'CNY', key: 'CNY' },
        { title: 'ERU', key: 'ERU' },
        { title: 'JPY', key: 'JPY' }
      ],
      exchangeratelist_get_data: []
    }
  },
  components: {
    assetsHead
  },
  mounted() {
    this.init()
  },
  methods: {
    ...mapActions('home', [SET_CURRENCY]),
    init() {
      // this.show_ex = this.$store.state.home.currency.currency
      this.getExchangeRate()
      this.exchangeratelist_get()
    },
    handleImage(url) {
      return new URL(url, import.meta.url).href
    },
    getExchangeRate() {
      _getExchangeRate({}).then((res) => {
        this.show_ex = res.currency
      })
    },
    exchangeratelist_get() {
      const t = this
      _exchangeratelist({}).then((data) => {
        t.exchangeratelist_get_data = data
        t.exchangeratelist_get_data.forEach((item) => {
          item.image = new URL(`../../../assets/image/exchange-rate/${item.currency}.png`, import.meta.url)
          item.url = this.handleImage(item.image)
        })
      })
    },
    handleSetLang(e) {
      const t = this
      _exchangerateuserconfig({ rateId: e.uuid }).then((res) => {
        this.SET_CURRENCY()
        t.show_ex = e.currency
 
      })
 
    },
    onClickLeft() {
      this.$router.go(-1)
      console.log(this.$i18n.locale)
    },
  }
}
</script>
<style lang="scss">
@import "@/assets/init.scss";
 
#cryptos {
  .exchangeRate {
    width: 100%;
    box-sizing: border-box;
  }
 
  .lang-padding {
    border-bottom: 1px solid $line_color;
    font-weight: 400;
    color: $black;
  }
 
 
 
}
 
.px-35 {
  padding: 0 20px !important;
}
 
.h-127 {
  height: 127px;
}
 
.lang-padding {
  padding: 20px 0;
}
 
.lang-title {
  font-size: 30px;
}
</style>