10.10综合交易所原始源码_移动端
admin
2026-01-06 04d8c6bfd48267c7b2eaccaa03170618d83e4cbd
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<template>
  <div class="bindVerify">
    <fx-header>
      <template #title>
        {{ title }}
      </template>
    </fx-header>
    <div class="content">
      <!-- 手机邮箱验证 -->
      <div v-if="type == 1 || type == 2">
        <ExInput
          :label="type == 2 ? $t('email') : $t('phoneNum')"
          :placeholderText="type == 2 ? $t('entryEmail') : $t('entryPhone')"
          v-model="account"
          :area="isArea"
          @selectArea="onSelectArea"
          :dialCode="dialCode"
          :icon="icon"
        />
        <p class="label mt-2 textColor">{{ $t("verificationCode") }}</p>
        <div class="iptbox inputBackground">
          <input
            class="inputBackground textColor"
            type="text"
            :placeholder="$t('entryVerifyCode')"
            v-model="verifyCode"
          />
          <span v-if="type != 3" @click="senCode"
            >{{ $t("sendVerifyCode")
            }}<template v-if="time"> ({{ time }})s</template></span
          >
        </div>
      </div>
      <!-- 谷歌验证 -->
      <div v-if="type == 3">
        <div
          class="pl-30 pr-30 text-center flex flex-col items-center justify-center mt40"
        >
          <div class="imgbox">
            <van-image :src="google_auth_url">
              <template v-slot:loading>
                <van-loading type="spinner" size="20" />
              </template>
            </van-image>
          </div>
          <div class="code flex items-center justify-center textColor">
            {{ google_auth_secret }}
            <img src="@/assets/image/reload.png" alt="" @click="getGoogleauth" />
          </div>
          <p class="tips">{{ $t("saveKeyTips") }}</p>
          <div class="copy textColor" @click="copy">{{ $t("copy") }}</div>
        </div>
        <div class="flex justify-between mt-6 mb-3">
          <div>{{ $t("googleVerificationCode") }}</div>
          <div class="flex items-center">
            <div class="colorMain" @click="googleverifyCode = ''">{{ $t("clear") }}</div>
            <div class="colorMain ml-30" @click="pastCont">{{ $t("paste") }}</div>
          </div>
        </div>
        <van-password-input
          :value="googleverifyCode"
          :gutter="16"
          :focused="showKeyboard"
          @focus="showKeyboard = true"
          :mask="false"
        />
        <van-number-keyboard
          v-model="googleverifyCode"
          :show="showKeyboard"
          @blur="showKeyboard = false"
        />
        <div class="mt-2"></div>
        <div class="mt-5 bottom tabBackground textColor">
          <p>{{ $t("precautions") }}</p>
          <p>{{ $t("precautionsTips1") }}</p>
          <p>{{ $t("precautionsTips2") }}</p>
        </div>
      </div>
      <van-button class="w-full" style="margin-top: 10px" type="primary" @click="submit"
        >{{ $t("confirm") }}
      </van-button>
    </div>
    <nationality-list ref="controlChildRef" :title="$t('selectArea')" @getName="getName">
    </nationality-list>
  </div>
</template>
 
<script setup>
import ExInput from "@/components/ex-input/index.vue";
import { _sendVerifyCode } from "@/service/login.api";
import {
  _bindEmail,
  _bindPhone,
  _getGoogleauth,
  _bindGoogleauth,
} from "@/service/user.api.js";
import nationalityList from "../authentication/components/nationalityList.vue";
import { PasswordInput, NumberKeyboard, showToast, Image as VanImage } from "vant";
import { ref, onMounted, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
import useClipboard from "vue-clipboard3";
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
const { toClipboard } = useClipboard();
 
const title = ref("");
const account = ref("");
const isArea = ref(false);
const type = ref(0);
const verifyCode = ref("");
const google_auth_secret = ref("");
const showKeyboard = ref(false);
const googleverifyCode = ref(""); //谷歌验证码code
const imgshow = ref(true);
const google_auth_url = ref("");
const dialCode = ref(0); //电话号前缀
const timer = ref(null);
const time = ref(0);
const icon = ref("");
 
onMounted(() => {
  init();
  clearInterval(timer.value);
  timer.value = null;
});
 
const init = () => {
  type.value = route.query.type;
  if (type.value == 1) {
    title.value = t("bindPhone");
    isArea.value = true;
  } else if (type.value == 2) {
    title.value = t("bindEmail");
  } else if (type.value == 3) {
    title.value = t("googleAuthenticatorEn");
    getGoogleauth();
  }
};
const senCode = () => {
  if (type.value == 2) {
    if (account.value == "") {
      showToast(t("entryEmail"));
      return;
    }
    if (account.value.indexOf("@") === -1) {
      showToast(t("请输入正确的邮箱地址"));
      return;
    }
  }
  if (type.value == 1 && account.value == "") {
    showToast(t("entryPhone"));
    return;
  }
  if (type.value == 1 && isNaN(account.value)) {
    showToast(t("请输入正确的手机号码"));
    return;
  }
  if (time.value > 0) {
    return false;
  }
  _sendVerifyCode({
    target: type.value == 1 ? `${dialCode.value}${account.value}` : account.value,
  }).then((res) => {
    showToast(t("sendSuccess"));
    time.value = 30;
    timer.value = setInterval(() => {
      if (time.value > 0) {
        time.value = time.value - 1;
      } else {
        time.value = 0;
        clearInterval(timer.value);
        timer.value = null;
      }
    }, 1000);
  });
};
const submit = () => {
  if (type.value == 2) {
    if (account.value == "") {
      showToast(t("entryEmail"));
      return;
    }
    if (account.value.indexOf("@") === -1) {
      showToast(t("请输入正确的邮箱地址"));
      return;
    }
  }
  if (type.value == 1 && account.value == "") {
    showToast(t("entryPhone"));
    return;
  }
  if (type.value == 1 && isNaN(account.value)) {
    showToast(t("请输入正确的手机号码"));
    return;
  }
  if (type.value == 1) {
    bindPhone();
  } else if (type.value == 2) {
    bindEmail();
  } else if (type.value == 3) {
    bindGoogleauth();
  }
};
const bindEmail = () => {
  _bindEmail({
    email: account.value,
    verifcode: verifyCode.value,
  }).then((res) => {
    showToast(t("bindSuccess"));
    router.push("/safety");
  });
};
const bindPhone = () => {
  _bindPhone({
    phone: `${dialCode.value || ""}${account.value}`,
    verifcode: verifyCode.value,
  }).then((res) => {
    showToast(t("bindSuccess"));
    router.push("/safety");
  });
};
const getGoogleauth = () => {
  _getGoogleauth({}).then((res) => {
    google_auth_secret.value = res.googleAuthSecret;
    google_auth_url.value = res.googleAuthImg;
  });
};
const bindGoogleauth = () => {
  if (!googleverifyCode.value) {
    showToast(t("请输入谷歌验证码"));
    return;
  }
  _bindGoogleauth({
    secret: google_auth_secret.value,
    code: googleverifyCode.value,
  }).then((res) => {
    let google_auth_bind = res.google_auth_bind;
    if (google_auth_bind) {
      showToast(t("bindSuccess"));
      router.push("/safety");
    } else {
      showToast(t("bindFailed"));
    }
  });
};
 
const copy = async () => {
  try {
    await toClipboard(google_auth_secret.value);
    showToast(t("copySuccess"));
  } catch (e) {
    console.error(e);
  }
};
const pastCont = async () => {
  googleverifyCode.value = await navigator.clipboard.readText();
};
 
// 选择了国家
const getName = (params) => {
  icon.value = params.code;
  dialCode.value = params.dialCode;
};
 
const controlChildRef = ref(null);
const onSelectArea = () => {
  controlChildRef.value.open();
};
 
watch(googleverifyCode, (val, oldVal) => {
  if (googleverifyCode.value.length === 6) {
    showKeyboard.value = false;
  }
});
</script>
 
<style lang="scss" scoped>
:deep(.van-key) {
  background: $btn-group;
}
 
:deep(.van-number-keyboard__body) {
  background: $selectSymbol_background;
}
 
.bindVerify {
  width: 100%;
  box-sizing: border-box;
}
 
.content {
  font-size: 12px;
  padding: 0 16px;
}
 
.iptbox {
  height: 44px;
  margin-top: 8px;
  padding: 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 3px;
 
  input {
    flex: 1;
    height: 100%;
    border: none;
  }
 
  span {
    color: $color_main;
  }
}
 
.imgbox {
  border: 1px solid $border-grey;
  padding: 5px;
  width: 182px;
  height: 182px;
  box-sizing: border-box;
 
  img {
    width: 100%;
    height: 100%;
  }
}
 
.code {
  font-size: 15px;
  font-weight: 300;
  line-height: 18px;
  margin-top: 22px;
  height: 18px;
 
  img {
    width: 14px;
    height: 14px;
    margin-left: 5px;
  }
}
 
.tips {
  margin-top: 10px;
  color: #999999;
}
 
.copy {
  border-radius: 4px;
  width: 132px;
  height: 40px;
  margin-top: 16px;
  border: 1px solid $border-grey;
  line-height: 40px;
}
 
.bottom {
  padding: 20px 16px 7px 16px;
 
  p {
    padding-bottom: 13px;
  }
}
 
.van-password-input {
  margin: 0;
}
 
.van-password-input__security li {
  background: $input_background;
  width: 50px;
  height: 50px;
  color: $text_color;
}
 
:deep(.van-password-input__security li) {
  background: $input_background;
  width: 50px;
  height: 50px;
  color: $text_color;
}
</style>