cwg-payment.vue 8.1 KB

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