index.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true" >
  3. <!-- <cwg-header :title="t('Home.page_ib.item1')" :showBack="false" />-->
  4. <uni-loading v-if="loading" />
  5. <uni-row v-else class="demo-uni-row uni-row1" :gutter="20">
  6. <uni-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  7. <view class="border-0 card-header ">
  8. <view class="d-flex flex-wrap gap-3 align-items-center justify-content-between mb-3" style="width: 100%;">
  9. <view class="mb-0 h3" style="align-self: flex-start">{{t('Home.msg.Ib')}}</view>
  10. <button type="button" class="btn btn-secondary btn-shadow waves-effect" @click="LinkActivity1">
  11. <cwg-icon name="crm-share-nodes" :size="16" color="#fff" />{{t('Ib.Index.CreateLink')}}</button>
  12. </view>
  13. </view>
  14. </uni-col>
  15. <uni-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="uni-col-left">
  16. <uni-row class="dashboard-container">
  17. <!-- 余额卡片 操作代码隐藏了,-->
  18. <!-- <cwg-dropdown :menu-list="menuList" @menuClick="handleMenuClick">-->
  19. <!-- <view class="pc-header-btn">-->
  20. <!-- <cwg-icon name="crm-ellipsis" :size="24" color="#000" />-->
  21. <!-- </view>-->
  22. <!-- </cwg-dropdown>-->
  23. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  24. <view class="card position-relative">
  25. <view class="card-body d-flex gap-3 align-items-center">
  26. <view class="clearfix pe-2 text-warning"> <img src="/static/images/dollar.png" alt="dollar" class="img-fluid"> </view>
  27. <view class="clearfix">
  28. <view class="mb-1">{{ t('news_add_field.Label.Balance') }}</view>
  29. <view class="mb-0 fw-bold ">${{ ibData.balance.toFixed(2) }}<text class="badge bg-danger-subtle text-danger">{{ t('Ib.Index.TotalRevenue') }}: ${{numberFormat(ibData.all || '0')}}</text></view>
  30. </view>
  31. </view>
  32. </view>
  33. </uni-col>
  34. <!-- 开户链接 -->
  35. <!-- <view class="card partner-card">-->
  36. <!-- <view class="card-header">-->
  37. <!-- <view class="header-left">-->
  38. <!-- <cwg-icon name="crm-share-nodes" :size="24" color="#000" />-->
  39. <!-- <text class="header-title">{{ t('Ib.Index.Link') }}</text>-->
  40. <!-- </view>-->
  41. <!-- </view>-->
  42. <!-- <view class="partner-content">-->
  43. <!-- <view class="link-area">-->
  44. <!-- <button class="link-btn" @click="LinkActivity1">-->
  45. <!-- {{ t('Ib.Index.CreateLink') }}-->
  46. <!-- </button>-->
  47. <!-- &lt;!&ndash; <button class="link-btn" @click="LinkActivity">&ndash;&gt;-->
  48. <!-- &lt;!&ndash; {{ t('Ib.Index.CreateLinkActivity') }}&ndash;&gt;-->
  49. <!-- &lt;!&ndash; </button>&ndash;&gt;-->
  50. <!-- </view>-->
  51. <!-- </view>-->
  52. <!-- </view>-->
  53. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  54. <view class="card position-relative stat-card-clickable" @click="toCustomManagement">
  55. <view class="card-body d-flex gap-3 align-items-center">
  56. <view class="clearfix pe-2 text-warning">
  57. <cwg-icon name="crm-user" :size="35" color="#FDBB1F" />
  58. </view>
  59. <view class="clearfix">
  60. <view class="mb-1">{{ t('Ib.Index.NameCustom') }}-{{ t('Ib.Index.Custom') }}</view>
  61. <view class="mb-0 fw-bold">{{ ibData.customAmount || '0' }}</view>
  62. </view>
  63. </view>
  64. </view>
  65. </uni-col>
  66. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  67. <view class="card position-relative stat-card-clickable" @click="toIbManagement">
  68. <view class="card-body d-flex gap-3 align-items-center">
  69. <view class="clearfix pe-2 text-warning">
  70. <cwg-icon name="crm-ib" :size="35" color="#FDBB1F" />
  71. </view>
  72. <view class="clearfix">
  73. <view class="mb-1">{{ t('Ib.Index.NameCustom') }}-{{ t('Ib.Index.Agent') }}</view>
  74. <view class="mb-0 fw-bold">{{ ibData.ibAmount || '0' }}</view>
  75. </view>
  76. </view>
  77. </view>
  78. </uni-col>
  79. <!-- 名下客户 -->
  80. <!-- <view class="card custom-card">-->
  81. <!-- <view class="card-header">-->
  82. <!-- <view class="header-left">-->
  83. <!-- <cwg-icon name="crm-custom" :size="24" color="#333" />-->
  84. <!-- <text class="header-title">{{ t('Ib.Index.NameCustom') }}</text>-->
  85. <!-- </view>-->
  86. <!-- </view>-->
  87. <!-- <view class="custom-content">-->
  88. <!-- <view class="con" @click="toCustomManagement">-->
  89. <!-- <view class="num">-->
  90. <!-- {{ ibData.customAmount || '0' }}-->
  91. <!-- </view>-->
  92. <!-- <view class="des">-->
  93. <!-- {{ t('Ib.Index.Custom') }}-->
  94. <!-- </view>-->
  95. <!-- </view>-->
  96. <!-- <view class="con" @click="toIbManagement">-->
  97. <!-- <view class="num">-->
  98. <!-- {{ ibData.ibAmount || '0' }}-->
  99. <!-- </view>-->
  100. <!-- <view class="des">-->
  101. <!-- {{ t('Ib.Index.Agent') }}-->
  102. <!-- </view>-->
  103. <!-- </view>-->
  104. <!-- </view>-->
  105. <!-- </view>-->
  106. <!-- 归属推荐码 -->
  107. <!-- <view class="card code-card">
  108. <view class="card-header">
  109. <view class="header-left">
  110. <text class="header-title">{{ t('Tips.AttributionCode') }}</text>
  111. <uni-tooltip placement="top">
  112. <text class="icon-tip">?</text>
  113. <template v-slot:content>
  114. <view style="width: 100px;">
  115. {{ t('Tips.tips') }}
  116. </view>
  117. </template>
  118. </uni-tooltip>
  119. </view>
  120. </view>
  121. <view class="code-content">
  122. <uni-easyinput class="code-input" :disabled="true" v-model="getInfoId" :clearable="false"></uni-easyinput>
  123. <button class="link-btn">{{ t('Ib.Index.Copy') }}</button>
  124. </view>
  125. </view>-->
  126. </uni-row>
  127. </uni-col>
  128. <uni-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="uni-col-right">
  129. <view class="card">
  130. <view class="card-body">
  131. <view class="d-flex flex-wrap gap-3 align-items-center justify-content-between mb-3 ">
  132. <view class="header-left">
  133. <text class="header-title">{{ t('Ib.Index.MAMList') }}</text>
  134. </view>
  135. <view class="header-right" v-if="showAddMamAccount">
  136. <cwg-dropdown :menu-list="addMamAccountMenus" @menuClick="handleAddMamAccountMenuClick">
  137. <button type="button" class="btn btn-danger btn-shadow waves-effect add-mam-btn">
  138. <cwg-icon name="icon_add" :size="16" color="#fff" />{{ t('Custom.Index.AddAccount') }}</button>
  139. </cwg-dropdown>
  140. </view>
  141. </view>
  142. <cwg-tabel ref="mamTableRef" :columns="mamColumns" :mobilePrimaryFields="mamMobilePrimaryFields"
  143. :queryParams="mamSearch" :api="mamListApi" :show-operation="false" :showPagination="true">
  144. <template #mamAccount="{ row }">
  145. <view v-if="row.type == 1 || row.type == 2">
  146. <text>{{ row.login || '-' }}</text>
  147. </view>
  148. <view v-else-if="row.type == 3">
  149. <view class="mam-line">
  150. <text>{{ t('Ib.PammManager.ownerId') }}:</text>
  151. <text>{{ row.ownerId || '--' }}</text>
  152. </view>
  153. <view class="mam-line">
  154. <text>{{ t('Ib.PammManager.accountId') }}:</text>
  155. <text>{{ row.accountId || '--' }}</text>
  156. </view>
  157. <view class="mam-line">
  158. <text>{{ t('Ib.PammManager.percent') }}:</text>
  159. <text>{{ (row.percent ?? '--') + '%' }}</text>
  160. </view>
  161. </view>
  162. </template>
  163. <template #mamType="{ row }">
  164. <text>{{ formatMamType(row.type) }}</text>
  165. </template>
  166. <template #loginType="{ row }">
  167. <text>{{ formatAccountType(row.accountType) }}</text>
  168. </template>
  169. <template #leverage="{ row }">
  170. <text>{{ row.leverage ? '1:' + row.leverage : '-' }}</text>
  171. </template>
  172. <template #balance="{ row }">
  173. <text>{{ numberFormat(row.balance || 0) }}</text>
  174. </template>
  175. <template #equity="{ row }">
  176. <text>{{ numberFormat(row.equity || 0) }}</text>
  177. </template>
  178. <template #operation="{ row }">
  179. <view class="mam-ops">
  180. <view v-if="row.type == 1 || row.type == 2" class="mam-op" @click.stop="toSettings(row)">
  181. <text>{{ t('Ib.Index.Settings') }}</text>
  182. </view>
  183. <view v-if="row.type == 3" class="mam-op" @click.stop="toSettings(row)">
  184. <text>{{ t('Ib.PammManager.btn1') }}</text>
  185. </view>
  186. <view v-if="row.type == 3" class="mam-op" @click.stop="toDialogPercent(row)">
  187. <text>{{ t('Ib.PammManager.percent') }}</text>
  188. </view>
  189. <view class="mam-op" @click.stop="toDialogSubs(row)">
  190. <text>{{ t('blockchain.item1') }}</text>
  191. </view>
  192. </view>
  193. </template>
  194. </cwg-tabel>
  195. </view>
  196. </view>
  197. </uni-col>
  198. </uni-row>
  199. <!-- 调整收益分成弹窗 -->
  200. <cwg-popup :visible="dialogPercent" :title="t('Ib.PammManager.percent')" @close="closeDialogPercent"
  201. @confirm="applyPercent">
  202. <view class="dia-content custom-dialog-content">
  203. <uni-forms :model="dialogPercentData" label-width="150" label-position="left">
  204. <uni-forms-item :label="t('Ib.PammManager.ownerId') + ':'">
  205. <text class="info-text">{{ dialogPercentData.oldOwnerId || '--' }}</text>
  206. </uni-forms-item>
  207. <uni-forms-item :label="t('Ib.PammManager.accountId') + ':'">
  208. <text class="info-text">{{ dialogPercentData.oldAccountId || '--' }}</text>
  209. </uni-forms-item>
  210. <uni-forms-item :label="t('Ib.PammManager.percent') + ':'">
  211. <text class="info-text">{{ dialogPercentData.oldPercent }}%</text>
  212. </uni-forms-item>
  213. <uni-forms-item :label="t('Ib.PammManager.percentNew') + ':'" name="percent" required>
  214. <uni-easyinput v-model="dialogPercentData.percent" :placeholder="t('placeholder.input')" />
  215. </uni-forms-item>
  216. </uni-forms>
  217. </view>
  218. </cwg-popup>
  219. <!-- 子账户数量弹窗 -->
  220. <cwg-popup v-model:visible="isSubsDialogVisible" type="center" :title="t('blockchain.item1')" :showFooters="true"
  221. @close="isSubsDialogVisible = false" @confirm="isSubsDialogVisible = false">
  222. <view class="dia-content custom-dialog-content" style="padding: 10px 0; max-height: 50vh; overflow-y: auto;">
  223. <cwg-tabel :data="agentId_level" :columns="[
  224. { label: t('Ib.Index.TradingAccount'), prop: 'login', align: 'center' },
  225. { label: t('Ib.Index.Balance'), prop: 'balance', align: 'center' }
  226. ]" :showPagination="false" :showOperation="false" style="margin-bottom: 20px" />
  227. </view>
  228. </cwg-popup>
  229. </cwg-page-wrapper>
  230. </template>
  231. <script setup>
  232. import { ref, computed, watch, onMounted, nextTick } from 'vue'
  233. import { useI18n } from 'vue-i18n'
  234. import useRouter from '@/hooks/useRouter'
  235. import { ibApi } from '@/service/ib'
  236. import config from '@/config/index'
  237. import useUserStore from '@/stores/use-user-store'
  238. import { useStorage } from '@/hooks/useStorage'
  239. import QrCode from '@/components/QrCode.vue'
  240. import { useFilters } from '@/composables/useFilters'
  241. import { isAfterJuly28 } from '@/utils/dateUtils'
  242. import useGlobalStore from '@/stores/use-global-store'
  243. const { t } = useI18n()
  244. const loading = ref(false)
  245. const router = useRouter()
  246. const { Code } = config
  247. const { userInfo } = useUserStore()
  248. const { numberFormat } = useFilters()
  249. const globalStore = useGlobalStore()
  250. // 数据
  251. const totalEarnings = ref(0.00)
  252. const partnerLink = ref('https://one.exnessonelink.com/a/plokue4yj3')
  253. const partnerCode = ref('PLOKUE4YJ3')
  254. const activeTab = ref('link') // 'link' 或 'code'
  255. const isDark = computed(() => globalStore.theme === 'dark')
  256. const ibData = ref({
  257. customAmount: 0,
  258. ibAmount: 0,
  259. },
  260. )
  261. const selectedSpreadId = ref('')
  262. const spreadList = ref([])
  263. const excludeShowLoginTypes = ref([])
  264. const pammManagerValid = ref()
  265. const dialogPercent = ref(false)
  266. const dialogPercentData = ref({
  267. oldPercent: '',
  268. mamListId: '',
  269. oldOwnerId: '',
  270. oldAccountId: '',
  271. percent: '',
  272. })
  273. const isActionLoading = ref(false)
  274. const menuList = computed(() => [
  275. { label: t('Custom.Index.Withdrawals'), type: 1 },
  276. { label: t('Home.page_ib.item4'), type: 2 },
  277. { label: t('Ib.Transfer.CommissionIssue'), type: 3 },
  278. ])
  279. const excludeList = ref([])
  280. const excludeLists = ref([
  281. { text: t('AccountType.SeniorAccount'), value: '2' },
  282. // {text: t('AccountType.SeniorAccount'),value: '3'},
  283. { text: t('AccountType.StandardAccount'), value: '7' },
  284. { text: t('AccountType.CentAccount'), value: '8' },
  285. ])
  286. const link = ref('')
  287. const loginTypes = ref('')
  288. const ibInvalid = ref('B0')
  289. const qrCode = ref(null)
  290. const qrCode1 = ref(null)
  291. // 语言
  292. const lang = useStorage('lang')
  293. const flag = ref(false)
  294. const agentLinkList = ref([])
  295. const activityLing = ref('')
  296. const linkActivity = ref('')
  297. const commission = ref('')
  298. const linkActivityPopup = ref(null)
  299. // 开户链接
  300. const linkPopup = ref(null)
  301. const qrSize = ref(200)
  302. const levelNum = computed(() => {
  303. return userInfo.ibInfo.levelNum
  304. })
  305. const fixedHide = computed(() => {
  306. return userInfo.ibInfo.fixedHide
  307. })
  308. const getInfoId = computed(() => {
  309. return userInfo.ibInfo.id
  310. })
  311. const balanceInt = computed(() => {
  312. return numberFormat(ibData.value?.balance || 0, true)[0]
  313. })
  314. const balanceDecimal = computed(() => {
  315. return numberFormat(ibData.value?.balance || 0, true)[1] || '00'
  316. })
  317. // 国家
  318. const country = computed(() => {
  319. console.log(userInfo.customInfo.country, '2')
  320. return userInfo.customInfo.country
  321. })
  322. // 修改多选
  323. const handleChange = (val) => {
  324. excludeShowLoginTypes.value = val
  325. }
  326. const isAfterJuly7 = () => {
  327. const currentDate = new Date()
  328. const july7 = new Date(currentDate.getFullYear(), 6, 7) // 月份从0开始,6表示7月
  329. return currentDate >= july7
  330. }
  331. const getValidAccountTypes = (selectedExcludeValues, selectedSpreadId) => {
  332. const spread = spreadList.value.find(
  333. (item) => item.id === selectedSpreadId,
  334. )
  335. let data = {
  336. hide: '',
  337. commission: '',
  338. excludeShowLoginTypes: [],
  339. }
  340. if (!spread) return data
  341. const validValues = selectedExcludeValues.filter((value) =>
  342. spread.loginTypes.includes(value),
  343. )
  344. const invalidValues = selectedExcludeValues.filter(
  345. (value) => !spread.loginTypes.includes(value),
  346. )
  347. const invalidLabels = excludeList.value
  348. .filter((item) => invalidValues.includes(item.value))
  349. .map((item) => item.label)
  350. const excludeTypes = excludeLists.value
  351. .filter((item) => !validValues.includes(item.value))
  352. .map((item) => item.value)
  353. loginTypes.value = invalidLabels.join('、')
  354. return {
  355. hide: spread.hide,
  356. commission: spread.comPoint,
  357. excludeShowLoginTypes: excludeTypes,
  358. invalidLabels,
  359. invalidValues,
  360. }
  361. }
  362. const downloadQrCode = (type = 0) => {
  363. if (type === 1) {
  364. qrCode1.value.download()
  365. } else {
  366. qrCode.value.download()
  367. }
  368. }
  369. // 复制
  370. const CopyShareLink = (value) => {
  371. uni.setClipboardData({ data: value })
  372. }
  373. const getLink1 = async () => {
  374. console.log(excludeShowLoginTypes.value, 2)
  375. if (excludeShowLoginTypes.value.length == 0) {
  376. uni.showToast({
  377. title: t('Ib.Index.Spread5'), icon: 'none',
  378. })
  379. link.value = ''
  380. return
  381. }
  382. if (!selectedSpreadId.value.length) {
  383. uni.showToast({
  384. title: t('Ib.Index.Spread4'), icon: 'none',
  385. })
  386. link.value = ''
  387. return
  388. }
  389. const validList = getValidAccountTypes(
  390. excludeShowLoginTypes.value,
  391. selectedSpreadId.value,
  392. )
  393. if (validList.invalidLabels.length > 0) {
  394. return new Promise((resolve) => {
  395. uni.showModal({
  396. title: t('Msg.SystemPrompt'),
  397. content: `${t('Ib.Index.Spread1')}${loginTypes.value
  398. }${t('')}`,
  399. confirmText: t('Btn.Confirm'),
  400. cancelText: t('Btn.Cancel'),
  401. success: async (res) => {
  402. if (res.confirm) {
  403. const res = await ibApi.customLink(validList)
  404. if (res.code === Code.StatusOK) {
  405. uni.showToast({
  406. title: res.msg,
  407. icon: 'none',
  408. })
  409. resolve(res.data)
  410. } else {
  411. uni.showToast({
  412. title: res.msg,
  413. icon: 'none',
  414. })
  415. resolve('')
  416. }
  417. }
  418. },
  419. fail: () => resolve(''),
  420. })
  421. })
  422. } else {
  423. const res = await ibApi.customLink(validList)
  424. if (res.code === Code.StatusOK) {
  425. uni.showToast({
  426. title: res.msg,
  427. icon: 'none',
  428. })
  429. return res.data
  430. } else {
  431. uni.showToast({
  432. title: res.msg,
  433. icon: 'none',
  434. })
  435. return ''
  436. }
  437. }
  438. }
  439. const CreateLink = async () => {
  440. const linkValue = await getLink1()
  441. if (!linkValue) return
  442. link.value = `${Host80}/#/signup/${getInfoId.value}/${linkValue}/${ibInvalid.value}`
  443. }
  444. const loginTypeList = async () => {
  445. const res = await ibApi.loginTypeList(
  446. {
  447. page: {
  448. current: 1,
  449. row: 100,
  450. },
  451. },
  452. )
  453. if (res.code === Code.StatusOK) {
  454. spreadList.value = res.data
  455. } else {
  456. uni.showToast({ title: res.msg, icon: 'none' })
  457. }
  458. }
  459. const getAgentAccountSetting = async () => {
  460. const { agentAccountSetting = '' } = userInfo.ibInfo ?? {}
  461. if (agentAccountSetting === 0) {
  462. const excludeValues = userInfo.customInfo.excludeShowLoginTypes
  463. try {
  464. excludeList.value = excludeLists.value.filter(
  465. (item) => !excludeValues.includes(item.value),
  466. )
  467. excludeShowLoginTypes.value = []
  468. } catch (e) {
  469. excludeShowLoginTypes.value = []
  470. excludeList.value = excludeLists.value
  471. }
  472. } else {
  473. excludeShowLoginTypes.value = []
  474. excludeList.value = excludeLists.value
  475. }
  476. }
  477. // 生成开户链接
  478. const LinkActivity1 = async () => {
  479. // 跳转到开户链接页面
  480. uni.navigateTo({
  481. url: '/pages/ib/linkList',
  482. })
  483. }
  484. const handleMenuClick = ({ value }) => {
  485. console.log(value.type)
  486. if (value.type === 1) {
  487. toWithdraw()
  488. } else if (value.type === 2) {
  489. toTransfer()
  490. } else {
  491. toTransfer(2)
  492. }
  493. }
  494. const toWithdraw = () => {
  495. router.push({
  496. path: '/pages/ib/withdraw-select',
  497. },
  498. )
  499. }
  500. const toTransfer = (tab = 1) => {
  501. router.push({
  502. path: '/pages/ib/transfer',
  503. query: { tab },
  504. },
  505. )
  506. }
  507. const toCustomManagement = () => {
  508. router.push({
  509. path: '/pages/ib/customer',
  510. query: { type: 3 },
  511. },
  512. )
  513. }
  514. const toIbManagement = () => {
  515. router.push({
  516. path: '/pages/ib/subsList',
  517. query: { type: 2 },
  518. },
  519. )
  520. }
  521. const getIbData = async () => {
  522. const res = await ibApi.IbData()
  523. if (res.code === Code.StatusOK) {
  524. if (res.data != null)
  525. ibData.value = res.data
  526. } else {
  527. uni.showToast({ title: res.msg, icon: 'none' })
  528. }
  529. }
  530. const getPammManagerValid = async () => {
  531. // 没有ib状态不调用
  532. if (!userInfo.ibInfo) {
  533. return
  534. }
  535. const res = await ibApi.mamApplyPammManagerValid()
  536. if (res.code === Code.StatusOK) {
  537. if (res.data != null)
  538. pammManagerValid.value = res.data
  539. } else {
  540. uni.showToast({ title: res.msg, icon: 'none' })
  541. }
  542. }
  543. const mamTableRef = ref(null)
  544. const mamSearch = ref({})
  545. const mamListApi = computed(() => {
  546. // 模拟,没有ib不调用接口
  547. if (!userInfo.ibInfo) {
  548. return (params) => new Promise(resolve => {
  549. resolve({
  550. code: 200,
  551. data: [],
  552. })
  553. })
  554. }
  555. return (params) => ibApi.MamList(params)
  556. })
  557. const showAddMamAccount = computed(() => {
  558. return !!(
  559. pammManagerValid.value?.mamValid ||
  560. pammManagerValid.value?.pammValid ||
  561. pammManagerValid.value?.pammManagerValid
  562. )
  563. })
  564. const addMamAccountMenus = computed(() => {
  565. const list = []
  566. if (pammManagerValid.value?.mamValid) list.push({ label: 'MAM', type: 1 })
  567. if (pammManagerValid.value?.pammValid) list.push({ label: 'Money Manager', type: 2 })
  568. if (pammManagerValid.value?.pammManagerValid) list.push({ label: t('Ib.PammManager.title'), type: 3 })
  569. return list
  570. })
  571. const handleAddMamAccountMenuClick = ({ value }) => {
  572. toNewAccount(value.type)
  573. }
  574. const formatMamType = (type) => {
  575. if (type == 1) return 'MAM'
  576. if (type == 2) return 'Money Manager'
  577. if (type == 3) return t('Ib.PammManager.title1')
  578. return '--'
  579. }
  580. const formatAccountType = (accountType) => {
  581. if (accountType == 1) return t('AccountType.ClassicAccount')
  582. if (accountType == 2) return t('AccountType.SeniorAccount')
  583. if (accountType == 3 && !isAfterJuly28()) return t('AccountType.AgencyAccount')
  584. if (accountType == 5) return t('AccountType.SpeedAccount')
  585. if (accountType == 6) return t('AccountType.SpeedAccount')
  586. if (accountType == 7) return t('AccountType.StandardAccount')
  587. if (accountType == 8) return t('AccountType.CentAccount')
  588. return '--'
  589. }
  590. const mamColumns = computed(() => [
  591. { prop: 'mamAccount', label: t('Ib.Index.MAMAccount'), align: 'center', slot: 'mamAccount' },
  592. { prop: 'type', label: t('Label.Type'), align: 'center', slot: 'mamType' },
  593. { prop: 'accountType', label: t('Ib.Index.LoginType'), align: 'center', slot: 'loginType' },
  594. { prop: 'platform', label: t('Ib.Index.Platform'), align: 'center' },
  595. { prop: 'currency', label: t('Ib.Index.Currency'), align: 'center' },
  596. { prop: 'leverage', label: t('Ib.Index.Leverage'), align: 'center', slot: 'leverage' },
  597. { prop: 'balance', label: t('Ib.Index.Balance'), align: 'center', slot: 'balance' },
  598. { prop: 'equity', label: t('Ib.Index.Equity'), align: 'center', slot: 'equity' },
  599. { prop: 'commission', label: t('Ib.Index.Commission'), align: 'center' },
  600. { prop: 'operation', label: t('Ib.Index.Operation'), align: 'center', slot: 'operation' },
  601. ])
  602. const mamMobilePrimaryFields = computed(() => [
  603. { prop: 'mamAccount', label: t('Ib.Index.MAMAccount'), align: 'center', slot: 'mamAccount' },
  604. { prop: 'type', label: t('Label.Type'), align: 'center', slot: 'mamType' },
  605. { prop: 'platform', label: t('Ib.Index.Platform'), align: 'center' },
  606. { prop: 'more', type: 'more', width: 20, align: 'right' },
  607. ])
  608. const toNewAccount = (type) => {
  609. if (type == 3) {
  610. router.push({
  611. path: '/pages/ib/openPammManager',
  612. query: {
  613. type: type,
  614. },
  615. })
  616. } else {
  617. router.push({
  618. path: '/pages/ib/openAccount',
  619. query: {
  620. type: type,
  621. },
  622. })
  623. }
  624. }
  625. const toSettings = (row) => {
  626. router.push({
  627. path: '/pages/ib/settingPammManager',
  628. query: { login: row.accountId, id: row.id },
  629. })
  630. }
  631. const toDialogPercent = (row) => {
  632. dialogPercentData.value.oldPercent = row.percent
  633. dialogPercentData.value.mamListId = row.id
  634. dialogPercentData.value.oldOwnerId = row.ownerId
  635. dialogPercentData.value.oldAccountId = row.accountId
  636. dialogPercentData.value.percent = ''
  637. dialogPercent.value = true
  638. }
  639. const closeDialogPercent = () => {
  640. dialogPercent.value = false
  641. }
  642. const applyPercent = async () => {
  643. if (isActionLoading.value) return
  644. if (!dialogPercentData.value.percent) {
  645. uni.showToast({ title: t('placeholder.input'), icon: 'none' })
  646. return
  647. }
  648. isActionLoading.value = true
  649. try {
  650. const res = await ibApi.applyPercent({
  651. mamListId: dialogPercentData.value.mamListId,
  652. percent: dialogPercentData.value.percent,
  653. })
  654. if (res.code === Code.StatusOK) {
  655. uni.showToast({ title: res.msg, icon: 'success' })
  656. dialogPercent.value = false
  657. // Refresh MAM list
  658. mamTableRef.value?.refreshTable()
  659. } else {
  660. uni.showToast({ title: res.msg, icon: 'none' })
  661. }
  662. } catch (error) {
  663. uni.showToast({ title: t('Msg.Fail'), icon: 'none' })
  664. } finally {
  665. isActionLoading.value = false
  666. }
  667. }
  668. const isSubsDialogVisible = ref(false)
  669. const agentId_level = ref([])
  670. const toDialogSubs = async (row) => {
  671. agentId_level.value = []
  672. try {
  673. const res = await ibApi.pammListSubs({ id: row.id })
  674. if (res.code === Code.StatusOK) {
  675. agentId_level.value = res.data || []
  676. } else {
  677. uni.showToast({ title: res.msg, icon: 'none' })
  678. }
  679. } catch (e) {
  680. // uni.showToast({ title: t('Msg.Fail'), icon: 'none' })
  681. }
  682. nextTick(() => {
  683. isSubsDialogVisible.value = true
  684. })
  685. }
  686. onMounted(async () => {
  687. let a= numberFormat(80.7)
  688. console.log(a)
  689. loading.value = true
  690. // 初始化数据
  691. await getIbData()
  692. await getPammManagerValid()
  693. loading.value = false
  694. })
  695. </script>
  696. <style lang="scss" scoped>
  697. @import "@/uni.scss";
  698. .clearfix{
  699. .fw-bold{
  700. color: var(--bs-emphasis-color);
  701. }
  702. }
  703. .demo-uni-row {
  704. display: flex;
  705. flex-wrap: wrap;
  706. align-items: stretch;
  707. margin: 0 auto !important;
  708. }
  709. .uni-col-left {
  710. display: flex;
  711. flex-direction: column;
  712. }
  713. .uni-col-right {
  714. display: flex;
  715. flex-direction: column;
  716. }
  717. .dashboard-container {
  718. min-height: 10vh;
  719. box-sizing: border-box;
  720. height: 100%;
  721. }
  722. .mam-card {
  723. flex: 1;
  724. display: flex;
  725. flex-direction: column;
  726. }
  727. /* 卡片通用样式 */
  728. .card {
  729. border-radius: px2rpx(8);
  730. box-shadow: 0 px2rpx(2) px2rpx(8) rgba(0, 0, 0, 0.06);
  731. //background: var(--bs-body-bg);
  732. //color: var(--bs-emphasis-color);
  733. //padding: px2rpx(12) px2rpx(16);
  734. //border-radius: 4rpx;
  735. flex: 1;
  736. margin: 0 px2rpx(5) px2rpx(10);
  737. //box-shadow: 0 px2rpx(4) px2rpx(12) rgba(0, 0, 0, 0.2);
  738. display: flex;
  739. flex-direction: column;
  740. min-height: px2rpx(110);
  741. }
  742. .stat-card-clickable {
  743. cursor: pointer;
  744. &:hover {
  745. box-shadow: 0 px2rpx(4) px2rpx(12) rgba(0, 0, 0, 0.1);
  746. }
  747. }
  748. .dashboard-container .card-body {
  749. flex: 1;
  750. display: flex;
  751. align-items: center;
  752. padding: px2rpx(16);
  753. }
  754. .custom-dialog-content {
  755. padding: px2rpx(20);
  756. .info-text {
  757. color: var(--bs-heading-color);
  758. font-size: px2rpx(14);
  759. line-height: px2rpx(36);
  760. }
  761. }
  762. .card-header {
  763. display: flex;
  764. justify-content: space-between;
  765. align-items: center;
  766. margin-bottom: px2rpx(12);
  767. .btn{
  768. margin: 0;
  769. display: flex;
  770. align-items: center;
  771. }
  772. }
  773. .header-left {
  774. display: flex;
  775. align-items: center;
  776. gap: 12rpx;
  777. }
  778. .header-title {
  779. font-size: px2rpx(24.5);
  780. font-weight: 600;
  781. color: var(--bs-emphasis-color);
  782. }
  783. .header-right {
  784. display: flex;
  785. align-items: center;
  786. }
  787. .action-btn {
  788. background: #ffde02;
  789. border: none;
  790. border-radius: 50%;
  791. width: px2rpx(32);
  792. height: px2rpx(32);
  793. display: flex;
  794. align-items: center;
  795. justify-content: center;
  796. padding: 0;
  797. margin: 0;
  798. &:after {
  799. border: none;
  800. }
  801. }
  802. /* 余额区域 */
  803. .balance-content {
  804. display: flex;
  805. flex-direction: column;
  806. align-items: center;
  807. gap: 16rpx;
  808. }
  809. .balance-main {
  810. display: flex;
  811. align-items: baseline;
  812. flex-wrap: wrap;
  813. }
  814. .balance-amount {
  815. font-size: px2rpx(20);
  816. font-weight: 700;
  817. line-height: 1;
  818. }
  819. .balance-decimal {
  820. font-size: px2rpx(16);
  821. font-weight: 500;
  822. line-height: 1;
  823. }
  824. .balance-currency {
  825. font-size: px2rpx(16);
  826. font-weight: 500;
  827. }
  828. .total-earnings {
  829. display: flex;
  830. align-items: center;
  831. gap: 5px;
  832. color: var(--bs-emphasis-color);
  833. font-size: px2rpx(12);
  834. }
  835. .total-value {
  836. align-self: flex-end;
  837. }
  838. /* 合作伙伴卡片 */
  839. .partner-content {
  840. display: flex;
  841. flex-direction: column;
  842. gap: 12px;
  843. }
  844. .link-area {
  845. display: flex;
  846. flex-wrap: wrap;
  847. justify-content: space-around;
  848. align-items: center;
  849. gap: 12px;
  850. }
  851. .link-btn {
  852. height: px2rpx(32);
  853. background-color: rgb(108, 133, 149);
  854. line-height: px2rpx(32);
  855. color: var(--color-white);
  856. border-radius: px2rpx(16);
  857. font-size: px2rpx(14);
  858. margin: 0;
  859. }
  860. .code-content {
  861. display: flex;
  862. justify-content: center;
  863. }
  864. .code-input {
  865. width: 50%;
  866. max-width: px2rpx(178);
  867. margin-right: px2rpx(20);
  868. }
  869. .custom-content {
  870. display: flex;
  871. justify-content: space-around;
  872. flex-wrap: wrap;
  873. .con {
  874. cursor: pointer;
  875. text-align: center;
  876. font-size: px2rpx(16);
  877. margin: 5px;
  878. }
  879. .num {
  880. font-weight: bold;
  881. }
  882. .des {
  883. margin-top: px2rpx(5);
  884. }
  885. }
  886. .dia-content {
  887. padding: 20rpx;
  888. }
  889. .content {
  890. display: flex;
  891. flex-direction: column;
  892. gap: 20rpx;
  893. }
  894. .label {
  895. font-weight: 500;
  896. margin-bottom: 8rpx;
  897. }
  898. .btn {
  899. margin-top: 16rpx;
  900. text-align: center;
  901. }
  902. .crm-cursor {
  903. cursor: pointer;
  904. }
  905. .link {
  906. display: flex;
  907. margin-top: 20rpx;
  908. .btn {
  909. display: flex;
  910. align-items: center;
  911. justify-content: center;
  912. height: px2rpx(35);
  913. margin: 0 px2rpx(10);
  914. }
  915. }
  916. .qrCode {
  917. display: flex;
  918. flex-direction: column;
  919. align-items: center;
  920. gap: 16rpx;
  921. }
  922. .add-mam-btn {
  923. display: flex;
  924. justify-content: center;
  925. }
  926. .mam-line {
  927. display: flex;
  928. justify-content: center;
  929. gap: 6rpx;
  930. line-height: 1.5;
  931. }
  932. .mam-ops {
  933. display: flex;
  934. flex-wrap: wrap;
  935. justify-content: center;
  936. cursor: pointer;
  937. gap: 10rpx;
  938. }
  939. .mam-op {
  940. color: #2b5aed;
  941. font-size: px2rpx(12);
  942. line-height: 1.4;
  943. }
  944. </style>