AccountCardMobile.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  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({
  200. data: text,
  201. success: function () {
  202. uni.showToast({
  203. title: t('Btn.item8'),
  204. icon: 'none',
  205. duration: 2000
  206. });
  207. }
  208. });
  209. };
  210. // 按钮对应的操作方法
  211. const toHistory = () => {
  212. router.push(`/pages/customer/trade-history?login=${accountInfo.value.login}`)
  213. }
  214. // 按钮对应的操作方法
  215. const toPosition = () => {
  216. router.push(`/pages/customer/trade-position?login=${accountInfo.value.login}`)
  217. }
  218. // 按钮对应的操作方法
  219. const toPaymentHistory = () => {
  220. router.push(`/pages/customer/payment-history?login=${accountInfo.value.login}`)
  221. }
  222. // 按钮对应的操作方法
  223. const toDeposit = () => {
  224. router.push(`/pages/customer/deposit-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  225. }
  226. const toWithdraw = () => {
  227. router.push(`/pages/customer/withdrawal-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  228. }
  229. const toTransfer = () => {
  230. router.push(`/pages/customer/transfer?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  231. }
  232. // 格式化余额,拆分为整数和小数部分
  233. const balanceInteger = computed(() => {
  234. return Math.floor(accountInfo.value.balance).toString();
  235. });
  236. const balanceDecimal = computed(() => {
  237. const parts = accountInfo.value.balance.toFixed(2).split('.');
  238. return parts[1] ? '.' + parts[1] : '.00';
  239. });
  240. // 在组件挂载后初始化
  241. onMounted(() => {
  242. });
  243. onBeforeUnmount(() => {
  244. });
  245. </script>
  246. <style scoped lang="scss">
  247. @import '@/uni.scss';
  248. .account-card {
  249. border-radius: px2rpx(16);
  250. padding: px2rpx(16);
  251. margin-bottom: px2rpx(16);
  252. position: relative;
  253. border: 1px solid rgba(108, 133, 149, 0.12);
  254. color: #2e3a47;
  255. .labels-container {
  256. display: flex;
  257. align-items: center;
  258. flex-wrap: wrap;
  259. gap: px2rpx(12);
  260. margin-bottom: px2rpx(16);
  261. .labels {
  262. display: flex;
  263. gap: px2rpx(8);
  264. }
  265. .label-badge {
  266. background-color: rgba(108, 133, 149, 0.08);
  267. border-radius: px2rpx(4);
  268. padding: px2rpx(4) px2rpx(8);
  269. font-size: px2rpx(12);
  270. color: #6c8595;
  271. font-weight: 500;
  272. }
  273. .active {
  274. background-color: rgba(70, 205, 124, 0.08);
  275. color: rgb(14, 115, 55);
  276. font-weight: 500;
  277. }
  278. .account-number {
  279. font-size: px2rpx(18);
  280. font-weight: 600;
  281. line-height: 1.3;
  282. cursor: pointer;
  283. color: #2e3a47;
  284. &:hover {
  285. color: #1e2a3a;
  286. }
  287. }
  288. .account-nickname {
  289. font-size: px2rpx(14);
  290. color: #6c8595;
  291. }
  292. }
  293. .main-content {
  294. .balance {
  295. margin-bottom: px2rpx(16);
  296. .balance-number {
  297. font-size: px2rpx(32);
  298. font-weight: 700;
  299. }
  300. .balance-decimal {
  301. font-size: px2rpx(16);
  302. color: #6c8595;
  303. margin-left: px2rpx(4);
  304. }
  305. }
  306. }
  307. .info-section {
  308. display: flex;
  309. flex-direction: column;
  310. gap: px2rpx(12);
  311. padding: px2rpx(16) 0;
  312. margin: px2rpx(16) 0;
  313. .info-column {
  314. flex: 1;
  315. display: flex;
  316. flex-direction: column;
  317. gap: px2rpx(12);
  318. }
  319. .info-item {
  320. display: flex;
  321. justify-content: space-between;
  322. align-items: flex-end;
  323. font-size: px2rpx(14);
  324. .label {
  325. color: #6c8595;
  326. }
  327. .line {
  328. flex: 1;
  329. height: 1px;
  330. border-top: 1px dashed rgba(108, 133, 149, 0.5);
  331. margin-bottom: px2rpx(1);
  332. }
  333. .value {
  334. font-weight: 500;
  335. color: #2e3a47;
  336. }
  337. }
  338. }
  339. @media screen and (max-width: 768px) {
  340. .info-section {
  341. flex-direction: column;
  342. gap: px2rpx(12);
  343. }
  344. }
  345. .extra-actions {
  346. display: flex;
  347. align-items: center;
  348. gap: px2rpx(8);
  349. margin-bottom: px2rpx(12);
  350. .copy-row {
  351. display: flex;
  352. align-items: center;
  353. gap: px2rpx(4);
  354. font-size: px2rpx(14);
  355. .label {
  356. color: #6c8595;
  357. min-width: px2rpx(30);
  358. }
  359. .value {
  360. flex: 1;
  361. color: #2e3a47;
  362. font-family: monospace;
  363. }
  364. .copy-btn {
  365. background: transparent;
  366. border: 1px solid rgba(108, 133, 149, 0);
  367. padding: 0;
  368. cursor: pointer;
  369. color: #6c8595;
  370. width: px2rpx(24);
  371. height: px2rpx(24);
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. box-sizing: border-box;
  376. svg {
  377. width: px2rpx(20);
  378. height: px2rpx(20);
  379. }
  380. &:hover {
  381. background-color: rgba(108, 133, 149, 0.05);
  382. border: 1px solid rgba(108, 133, 149, 0.2);
  383. }
  384. }
  385. }
  386. .divider {
  387. width: 1px;
  388. height: px2rpx(20);
  389. border-left: 1px solid rgba(108, 133, 149, 0.5);
  390. }
  391. .change-password-btn {
  392. background: transparent;
  393. box-sizing: border-box;
  394. border: 1px solid rgba(108, 133, 149, 0);
  395. border-radius: px2rpx(8);
  396. padding: px2rpx(8) px2rpx(16);
  397. font-size: px2rpx(14);
  398. color: #2e3a47;
  399. display: inline-flex;
  400. gap: px2rpx(8);
  401. cursor: pointer;
  402. margin: 0;
  403. .btn-icon svg {
  404. width: px2rpx(16);
  405. height: px2rpx(16);
  406. }
  407. &:hover {
  408. background-color: rgba(108, 133, 149, 0.05);
  409. border: 1px solid rgba(108, 133, 149, 0.2);
  410. }
  411. }
  412. }
  413. .notificators {
  414. // 预留通知区域
  415. }
  416. }
  417. .card-top {
  418. display: flex;
  419. justify-content: space-between;
  420. align-items: flex-start;
  421. :deep(.cwg-dropdown-menu-container) {
  422. left: px2rpx(-190) !important;
  423. @media screen and (max-width: 768px) {
  424. left: px2rpx(-200) !important;
  425. width: px2rpx(240);
  426. }
  427. }
  428. .more-btn {
  429. flex-shrink: 0;
  430. width: px2rpx(40);
  431. height: px2rpx(40);
  432. display: flex;
  433. align-items: center;
  434. justify-content: center;
  435. gap: px2rpx(4);
  436. background-color: rgba(108, 133, 149, 0.08);
  437. border-radius: px2rpx(4);
  438. cursor: pointer;
  439. &:hover {
  440. background-color: rgba(108, 133, 149, 0.1);
  441. }
  442. }
  443. // 移动端按钮组
  444. .mobile-buttons {
  445. display: flex;
  446. justify-content: center;
  447. gap: px2rpx(12);
  448. padding-bottom: px2rpx(16);
  449. padding: px2rpx(20);
  450. border-bottom: 1px solid #f0f0f0;
  451. .circle-btn {
  452. display: flex;
  453. flex-direction: column;
  454. align-items: center;
  455. cursor: pointer;
  456. width: px2rpx(40);
  457. .circle-icon {
  458. width: px2rpx(40);
  459. height: px2rpx(40);
  460. border-radius: 50%;
  461. background-color: #f5f7f9;
  462. display: flex;
  463. align-items: center;
  464. justify-content: center;
  465. color: #2e3a47;
  466. transition: background-color 0.2s;
  467. &.primary {
  468. background-color: #cf1322;
  469. ;
  470. color: #fff;
  471. }
  472. &:hover {
  473. background-color: #e9ecef;
  474. }
  475. &.primary:hover {
  476. background-color: #cf1322;
  477. ;
  478. color: #fff;
  479. }
  480. svg {
  481. width: px2rpx(24);
  482. height: px2rpx(24);
  483. }
  484. }
  485. .circle-label {
  486. font-size: px2rpx(12);
  487. margin-top: px2rpx(4);
  488. color: #6c8595;
  489. }
  490. }
  491. }
  492. .is-disabled {
  493. cursor: not-allowed;
  494. opacity: 0.5;
  495. }
  496. }
  497. </style>