index.vue 33 KB

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