cwg-sidebar.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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.item15') }}</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. 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 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. const followBalance = computed(() => {
  156. const value = NumberDecimal(ibData.value?.all || 0)
  157. return isShow.value ? value : NumberDesensitization(value)
  158. })
  159. const getWalletList = async () => {
  160. let res = await drawApi.walletbalance({})
  161. if (res.code == 200) {
  162. if (res.data != null) {
  163. walletbalance.value = res.data
  164. }
  165. } else {
  166. uni.showToast({ title: res.msg, icon: 'none' })
  167. }
  168. }
  169. //获取处理中出金金额
  170. const getPendingWithdrawAmount = async () => {
  171. let res = await drawApi.pendingWithdrawAmount({})
  172. if (res.code == 200) {
  173. if (res.data != null) {
  174. pendingWithdrawAmount.value = res.data
  175. }
  176. } else {
  177. uni.showToast({
  178. title: res.msg,
  179. icon: 'none',
  180. })
  181. }
  182. }
  183. const getIbData = async () => {
  184. const res = await ibApi.IbData()
  185. if (res.code === 200) {
  186. if (res.data != null) ibData.value = res.data
  187. } else {
  188. uni.showToast({ title: res.msg, icon: 'none' })
  189. }
  190. }
  191. watch(() => mode.value, (newMode) => {
  192. if (!userToken.value) return
  193. if (newMode == 'customer') {
  194. getWalletList()
  195. getPendingWithdrawAmount()
  196. } else if (newMode == 'ib') {
  197. getIbData()
  198. }
  199. }, { immediate: true })
  200. const toggleShow = (e: any) => {
  201. isShow.value = !e.detail.value
  202. }
  203. const goPages = (type: number) => {
  204. let path = ''
  205. if (type == 1) {
  206. path = '/pages/customer/wallet-transfer'
  207. } else if (type == 2) {
  208. path = '/pages/customer/wallet-history'
  209. }
  210. if (path) router.push(path)
  211. }
  212. const goFollow = (type: number) => {
  213. router.push('/pages/follow/transfer')
  214. }
  215. const goIbPages = (type: number) => {
  216. let path = ''
  217. let query = {}
  218. if (type == 1) {
  219. path = '/pages/ib/withdraw-select'
  220. } else if (type == 2) {
  221. path = '/pages/ib/transfer'
  222. } else if (type == 3) {
  223. path = '/pages/ib/transfer'
  224. query = { tab: 2 }
  225. }
  226. if (path) router.push({ path, query })
  227. }
  228. </script>
  229. <style scoped lang="scss">
  230. @import "@/uni.scss";
  231. .cwg-sidebar {
  232. width: px2rpx(280);
  233. color: #6c8595;
  234. height: calc(100vh - 56px);
  235. overflow: auto;
  236. display: flex;
  237. flex-direction: column;
  238. align-items: center;
  239. padding: px2rpx(8);
  240. padding-top: px2rpx(20);
  241. box-sizing: border-box;
  242. gap: px2rpx(8);
  243. border-right: 1px solid rgba(108, 133, 149, 0.12);
  244. .wallet-widget {
  245. width: 100%;
  246. //border-radius: px2rpx(4);
  247. border-top: 1px solid rgba(108, 133, 149, 0.12);
  248. border-bottom: 1px solid rgba(108, 133, 149, 0.12);
  249. overflow: hidden;
  250. margin-bottom: px2rpx(4);
  251. .header-bottom {
  252. border-bottom: 1px solid rgba(108, 133, 149, 0.12);
  253. }
  254. .wallet-header {
  255. display: flex;
  256. align-items: center;
  257. justify-content: space-between;
  258. padding: px2rpx(10) px2rpx(12);
  259. //background: #f4f6f8;
  260. cursor: pointer;
  261. .wallet-header-left {
  262. display: flex;
  263. align-items: center;
  264. gap: px2rpx(8);
  265. }
  266. .wallet-header-text {
  267. font-size: 14px;
  268. color: #141d22;
  269. font-weight: 500;
  270. }
  271. .wallet-header-right {
  272. transition: transform 0.3s;
  273. &.expanded {
  274. transform: rotate(180deg);
  275. }
  276. }
  277. }
  278. .wallet-body {
  279. padding: px2rpx(12);
  280. background: #ffffff;
  281. .wallet-body-header {
  282. display: flex;
  283. align-items: center;
  284. justify-content: space-between;
  285. margin-bottom: px2rpx(12);
  286. .drawer-title {
  287. font-size: 13px;
  288. color: #6c8595;
  289. }
  290. }
  291. .wallet-body-content {
  292. margin-bottom: px2rpx(16);
  293. .balance-amount {
  294. font-size: 16px;
  295. font-weight: 600;
  296. color: #141d22;
  297. margin-bottom: px2rpx(4);
  298. }
  299. .wallet-type {
  300. font-size: 12px;
  301. color: #999;
  302. margin-bottom: px2rpx(4);
  303. }
  304. .wallet-id-box {
  305. display: flex;
  306. align-items: center;
  307. gap: px2rpx(4);
  308. .wallet-id {
  309. font-size: 12px;
  310. color: #999;
  311. }
  312. }
  313. }
  314. .wallet-actions {
  315. display: flex;
  316. gap: px2rpx(8);
  317. .action-btn {
  318. flex: 1;
  319. height: px2rpx(32);
  320. line-height: px2rpx(32);
  321. background-color: #f5f7fa;
  322. color: #141d22;
  323. font-size: 13px;
  324. border-radius: px2rpx(4);
  325. margin: 0;
  326. &::after {
  327. border: none;
  328. }
  329. &:active {
  330. background-color: #e4e7ed;
  331. }
  332. }
  333. }
  334. }
  335. }
  336. .logo {
  337. width: px2rpx(54);
  338. }
  339. .menu-list {
  340. flex: 1;
  341. width: 100%;
  342. overflow-y: auto;
  343. display: flex;
  344. flex-direction: column;
  345. gap: px2rpx(8);
  346. }
  347. .submenu-box {
  348. width: 100%;
  349. height: 0;
  350. overflow: hidden;
  351. }
  352. .menu {
  353. width: 100%;
  354. position: relative;
  355. display: flex;
  356. flex-direction: column;
  357. align-items: center;
  358. box-sizing: border-box;
  359. }
  360. .menu-item {
  361. width: 100%;
  362. height: px2rpx(40);
  363. cursor: pointer;
  364. display: flex;
  365. align-items: center;
  366. justify-content: space-between;
  367. gap: px2rpx(8);
  368. padding: px2rpx(10);
  369. box-sizing: border-box;
  370. font-size: 14px;
  371. .menu-label {
  372. flex: 1;
  373. }
  374. &:hover {
  375. background: rgba(108, 133, 149, 0.12) !important;
  376. border: 1px solid rgb(145, 163, 176) !important;
  377. border-radius: px2rpx(4);
  378. }
  379. .expanded .icon {
  380. transform: rotate(180deg);
  381. }
  382. }
  383. .ib-box {
  384. background: rgba(140, 69, 246, 0.08) !important;
  385. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  386. font-size: px2rpx(18);
  387. font-weight: 600;
  388. color: #141d22;
  389. &:hover {
  390. background: rgba(140, 69, 246, 0.08) !important;
  391. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  392. }
  393. }
  394. .zy-box {
  395. display: flex;
  396. align-items: center;
  397. justify-content: center;
  398. }
  399. .fixed {
  400. position: relative;
  401. width: 100%;
  402. display: flex;
  403. align-items: center;
  404. justify-content: center;
  405. gap: px2rpx(8);
  406. }
  407. }
  408. </style>