cwg-payment.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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 useRouter from '@/hooks/useRouter'
  34. import { drawApi } from '@/service/draw'
  35. import { useI18n } from 'vue-i18n'
  36. import useUserStore from '@/stores/use-user-store'
  37. const { t, locale } = useI18n()
  38. const userStore = useUserStore()
  39. import { userToken } from '@/composables/config'
  40. const isRed = ref(false)
  41. const dropdownRef = ref(null)
  42. const close = () => {
  43. dropdownRef.value.close()
  44. }
  45. const router = useRouter()
  46. const menuList = []
  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 toggleShow = (e) => {
  111. isShow.value = !e.detail.value
  112. }
  113. const goPages = (type) => {
  114. let path
  115. if (type == 1) {
  116. path = '/pages/customer/wallet-transfer'
  117. } else if (type == 2) {
  118. path = '/pages/customer/wallet-history' // 此处根据实际“出金”路由修改
  119. }
  120. router.push(path)
  121. close()
  122. }
  123. const toPaymentHistory = () => {
  124. router.push({ path: '/pages/customer/payment-history',query:{fromPending: "true"} })
  125. }
  126. const goMore = () => {
  127. router.push({
  128. path: '/pages/common/notice',
  129. })
  130. close()
  131. }
  132. onMounted(() => {
  133. if (!userToken.value) return
  134. getWalletList()
  135. getPendingWithdrawAmount()
  136. })
  137. </script>
  138. <style scoped lang="scss">
  139. @import "@/uni.scss";
  140. .notice-container {
  141. :deep(.cwg-dropdown-menu-container) {
  142. //left: px2rpx(-280) !important;
  143. //right: px2rpx(0) !important;
  144. }
  145. @media screen and (max-width: 991px) {
  146. :deep(.cwg-dropdown-menu-container) {
  147. left: px2rpx(-270) !important;
  148. //max-width: px2rpx(400);
  149. }
  150. }
  151. .pc-header-btn {
  152. position: relative;
  153. width: fit-content;
  154. display: flex;
  155. align-items: center;
  156. justify-content: center;
  157. padding: 0 px2rpx(12);
  158. &.has-dot::after {
  159. content: '';
  160. position: absolute;
  161. top: px2rpx(4);
  162. right: px2rpx(4);
  163. width: px2rpx(8);
  164. height: px2rpx(8);
  165. background-color: #f56c6c;
  166. border-radius: 50%;
  167. }
  168. }
  169. .pc-payment-btn {
  170. border-radius: px2rpx(4);
  171. padding: px2rpx(4) px2rpx(12);
  172. height: px2rpx(36);
  173. cursor: pointer;
  174. .balance-text {
  175. margin-left: px2rpx(6);
  176. font-size: px2rpx(14);
  177. font-weight: 500;
  178. color: #141d22;
  179. }
  180. }
  181. .custom-payment-drawer {
  182. width: px2rpx(260);
  183. background-color: var(--color-white);
  184. padding: 0;
  185. border-radius: px2rpx(8);
  186. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  187. .drawer-header {
  188. display: flex;
  189. justify-content: space-between;
  190. align-items: center;
  191. padding: px2rpx(12) px2rpx(16);
  192. border-bottom: 1px solid #f0f0f0;
  193. .drawer-title {
  194. font-size: px2rpx(14);
  195. color: #333;
  196. }
  197. }
  198. .drawer-content {
  199. padding: px2rpx(20) px2rpx(16);
  200. .balance-amount {
  201. font-size: px2rpx(18);
  202. font-weight: bold;
  203. color: #141d22;
  204. margin-bottom: px2rpx(8);
  205. }
  206. .account-type {
  207. font-size: px2rpx(13);
  208. color: #666;
  209. margin-bottom: px2rpx(4);
  210. }
  211. .account-number {
  212. font-size: px2rpx(13);
  213. color: #999;
  214. }
  215. }
  216. .drawer-actions {
  217. display: flex;
  218. gap: px2rpx(12);
  219. padding: 0 px2rpx(16) px2rpx(20);
  220. .action-btn {
  221. flex: 1;
  222. height: px2rpx(36);
  223. line-height: px2rpx(36);
  224. background-color: #f5f7fa;
  225. color: #333;
  226. font-size: px2rpx(13);
  227. border-radius: px2rpx(4);
  228. margin: 0;
  229. &::after {
  230. border: none;
  231. }
  232. &:active {
  233. background-color: #e4e7ed;
  234. }
  235. }
  236. }
  237. }
  238. .notification-list {
  239. width: 100%;
  240. }
  241. .notification-item {
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. padding: px2rpx(12) px2rpx(16);
  246. border-bottom: 1px solid #f0f0f0;
  247. cursor: pointer;
  248. transition: all 0.3s;
  249. &:hover {
  250. background-color: rgba(0, 0, 0, 0.05);
  251. }
  252. .item-content {
  253. flex: 1;
  254. .item-title {
  255. font-size: px2rpx(14);
  256. color: #333;
  257. line-height: 1.4;
  258. margin-bottom: px2rpx(4);
  259. }
  260. .item-time {
  261. font-size: px2rpx(12);
  262. color: #999;
  263. }
  264. }
  265. .item-badge {
  266. margin-left: px2rpx(12);
  267. .dot {
  268. width: px2rpx(8);
  269. height: px2rpx(8);
  270. background-color: #f56c6c;
  271. border-radius: 50%;
  272. }
  273. }
  274. }
  275. .logout-wrap {
  276. margin-top: auto;
  277. padding: 20px 16px;
  278. margin-bottom: 20px;
  279. }
  280. .logout-btn {
  281. height: 44px;
  282. background: #f4eadf;
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. gap: 8px;
  287. color: #ff9800;
  288. font-weight: 600;
  289. cursor: pointer;
  290. }
  291. }
  292. </style>