AccountCard.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="col-lg-4 col-md-6">
  3. <view class="card">
  4. <view class="card-header d-flex align-items-center justify-content-between border-0 pb-0 p-3">
  5. <text class="badge bg-success-subtle text-success">Active</text>
  6. <view class="clearfix">
  7. <view class="btn-group">
  8. <cwg-dropdown ref="dropdownRef" @open="onOpen" @close="onClose" :menu-list="customMenuList"
  9. @menuClick="handleCustomClick">
  10. <button class="btn btn-white btn-sm btn-shadow btn-icon waves-effect dropdown-toggle"
  11. type="button">
  12. <cwg-icon name="crm-ellipsis-vertical" :size="18"
  13. :color="!isDark ? '#6c8595' : '#fff'" />
  14. </button>
  15. </cwg-dropdown>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="card-body p-2 pt-0">
  20. <view class="text-center mb-3">
  21. <h5 class="fw-bold mb-0 text-secondary cursor-pointer" @click="copy(account.accountNumber)"># {{
  22. account.accountNumber }}</h5>
  23. <h4 class="mb-2 cursor-pointer" @click="copy(account.fwq)">{{ account.fwq }}</h4>
  24. <template v-for="(label, index) in account.labels" :key="index">
  25. <text v-if="label" class="badge bg-danger-subtle text-danger mx-1">{{ label }}</text>
  26. </template>
  27. <h1 class="mt-2">${{ balanceInteger }}{{ balanceDecimal }}</h1>
  28. <button type="submit" value="Submit" class="btn btn-secondary btn-sm w-75 waves-effect waves-light"
  29. @click="handleAction('trade')">
  30. <cwg-icon name="crm-trade" :size="16" color="#fff" />
  31. 开始交易
  32. </button>
  33. <hr>
  34. </view>
  35. <view class="text-left">
  36. <view class="border-0 card-header p-2">
  37. <view class="row">
  38. <view class="col-6">
  39. <view class="mb-3">
  40. <text class="mb-1">{{ t('Label.Leverage') }}</text>
  41. <view class="d-flex fw-semibold mb-0 text-dark">{{ account.actualLeverage }}</view>
  42. </view>
  43. <view class="mb-3">
  44. <text class="mb-1">{{ t('Label.FloatingPL') }}</text>
  45. <view class="d-flex fw-semibold mb-0 text-dark">{{ account.floatingPL }}</view>
  46. </view>
  47. <view class="mb-3">
  48. <text class="mb-1">{{ t('Label.Balance') }}</text>
  49. <view class="text-dark fw-semibold mb-0">{{ account.balanceWithSymbol }}</view>
  50. </view>
  51. </view>
  52. <view class="col-6">
  53. <view class="mb-3">
  54. <text class="mb-1">{{ t('Label.Equity') }}</text>
  55. <view class="text-dark fw-semibold mb-0">{{ account.equityWithSymbol }}</view>
  56. </view>
  57. <view class="mb-3">
  58. <text class="mb-1">{{ t('Label.Credit') }}</text>
  59. <view class="text-dark fw-semibold mb-0">{{ account.creditWithSymbol }}</view>
  60. </view>
  61. <view class="mb-3">
  62. <text class="mb-1">{{ t('Documentary.console.item3') }}</text>
  63. <view class="text-dark fw-semibold mb-0">{{ account.platform }}</view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="d-flex flex-wrap gap-2" v-if="!isDemo">
  68. <button v-for="btn in actionButtons" :key="btn.key" type="submit" value="Submit"
  69. class="btn btn-dark btn-sm waves-effect waves-light"
  70. :class="{ 'disabled': btn.disabled.value }" @click="handleAction(btn.action)">
  71. <cwg-icon :name="btn.icon" :size="14" color="#fff" />
  72. {{ t(btn.label) }}
  73. </button>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <TerminalDialog v-model:visible="terminalDialogVisible" />
  81. <TerminalChangePasswordDialog v-model:visible="terminalChangePasswordDialogVisible" :pwdType="pwdType"
  82. :account="account" :accountLabel="t('Documentary.tradingCenter.item29') + ' # '" />
  83. <TerminalInfoDialog v-model:visible="terminalInfoDialogVisible" :accountNumber="accountInfo.login"
  84. :form="accountInfo" :fieldList="fieldList" :title="t('Documentary.TundManagement.item29')"
  85. :accountLabel="t('Documentary.tradingCenter.item29') + ' # '" />
  86. </template>
  87. <script setup lang="ts">
  88. import { ref, computed, onMounted, nextTick, onBeforeUnmount } from 'vue';
  89. import useRouter from "@/hooks/useRouter";
  90. const router = useRouter();
  91. import { useI18n } from 'vue-i18n';
  92. const { t } = useI18n();
  93. import TerminalDialog from './TerminalDialog.vue'
  94. import TerminalChangePasswordDialog from './TerminalChangePasswordDialog.vue'
  95. import TerminalInfoDialog from './TerminalInfoDialog.vue'
  96. import useGlobalStore from '@/stores/use-global-store'
  97. const globalStore = useGlobalStore()
  98. const isDark = computed(() => globalStore.theme === 'dark')
  99. const props = defineProps<{
  100. account: Account;
  101. }>();
  102. const accountInfo = ref(props.account)
  103. export interface Account {
  104. labels: string[]; // 标签数组,如 ['真实', 'MT4', 'Standard']
  105. accountNumber: string; // 账号,如 '85319215'
  106. nickName: string; // 昵称,如 '标准账户'
  107. balance: number; // 余额数字
  108. currency: string; // 货币,如 'USD'
  109. actualLeverage: string; // 实际杠杆,如 '1:2000'
  110. maxLeverage: string; // 调整杠杆,如 '1:2000'
  111. floatingPL: string; // 浮动盈亏,如 '0.00 USD'
  112. creditWithSymbol: string; // 可用保证金,如 '0.00 USD'
  113. equityWithSymbol: string; // 净值,如 '0.00 USD'
  114. platform: string; // 平台,如 'MT4'
  115. server: string; // 服务器,如 'Exness-Real28'
  116. login: string; // 登录名,如 '85319215'
  117. balanceWithSymbol: string; // 余额,如 '85319215'
  118. fwq: string; // 服务器名称
  119. listType: string; // 账户类型,如 'real' 或 'demo'
  120. closeFunctions?: string; // 关闭的功能
  121. }
  122. const isDemo = computed(() => accountInfo.value.listType == 'demo')
  123. const closeFunctionOpen = (code) => {
  124. const closeFunctions = accountInfo.value.closeFunctions || ""
  125. if (closeFunctions == null || closeFunctions === "") {
  126. return true;
  127. }
  128. return String(closeFunctions).indexOf(String(code)) === -1;
  129. }
  130. const circleButtons = ref([
  131. { key: 'deposit', label: 'Home.page_customer.item2', icon: 'crm-deposit', action: 'deposit', needDemo: isDemo.value, disabled: !closeFunctionOpen('1'), color: '#6c8595' },
  132. { key: 'withdraw', label: 'Home.page_customer.item3', icon: 'crm-withdraw', action: 'withdraw', needDemo: isDemo.value, disabled: !closeFunctionOpen('2'), color: '#6c8595' },
  133. { key: 'transfer', label: 'Custom.Index.Transfer', icon: 'crm-transfer', action: 'transfer', needDemo: isDemo.value, disabled: !(closeFunctionOpen('5') && closeFunctionOpen('6') && closeFunctionOpen('3')), color: '#6c8595' }
  134. ])
  135. const fieldList = ref([
  136. { label: t('Custom.PaymentHistory.AccountType'), key: 'nickname', copyable: false },
  137. { label: t('Label.Leverage'), key: 'actualLeverage', copyable: false },
  138. { label: t('Label.FloatingPL'), key: 'floatingPL', copyable: false },
  139. { label: t('Label.Balance'), key: 'balanceWithSymbol', copyable: false },
  140. { label: t('Label.Equity'), key: 'equityWithSymbol', copyable: false },
  141. { label: t('Label.Credit'), key: 'creditWithSymbol', copyable: false },
  142. { label: t('Documentary.console.item3'), key: 'platform', copyable: false },
  143. { label: t('Documentary.console.item4'), key: 'login', copyable: true }
  144. ])
  145. const nickName = ref(accountInfo.value.nickName);
  146. const actionButtons = ref([
  147. { key: 'deposit', label: 'Home.page_customer.item2', icon: 'crm-upload', action: 'deposit', disabled: computed(() => !closeFunctionOpen('1')) },
  148. { key: 'withdraw', label: 'Home.page_customer.item3', icon: 'crm-download', action: 'withdraw', disabled: computed(() => !closeFunctionOpen('2')) },
  149. { key: 'transfer', label: 'Custom.Index.Transfer', icon: 'crm-exchange', action: 'transfer', disabled: computed(() => !(closeFunctionOpen('5') && closeFunctionOpen('6') && closeFunctionOpen('3'))) }
  150. ])
  151. const terminalDialogVisible = ref(false)
  152. const terminalChangePasswordDialogVisible = ref(false)
  153. const terminalInfoDialogVisible = ref(false)
  154. const pwdType = ref(1)
  155. const dropdownRef = ref(null)
  156. const handleAction = (type: string) => {
  157. if (dropdownRef.value) {
  158. dropdownRef.value.close()
  159. }
  160. switch (type) {
  161. case 'trade':
  162. terminalDialogVisible.value = true
  163. break;
  164. case 'changePassword1':
  165. pwdType.value = 1
  166. terminalChangePasswordDialogVisible.value = true
  167. break;
  168. case 'changePassword2':
  169. pwdType.value = 2
  170. terminalChangePasswordDialogVisible.value = true
  171. break;
  172. case 'info':
  173. terminalInfoDialogVisible.value = true
  174. break;
  175. case 'deposit':
  176. toDeposit()
  177. break;
  178. case 'withdraw':
  179. toWithdraw()
  180. break;
  181. case 'transfer':
  182. toTransfer()
  183. break;
  184. case 'position':
  185. toPosition()
  186. break;
  187. case 'history':
  188. toHistory()
  189. break;
  190. case 'payment-history':
  191. toPaymentHistory()
  192. break;
  193. default:
  194. break;
  195. }
  196. };
  197. const customMenuList = computed(() => !isDemo.value ? [
  198. { label: t('Ib.Report.Tit1'), type: 'history' },
  199. { label: t('Ib.Report.Tit4'), type: 'position' },
  200. { label: t('Home.page_customer.item4'), type: 'payment-history' },
  201. { label: t('Documentary.TundManagement.item29'), type: 'info' },
  202. { label: t('vu.item3'), type: 'changePassword1' },
  203. { label: t('vu.item4'), type: 'changePassword2' }
  204. ] : [
  205. { label: t('Documentary.TundManagement.item29'), type: 'info' }
  206. ])
  207. const handleCustomClick = (item, index) => {
  208. handleAction(item.value.type)
  209. }
  210. const copy = (text: string) => {
  211. uni.setClipboardData({
  212. data: text,
  213. success: function () {
  214. uni.showToast({
  215. title: t('Btn.item8'),
  216. icon: 'none',
  217. duration: 2000
  218. });
  219. }
  220. });
  221. };
  222. const toHistory = () => {
  223. router.push(`/pages/customer/trade-history?login=${accountInfo.value.login}`)
  224. }
  225. const toPosition = () => {
  226. router.push(`/pages/customer/trade-position?login=${accountInfo.value.login}`)
  227. }
  228. const toPaymentHistory = () => {
  229. router.push(`/pages/customer/payment-history?login=${accountInfo.value.login}`)
  230. }
  231. const toDeposit = () => {
  232. router.push(`/pages/customer/deposit-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  233. }
  234. const toWithdraw = () => {
  235. router.push(`/pages/customer/withdrawal-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  236. }
  237. const toTransfer = () => {
  238. router.push(`/pages/customer/transfer?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  239. }
  240. const balanceInteger = computed(() => {
  241. return Math.floor(accountInfo.value.balance).toString();
  242. });
  243. const balanceDecimal = computed(() => {
  244. const parts = accountInfo.value.balance.toFixed(2).split('.');
  245. return parts[1] ? '.' + parts[1] : '.00';
  246. });
  247. onMounted(() => {
  248. });
  249. onBeforeUnmount(() => {
  250. });
  251. </script>
  252. <style scoped lang="scss">
  253. @import '@/uni.scss';
  254. .btn.disabled {
  255. opacity: 0.5;
  256. cursor: not-allowed;
  257. }
  258. .btn{
  259. margin-left: 0;
  260. margin-right: 0;
  261. }
  262. </style>