cwg-payment.vue 10 KB

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