cwg-sidebar.vue 14 KB

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