| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494 |
- <template>
- <view class="cwg-sidebar">
- <view class="wallet-widget">
- <view class="wallet-header" :class="{ 'header-bottom': isWalletOpen }" @click="isWalletOpen = !isWalletOpen">
- <view v-if="mode == 'follow'" class="wallet-header-left">
- <cwg-icon name="crm-payment" :size="16" color="#141d22" />
- <text>{{ t('Documentary.console.item14') }}</text>
- <text class="wallet-header-text">{{ followBalance }} USD</text>
- </view>
- <view v-else class="wallet-header-left">
- <cwg-icon name="crm-payment" :size="16" color="#141d22" />
- <text class="wallet-header-text">{{ mode === 'customer' ? formattedBalance : ibBalance }} USD</text>
- </view>
- <view class="wallet-header-right" :class="{ 'expanded': isWalletOpen }">
- <cwg-icon name="crm-chevron-down" :size="16" color="#6c8595" />
- </view>
- </view>
- <view class="wallet-body" v-if="isWalletOpen">
- <view class="wallet-body-header">
- <text class="drawer-title">隐藏余额</text>
- <switch :checked="!isShow" @change="toggleShow" color="#6c8595"
- style="transform:scale(0.7); margin-right: -10px;" />
- </view>
- <view class="wallet-body-content">
- <template v-if="mode === 'follow'">
- <view class="balance-amount">{{ followBalance }} USD</view>
- </template>
- <template v-else>
- <view class="balance-amount">{{ mode === 'customer' ? formattedBalance : ibBalance }} USD</view>
- <view class="wallet-type">{{ mode === 'customer' ? t('wallet.pendingWithdraw') :
- t('Ib.Index.TotalRevenue') }}
- </view>
- <view class="wallet-id-box">
- {{ mode === 'customer' ? formattedPendingWithdrawAmount : ibTotalBalance }}
- </view>
- </template>
- </view>
- <view class="wallet-actions" v-if="mode === 'customer'">
- <button class="action-btn" @click.stop="goPages(1)" v-t="'wallet.item6'"></button>
- <button class="action-btn" @click.stop="goPages(2)" v-t="'wallet.item7'"></button>
- </view>
- <view class="wallet-actions" v-if="mode === 'ib'">
- <button class="action-btn" @click.stop="goIbPages(1)" v-t="'Custom.Index.Withdrawals'"></button>
- <button class="action-btn" @click.stop="goIbPages(2)" v-t="'Home.page_ib.item4'"></button>
- <!-- <button class="action-btn" @click.stop="goIbPages(3)" v-t="'Ib.Transfer.CommissionIssue'"></button>-->
- </view>
- <view class="wallet-actions" v-if="mode === 'follow'">
- <button class="action-btn" @click.stop="goFollow()" v-t="'Documentary.console.item17'"></button>
- </view>
- </view>
- </view>
- <view class="menu-list">
- <view class="menu" v-for="(item, index) in menus" :key="item.path">
- <view class="menu-item" @click="handleClick(index)">
- <cwg-icon :name="item.icon" :size="20" color="#6c8595" />
- <view class="menu-label" v-t="item.label" />
- <view class="chevron-icon" :class="{ 'expanded': item.isOpenMenu }">
- <cwg-icon v-if="item.children && item.children.length" name="crm-chevron-down" :size="20" color="#6c8595" />
- </view>
- </view>
- <view :ref="(el) => setSubmenuRef(index, el)" class="submenu-box" :a="index" :key1="item.path + index" :b="item"
- :style="{
- height: !(item.children && item.children.length) ? '0px' : item.isOpenMenu ? item.submenuHeight + 'px' : '0px',
- transition: 'height 281ms cubic-bezier(0.4, 0, 0.2, 1)'
- }" :class="{ 'active': item.isOpenMenu }">
- <cwg-submenu v-if="item.children && item.children.length" :submenu-items="item.children"
- @submenu-click="handleClick1" />
- </view>
- </view>
- </view>
- <view class="menu fixed">
- <view class="menu-item ib-box" @click="setMode('customer')" v-if="mode !== 'customer'">
- <cwg-icon name="crm-trade" :size="20" color="#6c8595" />
- <view class="menu-label" v-t="'Home.msg.Custom'" />
- </view>
- <view class="menu-item ib-box" @click="setMode('ib')" v-if="mode !== 'ib' && ibStatus">
- <cwg-icon name="crm-ib" :size="20" color="#6c8595" />
- <view class="menu-label" v-t="'Home.msg.Ib'" />
- </view>
- <view class="menu-item ib-box" @click="setMode('follow')" v-if="mode !== 'follow'">
- <cwg-icon name="crm-gd" :size="20" color="#6c8595" />
- <view class="menu-label" v-t="'Documentary.title'" />
- </view>
- </view>
- </view>
- </template>
- <script lang="ts" setup>
- import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
- import useUserStore from '@/stores/use-user-store'
- import { useMenuSplit } from '@/composables/useMenuSplit'
- import { storeToRefs } from 'pinia'
- import { drawApi } from '@/service/draw'
- import { ibApi } from '@/service/ib'
- import { userToken } from '@/composables/config'
- import useRouter from '@/hooks/useRouter'
- import { useI18n } from 'vue-i18n'
- import { documentaryApi } from '@/service/documentary'
- const { t } = useI18n()
- const router = useRouter()
- const handleClick1 = (item: MenuItem) => {
- emit('handle-click', item)
- }
- const { menus, setSubmenuRef, setMode, handleClick, handleSubmenuClick, mode } = useMenuSplit(handleClick1)
- const userStore = useUserStore()
- const { userInfo } = storeToRefs(userStore)
- const emit = defineEmits(['handle-click'])
- // ib按钮展示
- const ibStatus = computed(() => {
- const info: any = userInfo.value
- return !!info && !!info.customInfo && info.customInfo.ibInvalid == 0 && !!info.ibInfo
- })
- const isWalletOpen = ref(true)
- const isShow = ref(true)
- const walletbalance = ref(0)
- const pendingWithdrawAmount = ref(0)
- const ibData = ref({} as any)
- const walletData = ref({} as any)
- const NumberDecimal = (value: any) => {
- let realVal = ''
- if (!isNaN(value) && value !== '') {
- realVal = parseFloat(value).toFixed(2)
- } else {
- realVal = '0.00'
- }
- return realVal
- }
- const NumberDesensitization = (value: any) => {
- let realVal = ''
- if (!isNaN(value) && value !== '') {
- value = value.toString()
- realVal = value.substr(0, 2) + '****' + value.substr(-2)
- } else {
- realVal = '--'
- }
- return realVal
- }
- const formattedBalance = computed(() => {
- const value = walletbalance.value || '0'
- const decimalValue = NumberDecimal(value)
- return isShow.value ? decimalValue : NumberDesensitization(decimalValue)
- })
- const ibBalance = computed(() => {
- const value = NumberDecimal(ibData.value?.balance || 0)
- return isShow.value ? value : NumberDesensitization(value)
- })
- const formattedPendingWithdrawAmount = computed(() => {
- const value = pendingWithdrawAmount.value || '0'
- const decimalValue = NumberDecimal(value)
- return isShow.value ? decimalValue : NumberDesensitization(decimalValue)
- })
- const ibTotalBalance = computed(() => {
- const value = NumberDecimal(ibData.value?.all || 0)
- return isShow.value ? value : NumberDesensitization(value)
- })
- // 跟单分润
- const followBalance = computed(() => {
- const value = NumberDecimal(walletData.value?.walletAmount || 0)
- return isShow.value ? value : NumberDesensitization(value)
- })
- const getWalletList = async () => {
- let res = await drawApi.walletbalance({})
- if (res.code == 200) {
- if (res.data != null) {
- walletbalance.value = res.data
- }
- } else {
- uni.showToast({ title: res.msg, icon: 'none' })
- }
- }
- //获取处理中出金金额
- const getPendingWithdrawAmount = async () => {
- let res = await drawApi.pendingWithdrawAmount({})
- if (res.code == 200) {
- if (res.data != null) {
- pendingWithdrawAmount.value = res.data
- }
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none',
- })
- }
- }
- const getIbData = async () => {
- const res = await ibApi.IbData()
- if (res.code === 200) {
- if (res.data != null) ibData.value = res.data
- } else {
- uni.showToast({ title: res.msg, icon: 'none' })
- }
- }
- //跟单金额
- const getMoneyList = async () => {
- let res = await documentaryApi.followWalletSingle({})
- if (res.code == 200) {
- if (res.data != null) {
- walletData.value = res.data
- }
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none',
- })
- }
- }
- const toggleShow = (e: any) => {
- isShow.value = !e.detail.value
- }
- const goPages = (type: number) => {
- let path = ''
- if (type == 1) {
- path = '/pages/customer/wallet-transfer'
- } else if (type == 2) {
- path = '/pages/customer/wallet-history'
- }
- if (path) router.push(path)
- }
- const goFollow = (type: number) => {
- router.push('/pages/follow/transfer')
- }
- const goIbPages = (type: number) => {
- let path = ''
- let query = {}
- if (type == 1) {
- path = '/pages/ib/withdraw-select'
- } else if (type == 2) {
- path = '/pages/ib/transfer'
- } else if (type == 3) {
- path = '/pages/ib/transfer'
- query = { tab: 2 }
- }
- if (path) router.push({ path, query })
- }
- const getPay = (newMode) => {
- if (newMode == 'customer') {
- getWalletList()
- getPendingWithdrawAmount()
- } else if (newMode == 'ib') {
- getIbData()
- } else if (newMode == 'follow') {
- getMoneyList()
- }
- }
- watch(() => mode.value, (newMode) => {
- if (!userToken.value) return
- console.log(newMode, 'mode')
- getPay(newMode)
- },
- { immediate: true })
- onMounted(() => {
- uni.$on('updatePayment', () => {
- getPay(mode.value)
- })
- })
- onUnmounted(() => {
- uni.$off('updatePayment')
- })
- </script>
- <style scoped lang="scss">
- @import "@/uni.scss";
- .cwg-sidebar {
- width: px2rpx(280);
- color: #6c8595;
- height: calc(100vh - (56px + var(--status-bar-height)));
- overflow: auto;
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: px2rpx(8);
- padding-top: px2rpx(20);
- box-sizing: border-box;
- gap: px2rpx(8);
- border-right: 1px solid rgba(108, 133, 149, 0.12);
- .wallet-widget {
- width: 100%;
- //border-radius: px2rpx(4);
- border-top: 1px solid rgba(108, 133, 149, 0.12);
- border-bottom: 1px solid rgba(108, 133, 149, 0.12);
- overflow: hidden;
- margin-bottom: px2rpx(4);
- .header-bottom {
- border-bottom: 1px solid rgba(108, 133, 149, 0.12);
- }
- .wallet-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: px2rpx(10) px2rpx(12);
- //background: #f4f6f8;
- cursor: pointer;
- .wallet-header-left {
- display: flex;
- align-items: center;
- gap: px2rpx(8);
- }
- .wallet-header-text {
- font-size: 14px;
- color: #141d22;
- font-weight: 500;
- }
- .wallet-header-right {
- transition: transform 0.3s;
- &.expanded {
- transform: rotate(180deg);
- }
- }
- }
- .wallet-body {
- padding: px2rpx(12);
- background: #ffffff;
- .wallet-body-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: px2rpx(12);
- .drawer-title {
- font-size: 13px;
- color: #6c8595;
- }
- }
- .wallet-body-content {
- margin-bottom: px2rpx(16);
- .balance-amount {
- font-size: 16px;
- font-weight: 600;
- color: #141d22;
- margin-bottom: px2rpx(4);
- }
- .wallet-type {
- font-size: 12px;
- color: #999;
- margin-bottom: px2rpx(4);
- }
- .wallet-id-box {
- display: flex;
- align-items: center;
- gap: px2rpx(4);
- .wallet-id {
- font-size: 12px;
- color: #999;
- }
- }
- }
- .wallet-actions {
- display: flex;
- gap: px2rpx(8);
- .action-btn {
- flex: 1;
- height: px2rpx(32);
- line-height: px2rpx(32);
- background-color: #f5f7fa;
- color: #141d22;
- font-size: 13px;
- border-radius: px2rpx(4);
- margin: 0;
- &::after {
- border: none;
- }
- &:active {
- background-color: #e4e7ed;
- }
- }
- }
- }
- }
- .logo {
- width: px2rpx(54);
- }
- .menu-list {
- flex: 1;
- width: 100%;
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- gap: px2rpx(8);
- }
- .submenu-box {
- width: 100%;
- height: 0;
- overflow: hidden;
- }
- .menu {
- width: 100%;
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: center;
- box-sizing: border-box;
- }
- .menu-item {
- width: 100%;
- height: px2rpx(40);
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: px2rpx(8);
- padding: px2rpx(10);
- box-sizing: border-box;
- font-size: 14px;
- .menu-label {
- flex: 1;
- }
- &:hover {
- background: rgba(108, 133, 149, 0.12) !important;
- border: 1px solid rgb(145, 163, 176) !important;
- border-radius: px2rpx(4);
- }
- .expanded .icon {
- transform: rotate(180deg);
- }
- }
- .ib-box {
- background: rgba(140, 69, 246, 0.08) !important;
- border: 1px solid rgba(140, 69, 246, 0.2) !important;
- font-size: px2rpx(18);
- font-weight: 600;
- color: #141d22;
- &:hover {
- background: rgba(140, 69, 246, 0.08) !important;
- border: 1px solid rgba(140, 69, 246, 0.2) !important;
- }
- }
- .zy-box {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .fixed {
- position: relative;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: px2rpx(8);
- }
- }
- </style>
|