AccountCardMobile.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <template>
  2. <view class="account-card">
  3. <!-- 标签区域 -->
  4. <view class="card-top">
  5. <view class="labels-container">
  6. <view class="account-number" @click="copy(account.accountNumber)"># {{ account.accountNumber }}</view>
  7. <view class="account-number" @click="copy(account.fwq)">{{ account.fwq }}</view>
  8. <view class="labels">
  9. <template v-for="(label, index) in account.labels" :key="index">
  10. <view v-if="label" class="label-badge" :class="{ 'active': index === 0 && isDemo }">
  11. {{ label }}
  12. </view>
  13. </template>
  14. </view>
  15. </view>
  16. <cwg-dropdown ref="dropdownRef" @open="onOpen" @close="onClose" :menu-list="customMenuList"
  17. @menuClick="handleCustomClick">
  18. <view class="more-icon more-btn">
  19. <cwg-icon name="crm-ellipsis-vertical" :size="20" :color="!isDark ? '#6c8595' : '#fff'" />
  20. </view>
  21. <template #btn>
  22. <view class="mobile-buttons">
  23. <!-- 交易 -->
  24. <template v-for="(item, index) in circleButtons" :key="index">
  25. <view class="circle-btn" :class="{ 'is-disabled': item.disabled }"
  26. @click="handleAction1(item)" v-if="!item.needDemo">
  27. <view class="circle-icon" :class="{ 'primary': item.primary }">
  28. <cwg-icon :name="item.icon" :size="16" :color="!isDark ? item.color : '#fff'" />
  29. </view>
  30. <text class="circle-label" v-t="item.label" />
  31. </view>
  32. </template>
  33. </view>
  34. </template>
  35. </cwg-dropdown>
  36. </view>
  37. <!-- 主要内容区域(余额和操作按钮) -->
  38. <view class="main-content">
  39. <!-- 余额 -->
  40. <view class="balance">
  41. <text class="balance-number">{{ balanceInteger }}</text>
  42. <text class="balance-decimal">{{ balanceDecimal }} {{ account.currency }}</text>
  43. </view>
  44. </view>
  45. <view class="info-bottom">
  46. <!-- 底部信息区域(折叠时隐藏) -->
  47. <view class="info-section">
  48. <view class="info-column">
  49. <cwg-label-line-value :label="t('Label.Leverage')" :value="account.actualLeverage" />
  50. <cwg-label-line-value :label="t('Label.FloatingPL')" :value="account.floatingPL" />
  51. <cwg-label-line-value :label="t('Label.Balance')" :value="account.balanceWithSymbol" />
  52. </view>
  53. <view class="info-column">
  54. <cwg-label-line-value :label="t('Label.Equity')" :value="account.equityWithSymbol" />
  55. <cwg-label-line-value :label="t('Label.Credit')" :value="account.creditWithSymbol" />
  56. <cwg-label-line-value :label="t('Documentary.console.item3')" :value="account.platform" />
  57. </view>
  58. </view>
  59. </view>
  60. <TerminalDialog v-model:visible="terminalDialogVisible" />
  61. <TerminalChangePasswordDialog v-model:visible="terminalChangePasswordDialogVisible" :pwdType="pwdType"
  62. :account="account" :accountLabel="t('Documentary.tradingCenter.item29') + ' # '" />
  63. <TerminalInfoDialog v-model:visible="terminalInfoDialogVisible" :accountNumber="accountInfo.login"
  64. :form="accountInfo" :fieldList="fieldList" :title="t('Documentary.TundManagement.item29')"
  65. :accountLabel="t('Documentary.tradingCenter.item29') + ' # '" />
  66. </view>
  67. </template>
  68. <script setup lang="ts">
  69. import { ref, computed, onMounted, nextTick, onBeforeUnmount } from 'vue';
  70. import useRouter from "@/hooks/useRouter";
  71. const router = useRouter();
  72. import { useI18n } from 'vue-i18n';
  73. const { t } = useI18n();
  74. import TerminalDialog from './TerminalDialog.vue'
  75. import TerminalChangePasswordDialog from './TerminalChangePasswordDialog.vue'
  76. import TerminalInfoDialog from './TerminalInfoDialog.vue'
  77. import useGlobalStore from '@/stores/use-global-store'
  78. const globalStore = useGlobalStore()
  79. const isDark = computed(() => globalStore.theme === 'dark')
  80. const props = defineProps<{
  81. account: Account;
  82. }>();
  83. const accountInfo = ref(props.account)
  84. // 定义账户数据类型
  85. export interface Account {
  86. labels: string[]; // 标签数组,如 ['真实', 'MT4', 'Standard']
  87. accountNumber: string; // 账号,如 '85319215'
  88. nickName: string; // 昵称,如 '标准账户'
  89. balance: number; // 余额数字
  90. currency: string; // 货币,如 'USD'
  91. actualLeverage: string; // 实际杠杆,如 '1:2000'
  92. maxLeverage: string; // 调整杠杆,如 '1:2000'
  93. floatingPL: string; // 浮动盈亏,如 '0.00 USD'
  94. creditWithSymbol: string; // 可用保证金,如 '0.00 USD'
  95. equityWithSymbol: string; // 净值,如 '0.00 USD'
  96. platform: string; // 平台,如 'MT4'
  97. server: string; // 服务器,如 'Exness-Real28'
  98. login: string; // 登录名,如 '85319215'
  99. balanceWithSymbol: string; // 余额,如 '85319215'
  100. fwq: string; // 服务器名称
  101. listType: string; // 账户类型,如 'real' 或 'demo'
  102. closeFunctions?: string; // 关闭的功能
  103. }
  104. const isDemo = computed(() => accountInfo.value.listType == 'demo')
  105. const closeFunctionOpen = (code) => {
  106. const closeFunctions = accountInfo.value.closeFunctions || ""
  107. if (closeFunctions == null || closeFunctions === "") {
  108. return true;
  109. }
  110. return String(closeFunctions).indexOf(String(code)) === -1;
  111. }
  112. // 圆形按钮数据
  113. const circleButtons = ref([
  114. { key: 'trade', label: 'Shop.Index.Transaction', icon: 'crm-trade', action: 'trade', needDemo: false, primary: true, disabled: false, color: '#fff' },
  115. { key: 'deposit', label: 'Home.page_customer.item2', icon: 'crm-deposit', action: 'deposit', needDemo: isDemo.value, disabled: !closeFunctionOpen('1'), color: '#6c8595' },
  116. { key: 'withdraw', label: 'Home.page_customer.item3', icon: 'crm-withdraw', action: 'withdraw', needDemo: isDemo.value, disabled: !closeFunctionOpen('2'), color: '#6c8595' },
  117. { key: 'transfer', label: 'Custom.Index.Transfer', icon: 'crm-transfer', action: 'transfer', needDemo: isDemo.value, disabled: !(closeFunctionOpen('5') && closeFunctionOpen('6') && closeFunctionOpen('3')), color: '#6c8595' }
  118. ])
  119. const fieldList = ref([
  120. { label: t('Custom.PaymentHistory.AccountType'), key: 'nickname', copyable: false },
  121. { label: t('Label.Leverage'), key: 'actualLeverage', copyable: false },
  122. { label: t('Label.FloatingPL'), key: 'floatingPL', copyable: false },
  123. { label: t('Label.Balance'), key: 'balanceWithSymbol', copyable: false },
  124. { label: t('Label.Equity'), key: 'equityWithSymbol', copyable: false },
  125. { label: t('Label.Credit'), key: 'creditWithSymbol', copyable: false },
  126. { label: t('Documentary.console.item3'), key: 'platform', copyable: false },
  127. { label: t('Documentary.console.item4'), key: 'login', copyable: true }
  128. ])
  129. const nickName = ref(accountInfo.value.nickName);
  130. const terminalDialogVisible = ref(false)
  131. const terminalChangePasswordDialogVisible = ref(false)
  132. const terminalInfoDialogVisible = ref(false)
  133. const pwdType = ref(1)
  134. const handleAction1 = (item) => {
  135. if (item.disabled) {
  136. uni.showToast({
  137. title: t('news_add_field.Des.item1'),
  138. icon: 'none'
  139. })
  140. return
  141. }
  142. handleAction(item.action, item)
  143. }
  144. const dropdownRef = ref(null)
  145. // 处理按钮操作
  146. const handleAction = (type: string) => {
  147. dropdownRef.value.close()
  148. switch (type) {
  149. case 'trade':
  150. terminalDialogVisible.value = true
  151. break;
  152. case 'changePassword1':
  153. pwdType.value = 1
  154. terminalChangePasswordDialogVisible.value = true
  155. break;
  156. case 'changePassword2':
  157. pwdType.value = 2
  158. terminalChangePasswordDialogVisible.value = true
  159. break;
  160. case 'info':
  161. terminalInfoDialogVisible.value = true
  162. break;
  163. case 'deposit':
  164. toDeposit()
  165. break;
  166. case 'withdraw':
  167. toWithdraw()
  168. break;
  169. case 'transfer':
  170. toTransfer()
  171. break;
  172. case 'position':
  173. toPosition()
  174. break;
  175. case 'history':
  176. toHistory()
  177. break;
  178. case 'payment-history':
  179. toPaymentHistory()
  180. break;
  181. default:
  182. break;
  183. }
  184. };
  185. const customMenuList = computed(() => !isDemo.value ? [
  186. { label: t('Ib.Report.Tit1'), type: 'history' },
  187. { label: t('Ib.Report.Tit4'), type: 'position' },
  188. { label: t('Home.page_customer.item4'), type: 'payment-history' },
  189. { label: t('Documentary.TundManagement.item29'), type: 'info' },
  190. { label: t('vu.item3'), type: 'changePassword1' },
  191. { label: t('vu.item4'), type: 'changePassword2' }
  192. ] : [
  193. // { label: t('Ib.Report.Tit1'), type: 'history' },
  194. // { label: t('Ib.Report.Tit4'), type: 'position' },
  195. { label: t('Documentary.TundManagement.item29'), type: 'info' }
  196. ])
  197. const handleCustomClick = (item, index) => {
  198. handleAction(item.value.type)
  199. }
  200. // 复制文本
  201. const copy = (text: string) => {
  202. uni.setClipboardData({
  203. data: text,
  204. success: function () {
  205. uni.showToast({
  206. title: t('Btn.item8'),
  207. icon: 'none',
  208. duration: 2000
  209. });
  210. }
  211. });
  212. };
  213. // 按钮对应的操作方法
  214. const toHistory = () => {
  215. router.push(`/pages/customer/trade-history?login=${accountInfo.value.login}`)
  216. }
  217. // 按钮对应的操作方法
  218. const toPosition = () => {
  219. router.push(`/pages/customer/trade-position?login=${accountInfo.value.login}`)
  220. }
  221. // 按钮对应的操作方法
  222. const toPaymentHistory = () => {
  223. router.push(`/pages/customer/payment-history?login=${accountInfo.value.login}`)
  224. }
  225. // 按钮对应的操作方法
  226. const toDeposit = () => {
  227. router.push(`/pages/customer/deposit-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  228. }
  229. const toWithdraw = () => {
  230. router.push(`/pages/customer/withdrawal-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  231. }
  232. const toTransfer = () => {
  233. router.push(`/pages/customer/transfer?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  234. }
  235. // 格式化余额,拆分为整数和小数部分
  236. const balanceInteger = computed(() => {
  237. return Math.floor(accountInfo.value.balance).toString();
  238. });
  239. const balanceDecimal = computed(() => {
  240. const parts = accountInfo.value.balance.toFixed(2).split('.');
  241. return parts[1] ? '.' + parts[1] : '.00';
  242. });
  243. // 在组件挂载后初始化
  244. onMounted(() => {
  245. });
  246. onBeforeUnmount(() => {
  247. });
  248. </script>
  249. <style scoped lang="scss">
  250. @import '@/uni.scss';
  251. .account-card {
  252. border-radius: px2rpx(16);
  253. padding: px2rpx(16);
  254. margin-bottom: px2rpx(16);
  255. position: relative;
  256. border: 1px solid rgba(108, 133, 149, 0.12);
  257. color: var(--bs-emphasis-color);
  258. .labels-container {
  259. display: flex;
  260. align-items: center;
  261. flex-wrap: wrap;
  262. gap: px2rpx(12);
  263. margin-bottom: px2rpx(16);
  264. .labels {
  265. display: flex;
  266. gap: px2rpx(8);
  267. }
  268. .label-badge {
  269. background-color: rgba(108, 133, 149, 0.08);
  270. border-radius: px2rpx(4);
  271. padding: px2rpx(4) px2rpx(8);
  272. font-size: px2rpx(12);
  273. color: var(--bs-emphasis-color);
  274. font-weight: 500;
  275. }
  276. .active {
  277. background-color: rgba(70, 205, 124, 0.08);
  278. color: rgb(14, 115, 55);
  279. font-weight: 500;
  280. }
  281. .account-number {
  282. font-size: px2rpx(18);
  283. font-weight: 600;
  284. line-height: 1.3;
  285. cursor: pointer;
  286. color: var(--bs-emphasis-color);
  287. &:hover {
  288. color: var(--bs-emphasis-color);
  289. }
  290. }
  291. .account-nickname {
  292. font-size: px2rpx(14);
  293. color: var(--bs-emphasis-color);
  294. }
  295. }
  296. .main-content {
  297. .balance {
  298. margin-bottom: px2rpx(16);
  299. .balance-number {
  300. font-size: px2rpx(32);
  301. font-weight: 700;
  302. }
  303. .balance-decimal {
  304. font-size: px2rpx(16);
  305. color: var(--bs-emphasis-color);
  306. margin-left: px2rpx(4);
  307. }
  308. }
  309. }
  310. .info-section {
  311. display: flex;
  312. flex-direction: column;
  313. gap: px2rpx(12);
  314. padding: px2rpx(16) 0;
  315. margin: px2rpx(16) 0;
  316. .info-column {
  317. flex: 1;
  318. display: flex;
  319. flex-direction: column;
  320. gap: px2rpx(12);
  321. }
  322. .info-item {
  323. display: flex;
  324. justify-content: space-between;
  325. align-items: flex-end;
  326. font-size: px2rpx(14);
  327. .label {
  328. color: var(--bs-emphasis-color);
  329. }
  330. .line {
  331. flex: 1;
  332. height: 1px;
  333. border-top: 1px dashed rgba(108, 133, 149, 0.5);
  334. margin-bottom: px2rpx(1);
  335. }
  336. .value {
  337. font-weight: 500;
  338. color: var(--bs-emphasis-color);
  339. }
  340. }
  341. }
  342. @media screen and (max-width: 768px) {
  343. .info-section {
  344. flex-direction: column;
  345. gap: px2rpx(12);
  346. }
  347. }
  348. .extra-actions {
  349. display: flex;
  350. align-items: center;
  351. gap: px2rpx(8);
  352. margin-bottom: px2rpx(12);
  353. .copy-row {
  354. display: flex;
  355. align-items: center;
  356. gap: px2rpx(4);
  357. font-size: px2rpx(14);
  358. .label {
  359. color: var(--bs-emphasis-color);
  360. min-width: px2rpx(30);
  361. }
  362. .value {
  363. flex: 1;
  364. color: var(--bs-emphasis-color);
  365. font-family: monospace;
  366. }
  367. .copy-btn {
  368. background: transparent;
  369. border: 1px solid rgba(108, 133, 149, 0);
  370. padding: 0;
  371. cursor: pointer;
  372. color: var(--bs-emphasis-color);
  373. width: px2rpx(24);
  374. height: px2rpx(24);
  375. display: flex;
  376. align-items: center;
  377. justify-content: center;
  378. box-sizing: border-box;
  379. svg {
  380. width: px2rpx(20);
  381. height: px2rpx(20);
  382. }
  383. &:hover {
  384. background-color: rgba(108, 133, 149, 0.05);
  385. border: 1px solid rgba(108, 133, 149, 0.2);
  386. }
  387. }
  388. }
  389. .divider {
  390. width: 1px;
  391. height: px2rpx(20);
  392. border-left: 1px solid rgba(108, 133, 149, 0.5);
  393. }
  394. .change-password-btn {
  395. background: transparent;
  396. box-sizing: border-box;
  397. border: 1px solid rgba(108, 133, 149, 0);
  398. border-radius: px2rpx(8);
  399. padding: px2rpx(8) px2rpx(16);
  400. font-size: px2rpx(14);
  401. color: var(--bs-emphasis-color);
  402. display: inline-flex;
  403. gap: px2rpx(8);
  404. cursor: pointer;
  405. margin: 0;
  406. .btn-icon svg {
  407. width: px2rpx(16);
  408. height: px2rpx(16);
  409. }
  410. &:hover {
  411. background-color: rgba(108, 133, 149, 0.05);
  412. border: 1px solid rgba(108, 133, 149, 0.2);
  413. }
  414. }
  415. }
  416. .notificators {
  417. // 预留通知区域
  418. }
  419. }
  420. .card-top {
  421. display: flex;
  422. justify-content: space-between;
  423. align-items: flex-start;
  424. :deep(.cwg-dropdown-menu-container) {
  425. left: px2rpx(-190) !important;
  426. @media screen and (max-width: 768px) {
  427. left: px2rpx(-200) !important;
  428. width: px2rpx(240);
  429. }
  430. }
  431. .more-btn {
  432. flex-shrink: 0;
  433. width: px2rpx(40);
  434. height: px2rpx(40);
  435. display: flex;
  436. align-items: center;
  437. justify-content: center;
  438. gap: px2rpx(4);
  439. background-color: rgba(108, 133, 149, 0.08);
  440. border-radius: px2rpx(4);
  441. cursor: pointer;
  442. &:hover {
  443. background-color: rgba(108, 133, 149, 0.1);
  444. }
  445. }
  446. // 移动端按钮组
  447. .mobile-buttons {
  448. display: flex;
  449. justify-content: center;
  450. gap: px2rpx(12);
  451. padding-bottom: px2rpx(16);
  452. padding: px2rpx(20);
  453. border-bottom: 1px solid var(--bs-border-color);
  454. .circle-btn {
  455. display: flex;
  456. flex-direction: column;
  457. align-items: center;
  458. cursor: pointer;
  459. width: px2rpx(40);
  460. .circle-icon {
  461. width: px2rpx(40);
  462. height: px2rpx(40);
  463. border-radius: 50%;
  464. background-color: #f5f7f9;
  465. display: flex;
  466. align-items: center;
  467. justify-content: center;
  468. color: var(--bs-emphasis-color);
  469. transition: background-color 0.2s;
  470. &.primary {
  471. background-color: #cf1322;
  472. ;
  473. color: var(--bs-emphasis-color);
  474. }
  475. &:hover {
  476. background-color: #e9ecef;
  477. }
  478. &.primary:hover {
  479. background-color: #cf1322;
  480. ;
  481. color: var(--bs-emphasis-color);
  482. }
  483. svg {
  484. width: px2rpx(24);
  485. height: px2rpx(24);
  486. }
  487. }
  488. .circle-label {
  489. font-size: px2rpx(12);
  490. margin-top: px2rpx(4);
  491. color: var(--bs-emphasis-color);
  492. }
  493. }
  494. }
  495. .is-disabled {
  496. cursor: not-allowed;
  497. opacity: 0.5;
  498. }
  499. }
  500. </style>