cwg-sidebar.vue 14 KB

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