cwg-sidebar.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <view class="cwg-sidebar">
  3. <view class="wallet-widget">
  4. <view class="wallet-header" :class="{ 'header-bottom': isWalletOpen }" @click="isWalletOpen = !isWalletOpen">
  5. <view v-if="mode == 'follow'" class="wallet-header-left">
  6. <cwg-icon name="crm-payment" :size="16" color="#97A1C0" />
  7. <text>{{ t('Documentary.console.item14') }}</text>
  8. <text class="wallet-header-text">{{ followBalance }} USD</text>
  9. </view>
  10. <view v-else class="wallet-header-left">
  11. <cwg-icon name="crm-payment" :size="16" color="#97A1C0" />
  12. <text>{{ t(mode === 'customer' ? 'wallet.item5' : 'news_add_field.Label.Balance') }}</text>
  13. <text class="wallet-header-text">{{ mode === 'customer' ? formattedBalance : ibBalance }} USD</text>
  14. </view>
  15. <view class="wallet-header-right" :class="{ 'expanded': isWalletOpen }">
  16. <cwg-icon name="crm-chevron-down" :size="16" color="#6c8595" />
  17. </view>
  18. </view>
  19. <view class="wallet-body" v-if="isWalletOpen">
  20. <view class="wallet-body-header">
  21. <text class="drawer-title">{{t('vu.item21')}}</text>
  22. <switch :checked="!isShow" @change="toggleShow" color="#97A1C0"
  23. style="transform:scale(0.7); margin-right: -10px;" />
  24. </view>
  25. <view class="wallet-body-content">
  26. <template v-if="mode === 'follow'">
  27. <view class="balance-amount">{{ followBalance }} USD</view>
  28. </template>
  29. <template v-else>
  30. <view class="balance-amount">{{ mode === 'customer' ? formattedBalance : ibBalance }} USD</view>
  31. <view class="wallet-type">{{ mode === 'customer' ? t('wallet.pendingWithdraw') :
  32. t('Ib.Index.TotalRevenue') }}
  33. </view>
  34. <view class="wallet-id-box">
  35. ${{ mode === 'customer' ? formattedPendingWithdrawAmount : ibTotalBalance }}
  36. </view>
  37. </template>
  38. </view>
  39. <view class="wallet-actions" v-if="mode === 'customer'">
  40. <button class="action-btn btn btn-outline-danger waves-effect waves-light" @click.stop="goPages(1)"
  41. v-t="'wallet.item6'"></button>
  42. <button class="action-btn btn btn-outline-danger waves-effect waves-light" @click.stop="goPages(2)"
  43. v-t="'wallet.item7'"></button>
  44. </view>
  45. <view class="wallet-actions" v-if="mode === 'ib'">
  46. <button class="action-btn btn btn-outline-danger waves-effect waves-light" @click.stop="goIbPages(1)"
  47. v-t="'Custom.Index.Withdrawals'"></button>
  48. <button class="action-btn btn btn-outline-danger waves-effect waves-light" @click.stop="goIbPages(2)"
  49. v-t="'Home.page_ib.item4'"></button>
  50. <!-- <button class="action-btn" @click.stop="goIbPages(3)" v-t="'Ib.Transfer.CommissionIssue'"></button>-->
  51. </view>
  52. <view class="wallet-actions" v-if="mode === 'follow'">
  53. <button class="action-btn btn btn-outline-danger waves-effect waves-light" @click.stop="goFollow()"
  54. v-t="'Documentary.console.item17'"></button>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="menu-list">
  59. <view class="menu" v-for="(item, index) in menus" :key="item.path">
  60. <view class="menu-item" @click="handleClick(index)">
  61. <cwg-icon :name="item.icon" :size="20" color="#6c8595" />
  62. <view class="menu-label" v-t="item.label" />
  63. <view class="chevron-icon" :class="{ 'expanded': item.isOpenMenu }">
  64. <cwg-icon v-if="item.children && item.children.length" name="crm-chevron-down" :size="20" color="#6c8595" />
  65. </view>
  66. </view>
  67. <view :ref="(el) => setSubmenuRef(index, el)" class="submenu-box" :a="index" :key1="item.path + index" :b="item"
  68. :style="{
  69. height: !(item.children && item.children.length) ? '0px' : item.isOpenMenu ? item.submenuHeight + 'px' : '0px',
  70. transition: 'height 281ms cubic-bezier(0.4, 0, 0.2, 1)'
  71. }" :class="{ 'active': item.isOpenMenu }">
  72. <cwg-submenu v-if="item.children && item.children.length" :submenu-items="item.children"
  73. @submenu-click="handleClick1" />
  74. </view>
  75. </view>
  76. </view>
  77. <view class="menu fixed">
  78. <view
  79. class="menu-item btn-outline-danger btn btn-app-nav btn-shadow mb-2 w-100 waves-effect ib-box btn-mode menu-item ib-box"
  80. @click="setMode('customer')" v-if="mode !== 'customer'">
  81. <cwg-icon name="crm-trade" :size="20" color="#000" />
  82. <view class="menu-label" v-t="'Home.msg.Custom'" />
  83. </view>
  84. <view
  85. class="menu-item btn-outline-danger btn btn-app-nav btn-shadow mb-2 w-100 waves-effect ib-box btn-mode menu-item ib-box"
  86. @click="setMode('ib')" v-if="mode !== 'ib' && ibStatus">
  87. <cwg-icon name="crm-ib" :size="20" color="#000" />
  88. <view class="menu-label" v-t="'Home.msg.Ib'" />
  89. </view>
  90. <view
  91. class="menu-item btn-outline-danger btn btn-app-nav btn-shadow mb-2 w-100 waves-effect ib-box btn-mode menu-item ib-box"
  92. @click="setMode('follow')" v-if="mode !== 'follow'">
  93. <cwg-icon name="crm-gd" :size="20" color="#000" />
  94. <view class="menu-label" v-t="'Documentary.title'" />
  95. </view>
  96. </view>
  97. </view>
  98. </template>
  99. <script lang="ts" setup>
  100. import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
  101. import useUserStore from '@/stores/use-user-store'
  102. import { useMenuSplit } from '@/composables/useMenuSplit'
  103. import { storeToRefs } from 'pinia'
  104. import { drawApi } from '@/service/draw'
  105. import { ibApi } from '@/service/ib'
  106. import { userToken } from '@/composables/config'
  107. import useRouter from '@/hooks/useRouter'
  108. import { useI18n } from 'vue-i18n'
  109. import { documentaryApi } from '@/service/documentary'
  110. import useGlobalStore from '@/stores/use-global-store'
  111. const globalStore = useGlobalStore()
  112. import { useFilters } from '@/composables/useFilters'
  113. const { numberDecimal } = useFilters()
  114. const isDark = computed(() => globalStore.theme === 'dark')
  115. const { t } = useI18n()
  116. const router = useRouter()
  117. const handleClick1 = (item: MenuItem) => {
  118. emit('handle-click', item)
  119. }
  120. const { menus, setSubmenuRef, setMode, handleClick, handleSubmenuClick, mode } = useMenuSplit(handleClick1)
  121. const userStore = useUserStore()
  122. const { userInfo } = storeToRefs(userStore)
  123. const emit = defineEmits(['handle-click'])
  124. // ib按钮展示
  125. const ibStatus = computed(() => {
  126. const info: any = userInfo.value
  127. return !!info && !!info.customInfo && info.customInfo.ibInvalid == 0 && !!info.ibInfo
  128. })
  129. const isWalletOpen = ref(true)
  130. const isShow = ref(true)
  131. const walletbalance = ref(0)
  132. const pendingWithdrawAmount = ref(0)
  133. const ibData = ref({} as any)
  134. const walletData = ref({} as any)
  135. const NumberDesensitization = (value: any) => {
  136. let realVal = ''
  137. if (!isNaN(value) && value !== '') {
  138. value = value.toString()
  139. realVal = '*****'
  140. } else {
  141. realVal = '--'
  142. }
  143. return realVal
  144. }
  145. const formattedBalance = computed(() => {
  146. const value = walletbalance.value || '0'
  147. const decimalValue = numberDecimal(value)
  148. return isShow.value ? decimalValue : NumberDesensitization(decimalValue)
  149. })
  150. const ibBalance = computed(() => {
  151. const value = numberDecimal(ibData.value?.balance || 0)
  152. return isShow.value ? value : NumberDesensitization(value)
  153. })
  154. const formattedPendingWithdrawAmount = computed(() => {
  155. const value = pendingWithdrawAmount.value || '0'
  156. const decimalValue = numberDecimal(value)
  157. return isShow.value ? decimalValue : NumberDesensitization(decimalValue)
  158. })
  159. const ibTotalBalance = computed(() => {
  160. const value = numberDecimal(ibData.value?.all || 0)
  161. return isShow.value ? value : NumberDesensitization(value)
  162. })
  163. // 跟单分润
  164. const followBalance = computed(() => {
  165. const value = numberDecimal(walletData.value?.walletAmount || 0)
  166. return isShow.value ? value : NumberDesensitization(value)
  167. })
  168. const getWalletList = async () => {
  169. let res = await drawApi.walletbalance({})
  170. if (res.code == 200) {
  171. if (res.data != null) {
  172. walletbalance.value = res.data
  173. }
  174. } else {
  175. uni.showToast({ title: res.msg, icon: 'none' })
  176. }
  177. }
  178. //获取处理中出金金额
  179. const getPendingWithdrawAmount = async () => {
  180. let res = await drawApi.pendingWithdrawAmount({})
  181. if (res.code == 200) {
  182. if (res.data != null) {
  183. pendingWithdrawAmount.value = res.data
  184. }
  185. } else {
  186. uni.showToast({
  187. title: res.msg,
  188. icon: 'none',
  189. })
  190. }
  191. }
  192. const getIbData = async () => {
  193. const res = await ibApi.IbData()
  194. if (res.code === 200) {
  195. if (res.data != null) ibData.value = res.data
  196. } else {
  197. uni.showToast({ title: res.msg, icon: 'none' })
  198. }
  199. }
  200. //跟单金额
  201. const getMoneyList = async () => {
  202. let res = await documentaryApi.followWalletSingle({})
  203. if (res.code == 200) {
  204. if (res.data != null) {
  205. walletData.value = res.data
  206. }
  207. } else {
  208. uni.showToast({
  209. title: res.msg,
  210. icon: 'none',
  211. })
  212. }
  213. }
  214. const toggleShow = (e: any) => {
  215. isShow.value = !e.detail.value
  216. }
  217. const goPages = (type: number) => {
  218. let path = ''
  219. if (type == 1) {
  220. path = '/pages/customer/wallet-transfer'
  221. } else if (type == 2) {
  222. path = '/pages/customer/wallet-history'
  223. }
  224. if (path) router.push(path)
  225. }
  226. const goFollow = (type: number) => {
  227. router.push('/pages/follow/transfer')
  228. }
  229. const goIbPages = (type: number) => {
  230. let path = ''
  231. let query = {}
  232. if (type == 1) {
  233. path = '/pages/ib/withdraw-select'
  234. } else if (type == 2) {
  235. path = '/pages/ib/transfer'
  236. } else if (type == 3) {
  237. path = '/pages/ib/transfer'
  238. query = { tab: 2 }
  239. }
  240. if (path) router.push({ path, query })
  241. }
  242. const getPay = (newMode) => {
  243. if (newMode == 'customer') {
  244. getWalletList()
  245. getPendingWithdrawAmount()
  246. } else if (newMode == 'ib') {
  247. getIbData()
  248. } else if (newMode == 'follow') {
  249. getMoneyList()
  250. }
  251. }
  252. watch(() => mode.value, (newMode) => {
  253. if (!userToken.value) return
  254. console.log(newMode, 'mode')
  255. getPay(newMode)
  256. },
  257. { immediate: true })
  258. onMounted(() => {
  259. uni.$on('updatePayment', () => {
  260. getPay(mode.value)
  261. })
  262. })
  263. onUnmounted(() => {
  264. uni.$off('updatePayment')
  265. })
  266. </script>
  267. <style scoped lang="scss">
  268. @import "@/uni.scss";
  269. .cwg-sidebar {
  270. width: px2rpx(280);
  271. color: #6c8595;
  272. height: calc(100vh - (56px + var(--status-bar-height)));
  273. overflow: auto;
  274. display: flex;
  275. flex-direction: column;
  276. align-items: center;
  277. padding: px2rpx(8);
  278. padding-top: px2rpx(20);
  279. box-sizing: border-box;
  280. gap: px2rpx(8);
  281. border-right: 1px solid rgba(108, 133, 149, 0.12);
  282. .wallet-widget {
  283. width: 100%;
  284. //border-radius: px2rpx(4);
  285. border-top: 1px solid rgba(108, 133, 149, 0.12);
  286. border-bottom: 1px solid rgba(108, 133, 149, 0.12);
  287. overflow: hidden;
  288. margin-bottom: px2rpx(4);
  289. .header-bottom {
  290. border-bottom: 1px solid rgba(108, 133, 149, 0.12);
  291. }
  292. .wallet-header {
  293. display: flex;
  294. align-items: center;
  295. justify-content: space-between;
  296. padding: px2rpx(10) px2rpx(12);
  297. //background: #f4f6f8;
  298. cursor: pointer;
  299. .wallet-header-left {
  300. display: flex;
  301. align-items: center;
  302. gap: px2rpx(8);
  303. }
  304. .wallet-header-text {
  305. font-size: 14px;
  306. color: var(--bs-emphasis-color);
  307. font-weight: 500;
  308. }
  309. .wallet-header-right {
  310. transition: transform 0.3s;
  311. &.expanded {
  312. transform: rotate(180deg);
  313. }
  314. }
  315. }
  316. .wallet-body {
  317. padding: px2rpx(12);
  318. .wallet-body-header {
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. margin-bottom: px2rpx(12);
  323. .drawer-title {
  324. font-size: 13px;
  325. color: #6c8595;
  326. }
  327. }
  328. .wallet-body-content {
  329. margin-bottom: px2rpx(16);
  330. .balance-amount {
  331. font-size: 16px;
  332. font-weight: 600;
  333. color: var(--bs-emphasis-color);
  334. margin-bottom: px2rpx(4);
  335. }
  336. .wallet-type {
  337. font-size: 12px;
  338. color: var(--cwg-placeholder-color);
  339. margin-bottom: px2rpx(4);
  340. }
  341. .wallet-id-box {
  342. display: flex;
  343. align-items: center;
  344. gap: px2rpx(4);
  345. color: var(--cwg-placeholder-color);
  346. .wallet-id {
  347. font-size: 12px;
  348. }
  349. }
  350. }
  351. .wallet-actions {
  352. display: flex;
  353. gap: px2rpx(8);
  354. .action-btn {
  355. flex: 1;
  356. height: px2rpx(32);
  357. line-height: px2rpx(32);
  358. font-size: 13px;
  359. margin: 0;
  360. padding: 0 px2rpx(8);
  361. &::after {
  362. border: none;
  363. }
  364. }
  365. }
  366. }
  367. }
  368. .logo {
  369. width: px2rpx(54);
  370. }
  371. .menu-list {
  372. flex: 1;
  373. width: 100%;
  374. overflow-y: auto;
  375. display: flex;
  376. flex-direction: column;
  377. gap: px2rpx(8);
  378. }
  379. .submenu-box {
  380. width: 100%;
  381. height: 0;
  382. overflow: hidden;
  383. }
  384. .menu {
  385. width: 100%;
  386. position: relative;
  387. display: flex;
  388. flex-direction: column;
  389. align-items: center;
  390. box-sizing: border-box;
  391. }
  392. .menu-item {
  393. width: 100%;
  394. min-height: px2rpx(40);
  395. cursor: pointer;
  396. display: flex;
  397. align-items: center;
  398. justify-content: space-between;
  399. gap: px2rpx(8);
  400. padding: px2rpx(10);
  401. box-sizing: border-box;
  402. font-size: 14px;
  403. .menu-label {
  404. flex: 1;
  405. }
  406. &:hover {
  407. border-radius: px2rpx(4);
  408. }
  409. .expanded .icon {
  410. transform: rotate(180deg);
  411. }
  412. }
  413. .ib-box {
  414. border: var(--bs-btn-border-width) solid var(--bs-btn-border-color);
  415. border-radius: var(--bs-btn-border-radius);
  416. background-color: var(--bs-btn-bg);
  417. font-size: px2rpx(18);
  418. font-weight: 600;
  419. justify-content: center;
  420. align-items: center;
  421. gap: px2rpx(8);
  422. display: flex;
  423. color: var(--bs-emphasis-color);
  424. :deep(.zui-svg-icon-image) {
  425. transition: filter 0.15s ease;
  426. }
  427. &:hover {
  428. color: var(--bs-btn-hover-color);
  429. background-color: var(--bs-btn-hover-bg);
  430. border-color: var(--bs-btn-hover-border-color);
  431. :deep(.zui-svg-icon-image) {
  432. filter: brightness(0) invert(1);
  433. }
  434. }
  435. }
  436. .zy-box {
  437. display: flex;
  438. align-items: center;
  439. justify-content: center;
  440. }
  441. .fixed {
  442. position: relative;
  443. width: 100%;
  444. display: flex;
  445. align-items: center;
  446. justify-content: center;
  447. gap: px2rpx(8);
  448. .menu-label {
  449. flex: none;
  450. max-width: px2rpx(150);
  451. white-space: normal;
  452. word-wrap: break-word;
  453. word-break: break-all;
  454. text-align: center;
  455. display: flex;
  456. align-items: center;
  457. justify-content: center;
  458. }
  459. }
  460. }
  461. </style>