cwg-sidebar.vue 13 KB

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