cwg-sidebar.vue 14 KB

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