AccountCardMobile.vue 18 KB

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