cwg-payment.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="notice-container">
  3. <cwg-dropdown ref="dropdownRef" :menu-list="customMenuList" @menuClick="handleMenuClick">
  4. <view class="pc-header-btn">
  5. <cwg-icon name="crm-payment" color="#141d22" @click="openNotice" />
  6. {{ formattedBalance }} USD
  7. </view>
  8. <template #btn>
  9. <view class="right-drawer">
  10. <view class="drawer-item">
  11. <view class="drawer-item-title">钱包余额</view>
  12. <view class="drawer-item-content">{{ formattedBalance }} USD</view>
  13. </view>
  14. <view class="drawer-item">
  15. <view class="drawer-item-title">处理中出金金额</view>
  16. <view class="drawer-item-content">{{ formattedPendingWithdrawAmount }} USD</view>
  17. </view>
  18. </view>
  19. </template>
  20. </cwg-dropdown>
  21. </view>
  22. </template>
  23. <script setup lang="ts">
  24. import { computed, ref, onMounted } from 'vue'
  25. import { newsApi } from '@/service/news'
  26. import useRouter from "@/hooks/useRouter";
  27. import { drawApi } from "@/service/draw";
  28. import { useI18n } from 'vue-i18n'
  29. const { t, locale } = useI18n()
  30. import { userToken } from "@/composables/config";
  31. const isRed = ref(false)
  32. const dropdownRef = ref(null)
  33. const close = () => {
  34. dropdownRef.value.close()
  35. }
  36. const router = useRouter();
  37. const customMenuList = computed(() =>
  38. [{
  39. label: t('wallet.item6'),
  40. type: 1
  41. },
  42. {
  43. label: t('wallet.item7'),
  44. type: 2
  45. },
  46. ])
  47. const handleMenuClick = ({ value }) => {
  48. goPages(value)
  49. }
  50. const NumberDecimal = (value) => {
  51. let realVal = ''
  52. if (!isNaN(value) && value !== '') {
  53. // 截取当前数据到小数点后两位
  54. realVal = parseFloat(value).toFixed(2)
  55. } else {
  56. realVal = '0'
  57. }
  58. return realVal
  59. };
  60. const NumberDesensitization = (value) => {
  61. let realVal = ''
  62. if (!isNaN(value) && value !== '') {
  63. value = value.toString();
  64. realVal = value.substr(0, 2) + '****' + value.substr(-2);
  65. } else {
  66. realVal = '--'
  67. }
  68. return realVal
  69. };
  70. const isShow = ref(true)
  71. const walletbalance = ref(0)
  72. const pendingWithdrawAmount = ref(0)
  73. const formattedBalance = computed(() => {
  74. const value = walletbalance.value || "0"
  75. const decimalValue = NumberDecimal(value)
  76. return isShow.value ? decimalValue : NumberDesensitization(decimalValue)
  77. })
  78. const formattedPendingWithdrawAmount = computed(() => {
  79. const value = pendingWithdrawAmount.value || "0"
  80. const decimalValue = NumberDecimal(value)
  81. return isShow.value ? decimalValue : NumberDesensitization(decimalValue)
  82. })
  83. const getWalletList = async () => {
  84. let res = await drawApi.walletbalance({});
  85. if (res.code == 200) {
  86. if (res.data != null) {
  87. walletbalance.value = res.data;
  88. }
  89. } else {
  90. uni.showToast({
  91. title: res.msg,
  92. icon: 'none'
  93. });
  94. }
  95. }
  96. //获取处理中出金金额
  97. const getPendingWithdrawAmount = async () => {
  98. let res = await drawApi.pendingWithdrawAmount({});
  99. if (res.code == 200) {
  100. if (res.data != null) {
  101. pendingWithdrawAmount.value = res.data;
  102. }
  103. } else {
  104. uni.showToast({
  105. title: res.msg,
  106. icon: 'none'
  107. });
  108. }
  109. }
  110. const goPages = (type) => {
  111. let path
  112. if (type == 1) {
  113. path = '/pages/customer/wallet-transfer'
  114. } else if (type == 2) {
  115. path = '/pages/customer/wallet-history'
  116. }
  117. router.push(path)
  118. close()
  119. }
  120. const goMore = () => {
  121. router.push({
  122. path: '/pages/common/notice'
  123. })
  124. close()
  125. }
  126. onMounted(() => {
  127. if (!userToken.value) return
  128. getWalletList()
  129. getPendingWithdrawAmount()
  130. })
  131. </script>
  132. <style scoped lang="scss">
  133. @import "@/uni.scss";
  134. .notice-container {
  135. :deep(.cwg-dropdown-menu-container) {
  136. left: px2rpx(-280) !important;
  137. right: px2rpx(0) !important;
  138. }
  139. @media screen and (max-width: 991px) {
  140. :deep(.cwg-dropdown-menu-container) {
  141. left: px2rpx(-270) !important;
  142. max-width: px2rpx(400);
  143. }
  144. }
  145. .pc-header-btn {
  146. position: relative;
  147. width: fit-content;
  148. display: flex;
  149. align-items: center;
  150. justify-content: center;
  151. padding: 0 px2rpx(12);
  152. &.has-dot::after {
  153. content: '';
  154. position: absolute;
  155. top: px2rpx(4);
  156. right: px2rpx(4);
  157. width: px2rpx(8);
  158. height: px2rpx(8);
  159. background-color: #f56c6c;
  160. border-radius: 50%;
  161. }
  162. }
  163. .right-drawer {
  164. width: px2rpx(300);
  165. background-color: var(--color-white);
  166. display: flex;
  167. flex-direction: column;
  168. padding: 20px 16px;
  169. box-sizing: border-box;
  170. }
  171. .notification-list {
  172. width: 100%;
  173. }
  174. .notification-item {
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. padding: px2rpx(12) px2rpx(16);
  179. border-bottom: 1px solid #f0f0f0;
  180. cursor: pointer;
  181. transition: all 0.3s;
  182. &:hover {
  183. background-color: rgba(0, 0, 0, 0.05);
  184. }
  185. .item-content {
  186. flex: 1;
  187. .item-title {
  188. font-size: px2rpx(14);
  189. color: #333;
  190. line-height: 1.4;
  191. margin-bottom: px2rpx(4);
  192. }
  193. .item-time {
  194. font-size: px2rpx(12);
  195. color: #999;
  196. }
  197. }
  198. .item-badge {
  199. margin-left: px2rpx(12);
  200. .dot {
  201. width: px2rpx(8);
  202. height: px2rpx(8);
  203. background-color: #f56c6c;
  204. border-radius: 50%;
  205. }
  206. }
  207. }
  208. .logout-wrap {
  209. margin-top: auto;
  210. padding: 20px 16px;
  211. margin-bottom: 20px;
  212. }
  213. .logout-btn {
  214. height: 44px;
  215. background: #f4eadf;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. gap: 8px;
  220. color: #ff9800;
  221. font-weight: 600;
  222. cursor: pointer;
  223. }
  224. }
  225. </style>