dashboard.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <view class="header">
  4. <view class="title">
  5. <view class="mb-3 h3">{{ t('Home.msg.Custom') }}</view>
  6. <view class="">{{ dateWeek }}</view>
  7. </view>
  8. <button type="button" class="btn btn-danger btn-shadow waves-effect"
  9. @click="createAccount">
  10. <view class="d-flex align-items-center">
  11. <cwg-icon name="crm-plus" :size="14" color="#fff" />
  12. <text v-t="'Custom.Index.AddAccount'" />
  13. </view>
  14. </button>
  15. </view>
  16. <uni-loading v-if="loading" />
  17. <uni-row v-else class="demo-uni-row uni-row1" :gutter="20">
  18. <uni-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  19. <uni-row :gutter="10">
  20. <uni-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  21. <view class="card position-relative">
  22. <view class="card-body d-flex align-items-center gap-3">
  23. <view class="icon-placeholder">
  24. <cwg-icon name="crm-wallet" :size="28" color="red" />
  25. </view>
  26. <view class="flex-1">
  27. <view class="d-flex justify-between items-start mb-1">
  28. <text class="text-muted text-sm">{{t('vu.custom.t1')}}</text>
  29. <text
  30. :class="['growth-rate', compareData.totalBalanceGrowthRate||0 >= 0 ? 'rate-up' : 'rate-down']">
  31. {{ compareData.totalBalanceGrowthRate || 0 >= 0 ? '+' : ''
  32. }}{{ compareData.totalBalanceGrowthRate || 0 }}%
  33. </text>
  34. </view>
  35. <view class="fw-bold text-lg">${{ numberDecimal(compareData.totalBalance || '0') }}</view>
  36. </view>
  37. </view>
  38. </view>
  39. </uni-col>
  40. <uni-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  41. <view class="card position-relative">
  42. <view class="card-body d-flex align-items-center gap-3">
  43. <view class="icon-placeholder">
  44. <cwg-icon name="crm-money-up" :size="28" color="red" />
  45. </view>
  46. <view class="flex-1">
  47. <view class="d-flex justify-between items-start mb-1">
  48. <text class="text-muted text-sm">{{t('vu.custom.t2')}}</text>
  49. <text :class="['growth-rate', compareData.totalEquityGrowthRate ||0>= 0 ? 'rate-up' : 'rate-down']">
  50. {{ compareData.totalEquityGrowthRate || 0 >= 0 ? '+' : ''
  51. }}{{ compareData.totalEquityGrowthRate || 0 }}%
  52. </text>
  53. </view>
  54. <view class="fw-bold text-lg">${{ numberFormat(compareData.totalEquity || '0') }}</view>
  55. </view>
  56. </view>
  57. </view>
  58. </uni-col>
  59. <uni-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  60. <view class="card position-relative">
  61. <view class="card-body d-flex align-items-center gap-3">
  62. <view class="icon-placeholder">
  63. <cwg-icon name="icon_withdraw" :size="28" color="red" />
  64. </view>
  65. <view class="flex-1">
  66. <view class="d-flex justify-between items-start mb-1">
  67. <text class="text-muted text-sm">{{t('vu.custom.t3')}}</text>
  68. <text
  69. :class="['growth-rate', compareData.totalDepositAmountGrowthRate ||0 >= 0 ? 'rate-up' : 'rate-down']">
  70. {{ compareData.totalDepositAmountGrowthRate || 0 >= 0 ? '+' : ''
  71. }}{{ compareData.totalDepositAmountGrowthRate || 0 }}%
  72. </text>
  73. </view>
  74. <view class="fw-bold text-lg">${{ numberFormat(compareData.totalDepositAmount || '0') }}</view>
  75. </view>
  76. </view>
  77. </view>
  78. </uni-col>
  79. <uni-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  80. <view class="card position-relative">
  81. <view class="card-body d-flex align-items-center gap-3">
  82. <view class="icon-placeholder">
  83. <cwg-icon name="crm-money-bill-transfer" :size="28" color="red" />
  84. </view>
  85. <view class="flex-1">
  86. <view class="d-flex justify-between items-start mb-1">
  87. <text class="text-muted text-sm">{{t('vu.custom.t4')}}</text>
  88. <text
  89. :class="['growth-rate', compareData.totalWithdrawalAmountGrowthRate||0 >= 0 ? 'rate-up' : 'rate-down']">
  90. {{ compareData.totalWithdrawalAmountGrowthRate || 0 >= 0 ? '+' : ''
  91. }}{{ compareData.totalWithdrawalAmountGrowthRate || 0 }}%
  92. </text>
  93. </view>
  94. <view class="fw-bold text-lg">${{ numberFormat(compareData.totalWithdrawalAmount || '0') }}</view>
  95. </view>
  96. </view>
  97. </view>
  98. </uni-col>
  99. </uni-row>
  100. </uni-col>
  101. <uni-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  102. <uni-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mobilH mb-3">
  103. <view class="chart-box crm-border-radius">
  104. <view class="chart-title">
  105. <uni-row>
  106. <uni-row>
  107. <view class="opt-title mb-2">
  108. <view class="bigtitle">
  109. <text v-if="chartForm.chartType == 4">{{ t('Custom.Index.TradingVolumeStatistics') }}</text>
  110. <text v-if="chartForm.chartType == 2">{{ t('Custom.Index.DepositStatistical') }}</text>
  111. <text v-if="chartForm.chartType == 3">{{ t('Custom.Index.WithdrawalsStatistical') }}</text>
  112. <text v-if="chartForm.chartType == 6">{{ t('Custom.Index.ProfitLoss') }}</text>
  113. </view>
  114. <view class="time cursor-pointer" @click="toReload">
  115. <cwg-icon name="crm-refresh" :size="16" color="#666" />
  116. <text class="crm-cursor"> GMT+3 {{ time }}</text>
  117. </view>
  118. </view>
  119. </uni-row>
  120. <uni-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  121. <view class="btn-opt">
  122. <view class="title">
  123. <view class="account" v-if="chartForm.login">
  124. <text>{{ t('Custom.Index.TradingAccount') }}</text>
  125. <text> —</text>
  126. <text>{{ chartForm.login }}</text>
  127. </view>
  128. <view class="date">
  129. <uni-datetime-picker
  130. v-model="isDate"
  131. type="daterange"
  132. :placeholder="t('placeholder.Start') + ' - ' + t('placeholder.End')"
  133. @change="getSearchDate"
  134. />
  135. </view>
  136. </view>
  137. <button class="operation" @click="isChart = true">
  138. <text style="font-size: 14px">{{ t('Custom.Index.Parameter') }}</text>
  139. </button>
  140. </view>
  141. </uni-col>
  142. </uni-row>
  143. </view>
  144. <view class="chart-container">
  145. <cwg-match-media :max-width="991">
  146. <cwg-charts type="line" :chartData="chartData" :opts="chartOpts" tooltipFormat="tooltipCustom" ontouch />
  147. </cwg-match-media>
  148. <cwg-match-media :min-width="991">
  149. <cwg-charts type="line" :chartData="chartData" :opts="chartOpts" tooltipFormat="tooltipCustom" />
  150. </cwg-match-media>
  151. </view>
  152. </view>
  153. </uni-col>
  154. <uni-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mobilH">
  155. <view class="chart-box mh crm-border-radius">
  156. <view class="bigtitle mb-3">
  157. {{t('Custom.Index.MyAccount')}}
  158. </view>
  159. <view class="mb-2">
  160. <cwg-combox :clearable="false" v-model:value="loginValue"
  161. :options="loginComboxOptions" :placeholder="t('placeholder.choose')" @change="setCurData"/>
  162. </view>
  163. <view>
  164. <AccountCard :key="curData?.accountNumber"
  165. :account="curData" noCtrl />
  166. </view>
  167. </view>
  168. </uni-col>
  169. </uni-col>
  170. </uni-row>
  171. <cwg-improve-popup v-model:visible="dialogCheck" @confirm="confirm" />
  172. <cwg-popup v-model:visible="isChart" type="center" :mask-click="false" :show-footers="true"
  173. :title="t('Custom.Index.ChartSet')">
  174. <view class="dia-content">
  175. <uni-forms ref="chartFormRef" labelWidth="160">
  176. <uni-forms-item :label="t('Label.ChartType') + ':'" prop="chartType">
  177. <cwg-combox
  178. v-model:value="chartForm.chartType"
  179. :options="chartTypeOptions"
  180. :placeholder="t('placeholder.choose')"
  181. />
  182. </uni-forms-item>
  183. <uni-forms-item :label="t('Label.PlatformType') + ':'" prop="platform">
  184. <cwg-combox
  185. v-model:value="chartForm.platform"
  186. :options="platformOptions"
  187. :placeholder="t('placeholder.choose')"
  188. @change="onPlatformChange"
  189. />
  190. </uni-forms-item>
  191. <uni-forms-item :label="t('Label.TradingAccount') + ':'" prop="login">
  192. <cwg-combox
  193. v-model:value="chartForm.login"
  194. :options="loginOptions"
  195. :placeholder="t('placeholder.choose')"
  196. />
  197. </uni-forms-item>
  198. </uni-forms>
  199. </view>
  200. <template #footer>
  201. <button @click="isChart = false">{{ t('Btn.Cancel') }}</button>
  202. <button type="primary" @click="handleChartConfirm">{{ t('Btn.Confirm') }}</button>
  203. </template>
  204. </cwg-popup>
  205. </cwg-page-wrapper>
  206. </template>
  207. <script setup>
  208. import { ref, computed, watch, onMounted, nextTick,onUnmounted } from 'vue'
  209. import { useI18n } from 'vue-i18n'
  210. import dayjs from 'dayjs'
  211. import useRouter from '@/hooks/useRouter'
  212. import config from '@/config/index'
  213. import useUserStore from '@/stores/use-user-store'
  214. import { useFilters } from '@/composables/useFilters'
  215. import { documentaryApi } from '@/service/documentary'
  216. import { customApi } from '@/service/custom'
  217. import { userApi } from '@/api/user'
  218. import AccountCard from '@/pages/customer/components/AccountCard.vue'
  219. import { useWindowWidth } from '@/composables/useWindowWidth'
  220. const windowWidth = useWindowWidth(300)
  221. const { t, locale } = useI18n()
  222. const loading = ref(false)
  223. const router = useRouter()
  224. const { Code } = config
  225. const userStore = useUserStore()
  226. const { numberFormat ,numberDecimal} = useFilters()
  227. const loginOptions = ref([])
  228. const ChartSetDate = ref({})
  229. const isDealLogin = ref(false)
  230. const dealDate = ref({})
  231. const SubscribeProfitDate = ref([])
  232. const compareData = ref({})
  233. const loginValue = ref('')
  234. const isChart = ref(false)
  235. const isDate = ref(['', ''])
  236. const time = ref('')
  237. const chartData = ref({ categories: [], series: [] })
  238. const chartOpts = computed(() => ({
  239. color: ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'],
  240. padding: [15, 10, 0, 15],
  241. enableScroll: true,
  242. legend: {
  243. show: false,
  244. },
  245. xAxis: {
  246. // disableGrid: true,
  247. scrollShow: true,
  248. itemCount: isMobile.value?3:4,
  249. },
  250. tooltipFormat: 'tooltipCustom',
  251. extra: {
  252. line: {
  253. type: 'straight',
  254. width: 2,
  255. activeType: 'hollow',
  256. },
  257. tooltip: {
  258. legendShow: false,
  259. // showCategory: true,
  260. formatter: 'tooltipCustom',
  261. },
  262. },
  263. }))
  264. const dropDown = ref([])
  265. const chartFormRef = ref(null)
  266. const chartForm = ref({
  267. chartType: 4,
  268. platform: '',
  269. login: '',
  270. })
  271. const chartTypeOptions = computed(() => [
  272. { text: t('Custom.Index.TradingVolumeStatistics'), value: 4 },
  273. { text: t('Custom.Index.DepositStatistical'), value: 2 },
  274. { text: t('Custom.Index.WithdrawalsStatistical'), value: 3 },
  275. { text: t('Custom.Index.ProfitLoss'), value: 6 },
  276. ])
  277. const platformOptions = [
  278. { text: 'MT4', value: 'MT4' },
  279. { text: 'MT5', value: 'MT5' },
  280. ]
  281. const loginDataOptions = ref([])
  282. const loginComboxOptions = computed(() => {
  283. return loginDataOptions.value.map((item) => ({
  284. text: item.label,
  285. value: item.login
  286. }))
  287. })
  288. const chartLoading = ref(false)
  289. const isAfterJuly28 = () => {
  290. const now = new Date();
  291. const july28 = new Date(2025, 6, 28, 0, 0, 0); // 月份从0开始,所以7月是6
  292. return now >= july28;
  293. }
  294. const getLocalTime = () => {
  295. let timezone = 2 //目标时区时间,东2区 东时区正数 西市区负数
  296. let offset_GMT = new Date().getTimezoneOffset() // 本地时间和格林威治的时间差,单位为分钟
  297. let nowDate = new Date().getTime() // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数
  298. let now = new Date(
  299. nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000,
  300. )
  301. //当前时间
  302. let month = now.getMonth() + 1 //月
  303. let day = now.getDate() //日
  304. let hh = now.getHours() //时
  305. let mm = now.getMinutes() //分
  306. let clock
  307. if (month < 10) {
  308. month = '0' + month
  309. }
  310. if (day < 10) {
  311. day = '0' + day
  312. }
  313. if (hh < 10) {
  314. hh = '0' + hh
  315. }
  316. if (mm < 10) {
  317. mm = '0' + mm
  318. }
  319. clock = ' ' + hh + ':' + mm + ' ' + month + '/' + day
  320. time.value = clock
  321. }
  322. const toReload = () => {
  323. uni.showLoading({ title: t('common.loading') })
  324. goTime()
  325. }
  326. // 获取账户信息
  327. const getDateList = async () => {
  328. let res = await customApi.CustomDropdown({ platform: "" })
  329. if (res.code == Code.StatusOK) {
  330. loginDataOptions.value = res.data.map(item => ({
  331. ...item,
  332. label: `${item.login}`,
  333. disable: item.closeFunctions.includes('1')
  334. }))
  335. const found = loginDataOptions.value?.[0]
  336. loginValue.value = found?.login||null
  337. } else {
  338. uni.showToast({ title: res.msg, icon: 'none' })
  339. }
  340. }
  341. const getSearchDate = (val) => {
  342. if (Array.isArray(val)) {
  343. isDate.value = val
  344. }
  345. fetchChartData()
  346. }
  347. const onPlatformChange = (val) => {
  348. console.log('Platform changed:', val)
  349. }
  350. const handleChartConfirm = async () => {
  351. try {
  352. const params = {
  353. type: chartForm.value.chartType || 4,
  354. platform: chartForm.value.platform,
  355. login: chartForm.value.login,
  356. startDate: isDate.value[0],
  357. endDate: isDate.value[1],
  358. }
  359. const res = await customApi.getChartInfo(params)
  360. if (res.code === Code.StatusOK) {
  361. if (res.data) {
  362. let categories = []
  363. let seriesData = []
  364. res.data.forEach((item) => {
  365. categories.push(item.date.split(' ')[0])
  366. seriesData.push(item.amount)
  367. })
  368. chartData.value = { categories, series: [{ name: '', data: seriesData }] }
  369. } else {
  370. chartData.value = { categories: [], series: [] }
  371. }
  372. }
  373. isChart.value = false
  374. } catch (error) {
  375. console.error('获取图表数据失败', error)
  376. isChart.value = false
  377. }
  378. }
  379. const fetchChartData = async () => {
  380. try {
  381. const params = {
  382. type: chartForm.value.chartType || 4,
  383. platform: chartForm.value.platform,
  384. login: chartForm.value.login,
  385. startDate: isDate.value[0],
  386. endDate: isDate.value[1],
  387. }
  388. const res = await customApi.getChartInfo(params)
  389. if (res.code === Code.StatusOK) {
  390. if (res.data) {
  391. let categories = []
  392. let seriesData = []
  393. res.data.forEach((item) => {
  394. categories.push(item.date.split(' ')[0])
  395. seriesData.push(item.amount)
  396. })
  397. chartData.value = { categories, series: [{ name: '', data: seriesData }] }
  398. } else {
  399. chartData.value = { categories: [], series: [] }
  400. }
  401. }
  402. } catch (error) {
  403. console.error('获取图表数据失败', error)
  404. }finally {
  405. uni.hideLoading()
  406. }
  407. }
  408. const getDropDown = async () => {
  409. try {
  410. const res = await customApi.CustomDropdown()
  411. if (res.code === Code.StatusOK) {
  412. dropDown.value = res.data || []
  413. loginOptions.value = (res.data || []).map(item => ({
  414. text: item.login,
  415. value: item.login,
  416. }))
  417. }
  418. } catch (error) {
  419. console.error('获取账户列表失败', error)
  420. }
  421. }
  422. // 今日时间
  423. const dateWeek = computed(() => {
  424. const now = dayjs()
  425. const isChinese = locale.value === 'cn' || locale.value === 'zhHant'
  426. if (isChinese) {
  427. const weekDays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  428. const months = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  429. return `${weekDays[now.day()]}, ${months[now.month()]}${now.date()}日, ${now.year()}`
  430. } else {
  431. return now.format('ddd, MMMD, YYYY')
  432. }
  433. })
  434. const createAccount = () => {
  435. getCustomLoginInfo()
  436. }
  437. // 获取客户登录信息
  438. const dialogCheck = ref(false)
  439. async function getCustomLoginInfo() {
  440. try {
  441. const res = await userApi.getUserInfo()
  442. userStore.saveUserInfo(res.data)
  443. if (res.code === 200) {
  444. if (
  445. res.data.customInfo.status == 2 &&
  446. res.data.customInfo.applyRealStatus == 2
  447. ) {
  448. router.push(`/pages/customer/account-select?server=${'real'}`)
  449. } else {
  450. dialogCheck.value = true
  451. }
  452. }
  453. } catch (error) {
  454. // console.log(error, 111);
  455. }
  456. }
  457. const confirm = () => {
  458. dialogCheck.value = false
  459. router.push(`/pages/mine/improveImmediately`)
  460. }
  461. const getDailyCompare = async (login) => {
  462. const res = await documentaryApi.followDailyCompare({ login })
  463. if (res.code === Code.StatusOK) {
  464. ChartSetDate.value = res.data ?? {}
  465. } else {
  466. uni.showToast({ title: res.msg, icon: 'none' })
  467. }
  468. }
  469. const getDailyDeal = async (login) => {
  470. const res = await documentaryApi.followDailyDeal({ login })
  471. if (res.code === Code.StatusOK) {
  472. dealDate.value = res.data ?? {}
  473. } else {
  474. uni.showToast({ title: res.msg, icon: 'none' })
  475. }
  476. }
  477. const getDailySubscribeProfit = async (login) => {
  478. const res = await documentaryApi.followDailySubscribeProfit({ login })
  479. if (res.code === Code.StatusOK) {
  480. SubscribeProfitDate.value = res.data?.data ?? []
  481. } else {
  482. uni.showToast({ title: res.msg, icon: 'none' })
  483. }
  484. }
  485. watch(() => chartForm.value.login, async (login) => {
  486. await getDailyCompare(login)
  487. if (isDealLogin.value) {
  488. await getDailyDeal(login)
  489. } else {
  490. await getDailySubscribeProfit(login)
  491. }
  492. })
  493. const getData = async () => {
  494. try {
  495. const res = await customApi.customDailyCompare()
  496. if (res.code === Code.StatusOK) {
  497. compareData.value = res.data
  498. }
  499. } catch (e) {
  500. console.log(e)
  501. }
  502. }
  503. const goTime = () => {
  504. getLocalTime()
  505. let timezone = 2 //目标时区时间,东2区 东时区正数 西市区负数
  506. let offset_GMT = new Date().getTimezoneOffset() // 本地时间和格林威治的时间差,单位为分钟
  507. let nowDate = new Date().getTime() // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数
  508. let data = new Date(
  509. nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000,
  510. )
  511. //当月第一天和最后一天
  512. let mon1 = data.setDate(1) //当月第一天
  513. let mon2 = data.setMonth(data.getMonth() + 1) //下月
  514. let y1 = new Date(mon1).getFullYear()
  515. let m1 = new Date(mon1).getMonth() + 1
  516. let d1 = new Date(mon1).getDate()
  517. let y2 = new Date(mon2).getFullYear()
  518. let m2 = new Date(mon2).getMonth() + 1
  519. let d2 = 1
  520. isDate.value = [
  521. y1 + '-' + (m1 < 10 ? '0' + m1 : m1) + '-' + (d1 < 10 ? '0' + d1 : d1),
  522. y2 + '-' + (m2 < 10 ? '0' + m2 : m2) + '-' + (d2 < 10 ? '0' + d2 : d2),
  523. ]
  524. fetchChartData()
  525. }
  526. const isMobile = ref(false)
  527. onUnmounted(() => {
  528. // #ifdef H5
  529. window.removeEventListener('resize', handleResize)
  530. // #endif
  531. })
  532. const chartShow = ref(true)
  533. // 监听窗口大小变化(仅 H5)
  534. // #ifdef H5
  535. const handleResize = () => {
  536. checkIsMobile()
  537. }
  538. // #endif
  539. const checkIsMobile = () => {
  540. chartShow.value = false
  541. isMobile.value = windowWidth.value < 991
  542. chartShow.value = true
  543. }
  544. const AccountList = ref([])
  545. const getAccountList = async () => {
  546. AccountList.value = []
  547. const res = await customApi.AccountAllList({
  548. page: {
  549. current: 1,
  550. size: 100
  551. }
  552. })
  553. if (res.code === 200) {
  554. AccountList.value = res.data
  555. }
  556. }
  557. const typeMap = computed(() => ({
  558. 1: t('AccountType.ClassicAccount'),
  559. 2: t('AccountType.SeniorAccount'),
  560. 3: !isAfterJuly28() ? t('AccountType.AgencyAccount') : '',
  561. 5: t('AccountType.SpeedAccount'),
  562. 6: t('AccountType.SpeedAccount'),
  563. 7: t('AccountType.StandardAccount'),
  564. 8: t('AccountType.CentAccount')
  565. }));
  566. // 格式化数值函数
  567. function formatMoney(value) {
  568. if (value === null || value === undefined) value = 0;
  569. const sign = value >= 0 ? '' : '-';
  570. const absoluteValue = Math.abs(value);
  571. return '$' + sign + numberDecimal(absoluteValue);
  572. }
  573. // 转换数组
  574. const accounts = computed(() => {
  575. if (!AccountList.value || AccountList.value.length == 0) return []
  576. let filteredAccounts = AccountList.value
  577. return filteredAccounts.map((acc, index) => {
  578. const currency = acc.currency || 'USD';
  579. const floating = acc.floating ?? 0;
  580. let labels = [t('vu.item1'), 'MT4', 'Standard'];
  581. labels[0] = t('vu.item1');
  582. labels[1] = acc.platform || 'MT4';
  583. labels[2] = typeMap.value[acc.type];
  584. let nickname = typeMap.value[acc.type];
  585. let fwq
  586. fwq = acc.platform == 'MT4' ? 'CWGMarketsLtd-Live' : 'CWGMarketsSVG-Live';
  587. const balance = acc.balance
  588. return {
  589. ...acc,
  590. labels,
  591. isExpanded: index == 0,
  592. balance,
  593. accountNumber: acc.login.toString(),
  594. nickname,
  595. fwq,
  596. balanceWithSymbol: acc.balanceWithSymbol ?? '$0.00',
  597. creditWithSymbol: acc.creditWithSymbol ?? '$0.00',
  598. equityWithSymbol: acc.equityWithSymbol ?? '$0.00',
  599. currency,
  600. actualLeverage: '1:' + (acc.leverage ?? 0),
  601. floatingPL: acc.floatingWithSymbol ?? '$0.00',
  602. platform: acc.platform || 'MT4',
  603. server: acc.groupCode || '',
  604. login: acc.login.toString(),
  605. listType: 'real'
  606. };
  607. })
  608. })
  609. const curData = ref()
  610. const setCurData = (val)=>{
  611. console.log(accounts.value, val)
  612. curData.value = accounts.value.find(item=>item.login == val)
  613. }
  614. watch(() => accounts.value, (val)=>{
  615. if (val.length){
  616. curData.value = accounts.value.find(item=>item.login == loginValue.value)
  617. }
  618. })
  619. onMounted(async () => {
  620. loading.value = true
  621. goTime()
  622. await getData()
  623. await getDropDown()
  624. await getDateList()
  625. await getAccountList()
  626. // #ifdef H5
  627. window.addEventListener('resize', handleResize)
  628. // #endif
  629. checkIsMobile()
  630. // await fetchChartData()
  631. loading.value = false
  632. })
  633. </script>
  634. <style lang="scss" scoped>
  635. @import "@/uni.scss";
  636. .mobilH{
  637. height: 100%;
  638. }
  639. @media screen and (max-width: 1200px){
  640. .mobilH{
  641. height: auto;
  642. }
  643. }
  644. .header {
  645. display: flex;
  646. align-items: center;
  647. justify-content: space-between;
  648. margin-bottom: px2rpx(20);
  649. .title {
  650. font-size: px2rpx(24);
  651. font-weight: bold;
  652. }
  653. }
  654. .demo-uni-row {
  655. display: flex;
  656. flex-wrap: wrap;
  657. align-items: stretch;
  658. margin: 0 auto !important;
  659. }
  660. .uni-col-left {
  661. //display: flex;
  662. //flex-direction: column;
  663. }
  664. .uni-col-right {
  665. display: flex;
  666. }
  667. .dashboard-container {
  668. min-height: 10vh;
  669. box-sizing: border-box;
  670. display: flex;
  671. flex-direction: column;
  672. height: 100%;
  673. }
  674. /* 卡片通用样式 */
  675. .card {
  676. background: var(--color-white);
  677. color: var(--bs-heading-color);
  678. border-radius: 4px;
  679. margin-bottom: px2rpx(20);
  680. box-shadow: 0 px2rpx(4) px2rpx(12) rgba(0, 0, 0, 0.2);
  681. }
  682. .card-body {
  683. padding: px2rpx(16);
  684. }
  685. .icon-placeholder {
  686. width: px2rpx(48);
  687. height: px2rpx(48);
  688. border-radius: px2rpx(24);
  689. background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  690. display: flex;
  691. align-items: center;
  692. justify-content: center;
  693. flex-shrink: 0;
  694. }
  695. .icon-text {
  696. font-size: px2rpx(20);
  697. font-weight: bold;
  698. color: #6c757d;
  699. }
  700. .growth-rate {
  701. font-size: px2rpx(12);
  702. font-weight: 500;
  703. padding: px2rpx(2) px2rpx(8);
  704. border-radius: px2rpx(2);
  705. }
  706. .growth-rate.rate-up {
  707. color: #10b981;
  708. background: rgba(16, 185, 129, 0.1);
  709. }
  710. .growth-rate.rate-down {
  711. color: #ef4444;
  712. background: rgba(239, 68, 68, 0.1);
  713. }
  714. .custom-number,
  715. .custom-money {
  716. background: var(--bs-body-bg);
  717. border: 1px solid var(--bs-border-color);
  718. padding: 15px;
  719. border-radius: 4px;
  720. margin-bottom: 20px;
  721. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  722. min-height: px2rpx(125);
  723. }
  724. .custom-number .title,
  725. .custom-money .left .tit,
  726. .custom-money .right .tit {
  727. font-size: 14px;
  728. color: var(--bs-heading-color);
  729. margin-bottom: 10px;
  730. }
  731. .custom-number .title {
  732. display: flex;
  733. justify-content: space-between;
  734. align-items: center;
  735. }
  736. .custom-money {
  737. display: flex;
  738. flex-direction: column;
  739. }
  740. .custom-money .left,
  741. .custom-money .right {
  742. flex: 1;
  743. }
  744. .custom-money .num {
  745. font-size: 20px;
  746. font-weight: bold;
  747. color: var(--bs-heading-color);
  748. }
  749. .custom-money .num.red {
  750. color: #eb3f57;
  751. }
  752. .el-dropdown-link {
  753. display: flex;
  754. align-items: center;
  755. gap: 4px;
  756. color: #6c8595;
  757. font-size: 12px;
  758. }
  759. .account-info1 {
  760. margin-bottom: 20px;
  761. }
  762. .custom-money-left .header,
  763. .custom-money-right .header {
  764. display: flex;
  765. align-items: center;
  766. justify-content: space-between;
  767. margin-bottom: px2rpx(15);
  768. }
  769. .custom-money-left .tab,
  770. .custom-money-right .tab {
  771. font-size: px2rpx(16);
  772. font-weight: 600;
  773. color: var(--bs-heading-color);
  774. }
  775. .bottomCol {
  776. font-size: 16px;
  777. color: #868686;
  778. .bo-left1 {
  779. margin: 20px 0;
  780. padding: 20px 0;
  781. border-right: 1px dashed #989898;
  782. text-align: center;
  783. font-size: 16px;
  784. }
  785. .bo-right1 {
  786. margin: 20px 0px;
  787. padding: 20px 0;
  788. text-align: center;
  789. font-size: 16px;
  790. }
  791. }
  792. .blue-font {
  793. margin-top: px2rpx(15);
  794. color: #007aff;
  795. font-weight: 600;
  796. font-size: px2rpx(24);
  797. }
  798. .subscribe-table {
  799. width: 100%;
  800. border: 1px solid #ebeef5;
  801. border-radius: 6px;
  802. overflow: hidden;
  803. }
  804. .subscribe-row {
  805. display: grid;
  806. grid-template-columns: 1fr 1fr 1fr 1fr;
  807. border-top: 1px solid #ebeef5;
  808. }
  809. .subscribe-head {
  810. background: #f5f7fa;
  811. border-top: none;
  812. }
  813. .subscribe-cell {
  814. padding: 10px 8px;
  815. font-size: 12px;
  816. color: var(--bs-heading-color);
  817. text-align: center;
  818. overflow: hidden;
  819. text-overflow: ellipsis;
  820. white-space: nowrap;
  821. }
  822. .custom-dialog-content {
  823. padding: px2rpx(20);
  824. .info-text {
  825. color: var(--bs-heading-color);
  826. font-size: px2rpx(14);
  827. line-height: px2rpx(36);
  828. }
  829. }
  830. .card-header {
  831. display: flex;
  832. justify-content: space-between;
  833. align-items: center;
  834. margin-bottom: px2rpx(12);
  835. }
  836. .header-left {
  837. display: flex;
  838. align-items: center;
  839. gap: 12rpx;
  840. }
  841. .header-title {
  842. font-size: px2rpx(14);
  843. font-weight: 600;
  844. }
  845. .header-right {
  846. display: flex;
  847. align-items: center;
  848. }
  849. .action-btn {
  850. background: #ffde02;
  851. border: none;
  852. border-radius: 50%;
  853. width: px2rpx(32);
  854. height: px2rpx(32);
  855. display: flex;
  856. align-items: center;
  857. justify-content: center;
  858. padding: 0;
  859. margin: 0;
  860. &:after {
  861. border: none;
  862. }
  863. }
  864. .dia-content {
  865. padding: 20rpx;
  866. }
  867. .content {
  868. display: flex;
  869. flex-direction: column;
  870. gap: 20rpx;
  871. }
  872. .label {
  873. font-weight: 500;
  874. margin-bottom: 8rpx;
  875. }
  876. .btn {
  877. text-align: center;
  878. //background-color: rgb(var(--bs-danger-rgb));
  879. //font-size: px2rpx(16);
  880. color: #fff;
  881. //padding: px2rpx(10) px2rpx(20);
  882. border-radius: px2rpx(8)!important;
  883. margin: 0;
  884. }
  885. .crm-cursor {
  886. cursor: pointer;
  887. }
  888. .link {
  889. display: flex;
  890. margin-top: 20rpx;
  891. .btn {
  892. display: flex;
  893. align-items: center;
  894. justify-content: center;
  895. height: px2rpx(35);
  896. margin: 0 px2rpx(10);
  897. }
  898. }
  899. .chart-box {
  900. background: var(--color-white);
  901. border-radius: 8px;
  902. padding: px2rpx(16);
  903. height: 100%;
  904. box-shadow: 0 px2rpx(4) px2rpx(12) rgba(0, 0, 0, 0.2);
  905. }
  906. .mh{
  907. height: 100%;
  908. }
  909. .chart-title {
  910. width: 100%;
  911. //display: flex;
  912. //justify-content: space-between;
  913. //align-items: flex-start;
  914. //margin-bottom: px2rpx(16);
  915. //padding-bottom: px2rpx(16);
  916. border-bottom: 1px solid #f0f0f0;
  917. }
  918. .bigtitle{
  919. font-size: px2rpx(18);
  920. }
  921. .opt-title{
  922. display: flex;
  923. align-items: center;
  924. justify-content: space-between;
  925. }
  926. .btn-opt{
  927. display: flex;
  928. height: 100%;
  929. align-items: flex-end;
  930. justify-content: flex-end;
  931. }
  932. .chart-title .time {
  933. display: flex;
  934. align-items: center;
  935. gap: px2rpx(8);
  936. font-size: px2rpx(14);
  937. margin-bottom: px2rpx(10);
  938. color: #999;
  939. }
  940. .chart-title .title {
  941. flex: 1;
  942. margin: 0;
  943. margin-bottom: px2rpx(10);
  944. }
  945. .chart-title .title .name {
  946. font-size: px2rpx(18);
  947. font-weight: 600;
  948. color: var(--bs-heading-color);
  949. text-align: center;
  950. margin-bottom: px2rpx(8);
  951. }
  952. .chart-title .title .account {
  953. font-size: px2rpx(14);
  954. color: #999;
  955. text-align: center;
  956. margin-bottom: px2rpx(8);
  957. }
  958. .chart-title .title .date {
  959. display: flex;
  960. }
  961. .chart-title .date-picker {
  962. font-size: px2rpx(12);
  963. color: #666;
  964. padding: px2rpx(6) px2rpx(12);
  965. background: #f5f5f5;
  966. border-radius: 4px;
  967. }
  968. .chart-title .operation {
  969. //gap: px2rpx(4);
  970. margin-left: px2rpx(10);
  971. color: #666;
  972. margin-bottom: px2rpx(10);
  973. height: px2rpx(48);
  974. width: px2rpx(100);
  975. font-size: px2rpx(16);
  976. line-height: px2rpx(48)!important;
  977. }
  978. .chart-container {
  979. margin-top: px2rpx(20);
  980. height: px2rpx(350);
  981. }
  982. .popup-content .form {
  983. padding: px2rpx(16);
  984. }
  985. .popup-content .form-item {
  986. margin-bottom: px2rpx(20);
  987. }
  988. .popup-content .form-label {
  989. display: block;
  990. font-size: px2rpx(14);
  991. color: #666;
  992. margin-bottom: px2rpx(8);
  993. }
  994. .popup-content .picker-value {
  995. display: flex;
  996. justify-content: space-between;
  997. align-items: center;
  998. padding: px2rpx(12);
  999. background: #f5f5f5;
  1000. border-radius: 4px;
  1001. font-size: px2rpx(14);
  1002. color: #333;
  1003. }
  1004. .crm-cursor {
  1005. cursor: pointer;
  1006. }
  1007. .crm-border-radius {
  1008. border-radius: 8px;
  1009. }
  1010. </style>