AccountCard.vue 13 KB

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