cwg-sidebar.vue 14 KB

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