cwg-sidebar.vue 13 KB

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