cwg-payment.vue 12 KB

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