dashboard.vue 31 KB

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