AccountCard.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <view class="col-lg-4 col-md-6" :class="noCtrl ? 'w100' : ''">
  3. <view class="card">
  4. <view class="card-header d-flex align-items-center justify-content-between border-0 pb-2 p-3">
  5. <uni-tooltip v-if="account.del == 1" placement="right">
  6. <view class="cwg-close d-flex align-items-center">
  7. <cwg-icon name="cwg-close" :size="14" :color="'#fff'" />
  8. </view>
  9. <template #content>
  10. <text>{{ t("Tips.item1")
  11. }}<text style="color: red">{{ account.markDelTime }}</text>{{ t("Tips.item2") }}</text>
  12. </template>
  13. </uni-tooltip>
  14. <template v-if="account.del != 1">
  15. <view v-if="!isDel" class="badge bg-success-subtle text-success d-flex align-items-center">
  16. <!-- <cwg-icon name="crm-check" :size="13" :color="'#22B07E'" /> -->
  17. <text v-t="'Blockchain.enabled'" />
  18. </view>
  19. <text v-if="isDel" class="badge bg-danger-subtle text-danger" v-t="'vu.item18'"></text>
  20. </template>
  21. <view class="clearfix" v-if="!noCtrl">
  22. <view class="btn-group">
  23. <cwg-dropdown ref="dropdownRef" @open="onOpen" @close="onClose" :menu-list="customMenuList"
  24. @menuClick="handleCustomClick">
  25. <button
  26. class="btn btn-white btn-sm btn-shadow btn-icon waves-effect dropdown-toggle cursor-pointer"
  27. :data-tooltip="t('Btn.More')" type="button">
  28. <cwg-icon name="crm-ellipsis-vertical" :size="18"
  29. :color="!isDark ? '#6c8595' : '#fff'" />
  30. </button>
  31. </cwg-dropdown>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="card-body p-3 pt-0">
  36. <view class="text-left mb-3">
  37. <h5 class="fw-bold mb-3 cursor-pointer"
  38. :data-tooltip="`${t('vu.tooltip.t2')}-${account.accountNumber}`" data-placement="top"
  39. @click="copy(account.accountNumber)"># {{
  40. account.accountNumber }}</h5>
  41. <h4 class="mb-2 cursor-pointer" :data-tooltip="`${t('vu.tooltip.t2')}-${account.fwq}`"
  42. :data-placement="top" @click="copy(account.fwq)">{{ account.fwq }}</h4>
  43. <template v-for="(label, index) in account.labels" :key="index">
  44. <text v-if="label" class="badge text-danger1 bg-danger-subtle mx-1 mb-1">{{ label }}</text>
  45. </template>
  46. <h1 class="mt-2">{{ account.balanceWithSymbol || '0.00' }}</h1>
  47. <!-- <button hover-class="" type="submit" value="Submit" class="btn btn-secondary btn-sm w-75 waves-effect waves-light"
  48. @click="handleAction('trade')">
  49. <view class="d-flex align-items-center justify-content-center gap-1"><cwg-icon name="crm-trade"
  50. :size="16" color="#fff" />
  51. 开始交易</view>
  52. </button> -->
  53. <hr>
  54. </view>
  55. <view class="text-left">
  56. <view class="border-0 card-header p-2">
  57. <view class="row">
  58. <view class="col-6">
  59. <view class="mb-3">
  60. <view class="mb-1">{{ t('Label.Leverage') }}</view>
  61. <view class="d-flex fw-semibold mb-0 text-dark">{{ account.actualLeverage }}</view>
  62. </view>
  63. <view class="mb-3">
  64. <view class="mb-1">{{ t('Label.FloatingPL') }}</view>
  65. <view class="d-flex fw-semibold mb-0 text-dark">{{ account.floatingPL }}</view>
  66. </view>
  67. <view class="mb-3">
  68. <view class="mb-1">{{ t('Label.Balance') }}</view>
  69. <view class="text-dark fw-semibold mb-0">{{ account.balanceWithSymbol }}</view>
  70. </view>
  71. </view>
  72. <view class="col-6">
  73. <view class="mb-3">
  74. <view class="mb-1">{{ t('Label.Equity') }}</view>
  75. <view class="text-dark fw-semibold mb-0">{{ account.equityWithSymbol }}</view>
  76. </view>
  77. <view class="mb-3">
  78. <view class="mb-1">{{ t('Label.Credit') }}</view>
  79. <view class="text-dark fw-semibold mb-0">{{ account.creditWithSymbol }}</view>
  80. </view>
  81. <view class="mb-3">
  82. <view class="mb-1">{{ t('Documentary.console.item3') }}</view>
  83. <view class="text-dark fw-semibold mb-0">{{ account.platform }}</view>
  84. </view>
  85. </view>
  86. </view>
  87. <template v-if="!noCtrl">
  88. <view class="d-flex flex-wrap gap-2" v-if="isReal">
  89. <button hover-class="" v-for="btn in actionButtons" :key="btn.key" type="submit"
  90. value="Submit" class="btn btn-dark btn-sm waves-effect waves-light"
  91. :class="{ 'disabled': btn.disabled, 'btn-outline-dark1': btn.key !== 'deposit' }"
  92. @click="handleAction(btn.action)">
  93. <view class="d-flex align-items-center justify-content-center gap-1">
  94. <cwg-icon :name="btn.icon" :size="14"
  95. :color="btn.key === 'deposit' ? '#fff' : ''" />
  96. {{ t(btn.label) }}
  97. </view>
  98. </button>
  99. </view>
  100. </template>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. <TerminalDialog v-model:visible="terminalDialogVisible" />
  107. <TerminalChangePasswordDialog v-model:visible="terminalChangePasswordDialogVisible" :pwdType="pwdType"
  108. :account="account" :accountLabel="t('Documentary.tradingCenter.item29') + ' # '" />
  109. <TerminalInfoDialog v-model:visible="terminalInfoDialogVisible" :accountNumber="accountInfo.login"
  110. :form="accountInfo" :fieldList="fieldList" :title="t('Documentary.TundManagement.item29')"
  111. :accountLabel="t('Documentary.tradingCenter.item29') + ' # '" />
  112. </template>
  113. <script setup lang="ts">
  114. import { ref, computed, onMounted, nextTick, onBeforeUnmount } from 'vue';
  115. import useRouter from "@/hooks/useRouter";
  116. const router = useRouter();
  117. import { useI18n } from 'vue-i18n';
  118. const { t } = useI18n();
  119. import TerminalDialog from './TerminalDialog.vue'
  120. import TerminalChangePasswordDialog from './TerminalChangePasswordDialog.vue'
  121. import TerminalInfoDialog from './TerminalInfoDialog.vue'
  122. import useGlobalStore from '@/stores/use-global-store'
  123. const globalStore = useGlobalStore()
  124. const isDark = computed(() => globalStore.theme === 'dark')
  125. const props = defineProps({
  126. account: {
  127. type: Object,
  128. },
  129. noCtrl: {
  130. type: Boolean,
  131. default: false,
  132. }
  133. });
  134. // console.log(props.account, 12121);
  135. const accountInfo = ref(props.account)
  136. export interface Account {
  137. labels: string[]; // 标签数组,如 ['真实', 'MT4', 'Standard']
  138. accountNumber: string; // 账号,如 '85319215'
  139. nickName: string; // 昵称,如 '标准账户'
  140. balance: number; // 余额数字
  141. currency: string; // 货币,如 'USD'
  142. actualLeverage: string; // 实际杠杆,如 '1:2000'
  143. maxLeverage: string; // 调整杠杆,如 '1:2000'
  144. floatingPL: string; // 浮动盈亏,如 '0.00 USD'
  145. creditWithSymbol: string; // 可用保证金,如 '0.00 USD'
  146. equityWithSymbol: string; // 净值,如 '0.00 USD'
  147. platform: string; // 平台,如 'MT4'
  148. server: string; // 服务器,如 'Exness-Real28'
  149. login: string; // 登录名,如 '85319215'
  150. balanceWithSymbol: string; // 余额,如 '85319215'
  151. fwq: string; // 服务器名称
  152. listType: string; // 账户类型,如 'real' 或 'demo'
  153. closeFunctions?: string; // 关闭的功能
  154. }
  155. const isDemo = computed(() => accountInfo.value.listType == 'demo')
  156. const isDel = computed(() => accountInfo.value.listType == 'del')
  157. const isReal = computed(() => accountInfo.value.listType == 'real')
  158. const closeFunctionOpen = (code) => {
  159. const closeFunctions = accountInfo.value.closeFunctions || ""
  160. if (closeFunctions == null || closeFunctions === "") {
  161. return true;
  162. }
  163. console.log(closeFunctions, 12121, String(closeFunctions).indexOf(String(code)) === -1);
  164. return String(closeFunctions).indexOf(String(code)) === -1;
  165. }
  166. const circleButtons = ref([
  167. { key: 'deposit', label: 'Home.page_customer.item2', icon: 'crm-deposit', action: 'deposit', needDemo: isDemo.value, disabled: !closeFunctionOpen('1'), color: '#6c8595' },
  168. { key: 'withdraw', label: 'Home.page_customer.item3', icon: 'crm-withdraw', action: 'withdraw', needDemo: isDemo.value, disabled: !closeFunctionOpen('2'), color: '#6c8595' },
  169. { key: 'transfer', label: 'Custom.Index.Transfer', icon: 'crm-transfer', action: 'transfer', needDemo: isDemo.value, disabled: !(closeFunctionOpen('5') && closeFunctionOpen('6') && closeFunctionOpen('3')), color: '#6c8595' }
  170. ])
  171. const isAfterJuly28 = () => {
  172. const now = new Date();
  173. const july28 = new Date(2025, 6, 28, 0, 0, 0); // 月份从0开始,所以7月是6
  174. return now >= july28;
  175. }
  176. const typeMap = computed(() => ({
  177. 1: t('AccountType.ClassicAccount'),
  178. 2: t('AccountType.SeniorAccount'),
  179. 3: !isAfterJuly28() ? t('AccountType.AgencyAccount') : '',
  180. 5: t('AccountType.SpeedAccount'),
  181. 6: t('AccountType.SpeedAccount'),
  182. 7: t('AccountType.StandardAccount'),
  183. 8: t('AccountType.CentAccount')
  184. }));
  185. const fieldList = computed(() => ([
  186. { label: t('Custom.PaymentHistory.AccountType'), key: 'type', copyable: false, isEnum: true, enums: typeMap.value },
  187. { label: t('Label.Leverage'), key: 'actualLeverage', copyable: false },
  188. { label: t('Label.FloatingPL'), key: 'floatingPL', copyable: false },
  189. { label: t('Label.Balance'), key: 'balanceWithSymbol', copyable: false },
  190. { label: t('Label.Equity'), key: 'equityWithSymbol', copyable: false },
  191. { label: t('Label.Credit'), key: 'creditWithSymbol', copyable: false },
  192. { label: t('Documentary.console.item3'), key: 'platform', copyable: false },
  193. { label: t('Documentary.console.item4'), key: 'login', copyable: true }
  194. ]))
  195. const nickName = ref(accountInfo.value.nickName);
  196. const actionButtons = computed(() => ([
  197. { key: 'deposit', label: 'Home.page_customer.item2', icon: 'crm-deposit', action: 'deposit', disabled: !closeFunctionOpen('1') },
  198. { key: 'withdraw', label: 'Home.page_customer.item3', icon: 'crm-withdraw', action: 'withdraw', disabled: !closeFunctionOpen('2') },
  199. { key: 'transfer', label: 'Custom.Index.Transfer', icon: 'crm-transfer', action: 'transfer', disabled: !(closeFunctionOpen('5') && closeFunctionOpen('6') && closeFunctionOpen('3')) }
  200. ]))
  201. const terminalDialogVisible = ref(false)
  202. const terminalChangePasswordDialogVisible = ref(false)
  203. const terminalInfoDialogVisible = ref(false)
  204. const pwdType = ref(1)
  205. const dropdownRef = ref(null)
  206. const handleAction = (type: string) => {
  207. if (dropdownRef.value) {
  208. dropdownRef.value.close()
  209. }
  210. switch (type) {
  211. case 'trade':
  212. terminalDialogVisible.value = true
  213. break;
  214. case 'changePassword1':
  215. pwdType.value = 1
  216. terminalChangePasswordDialogVisible.value = true
  217. break;
  218. case 'changePassword2':
  219. pwdType.value = 2
  220. terminalChangePasswordDialogVisible.value = true
  221. break;
  222. case 'changePassword3':
  223. pwdType.value = 3
  224. terminalChangePasswordDialogVisible.value = true
  225. break;
  226. case 'info':
  227. terminalInfoDialogVisible.value = true
  228. break;
  229. case 'deposit':
  230. toDeposit()
  231. break;
  232. case 'withdraw':
  233. toWithdraw()
  234. break;
  235. case 'transfer':
  236. toTransfer()
  237. break;
  238. case 'position':
  239. toPosition()
  240. break;
  241. case 'history':
  242. toHistory()
  243. break;
  244. case 'payment-history':
  245. toPaymentHistory()
  246. break;
  247. default:
  248. break;
  249. }
  250. };
  251. const customMenuList = computed(() => {
  252. switch (accountInfo.value.listType) {
  253. case 'real':
  254. return [
  255. { label: t('vu.item17'), type: 'trade' },
  256. { label: t('Ib.Report.Tit1'), type: 'history' },
  257. { label: t('Ib.Report.Tit4'), type: 'position' },
  258. { label: t('Home.page_customer.item4'), type: 'payment-history' },
  259. { label: t('Documentary.TundManagement.item29'), type: 'info' },
  260. { label: t('vu.item3'), type: 'changePassword1', disabled: !closeFunctionOpen('4') },
  261. { label: t('vu.item4'), type: 'changePassword2', disabled: !closeFunctionOpen('4') },
  262. { label: t('Btn.ResetPassword'), type: 'changePassword3', disabled: !closeFunctionOpen('4') }
  263. ]
  264. case 'demo':
  265. return [
  266. { label: t('vu.item17'), type: 'trade' },
  267. { label: t('Documentary.TundManagement.item29'), type: 'info' }
  268. ]
  269. case 'del':
  270. return [
  271. { label: t('Documentary.TundManagement.item29'), type: 'info' }
  272. ]
  273. }
  274. })
  275. const handleCustomClick = (item, index) => {
  276. handleAction(item.value.type)
  277. }
  278. const copy = (text: string) => {
  279. uni.setClipboardData({
  280. data: text,
  281. success: function () {
  282. uni.showToast({
  283. title: t('Btn.item8'),
  284. icon: 'none',
  285. duration: 2000
  286. });
  287. }
  288. });
  289. };
  290. const toHistory = () => {
  291. router.push(`/pages/customer/trade-history?login=${accountInfo.value.login}`)
  292. }
  293. const toPosition = () => {
  294. router.push(`/pages/customer/trade-position?login=${accountInfo.value.login}`)
  295. }
  296. const toPaymentHistory = () => {
  297. router.push(`/pages/customer/payment-history?login=${accountInfo.value.login}`)
  298. }
  299. const toDeposit = () => {
  300. router.push(`/pages/customer/deposit-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  301. }
  302. const toWithdraw = () => {
  303. router.push(`/pages/customer/withdrawal-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  304. }
  305. const toTransfer = () => {
  306. router.push(`/pages/customer/transfer?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  307. }
  308. const balanceInteger = computed(() => {
  309. return accountInfo.value.balance ? Math.floor(accountInfo.value.balance).toString() : '0';
  310. });
  311. const balanceDecimal = computed(() => {
  312. const parts = accountInfo.value?.balance?.toFixed(2)?.split || [];
  313. console.log(accountInfo.value?.balance, 1212);
  314. if (!accountInfo.value?.balance) return '.00'
  315. return parts[1] ? '.' + parts[1] : '.00';
  316. });
  317. onMounted(() => {
  318. });
  319. onBeforeUnmount(() => {
  320. });
  321. </script>
  322. <style scoped lang="scss">
  323. @import '@/uni.scss';
  324. .btn-group {
  325. @media screen and (max-width: 991px) {
  326. :deep(.cwg-dropdown-menu-container) {
  327. right: px2rpx(0) !important;
  328. }
  329. }
  330. }
  331. .cwg-close {
  332. width: px2rpx(20);
  333. height: px2rpx(20);
  334. display: flex;
  335. align-items: center;
  336. justify-content: center;
  337. border-radius: 50%;
  338. background-color: #F56C6C;
  339. }
  340. .btn.disabled {
  341. opacity: 0.5;
  342. cursor: not-allowed;
  343. }
  344. .btn {
  345. margin-left: 0;
  346. margin-right: 0;
  347. }
  348. .text-danger1 {
  349. color: var(--bs-emphasis-color) !important;
  350. }
  351. .btn-outline-dark1 {
  352. background-color: var(--btn-color) !important;
  353. color: var(--bs-emphasis-color) !important;
  354. border-color: var(--btn-color) !important;
  355. }
  356. .w100 {
  357. width: 100% !important;
  358. }
  359. </style>