AccountCard.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. <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">已删除</text>
  20. </template>
  21. <view class="clearfix">
  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. <view class="d-flex flex-wrap gap-2" v-if="isReal">
  84. <button v-for="btn in actionButtons" :key="btn.key" type="submit" value="Submit"
  85. class="btn btn-dark btn-sm waves-effect waves-light"
  86. :class="{ 'disabled': btn.disabled, 'btn-outline-dark1': btn.key !== 'deposit' }"
  87. @click="handleAction(btn.action)">
  88. <view class="d-flex align-items-center justify-content-center gap-1">
  89. <cwg-icon :name="btn.icon" :size="14"
  90. :color="btn.key === 'deposit' ? '#fff' : ''" />
  91. {{ t(btn.label) }}
  92. </view>
  93. </button>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <TerminalDialog v-model:visible="terminalDialogVisible" />
  101. <TerminalChangePasswordDialog v-model:visible="terminalChangePasswordDialogVisible" :pwdType="pwdType"
  102. :account="account" :accountLabel="t('Documentary.tradingCenter.item29') + ' # '" />
  103. <TerminalInfoDialog v-model:visible="terminalInfoDialogVisible" :accountNumber="accountInfo.login"
  104. :form="accountInfo" :fieldList="fieldList" :title="t('Documentary.TundManagement.item29')"
  105. :accountLabel="t('Documentary.tradingCenter.item29') + ' # '" />
  106. </template>
  107. <script setup lang="ts">
  108. import { ref, computed, onMounted, nextTick, onBeforeUnmount } from 'vue';
  109. import useRouter from "@/hooks/useRouter";
  110. const router = useRouter();
  111. import { useI18n } from 'vue-i18n';
  112. const { t } = useI18n();
  113. import TerminalDialog from './TerminalDialog.vue'
  114. import TerminalChangePasswordDialog from './TerminalChangePasswordDialog.vue'
  115. import TerminalInfoDialog from './TerminalInfoDialog.vue'
  116. import useGlobalStore from '@/stores/use-global-store'
  117. const globalStore = useGlobalStore()
  118. const isDark = computed(() => globalStore.theme === 'dark')
  119. const props = defineProps<{
  120. account: Account;
  121. }>();
  122. const accountInfo = ref(props.account)
  123. export interface Account {
  124. labels: string[]; // 标签数组,如 ['真实', 'MT4', 'Standard']
  125. accountNumber: string; // 账号,如 '85319215'
  126. nickName: string; // 昵称,如 '标准账户'
  127. balance: number; // 余额数字
  128. currency: string; // 货币,如 'USD'
  129. actualLeverage: string; // 实际杠杆,如 '1:2000'
  130. maxLeverage: string; // 调整杠杆,如 '1:2000'
  131. floatingPL: string; // 浮动盈亏,如 '0.00 USD'
  132. creditWithSymbol: string; // 可用保证金,如 '0.00 USD'
  133. equityWithSymbol: string; // 净值,如 '0.00 USD'
  134. platform: string; // 平台,如 'MT4'
  135. server: string; // 服务器,如 'Exness-Real28'
  136. login: string; // 登录名,如 '85319215'
  137. balanceWithSymbol: string; // 余额,如 '85319215'
  138. fwq: string; // 服务器名称
  139. listType: string; // 账户类型,如 'real' 或 'demo'
  140. closeFunctions?: string; // 关闭的功能
  141. }
  142. const isDemo = computed(() => accountInfo.value.listType == 'demo')
  143. const isDel = computed(() => accountInfo.value.listType == 'del')
  144. const isReal = computed(() => accountInfo.value.listType == 'real')
  145. const closeFunctionOpen = (code) => {
  146. const closeFunctions = accountInfo.value.closeFunctions || ""
  147. if (closeFunctions == null || closeFunctions === "") {
  148. return true;
  149. }
  150. return String(closeFunctions).indexOf(String(code)) === -1;
  151. }
  152. const circleButtons = ref([
  153. { key: 'deposit', label: 'Home.page_customer.item2', icon: 'crm-deposit', action: 'deposit', needDemo: isDemo.value, disabled: !closeFunctionOpen('1'), color: '#6c8595' },
  154. { key: 'withdraw', label: 'Home.page_customer.item3', icon: 'crm-withdraw', action: 'withdraw', needDemo: isDemo.value, disabled: !closeFunctionOpen('2'), color: '#6c8595' },
  155. { key: 'transfer', label: 'Custom.Index.Transfer', icon: 'crm-transfer', action: 'transfer', needDemo: isDemo.value, disabled: !(closeFunctionOpen('5') && closeFunctionOpen('6') && closeFunctionOpen('3')), color: '#6c8595' }
  156. ])
  157. const fieldList = ref([
  158. { label: t('Custom.PaymentHistory.AccountType'), key: 'nickname', copyable: false },
  159. { label: t('Label.Leverage'), key: 'actualLeverage', copyable: false },
  160. { label: t('Label.FloatingPL'), key: 'floatingPL', copyable: false },
  161. { label: t('Label.Balance'), key: 'balanceWithSymbol', copyable: false },
  162. { label: t('Label.Equity'), key: 'equityWithSymbol', copyable: false },
  163. { label: t('Label.Credit'), key: 'creditWithSymbol', copyable: false },
  164. { label: t('Documentary.console.item3'), key: 'platform', copyable: false },
  165. { label: t('Documentary.console.item4'), key: 'login', copyable: true }
  166. ])
  167. const nickName = ref(accountInfo.value.nickName);
  168. const actionButtons = ref([
  169. { key: 'deposit', label: 'Home.page_customer.item2', icon: 'crm-deposit', action: 'deposit', disabled: computed(() => !closeFunctionOpen('1')) },
  170. { key: 'withdraw', label: 'Home.page_customer.item3', icon: 'crm-withdraw', action: 'withdraw', disabled: computed(() => !closeFunctionOpen('2')) },
  171. { key: 'transfer', label: 'Custom.Index.Transfer', icon: 'crm-transfer', action: 'transfer', disabled: computed(() => !(closeFunctionOpen('5') && closeFunctionOpen('6') && closeFunctionOpen('3'))) }
  172. ])
  173. const terminalDialogVisible = ref(false)
  174. const terminalChangePasswordDialogVisible = ref(false)
  175. const terminalInfoDialogVisible = ref(false)
  176. const pwdType = ref(1)
  177. const dropdownRef = ref(null)
  178. const handleAction = (type: string) => {
  179. if (dropdownRef.value) {
  180. dropdownRef.value.close()
  181. }
  182. switch (type) {
  183. case 'trade':
  184. terminalDialogVisible.value = true
  185. break;
  186. case 'changePassword1':
  187. pwdType.value = 1
  188. terminalChangePasswordDialogVisible.value = true
  189. break;
  190. case 'changePassword2':
  191. pwdType.value = 2
  192. terminalChangePasswordDialogVisible.value = true
  193. break;
  194. case 'changePassword3':
  195. pwdType.value = 3
  196. terminalChangePasswordDialogVisible.value = true
  197. break;
  198. case 'info':
  199. terminalInfoDialogVisible.value = true
  200. break;
  201. case 'deposit':
  202. toDeposit()
  203. break;
  204. case 'withdraw':
  205. toWithdraw()
  206. break;
  207. case 'transfer':
  208. toTransfer()
  209. break;
  210. case 'position':
  211. toPosition()
  212. break;
  213. case 'history':
  214. toHistory()
  215. break;
  216. case 'payment-history':
  217. toPaymentHistory()
  218. break;
  219. default:
  220. break;
  221. }
  222. };
  223. const customMenuList = computed(() => {
  224. switch (accountInfo.value.listType) {
  225. case 'real':
  226. return [
  227. { label: '开始交易', type: 'trade' },
  228. { label: t('Ib.Report.Tit1'), type: 'history' },
  229. { label: t('Ib.Report.Tit4'), type: 'position' },
  230. { label: t('Home.page_customer.item4'), type: 'payment-history' },
  231. { label: t('Documentary.TundManagement.item29'), type: 'info' },
  232. { label: t('vu.item3'), type: 'changePassword1' },
  233. { label: t('vu.item4'), type: 'changePassword2' },
  234. { label: t('Btn.ResetPassword'), type: 'changePassword3' }
  235. ]
  236. case 'demo':
  237. return [
  238. { label: '开始交易', type: 'trade' },
  239. { label: t('Documentary.TundManagement.item29'), type: 'info' }
  240. ]
  241. case 'del':
  242. return [
  243. { label: t('Documentary.TundManagement.item29'), type: 'info' }
  244. ]
  245. }
  246. })
  247. const handleCustomClick = (item, index) => {
  248. handleAction(item.value.type)
  249. }
  250. const copy = (text: string) => {
  251. uni.setClipboardData({
  252. data: text,
  253. success: function () {
  254. uni.showToast({
  255. title: t('Btn.item8'),
  256. icon: 'none',
  257. duration: 2000
  258. });
  259. }
  260. });
  261. };
  262. const toHistory = () => {
  263. router.push(`/pages/customer/trade-history?login=${accountInfo.value.login}`)
  264. }
  265. const toPosition = () => {
  266. router.push(`/pages/customer/trade-position?login=${accountInfo.value.login}`)
  267. }
  268. const toPaymentHistory = () => {
  269. router.push(`/pages/customer/payment-history?login=${accountInfo.value.login}`)
  270. }
  271. const toDeposit = () => {
  272. router.push(`/pages/customer/deposit-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  273. }
  274. const toWithdraw = () => {
  275. router.push(`/pages/customer/withdrawal-select?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  276. }
  277. const toTransfer = () => {
  278. router.push(`/pages/customer/transfer?login=${accountInfo.value.login}&type=${accountInfo.value.type}&balance=${accountInfo.value.balance}&currency=${accountInfo.value.currency}`)
  279. }
  280. const balanceInteger = computed(() => {
  281. return accountInfo.value.balance ? Math.floor(accountInfo.value.balance).toString() : '0';
  282. });
  283. const balanceDecimal = computed(() => {
  284. const parts = accountInfo.value?.balance?.toFixed(2)?.split || [];
  285. console.log(accountInfo.value?.balance, 1212);
  286. if (!accountInfo.value?.balance) return '.00'
  287. return parts[1] ? '.' + parts[1] : '.00';
  288. });
  289. onMounted(() => {
  290. });
  291. onBeforeUnmount(() => {
  292. });
  293. </script>
  294. <style scoped lang="scss">
  295. @import '@/uni.scss';
  296. .cwg-close{
  297. width: px2rpx(20);
  298. height: px2rpx(20);
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. border-radius: 50%;
  303. background-color: #F56C6C;
  304. }
  305. .btn.disabled {
  306. opacity: 0.5;
  307. cursor: not-allowed;
  308. }
  309. .btn {
  310. margin-left: 0;
  311. margin-right: 0;
  312. }
  313. .text-danger1 {
  314. color: var(--bs-emphasis-color) !important;
  315. }
  316. .btn-outline-dark1 {
  317. background-color: var(--btn-color) !important;
  318. color: var(--bs-emphasis-color) !important;
  319. border-color: var(--btn-color) !important;
  320. }
  321. </style>