index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  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">{{t('Ib.Index.Welcome')}}</view>
  10. <button type="button" class="btn btn-secondary btn-shadow waves-effect" @click="LinkActivity1">
  11. <cwg-icon name="crm-share-nodes" :size="24" 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">${{ balanceInt }}.{{ balanceDecimal }}<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">
  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" @click="toCustomManagement">
  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">
  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-user" :size="35" color="#FDBB1F" />
  71. </view>
  72. <view class="clearfix" @click="toIbManagement">
  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-secondary 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. loading.value = true
  688. // 初始化数据
  689. await getIbData()
  690. await getPammManagerValid()
  691. loading.value = false
  692. })
  693. </script>
  694. <style lang="scss" scoped>
  695. @import "@/uni.scss";
  696. .demo-uni-row {
  697. display: flex;
  698. flex-wrap: wrap;
  699. align-items: stretch;
  700. margin: 0 auto !important;
  701. }
  702. .uni-col-left {
  703. display: flex;
  704. flex-direction: column;
  705. }
  706. .uni-col-right {
  707. display: flex;
  708. flex-direction: column;
  709. }
  710. .dashboard-container {
  711. min-height: 10vh;
  712. box-sizing: border-box;
  713. height: 100%;
  714. }
  715. .mam-card {
  716. flex: 1;
  717. display: flex;
  718. flex-direction: column;
  719. }
  720. /* 卡片通用样式 */
  721. .card {
  722. //background: var(--bs-body-bg);
  723. //color: var(--bs-emphasis-color);
  724. //padding: px2rpx(12) px2rpx(16);
  725. //border-radius: 4rpx;
  726. flex: 1;
  727. margin: 0 px2rpx(5) px2rpx(10);
  728. //box-shadow: 0 px2rpx(4) px2rpx(12) rgba(0, 0, 0, 0.2);
  729. display: flex;
  730. flex-direction: column;
  731. min-height: px2rpx(110);
  732. }
  733. .dashboard-container .card-body {
  734. flex: 1;
  735. display: flex;
  736. align-items: center;
  737. padding: px2rpx(16);
  738. }
  739. .custom-dialog-content {
  740. padding: px2rpx(20);
  741. .info-text {
  742. color: var(--bs-heading-color);
  743. font-size: px2rpx(14);
  744. line-height: px2rpx(36);
  745. }
  746. }
  747. .card-header {
  748. display: flex;
  749. justify-content: space-between;
  750. align-items: center;
  751. margin-bottom: px2rpx(12);
  752. .btn{
  753. margin: 0;
  754. display: flex;
  755. align-items: center;
  756. }
  757. }
  758. .header-left {
  759. display: flex;
  760. align-items: center;
  761. gap: 12rpx;
  762. }
  763. .header-title {
  764. font-size: px2rpx(24.5);
  765. font-weight: 600;
  766. }
  767. .header-right {
  768. display: flex;
  769. align-items: center;
  770. }
  771. .action-btn {
  772. background: #ffde02;
  773. border: none;
  774. border-radius: 50%;
  775. width: px2rpx(32);
  776. height: px2rpx(32);
  777. display: flex;
  778. align-items: center;
  779. justify-content: center;
  780. padding: 0;
  781. margin: 0;
  782. &:after {
  783. border: none;
  784. }
  785. }
  786. /* 余额区域 */
  787. .balance-content {
  788. display: flex;
  789. flex-direction: column;
  790. align-items: center;
  791. gap: 16rpx;
  792. }
  793. .balance-main {
  794. display: flex;
  795. align-items: baseline;
  796. flex-wrap: wrap;
  797. }
  798. .balance-amount {
  799. font-size: px2rpx(20);
  800. font-weight: 700;
  801. line-height: 1;
  802. }
  803. .balance-decimal {
  804. font-size: px2rpx(16);
  805. font-weight: 500;
  806. line-height: 1;
  807. }
  808. .balance-currency {
  809. font-size: px2rpx(16);
  810. font-weight: 500;
  811. }
  812. .total-earnings {
  813. display: flex;
  814. align-items: center;
  815. gap: 5px;
  816. color: var(--bs-emphasis-color);
  817. font-size: px2rpx(12);
  818. }
  819. .total-value {
  820. align-self: flex-end;
  821. }
  822. /* 合作伙伴卡片 */
  823. .partner-content {
  824. display: flex;
  825. flex-direction: column;
  826. gap: 12px;
  827. }
  828. .link-area {
  829. display: flex;
  830. flex-wrap: wrap;
  831. justify-content: space-around;
  832. align-items: center;
  833. gap: 12px;
  834. }
  835. .link-btn {
  836. height: px2rpx(32);
  837. background-color: rgb(108, 133, 149);
  838. line-height: px2rpx(32);
  839. color: var(--color-white);
  840. border-radius: px2rpx(16);
  841. font-size: px2rpx(14);
  842. margin: 0;
  843. }
  844. .code-content {
  845. display: flex;
  846. justify-content: center;
  847. }
  848. .code-input {
  849. width: 50%;
  850. max-width: px2rpx(178);
  851. margin-right: px2rpx(20);
  852. }
  853. .custom-content {
  854. display: flex;
  855. justify-content: space-around;
  856. flex-wrap: wrap;
  857. .con {
  858. cursor: pointer;
  859. text-align: center;
  860. font-size: px2rpx(16);
  861. margin: 5px;
  862. }
  863. .num {
  864. font-weight: bold;
  865. }
  866. .des {
  867. margin-top: px2rpx(5);
  868. }
  869. }
  870. .dia-content {
  871. padding: 20rpx;
  872. }
  873. .content {
  874. display: flex;
  875. flex-direction: column;
  876. gap: 20rpx;
  877. }
  878. .label {
  879. font-weight: 500;
  880. margin-bottom: 8rpx;
  881. }
  882. .btn {
  883. margin-top: 16rpx;
  884. text-align: center;
  885. }
  886. .crm-cursor {
  887. cursor: pointer;
  888. }
  889. .link {
  890. display: flex;
  891. margin-top: 20rpx;
  892. .btn {
  893. display: flex;
  894. align-items: center;
  895. justify-content: center;
  896. height: px2rpx(35);
  897. margin: 0 px2rpx(10);
  898. }
  899. }
  900. .qrCode {
  901. display: flex;
  902. flex-direction: column;
  903. align-items: center;
  904. gap: 16rpx;
  905. }
  906. .add-mam-btn {
  907. display: flex;
  908. justify-content: center;
  909. }
  910. .mam-line {
  911. display: flex;
  912. justify-content: center;
  913. gap: 6rpx;
  914. line-height: 1.5;
  915. }
  916. .mam-ops {
  917. display: flex;
  918. flex-wrap: wrap;
  919. justify-content: center;
  920. gap: 10rpx;
  921. }
  922. .mam-op {
  923. color: #2b5aed;
  924. font-size: px2rpx(12);
  925. line-height: 1.4;
  926. }
  927. </style>