10.10综合交易所原始源码_移动端
1
李凌
yesterday dce10d37ad35efe8ed1d39d6e5fcf7e4904381df
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
<template>
  <section class="my-center-page">
    <!-- 头部:返回 + 个人中心 + 右侧客服 -->
 
    <assets-head :title="$t('个人中心')" :back-func="() => router.push('/')" />
 
    <!-- 未登录:欢迎 + 登录注册 -->
    <template v-if="!(userStore.userInfo && userStore.userInfo.token)">
      <div class="guest-wrap px-8 mt-4">
        <h1 class="guest-title">{{ $t("welcome") }}&nbsp;{{ $title }}!</h1>
        <p class="guest-desc">{{ $t("全球最大的区块链资产平台") }}</p>
        <div class="guest-btns">
          <van-button class="flex-1" @click="onRoute('/register')">{{ $t("register") }}</van-button>
          <van-button class="flex-1" type="primary" @click="onRoute('/login')">{{ $t("login") }}</van-button>
        </div>
      </div>
    </template>
 
    <!-- 已登录:深色用户卡 + 合并菜单列表 -->
    <template v-else>
      <!-- 用户信息卡(深色) + user-row 下方弹出框 -->
      <div class="user-card">
        <div class="user-card-inner">
          <div class="user-avatar flex items-center justify-center">
            <img src="@/assets/image/login_logo.png" alt="avatar" />
          </div>
          <div class="user-info">
            <div class="user-row" @click.stop="showAccountPopup = !showAccountPopup">
              <span class="user-account">{{ maskedAccount }}</span>
              <van-icon name="arrow-down" class="user-arrow" />
 
              <!-- 当前为模拟账户时显示「真实账户」,否则显示「模拟账户」 -->
              <div v-show="showAccountPopup" class="account-option-pill" @click="isSimulation ? onSwitchToReal() : onSwitchToSimulation()">
                {{ isSimulation ? ($t('真实账户') || '真实账户') : ($t('模拟账户') || '模拟账户') }}
              </div>
            </div>
            <div class="user-uid">UID: {{ userStore.userInfo.usercode || '--' }}</div>
          </div>
          <div class="user-vip">VIP 1</div>
        </div>
      </div>
 
      <!-- 合并列表:快捷入口 + 通用 + 更多(单列白卡片) -->
      <div class="menu-list">
        <div v-for="(item, index) in mergedMenuList" :key="index" class="menu-item" @click="onMenuItemClick(item)">
          <img class="menu-icon" :src="item.icon" alt="" />
          <span class="menu-title">{{ item.title }}</span>
          <span v-if="item.rightText" class="menu-right-text">{{ item.rightText }}</span>
          <van-icon name="arrow" class="menu-arrow" />
        </div>
      </div>
 
      <!-- 退出登录 -->
      <div class="logout-wrap">
        <span class="logout-btn" @click="loginOut">{{ $t("loginOut") }}</span>
      </div>
    </template>
  </section>
</template>
 
<script setup>
import assetsHead from '@/components/Transform/assets-head/index.vue'
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { _getIdentify, _getKycHighLevel, _logOut, _switchAccount } from '@/service/user.api.js'
import { useUserStore } from '@/store/user'
import { _getUnreadMsg } from '@/service/im.api'
import { themeStore } from '@/store/theme'
import store from '@/store/store'
import userIcon1 from '@/assets/image/userCenter/user_1.png'
import userIcon2 from '@/assets/image/userCenter/user_2.png'
import userIcon3 from '@/assets/image/userCenter/user_3.png'
import userIcon4 from '@/assets/image/userCenter/user_4.png'
import userIcon5 from '@/assets/image/userCenter/user_5.png'
import userIcon6 from '@/assets/image/userCenter/user_6.png'
import userIcon7 from '@/assets/image/userCenter/user_7.png'
import userIcon8 from '@/assets/image/userCenter/user_8.png'
 
const { t, locale } = useI18n()
const router = useRouter()
const userStore = useUserStore()
const thStore = themeStore()
 
const status = ref(null)
const kycHighStatus = ref(null)
const unreadMsg = ref('')
const showAccountPopup = ref(false)
 
const REAL_ACCOUNT_BACKUP_KEY = 'REAL_ACCOUNT_BACKUP'
 
// 当前语言展示文案(与语言设置页一致:简体中文、繁体中文、English 等)
const languageLabel = computed(() => {
  const map = {
    'zh-CN': '简体中文',
    'CN': '繁体中文',
    'en': 'English',
    'de': 'Deutsch',
    'es': 'Español',
    'fr': 'Français',
    'Italy': 'Italiano',
    'Japanese': '日本語',
    'Korean': '한국어',
    'pt': 'Português',
    'vi': 'Tiếng Việt',
    'gr': 'Ελληνικά',
    'th': 'ไทย',
  }
  return map[locale.value] || map['zh-CN'] || '简体中文'
})
const themeLabel = computed(() => {
  const theme = thStore.theme || 'white'
  return theme === 'white' ? t('浅色模式') || '浅色模式' : t('深色模式') || '深色模式'
})
 
// accountType:1 为模拟账户
const isSimulation = computed(() => userStore.userInfo?.accountType === 1)
 
// 掩码账号:前几位 + ****
const maskedAccount = computed(() => {
  const account = userStore.userInfo?.username || userStore.userInfo?.email || ''
  if (!account) return '--'
  if (account.includes('@')) {
    const [name, domain] = account.split('@')
    if (name.length <= 3) return name + '****@' + (domain || '')
    return name.slice(0, 3) + '****@' + (domain || '')
  }
  if (account.length <= 4) return account + '****'
  return account.slice(0, 3) + '****'
})
 
// 图标:静态导入以便打包后正确解析(动态 new URL 在生产构建中会失效)
const userIconUrls = [userIcon1, userIcon2, userIcon3, userIcon4, userIcon5, userIcon6, userIcon7, userIcon8]
const userIcon = (n) => userIconUrls[n - 1] || userIconUrls[7]
 
// 完整菜单;模拟账户(accountType===1)只保留语言切换
const mergedMenuList = computed(() => {
  const list = [
    { title: t('authVerify'), path: '/certificationCenter', icon: userIcon(1), rightText: status.value != null ? statusText(status.value) : undefined },
    { title: t('账变记录'), path: '/cryptos/accountChange', icon: userIcon(2) },
    { title: t('信用分'), path: '/my/creditScore', icon: userIcon(4) },
    { title: t('邀请推广'), path: '/promote', icon: userIcon(5) },
    { title: t('安全'), path: '/safety', icon: userIcon(6) },
    { title: t('language'), path: '/language', icon: userIcon(7), rightText: languageLabel.value },
  ]
  if (isSimulation.value) {
    return list.filter((item) => item.path === '/language')
  }
  return list
})
 
function statusText(s) {
  if (s === 0 || s === 3) return t('notCertified')
  if (s === 1) return t('reviewing')
  if (s === 2) return t('verified')
  if (s === 3) return t('noPassView')
  return ''
}
 
function onRoute(path) {
  router.push(path)
}
 
function onMenuItemClick(item) {
  if (item.path === '/theme') {
    // 主题切换:无独立页则跳转语言页或弹窗,这里简单跳语言页或保持当前
    router.push('/language')
    return
  }
  router.push(item.path)
}
 
function loginOut() {
  _logOut({ token: userStore.userInfo?.token }).then(() => {
    userStore.userInfo = {}
    store.state.user.userInfo = {}
    router.push('/login')
  })
}
 
// 切换为模拟账户:先保存真实账户信息与 token,再请求并替换
function onSwitchToSimulation() {
  const current = userStore.userInfo
  if (current && current.token && current.accountType !== 1) {
    try {
      localStorage.setItem(REAL_ACCOUNT_BACKUP_KEY, JSON.stringify({ ...current }))
    } catch (e) {}
  }
  _switchAccount().then((data) => {
    const info = data && typeof data === 'object' ? data : {}
    const token = info.token != null ? info.token : (userStore.userInfo?.token || '')
    const next = { ...userStore.userInfo, ...info, token }
    userStore.userInfo = next
    store.state.user.userInfo = next
    showAccountPopup.value = false
  })
}
 
// 当前为模拟账户时,点击「真实账户」:用本地保存的真实账户与 token 替换
function onSwitchToReal() {
  try {
    const raw = localStorage.getItem(REAL_ACCOUNT_BACKUP_KEY)
    if (!raw) return
    const backup = JSON.parse(raw)
    if (backup && backup.token) {
      userStore.userInfo = { ...backup }
      store.state.user.userInfo = { ...backup }
      showAccountPopup.value = false
    }
  } catch (e) {}
}
 
onMounted(() => {
  if (userStore.userInfo?.token) {
    getIdentify()
    getKycHighLevel()
    fetchUnread()
  }
})
 
function getIdentify() {
  _getIdentify().then((data) => { status.value = data?.status })
}
function getKycHighLevel() {
  _getKycHighLevel().then((data) => { kycHighStatus.value = data?.status })
}
function fetchUnread() {
  _getUnreadMsg().then((res) => { unreadMsg.value = (res * 1 > 0) ? res * 1 : '' })
}
</script>
 
<style lang="scss" scoped>
@import '@/assets/css/variable.scss';
 
.my-center-page {
  min-height: 100vh;
  background: $main_background;
  padding-bottom: calc(80px + constant(safe-area-inset-bottom));
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
 
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 5.5rem;
  padding: 0 2rem;
  background: #fff;
  box-sizing: border-box;
 
  .header-left {
    width: 4rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
 
  .back-icon {
    font-size: 2.2rem;
    color: $text_color;
  }
 
  .header-title {
    font-size: 3.2rem;
    font-weight: 700;
    color: $text_color;
    margin: 0;
  }
 
  .header-right {
    cursor: pointer;
    color: $text_color;
  }
}
 
.guest-wrap {
  .guest-title {
    font-size: 2.4rem;
    font-weight: 700;
    color: $text_color;
    margin: 0 0 0.8rem;
  }
 
  .guest-desc {
    color: $text_color1;
    font-size: 2.6rem;
    margin: 0 0 2rem;
  }
 
  .guest-btns {
    display: flex;
    gap: 1.2rem;
  }
}
 
/* 用户信息卡(深色) */
.user-card {
  margin: 2rem 2.4rem;
  border-radius: 2rem;
  overflow: visible;
  background: linear-gradient(-89deg, #5f5f5f 0%, #000000 100%), linear-gradient(#000000, #000000);
  box-shadow: 0 0.2rem 0.8rem rgba(0, 0, 0, 0.15);
  position: relative;
}
 
.user-card-inner {
  padding: 2.4rem 2rem;
  display: flex;
  align-items: center;
  position: relative;
  border-radius: inherit;
  // overflow: hidden;
}
 
.user-avatar {
  width: 7rem;
  height: 7rem;
  border-radius: 50%;
  overflow: hidden;
  background: $main_background;
  flex-shrink: 0;
 
  img {
    width: 70%;
    height: 70%;
    object-fit: cover;
  }
}
 
.user-info {
  flex: 1;
  margin-left: 2rem;
  min-width: 0;
}
 
.user-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  position: relative;
 
  .user-account {
    font-size: 3.2rem;
    font-weight: 600;
    color: #fff;
  }
 
  .user-arrow {
    font-size: 2.4rem;
    color: rgba(255, 255, 255, 0.7);
  }
}
 
.user-uid {
  font-size: 2.6rem;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 0.6rem;
}
 
.user-vip {
  position: absolute;
  top: 2rem;
  right: 2rem;
  font-size: 2.4rem;
  font-weight: 600;
  color: #f5c421;
}
 
/* 合并菜单列表(白卡片) */
.menu-list {
  margin: 0 2.4rem;
}
 
.menu-item {
  display: flex;
  align-items: center;
  padding: 2.2rem 2rem;
  background: #fff;
  border-radius: 2.2rem;
  margin-bottom: 1.8rem;
  box-shadow: 0rem 1.2rem 4rem 0rem rgba(0, 0, 0, 0.18);
  cursor: pointer;
  box-sizing: border-box;
 
  &:last-of-type {
    margin-bottom: 0;
  }
}
 
.menu-icon {
  width: 3rem;
  height: 3rem;
  margin-right: 1.6rem;
  flex-shrink: 0;
  object-fit: contain;
}
 
.menu-title {
  flex: 1;
  font-size: 2.2rem;
  color: $text_color;
  text-align: left;
}
 
.menu-right-text {
  font-size: 2.2rem;
  color: $text_color;
  margin-right: 0.6rem;
}
 
.menu-arrow {
  font-size: 2.8rem;
  color: $text_color1;
}
 
/* user-row 下方弹出框(不用 van-popup) */
 
.account-option-pill {
  position: absolute;
  left: 0;
  top: 4rem;
  border: 1px solid $text_color;
  border-radius: 1.5rem;
  font-size: 2.8rem;
  color: $text_color;
  text-align: center;
  background: $main_background;
  padding: 1.5rem 2rem;
  display: inline;
  z-index: 10;
  // width: 20rem;
  // height:7rem;
}
 
.logout-wrap {
  text-align: center;
  padding: 3rem 2rem 2rem;
}
 
.logout-btn {
  font-size: 3rem;
  color: #f2495e;
  cursor: pointer;
}
</style>