dashboard.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116
  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">${{ numberFormat(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="14" 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="12" :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" @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="12" :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 } = 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 isAfterJuly28 = () => {
  289. const now = new Date();
  290. const july28 = new Date(2025, 6, 28, 0, 0, 0); // 月份从0开始,所以7月是6
  291. return now >= july28;
  292. }
  293. const getLocalTime = () => {
  294. let timezone = 2 //目标时区时间,东2区 东时区正数 西市区负数
  295. let offset_GMT = new Date().getTimezoneOffset() // 本地时间和格林威治的时间差,单位为分钟
  296. let nowDate = new Date().getTime() // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数
  297. let now = new Date(
  298. nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000,
  299. )
  300. //当前时间
  301. let month = now.getMonth() + 1 //月
  302. let day = now.getDate() //日
  303. let hh = now.getHours() //时
  304. let mm = now.getMinutes() //分
  305. let clock
  306. if (month < 10) {
  307. month = '0' + month
  308. }
  309. if (day < 10) {
  310. day = '0' + day
  311. }
  312. if (hh < 10) {
  313. hh = '0' + hh
  314. }
  315. if (mm < 10) {
  316. mm = '0' + mm
  317. }
  318. clock = ' ' + hh + ':' + mm + ' ' + month + '/' + day
  319. time.value = clock
  320. }
  321. const toReload = () => {
  322. goTime()
  323. }
  324. // 获取账户信息
  325. const getDateList = async () => {
  326. let res = await customApi.CustomDropdown({ platform: "" })
  327. if (res.code == Code.StatusOK) {
  328. loginDataOptions.value = res.data.map(item => ({
  329. ...item,
  330. label: `${item.login}`
  331. }))
  332. const found = loginDataOptions.value?.[0]
  333. loginValue.value = found?.login||null
  334. } else {
  335. uni.showToast({ title: res.msg, icon: 'none' })
  336. }
  337. }
  338. const getSearchDate = (val) => {
  339. if (Array.isArray(val)) {
  340. isDate.value = val
  341. }
  342. fetchChartData()
  343. }
  344. const onPlatformChange = (val) => {
  345. console.log('Platform changed:', val)
  346. }
  347. const handleChartConfirm = async () => {
  348. try {
  349. const params = {
  350. type: chartForm.value.chartType || 4,
  351. platform: chartForm.value.platform,
  352. login: chartForm.value.login,
  353. startDate: isDate.value[0],
  354. endDate: isDate.value[1],
  355. }
  356. const res = await customApi.getChartInfo(params)
  357. if (res.code === Code.StatusOK) {
  358. if (res.data) {
  359. let categories = []
  360. let seriesData = []
  361. res.data.forEach((item) => {
  362. categories.push(item.date.split(' ')[0])
  363. seriesData.push(item.amount)
  364. })
  365. chartData.value = { categories, series: [{ name: '', data: seriesData }] }
  366. } else {
  367. chartData.value = { categories: [], series: [] }
  368. }
  369. }
  370. isChart.value = false
  371. } catch (error) {
  372. console.error('获取图表数据失败', error)
  373. isChart.value = false
  374. }
  375. }
  376. const fetchChartData = async () => {
  377. try {
  378. const params = {
  379. type: chartForm.value.chartType || 4,
  380. platform: chartForm.value.platform,
  381. login: chartForm.value.login,
  382. startDate: isDate.value[0],
  383. endDate: isDate.value[1],
  384. }
  385. const res = await customApi.getChartInfo(params)
  386. if (res.code === Code.StatusOK) {
  387. if (res.data) {
  388. let categories = []
  389. let seriesData = []
  390. res.data.forEach((item) => {
  391. categories.push(item.date.split(' ')[0])
  392. seriesData.push(item.amount)
  393. })
  394. chartData.value = { categories, series: [{ name: '', data: seriesData }] }
  395. } else {
  396. chartData.value = { categories: [], series: [] }
  397. }
  398. }
  399. } catch (error) {
  400. console.error('获取图表数据失败', error)
  401. }
  402. }
  403. const getDropDown = async () => {
  404. try {
  405. const res = await customApi.CustomDropdown()
  406. if (res.code === Code.StatusOK) {
  407. dropDown.value = res.data || []
  408. loginOptions.value = (res.data || []).map(item => ({
  409. text: item.login,
  410. value: item.login,
  411. }))
  412. }
  413. } catch (error) {
  414. console.error('获取账户列表失败', error)
  415. }
  416. }
  417. // 今日时间
  418. const dateWeek = computed(() => {
  419. const now = dayjs()
  420. const isChinese = locale.value === 'cn' || locale.value === 'zhHant'
  421. if (isChinese) {
  422. const weekDays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  423. const months = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  424. return `${weekDays[now.day()]}, ${months[now.month()]}${now.date()}日, ${now.year()}`
  425. } else {
  426. return now.format('ddd, MMMD, YYYY')
  427. }
  428. })
  429. const createAccount = () => {
  430. getCustomLoginInfo()
  431. }
  432. // 获取客户登录信息
  433. const dialogCheck = ref(false)
  434. async function getCustomLoginInfo() {
  435. try {
  436. const res = await userApi.getUserInfo()
  437. userStore.saveUserInfo(res.data)
  438. if (res.code === 200) {
  439. if (
  440. res.data.customInfo.status == 2 &&
  441. res.data.customInfo.applyRealStatus == 2
  442. ) {
  443. router.push(`/pages/customer/account-select?server=${'real'}`)
  444. } else {
  445. dialogCheck.value = true
  446. }
  447. }
  448. } catch (error) {
  449. // console.log(error, 111);
  450. }
  451. }
  452. const confirm = () => {
  453. dialogCheck.value = false
  454. router.push(`/pages/mine/improveImmediately`)
  455. }
  456. const getDailyCompare = async (login) => {
  457. const res = await documentaryApi.followDailyCompare({ login })
  458. if (res.code === Code.StatusOK) {
  459. ChartSetDate.value = res.data ?? {}
  460. } else {
  461. uni.showToast({ title: res.msg, icon: 'none' })
  462. }
  463. }
  464. const getDailyDeal = async (login) => {
  465. const res = await documentaryApi.followDailyDeal({ login })
  466. if (res.code === Code.StatusOK) {
  467. dealDate.value = res.data ?? {}
  468. } else {
  469. uni.showToast({ title: res.msg, icon: 'none' })
  470. }
  471. }
  472. const getDailySubscribeProfit = async (login) => {
  473. const res = await documentaryApi.followDailySubscribeProfit({ login })
  474. if (res.code === Code.StatusOK) {
  475. SubscribeProfitDate.value = res.data?.data ?? []
  476. } else {
  477. uni.showToast({ title: res.msg, icon: 'none' })
  478. }
  479. }
  480. watch(() => chartForm.value.login, async (login) => {
  481. await getDailyCompare(login)
  482. if (isDealLogin.value) {
  483. await getDailyDeal(login)
  484. } else {
  485. await getDailySubscribeProfit(login)
  486. }
  487. })
  488. const getData = async () => {
  489. try {
  490. const res = await customApi.customDailyCompare()
  491. if (res.code === Code.StatusOK) {
  492. compareData.value = res.data
  493. }
  494. } catch (e) {
  495. console.log(e)
  496. }
  497. }
  498. const goTime = () => {
  499. getLocalTime()
  500. let timezone = 2 //目标时区时间,东2区 东时区正数 西市区负数
  501. let offset_GMT = new Date().getTimezoneOffset() // 本地时间和格林威治的时间差,单位为分钟
  502. let nowDate = new Date().getTime() // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数
  503. let data = new Date(
  504. nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000,
  505. )
  506. //当月第一天和最后一天
  507. let mon1 = data.setDate(1) //当月第一天
  508. let mon2 = data.setMonth(data.getMonth() + 1) //下月
  509. let y1 = new Date(mon1).getFullYear()
  510. let m1 = new Date(mon1).getMonth() + 1
  511. let d1 = new Date(mon1).getDate()
  512. let y2 = new Date(mon2).getFullYear()
  513. let m2 = new Date(mon2).getMonth() + 1
  514. let d2 = 1
  515. isDate.value = [
  516. y1 + '-' + (m1 < 10 ? '0' + m1 : m1) + '-' + (d1 < 10 ? '0' + d1 : d1),
  517. y2 + '-' + (m2 < 10 ? '0' + m2 : m2) + '-' + (d2 < 10 ? '0' + d2 : d2),
  518. ]
  519. fetchChartData()
  520. }
  521. const isMobile = ref(false)
  522. onUnmounted(() => {
  523. // #ifdef H5
  524. window.removeEventListener('resize', handleResize)
  525. // #endif
  526. })
  527. const chartShow = ref(true)
  528. // 监听窗口大小变化(仅 H5)
  529. // #ifdef H5
  530. const handleResize = () => {
  531. checkIsMobile()
  532. }
  533. // #endif
  534. const checkIsMobile = () => {
  535. chartShow.value = false
  536. isMobile.value = windowWidth.value < 991
  537. chartShow.value = true
  538. }
  539. const AccountList = ref([])
  540. const getAccountList = async () => {
  541. AccountList.value = []
  542. const res = await customApi.AccountAllList({
  543. page: {
  544. current: 1,
  545. size: 100
  546. }
  547. })
  548. if (res.code === 200) {
  549. AccountList.value = res.data
  550. }
  551. }
  552. const typeMap = computed(() => ({
  553. 1: t('AccountType.ClassicAccount'),
  554. 2: t('AccountType.SeniorAccount'),
  555. 3: !isAfterJuly28() ? t('AccountType.AgencyAccount') : '',
  556. 5: t('AccountType.SpeedAccount'),
  557. 6: t('AccountType.SpeedAccount'),
  558. 7: t('AccountType.StandardAccount'),
  559. 8: t('AccountType.CentAccount')
  560. }));
  561. // 格式化数值函数
  562. function formatMoney(value) {
  563. if (value === null || value === undefined) value = 0;
  564. const sign = value >= 0 ? '' : '-';
  565. const absoluteValue = Math.abs(value);
  566. return '$' + sign + absoluteValue.toFixed(2);
  567. }
  568. // 转换数组
  569. const accounts = computed(() => {
  570. if (!AccountList.value || AccountList.value.length == 0) return []
  571. let filteredAccounts = AccountList.value
  572. return filteredAccounts.map((acc, index) => {
  573. const currency = acc.currency || 'USD';
  574. const floating = acc.floating ?? 0;
  575. let labels = [t('vu.item1'), 'MT4', 'Standard'];
  576. labels[0] = t('vu.item1');
  577. labels[1] = acc.platform || 'MT4';
  578. labels[2] = typeMap.value[acc.type];
  579. let nickname = typeMap.value[acc.type];
  580. let fwq
  581. fwq = acc.platform == 'MT4' ? 'CWGMarketsLtd-Live' : 'CWGMarketsSVG-Live';
  582. const balance = acc.balance
  583. return {
  584. ...acc,
  585. labels,
  586. isExpanded: index == 0,
  587. balance,
  588. accountNumber: acc.login.toString(),
  589. nickname,
  590. fwq,
  591. balanceWithSymbol: acc.balanceWithSymbol ?? '$0',
  592. creditWithSymbol: acc.creditWithSymbol ?? '$0',
  593. equityWithSymbol: acc.equityWithSymbol ?? '$0',
  594. currency,
  595. actualLeverage: '1:' + (acc.leverage ?? 0),
  596. floatingPL: formatMoney(floating),
  597. platform: acc.platform || 'MT4',
  598. server: acc.groupCode || '',
  599. login: acc.login.toString(),
  600. listType: 'real'
  601. };
  602. })
  603. })
  604. const curData = ref()
  605. const setCurData = (val)=>{
  606. console.log(accounts.value, val)
  607. curData.value = accounts.value.find(item=>item.login == val)
  608. }
  609. watch(() => accounts.value, (val)=>{
  610. if (val.length){
  611. curData.value = accounts.value.find(item=>item.login == loginValue.value)
  612. }
  613. })
  614. onMounted(async () => {
  615. loading.value = true
  616. goTime()
  617. await getData()
  618. await getDropDown()
  619. await getDateList()
  620. await getAccountList()
  621. // #ifdef H5
  622. window.addEventListener('resize', handleResize)
  623. // #endif
  624. checkIsMobile()
  625. // await fetchChartData()
  626. loading.value = false
  627. })
  628. </script>
  629. <style lang="scss" scoped>
  630. @import "@/uni.scss";
  631. .mobilH{
  632. height: 100%;
  633. }
  634. @media screen and (max-width: 991px){
  635. .mobilH{
  636. height: auto;
  637. }
  638. }
  639. .header {
  640. display: flex;
  641. align-items: center;
  642. justify-content: space-between;
  643. margin-bottom: px2rpx(20);
  644. .title {
  645. font-size: px2rpx(24);
  646. font-weight: bold;
  647. }
  648. }
  649. .demo-uni-row {
  650. display: flex;
  651. flex-wrap: wrap;
  652. align-items: stretch;
  653. margin: 0 auto !important;
  654. }
  655. .uni-col-left {
  656. //display: flex;
  657. //flex-direction: column;
  658. }
  659. .uni-col-right {
  660. display: flex;
  661. }
  662. .dashboard-container {
  663. min-height: 10vh;
  664. box-sizing: border-box;
  665. display: flex;
  666. flex-direction: column;
  667. height: 100%;
  668. }
  669. /* 卡片通用样式 */
  670. .card {
  671. background: var(--color-white);
  672. color: var(--bs-heading-color);
  673. border-radius: 4px;
  674. margin-bottom: px2rpx(20);
  675. box-shadow: 0 px2rpx(4) px2rpx(12) rgba(0, 0, 0, 0.2);
  676. }
  677. .card-body {
  678. padding: px2rpx(16);
  679. }
  680. .icon-placeholder {
  681. width: px2rpx(48);
  682. height: px2rpx(48);
  683. border-radius: px2rpx(24);
  684. background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  685. display: flex;
  686. align-items: center;
  687. justify-content: center;
  688. flex-shrink: 0;
  689. }
  690. .icon-text {
  691. font-size: px2rpx(20);
  692. font-weight: bold;
  693. color: #6c757d;
  694. }
  695. .growth-rate {
  696. font-size: px2rpx(12);
  697. font-weight: 500;
  698. padding: px2rpx(2) px2rpx(8);
  699. border-radius: px2rpx(2);
  700. }
  701. .growth-rate.rate-up {
  702. color: #10b981;
  703. background: rgba(16, 185, 129, 0.1);
  704. }
  705. .growth-rate.rate-down {
  706. color: #ef4444;
  707. background: rgba(239, 68, 68, 0.1);
  708. }
  709. .custom-number,
  710. .custom-money {
  711. background: var(--bs-body-bg);
  712. border: 1px solid var(--bs-border-color);
  713. padding: 15px;
  714. border-radius: 4px;
  715. margin-bottom: 20px;
  716. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  717. min-height: px2rpx(125);
  718. }
  719. .custom-number .title,
  720. .custom-money .left .tit,
  721. .custom-money .right .tit {
  722. font-size: 14px;
  723. color: var(--bs-heading-color);
  724. margin-bottom: 10px;
  725. }
  726. .custom-number .title {
  727. display: flex;
  728. justify-content: space-between;
  729. align-items: center;
  730. }
  731. .custom-money {
  732. display: flex;
  733. flex-direction: column;
  734. }
  735. .custom-money .left,
  736. .custom-money .right {
  737. flex: 1;
  738. }
  739. .custom-money .num {
  740. font-size: 20px;
  741. font-weight: bold;
  742. color: var(--bs-heading-color);
  743. }
  744. .custom-money .num.red {
  745. color: #eb3f57;
  746. }
  747. .el-dropdown-link {
  748. display: flex;
  749. align-items: center;
  750. gap: 4px;
  751. color: #6c8595;
  752. font-size: 12px;
  753. }
  754. .account-info1 {
  755. margin-bottom: 20px;
  756. }
  757. .custom-money-left .header,
  758. .custom-money-right .header {
  759. display: flex;
  760. align-items: center;
  761. justify-content: space-between;
  762. margin-bottom: px2rpx(15);
  763. }
  764. .custom-money-left .tab,
  765. .custom-money-right .tab {
  766. font-size: px2rpx(16);
  767. font-weight: 600;
  768. color: var(--bs-heading-color);
  769. }
  770. .bottomCol {
  771. font-size: 16px;
  772. color: #868686;
  773. .bo-left1 {
  774. margin: 20px 0;
  775. padding: 20px 0;
  776. border-right: 1px dashed #989898;
  777. text-align: center;
  778. font-size: 16px;
  779. }
  780. .bo-right1 {
  781. margin: 20px 0px;
  782. padding: 20px 0;
  783. text-align: center;
  784. font-size: 16px;
  785. }
  786. }
  787. .blue-font {
  788. margin-top: px2rpx(15);
  789. color: #007aff;
  790. font-weight: 600;
  791. font-size: px2rpx(24);
  792. }
  793. .subscribe-table {
  794. width: 100%;
  795. border: 1px solid #ebeef5;
  796. border-radius: 6px;
  797. overflow: hidden;
  798. }
  799. .subscribe-row {
  800. display: grid;
  801. grid-template-columns: 1fr 1fr 1fr 1fr;
  802. border-top: 1px solid #ebeef5;
  803. }
  804. .subscribe-head {
  805. background: #f5f7fa;
  806. border-top: none;
  807. }
  808. .subscribe-cell {
  809. padding: 10px 8px;
  810. font-size: 12px;
  811. color: var(--bs-heading-color);
  812. text-align: center;
  813. overflow: hidden;
  814. text-overflow: ellipsis;
  815. white-space: nowrap;
  816. }
  817. .custom-dialog-content {
  818. padding: px2rpx(20);
  819. .info-text {
  820. color: var(--bs-heading-color);
  821. font-size: px2rpx(14);
  822. line-height: px2rpx(36);
  823. }
  824. }
  825. .card-header {
  826. display: flex;
  827. justify-content: space-between;
  828. align-items: center;
  829. margin-bottom: px2rpx(12);
  830. }
  831. .header-left {
  832. display: flex;
  833. align-items: center;
  834. gap: 12rpx;
  835. }
  836. .header-title {
  837. font-size: px2rpx(14);
  838. font-weight: 600;
  839. }
  840. .header-right {
  841. display: flex;
  842. align-items: center;
  843. }
  844. .action-btn {
  845. background: #ffde02;
  846. border: none;
  847. border-radius: 50%;
  848. width: px2rpx(32);
  849. height: px2rpx(32);
  850. display: flex;
  851. align-items: center;
  852. justify-content: center;
  853. padding: 0;
  854. margin: 0;
  855. &:after {
  856. border: none;
  857. }
  858. }
  859. .dia-content {
  860. padding: 20rpx;
  861. }
  862. .content {
  863. display: flex;
  864. flex-direction: column;
  865. gap: 20rpx;
  866. }
  867. .label {
  868. font-weight: 500;
  869. margin-bottom: 8rpx;
  870. }
  871. .btn {
  872. text-align: center;
  873. //background-color: rgb(var(--bs-danger-rgb));
  874. //font-size: px2rpx(16);
  875. color: #fff;
  876. //padding: px2rpx(10) px2rpx(20);
  877. border-radius: px2rpx(8)!important;
  878. margin: 0;
  879. }
  880. .crm-cursor {
  881. cursor: pointer;
  882. }
  883. .link {
  884. display: flex;
  885. margin-top: 20rpx;
  886. .btn {
  887. display: flex;
  888. align-items: center;
  889. justify-content: center;
  890. height: px2rpx(35);
  891. margin: 0 px2rpx(10);
  892. }
  893. }
  894. .chart-box {
  895. background: var(--color-white);
  896. border-radius: 8px;
  897. padding: px2rpx(16);
  898. height: 100%;
  899. box-shadow: 0 px2rpx(4) px2rpx(12) rgba(0, 0, 0, 0.2);
  900. }
  901. .mh{
  902. height: 100%;
  903. }
  904. .chart-title {
  905. width: 100%;
  906. //display: flex;
  907. //justify-content: space-between;
  908. //align-items: flex-start;
  909. //margin-bottom: px2rpx(16);
  910. //padding-bottom: px2rpx(16);
  911. border-bottom: 1px solid #f0f0f0;
  912. }
  913. .bigtitle{
  914. font-size: px2rpx(18);
  915. }
  916. .opt-title{
  917. display: flex;
  918. align-items: center;
  919. justify-content: space-between;
  920. }
  921. .btn-opt{
  922. display: flex;
  923. height: 100%;
  924. align-items: flex-end;
  925. justify-content: flex-end;
  926. }
  927. .chart-title .time {
  928. display: flex;
  929. align-items: center;
  930. gap: px2rpx(8);
  931. font-size: px2rpx(14);
  932. margin-bottom: px2rpx(10);
  933. color: #999;
  934. }
  935. .chart-title .title {
  936. flex: 1;
  937. margin: 0;
  938. margin-bottom: px2rpx(10);
  939. }
  940. .chart-title .title .name {
  941. font-size: px2rpx(18);
  942. font-weight: 600;
  943. color: var(--bs-heading-color);
  944. text-align: center;
  945. margin-bottom: px2rpx(8);
  946. }
  947. .chart-title .title .account {
  948. font-size: px2rpx(14);
  949. color: #999;
  950. text-align: center;
  951. margin-bottom: px2rpx(8);
  952. }
  953. .chart-title .title .date {
  954. display: flex;
  955. }
  956. .chart-title .date-picker {
  957. font-size: px2rpx(12);
  958. color: #666;
  959. padding: px2rpx(6) px2rpx(12);
  960. background: #f5f5f5;
  961. border-radius: 4px;
  962. }
  963. .chart-title .operation {
  964. //gap: px2rpx(4);
  965. margin-left: px2rpx(10);
  966. color: #666;
  967. margin-bottom: px2rpx(10);
  968. height: px2rpx(48);
  969. width: px2rpx(100);
  970. font-size: px2rpx(16);
  971. line-height: px2rpx(48)!important;
  972. }
  973. .chart-container {
  974. margin-top: px2rpx(20);
  975. height: px2rpx(350);
  976. }
  977. .popup-content .form {
  978. padding: px2rpx(16);
  979. }
  980. .popup-content .form-item {
  981. margin-bottom: px2rpx(20);
  982. }
  983. .popup-content .form-label {
  984. display: block;
  985. font-size: px2rpx(14);
  986. color: #666;
  987. margin-bottom: px2rpx(8);
  988. }
  989. .popup-content .picker-value {
  990. display: flex;
  991. justify-content: space-between;
  992. align-items: center;
  993. padding: px2rpx(12);
  994. background: #f5f5f5;
  995. border-radius: 4px;
  996. font-size: px2rpx(14);
  997. color: #333;
  998. }
  999. .crm-cursor {
  1000. cursor: pointer;
  1001. }
  1002. .crm-border-radius {
  1003. border-radius: 8px;
  1004. }
  1005. </style>