index.vue 29 KB

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