cwg-sidebar.vue 14 KB

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