1
PC-20250623MANY\Administrator
2025-07-22 beff59e6065d3283cc9fb10fe7151f2b757cd154
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<!-- 谷歌验证 -->
<template>
  <div>
    <div style="margin-top: 50px">
      <main class="main css-6q12pm">
        <div class="css-108ucgm">
          <div class="binance-row css-16kn2us">
            <div class="binance-col css-1wz0uwi" style="margin-left: -12px">
              <div class="css-cz4mv2">
                <div class="css-6x3lo1">
                  <div class="css-vurnku">
                    <div class="css-ojbpe7" style="text-align: center">
                      {{ $t("gugeyanzhengqibangding") }}
                    </div>
 
                    <div class="css-vurnku">
                      <!-- QRCode -->
                      <div class="code-box">
                        <!-- 二维码 + 刷新 -->
                        <div class="qr_code">
                          <div class="code_img_wrapper">
                            <img
                              class="code-img"
                              :src="google_auth_url"
                              alt="QR code"
                            />
                          </div>
                          <div>
                            <i
                              class="el-icon-refresh-right font-size24"
                              style="color: rgb(29, 145, 255); margin-left: 8px"
                              @click="refreshBtn"
                            ></i>
                          </div>
                        </div>
 
                        <!-- 秘钥 + 复制 -->
                        <div class="label_top">
                          <span>{{ google_auth_secret }}</span>
                          <span
                            :data-clipboard-text="google_auth_secret"
                            class="copy-btn"
                            @click="copyBtn"
                            >{{ $t("message.user.fuzhi") }}</span
                          >
                        </div>
                        <!-- 妥善保管 -->
                        <div class="key_msg">
                          ({{ $t("message.user.chang15") }})
                        </div>
                      </div>
                      <!-- 输入谷歌验证码 -->
                      <div>
                        <div class="label_light">
                          {{ $t("message.user.gugeyanzhengma") }}
                        </div>
                        <security-code
                          @getGoogleCode="getGoogleCode"
                        ></security-code>
                      </div>
 
                      <!-- 提示语句 -->
                      <div class="illustrate">
                        <div>
                          <div>{{ $t("message.user.gugeyanzhengma") }}</div>
                          <p>{{ $t("message.user.chang16") }}</p>
                          <p>{{ $t("message.user.chang17") }}</p>
                        </div>
                        <div>
                          <div>{{ $t("message.user.chang18") }}</div>
                          <p>{{ $t("message.user.chang19") }}</p>
                          <p>{{ $t("message.user.chang20") }}</p>
                        </div>
                      </div>
 
                      <button @click="confirmBtn" class="css-1bsmpdm">
                        {{ $t("message.user.bangding") }}
                      </button>
 
                      <div
                        @click="jumpOver"
                        style="
                          text-align: center;
                          padding: 20px 0;
                          color: #868d9a;
                          cursor: pointer;
                        "
                      >
                        {{ $t("tiaoguo") }}
                      </div>
                    </div>
                    <div class="css-vurnku"></div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </main>
    </div>
  </div>
</template>
<script>
import securityCode from "@/components/my/securityCode.vue";
import Axios2 from "@/api/my.js";
import Clipboard from "clipboard";
 
export default {
  name: "googleSet",
  components: { securityCode },
  data() {
    return {
      google_auth_secret: "", //谷歌验证器密钥
      google_auth_url: "", //图片URL地址
      google_auth_bind: "", //是否已绑定:1/绑定;0/未绑定
      //验证码
      code: [],
    };
  },
  created() {
    let interimToken = localStorage.getItem("spToken");
    if (interimToken) {
      this.getGoogleInfo();
    }
  },
  computed: {},
  methods: {
    jumpOver() {
      this.$router.push("/setDone");
    },
    getGoogleCode(data) {
      this.code = data; //数组
    },
    //获取谷歌绑定的信息
    getGoogleInfo() {
      Axios2.getGoogleAuth().then((res) => {
        const { googleAuthSecret, googleAuthImg } = res.data;
        this.google_auth_secret = googleAuthSecret;
        this.google_auth_url = googleAuthImg;
      });
    },
    refreshBtn() {
      this.getGoogleInfo();
    },
    //绑定
    confirmBtn() {
      if (this.code.length === 6) {
        const paramsCode = this.code.join("");
        Axios2.bindGoogleAuth({
          secret: this.google_auth_secret,
          code: paramsCode,
        }).then((res) => {
          if (res.data?.google_auth_bind == true) {
            ElMessage.success(this.$t("message.user.bangdingchenggong"));
            this.$router.push("/setDone");
            this.handClose();
          }
        });
      } else {
        ElMessage.warning(this.$t("message.user.qsr_yanzhengma"));
      }
    },
    //复制密钥
    copyBtn() {
      const clipboard = new Clipboard(".copy-btn");
      clipboard.on("success", (e) => {
        ElMessage.success(this.$t("message.user.fuzhichenggong"));
        clipboard.destroy();
      });
      clipboard.on("error", (e) => {
        console.error("复制出错", e);
        clipboard.destroy();
      });
    },
    handClose() {
      this.visible = false;
      this.code = [];
    },
  },
};
</script>
<style scoped>
@import url("@/assets/css/login/register.css");
 
.el-input--suffix >>> .el-input__inner {
  padding-right: 30px;
  outline: none;
  border: none;
}
 
.code-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid #eeeeee;
}
 
.qr_code {
  display: flex;
}
 
.code_img_wrapper {
  border: 1px solid #e5e5e5;
}
 
.code-img {
  width: 200px;
  height: 200px;
}
 
.label_light {
  margin-top: 30px;
  font-size: 14px;
}
 
.key_msg {
  color: #999999;
  margin-bottom: 30px;
}
 
.num-content {
  display: flex;
  margin-top: 15px;
}
 
.num-content > p {
  font-size: 15px;
  margin-right: 10px;
}
 
.input-num-style {
  width: 40px;
  height: 40px;
  border: 1px solid #e5e5e5;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  border-radius: 3px;
  margin-right: 15px;
}
 
/* 提示 */
.illustrate {
  background: #fafafa;
  padding: 15px;
  margin-top: 25px;
  border-radius: 3px;
}
 
.illustrate > div:nth-child(1) {
  margin-bottom: 30px;
}
 
.illustrate > div > p {
  color: #484d56;
  font-size: 12px;
  line-height: 26px;
}
 
.illustrate > div > div {
  color: #202123;
  font-size: 12px;
  line-height: 26px;
}
 
.copy-btn {
  width: 120px;
  height: 36px;
  color: #333;
  border-radius: 4px;
  border: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
 
  cursor: pointer;
}
</style>