cwg-payment.vue 12 KB

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