cwg-payment.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="notice-container">
  3. <cwg-dropdown ref="dropdownRef" :menu-list="[]" @menuClick="handleMenuClick">
  4. <view class="pc-header-btn pc-payment-btn" v-if="mode === 'customer'">
  5. <cwg-icon name="crm-payment" color="#97A1C0" />
  6. <text class="balance-text">{{ formattedBalance }} USD</text>
  7. </view>
  8. <view class="pc-header-btn pc-payment-btn" v-if="mode === 'ib'">
  9. <cwg-icon name="crm-payment" color="#97A1C0" />
  10. <text class="balance-text">{{ ibBalance }} USD</text>
  11. </view>
  12. <view class="pc-header-btn pc-payment-btn" v-if="mode === 'follow'">
  13. <cwg-icon name="crm-payment" color="#97A1C0" />
  14. <text class="balance-text">{{ followBalance }} USD</text>
  15. </view>
  16. <template #btn>
  17. <view class="right-drawer custom-payment-drawer" v-if="mode === 'customer'">
  18. <view class="drawer-header">
  19. <text class="drawer-title">{{ t('vu.item21') }}</text>
  20. <switch class="cursor-pointer" :data-tooltip="!isShow ? t('vu.tooltip.t12') : t('vu.tooltip.t11')"
  21. :checked="!isShow" @change="toggleShow" color="#6c8595" style="transform:scale(0.7)" />
  22. </view>
  23. <view class="drawer-content">
  24. <view class="balance-amount">{{ formattedBalance }} USD</view>
  25. <view class="cursor-pointer cursor-pointer1" @click="toPaymentHistory"
  26. :data-tooltip="t('wallet.pendingWithdraw1')" data-placement="top">
  27. <view class="account-number">${{ formattedPendingWithdrawAmount }}</view>
  28. <view class="account-type" v-t="'wallet.pendingWithdraw1'"></view>
  29. </view>
  30. </view>
  31. <view class="drawer-actions">
  32. <button hover-class="" class="action-btn btn btn-outline-danger waves-effect waves-light "
  33. :data-tooltip="t('wallet.item6')" data-placement="top" @click.stop="goPages(1)"
  34. v-t="'wallet.item6'"></button>
  35. <button hover-class="" class="action-btn btn btn-outline-danger waves-effect waves-light "
  36. :data-tooltip="t('wallet.item7')" data-placement="top" @click.stop="goPages(2)"
  37. v-t="'wallet.item7'"></button>
  38. </view>
  39. </view>
  40. <view class="right-drawer custom-payment-drawer" v-if="mode === 'ib'">
  41. <view class="drawer-header">
  42. <text class="drawer-title">{{ t('vu.item21') }}</text>
  43. <switch class="cursor-pointer" :data-tooltip="!isShow ? t('vu.tooltip.t12') : t('vu.tooltip.t11')"
  44. :checked="!isShow" @change="toggleShow" color="#6c8595" style="transform:scale(0.7)" />
  45. </view>
  46. <view class="drawer-content">
  47. <view class="balance-amount">{{ ibBalance }} USD</view>
  48. <view>
  49. <view class="account-number">${{ ibTotalBalance }}</view>
  50. <view class="account-type" v-t="'Ib.Index.TotalRevenue'"></view>
  51. </view>
  52. </view>
  53. <view class="drawer-actions">
  54. <button hover-class="" class="action-btn btn btn-outline-danger waves-effect waves-light "
  55. @click.stop="goIbPages(1)" v-t="'Custom.Index.Withdrawals'"></button>
  56. <button hover-class="" class="action-btn btn btn-outline-danger waves-effect waves-light"
  57. :data-tooltip="t('Home.page_ib.item4')" data-placement="top" @click.stop="goIbPages(2)"
  58. v-t="'Home.page_ib.item4'"></button>
  59. <button hover-class="" class="action-btn btn btn-outline-danger waves-effect waves-light "
  60. data-placement="top" :data-tooltip="t('Ib.Transfer.CommissionIssue')" @click.stop="goIbPages(3)"
  61. v-t="'Ib.Transfer.CommissionIssue'"></button>
  62. </view>
  63. </view>
  64. <view class="right-drawer custom-payment-drawer" v-if="mode === 'follow'">
  65. <view class="drawer-header">
  66. <text class="drawer-title">{{ t('vu.item21') }}</text>
  67. <switch class="cursor-pointer" :data-tooltip="!isShow ? t('vu.tooltip.t12') : t('vu.tooltip.t11')"
  68. :checked="!isShow" @change="toggleShow" color="#6c8595" style="transform:scale(0.7)" />
  69. </view>
  70. <view class="drawer-content">
  71. <view class="balance-amount">{{ t('Documentary.console.item15') }}{{ followBalance }} USD</view>
  72. </view>
  73. <view class="drawer-actions">
  74. <button hover-class="" class="action-btn btn btn-outline-danger waves-effect waves-light "
  75. :data-tooltip="t('Documentary.console.item17')" @click.stop="goFollowPages(1)"
  76. v-t="'Documentary.console.item17'"></button>
  77. </view>
  78. </view>
  79. </template>
  80. </cwg-dropdown>
  81. </view>
  82. </template>
  83. <script setup lang="ts">
  84. import { computed, ref, onMounted, onUnmounted, watch } from 'vue'
  85. import useRouter from '@/hooks/useRouter'
  86. import { drawApi } from '@/service/draw'
  87. import { useI18n } from 'vue-i18n'
  88. import { useMenuSplit } from '@/composables/useMenuSplit'
  89. import useUserStore from '@/stores/use-user-store'
  90. import { userToken } from '@/composables/config'
  91. import { ibApi } from '@/service/ib'
  92. import { documentaryApi } from '@/service/documentary'
  93. import { useFilters } from '@/composables/useFilters'
  94. const { numberDecimal } = useFilters()
  95. const { mode } = useMenuSplit()
  96. const { t, locale } = useI18n()
  97. const userStore = useUserStore()
  98. const isRed = ref(false)
  99. const dropdownRef = ref(null)
  100. const close = () => {
  101. dropdownRef.value.close()
  102. }
  103. const router = useRouter()
  104. const menuList = []
  105. const ibData = ref({})
  106. const walletData = ref({})
  107. const handleMenuClick = ({ value }) => {
  108. goPages(value)
  109. }
  110. const NumberDesensitization = (value) => {
  111. let realVal = ''
  112. if (!isNaN(value) && value !== '') {
  113. value = value.toString()
  114. realVal = '*****'
  115. } else {
  116. realVal = '--'
  117. }
  118. return realVal
  119. }
  120. const isShow = ref(true)
  121. const walletbalance = ref(0)
  122. const pendingWithdrawAmount = ref(0)
  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 formattedPendingWithdrawAmount = computed(() => {
  129. const value = pendingWithdrawAmount.value || '0'
  130. const decimalValue = numberDecimal(value)
  131. return isShow.value ? decimalValue : NumberDesensitization(decimalValue)
  132. })
  133. //ib金额
  134. const ibBalance = computed(() => {
  135. const value = numberDecimal(ibData.value?.balance || 0)
  136. return isShow.value ? value : NumberDesensitization(value)
  137. })
  138. const ibTotalBalance = computed(() => {
  139. const value = numberDecimal(ibData.value?.all || 0)
  140. return isShow.value ? value : NumberDesensitization(value)
  141. })
  142. // 跟单
  143. const followBalance = computed(() => {
  144. const value = numberDecimal(walletData.value?.walletAmount || 0)
  145. return isShow.value ? value : NumberDesensitization(value)
  146. })
  147. const getWalletList = async () => {
  148. let res = await drawApi.walletbalance({})
  149. if (res.code == 200) {
  150. if (res.data != null) {
  151. walletbalance.value = res.data
  152. }
  153. } else {
  154. uni.showToast({
  155. title: res.msg,
  156. icon: 'none',
  157. })
  158. }
  159. }
  160. //获取处理中出金金额
  161. const getPendingWithdrawAmount = async () => {
  162. let res = await drawApi.pendingWithdrawAmount({})
  163. if (res.code == 200) {
  164. if (res.data != null) {
  165. pendingWithdrawAmount.value = res.data
  166. }
  167. } else {
  168. uni.showToast({
  169. title: res.msg,
  170. icon: 'none',
  171. })
  172. }
  173. }
  174. const toggleShow = (e) => {
  175. isShow.value = !e.detail.value
  176. }
  177. //跟单金额
  178. const getMoneyList = async () => {
  179. let res = await documentaryApi.followWalletSingle({})
  180. if (res.code == 200) {
  181. if (res.data != null) {
  182. walletData.value = res.data
  183. }
  184. } else {
  185. uni.showToast({
  186. title: res.msg,
  187. icon: 'none',
  188. })
  189. }
  190. }
  191. const goPages = (type) => {
  192. let path
  193. if (type == 1) {
  194. path = '/pages/customer/wallet-transfer'
  195. } else if (type == 2) {
  196. path = '/pages/customer/wallet-history' // 此处根据实际“出金”路由修改
  197. }
  198. router.push(path)
  199. close()
  200. }
  201. const goFollowPages = (type) => {
  202. // let path
  203. router.push('/pages/follow/transfer')
  204. close()
  205. }
  206. const goIbPages = (type) => {
  207. let path, query
  208. if (type == 1) {
  209. path = '/pages/ib/withdraw-select'
  210. } else if (type == 2) {
  211. path = '/pages/ib/transfer'
  212. } else if (type == 3) {
  213. path = '/pages/ib/transfer'
  214. query = { tab: 2 }
  215. }
  216. router.push({ path, query })
  217. close()
  218. }
  219. const toPaymentHistory = () => {
  220. router.push({ path: '/pages/customer/payment-history', query: { fromPending: 'true' } })
  221. }
  222. const getIbData = async () => {
  223. const res = await ibApi.IbData()
  224. if (res.code === 200) {
  225. if (res.data != null)
  226. ibData.value = res.data
  227. } else {
  228. uni.showToast({ title: res.msg, icon: 'none' })
  229. }
  230. }
  231. const getPay = (newMode) => {
  232. if (newMode == 'customer') {
  233. getWalletList()
  234. getPendingWithdrawAmount()
  235. } else if (newMode == 'ib') {
  236. getIbData()
  237. } else if (newMode == 'follow') {
  238. getMoneyList()
  239. }
  240. }
  241. watch(() => mode.value, (newMode) => {
  242. if (!userToken.value) return
  243. console.log(newMode, 'mode')
  244. getPay(newMode)
  245. },
  246. { immediate: true })
  247. onMounted(() => {
  248. uni.$on('updatePayment', () => {
  249. getPay(mode.value)
  250. })
  251. })
  252. onUnmounted(() => {
  253. uni.$off('updatePayment')
  254. })
  255. </script>
  256. <style scoped lang="scss">
  257. @import "@/uni.scss";
  258. .notice-container {
  259. :deep(.cwg-dropdown-menu-container) {
  260. //left: px2rpx(-280) !important;
  261. //right: px2rpx(0) !important;
  262. }
  263. @media screen and (max-width: 991px) {
  264. :deep(.cwg-dropdown-menu-container) {
  265. left: px2rpx(-270) !important;
  266. //max-width: px2rpx(400);
  267. }
  268. }
  269. .pc-header-btn {
  270. position: relative;
  271. width: fit-content;
  272. display: flex;
  273. align-items: center;
  274. justify-content: center;
  275. padding: 0 px2rpx(8);
  276. &.has-dot::after {
  277. content: '';
  278. position: absolute;
  279. top: px2rpx(4);
  280. right: px2rpx(4);
  281. width: px2rpx(8);
  282. height: px2rpx(8);
  283. background-color: #f56c6c;
  284. border-radius: 50%;
  285. }
  286. }
  287. .pc-payment-btn {
  288. border-radius: px2rpx(4);
  289. padding: px2rpx(4) px2rpx(8);
  290. height: px2rpx(36);
  291. cursor: pointer;
  292. .balance-text {
  293. margin-left: px2rpx(6);
  294. font-size: px2rpx(14);
  295. font-weight: 500;
  296. color: var(--bs-heading-color);
  297. }
  298. }
  299. .custom-payment-drawer {
  300. width: px2rpx(320);
  301. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  302. padding: 0;
  303. border-radius: px2rpx(8);
  304. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  305. .drawer-header {
  306. display: flex;
  307. justify-content: space-between;
  308. align-items: center;
  309. padding: px2rpx(12) px2rpx(16);
  310. border-bottom: 1px solid var(--bs-border-color);
  311. .drawer-title {
  312. font-size: px2rpx(14);
  313. color: var(--bs-heading-color);
  314. }
  315. }
  316. .drawer-content {
  317. padding: px2rpx(20) px2rpx(16);
  318. //cursor: pointer;
  319. .balance-amount {
  320. font-size: px2rpx(18);
  321. font-weight: bold;
  322. color: var(--bs-heading-color);
  323. margin-bottom: px2rpx(8);
  324. }
  325. .account-type {
  326. font-size: px2rpx(13);
  327. color: var(--cwg-placeholder-color);
  328. margin-bottom: px2rpx(4);
  329. }
  330. .account-number {
  331. font-size: px2rpx(13);
  332. color: var(--cwg-placeholder-color);
  333. }
  334. }
  335. .drawer-actions {
  336. position: relative;
  337. display: flex;
  338. gap: px2rpx(10);
  339. padding: 0 px2rpx(16) px2rpx(20);
  340. .action-btn {
  341. flex: 1;
  342. height: px2rpx(36);
  343. line-height: px2rpx(36);
  344. font-size: px2rpx(13);
  345. margin: 0;
  346. padding: 0 px2rpx(8);
  347. &::after {
  348. border: none;
  349. }
  350. }
  351. }
  352. }
  353. .notification-list {
  354. width: 100%;
  355. }
  356. .notification-item {
  357. display: flex;
  358. align-items: center;
  359. justify-content: space-between;
  360. padding: px2rpx(12) px2rpx(16);
  361. border-bottom: 1px solid var(--bs-border-color);
  362. cursor: pointer;
  363. transition: all 0.3s;
  364. &:hover {
  365. background-color: rgba(0, 0, 0, 0.05);
  366. }
  367. .item-content {
  368. flex: 1;
  369. .item-title {
  370. font-size: px2rpx(14);
  371. color: var(--bs-heading-color);
  372. line-height: 1.4;
  373. margin-bottom: px2rpx(4);
  374. }
  375. .item-time {
  376. font-size: px2rpx(12);
  377. color: var(--bs-heading-color);
  378. }
  379. }
  380. .item-badge {
  381. margin-left: px2rpx(12);
  382. .dot {
  383. width: px2rpx(8);
  384. height: px2rpx(8);
  385. background-color: #f56c6c;
  386. border-radius: 50%;
  387. }
  388. }
  389. }
  390. .logout-wrap {
  391. margin-top: auto;
  392. padding: 20px 16px;
  393. margin-bottom: 20px;
  394. }
  395. .logout-btn {
  396. height: 44px;
  397. background: #f4eadf;
  398. display: flex;
  399. align-items: center;
  400. justify-content: center;
  401. gap: 8px;
  402. color: #fff;
  403. font-weight: 600;
  404. cursor: pointer;
  405. }
  406. }
  407. </style>