AccountCard.vue 16 KB

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