dcc
2024-06-13 3616db170333df7d668c97323344335b52c4153c
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
<!--  语言汇率弹窗-->
<template>
  <div v-if="isShow">
    <div class="css-xplkkx">
      <div class="css-14doc9z">
        <div class="css-xhj0x8" @click="isShowClick">
          <svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            class="css-1iztezc"
          >
            <path
              d="M6.697 4.575L4.575 6.697 9.88 12l-5.304 5.303 2.122 2.122L12 14.12l5.303 5.304 2.122-2.122L14.12 12l5.304-5.303-2.122-2.122L12 9.88 6.697 4.575z"
              fill="currentColor"
            ></path>
          </svg>
        </div>
        <div class="css-1r3gvce">
          <div
            v-for="(val, index) in titleList"
            :key="index"
            :class="[active == index ? 'css-t94xhh' : 'css-ibfrnl']"
            @click="tabIndex(index)"
          >
            {{ val }}
          </div>
        </div>
        <div class="css-1tzfn88">
          <div class="css-cbzd9" v-if="active == 0">
            <div class="css-1p8zxym">
              {{ $t("message.user.qingxuanzeyuyanhediqu") }}
            </div>
            <div class="css-q2wk8b">
              <button
                data-active="true"
                id="fiatlngdialog_ba-languageRegion-zh-CN"
                :class="[
                  langActive == index ? 'rest_css-1szzq31' : '',
                  'css-1szzq3l',
                ]"
                style="width: 125px"
                v-for="(lang, index) in langOptions"
                :key="index"
                @click="changeLang(index, lang)"
              >
                <div class="css-1hv3jiv">
                  {{ lang.label }}
                </div>
                <svg
                  xmlns="http://www.w3.org/2000/svg"
                  fill="currentColor"
                  class="css-j1zueq"
                >
                  <use xlink:href="#checkmark-f"></use>
                </svg>
              </button>
            </div>
          </div>
          <!-- 汇率 -->
          <!-- <div class="css-fyzeir" v-else-if="active == 1">
            <div  class="css-1p8zxym">
              {{ $t("message.user.qingxuanzehuilv") }}
            </div>
            <div class="css-q2wk8b">
              <button
                data-active="true"
                id="fiatlngdialog_ba-Currency-CNY"
                class="css-1szzq3l"
                v-for="(val, index) in exchangeRateData"
                :class="[
                  moneyIndex == index ? 'rest_css-1szzq31' : '',
                  'css-1szzq3l',
                ]"
                @click="chooseRate(index, val)"
                :key="index"
              >
                <div  class="css-1hv3jiv">
                  {{ val.currency }}-{{ val.currency_symbol }}
                </div>
              </button>
            </div>
          </div> -->
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { strFirstBit } from "@/utils";
import { mapState, mapActions } from "pinia";
import { useUserStore } from "@/store/user";
import { useLanguageStore } from "@/store/lang";
import { langOptions } from "@/utils";
export default {
  name: "langSelect",
  data() {
    return {
      isShow: false,
      titleList: [this.$t("message.user.yuyanhediqu")],
      langOptions,
      active: 0, //选中汇率还是多语言
      langActive: 0,
      moneyIndex: 0,
      exchangeRateData: [], //TODO
    };
  },
  computed: {
    ...mapState(useUserStore, ["existToken"]),
    ...mapState(useLanguageStore, ["language"]),
 
    // ...mapState({
    //   exchangeRateData: (state) => state.exchangeRateData,
    // }),
  },
  methods: {
    ...mapActions(useLanguageStore, ["updateLang"]),
    isShowClick(type) {
      if (type == "lang") {
        this.active = 0;
        const langKeyList = this.langOptions.map((it) => it.value);
        this.langActive = langKeyList.indexOf(this.language);
      } else if (type == "exchange") {
        this.active = 1;
        this.moneyIndex = strFirstBit(this.exchangeRateData).indexOf(
          this.$store.state.rate
        );
      }
      this.isShow = !this.isShow;
    },
    tabIndex(index) {
      this.active = index;
    },
    changeLang(index, lang) {
      this.langActive = index;
      this.updateLang(lang.value);
      this.isShowClick();
      location.reload();
    },
    // chooseRate(index, rate) {
    //   this.$GloExchangeRate = rate;
    //   this.moneyIndex = index;
    //   this.$store.commit("SETRATE", rate.currency);
    //   this.isShowClick("exchange");
    // },
  },
};
</script>
<style scoped>
@import url("@/assets/css/login/langMoney.css");
</style>