index.vue 28 KB

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