AmountWallet.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="amount-wallet">
  3. <view class="content-title">
  4. <view>{{ greeting }}, {{ fullName }}</view>
  5. <view class="content-title-btns">
  6. <view class="btn-primary btn-primary1" @click="openAddFileDialog(1)">
  7. <cwg-icon icon="crm-circle-dollar-to-slot" :size="20" color="#fff" />
  8. <text v-t="'Custom.Index.Deposit'" />
  9. </view>
  10. <view class="btn-primary btn-primary1" @click="openDeleteAccountDialogs()">
  11. <cwg-icon icon="crm-credit-card" :size="20" color="#fff" />
  12. <text v-t="'Custom.Index.Withdrawals'" />
  13. </view>
  14. </view>
  15. </view>
  16. <view class="amount-wallet-content">
  17. <uni-row class="form-row uni-row1">
  18. <uni-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8" v-for="(row, index) in list" :key="index">
  19. <view class="amount-wallet-item" :class="row.className">
  20. <view class="item-left">
  21. <view class="item-name">{{ row.name }}</view>
  22. <view class="text">{{ row.content }}</view>
  23. </view>
  24. <view class="cwg-icon">
  25. <cwg-icon :name="row.icon" :size="24" :color="row.color" />
  26. </view>
  27. <view class="bg">
  28. <cwg-icon :name="row.icon" :size="48" :color="row.color" />
  29. </view>
  30. </view>
  31. </uni-col>
  32. </uni-row>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup lang="ts">
  37. import { computed, ref } from 'vue'
  38. import { useI18n } from 'vue-i18n'
  39. import { drawApi } from "@/service/draw";
  40. import { useFilters } from '@/composables/useFilters'
  41. const { numberFormat, numberDecimal } = useFilters()
  42. import useUserStore from "@/stores/use-user-store";
  43. const { userInfo } = useUserStore()
  44. import { formatName } from '@/utils/nameFormat'
  45. import { useGreeting } from '../composables/useGreeting'
  46. // 基础用法
  47. const { greeting } = useGreeting()
  48. const { t, locale } = useI18n()
  49. const list = computed(() => [
  50. {
  51. name: t('wallet.item4'), icon: 'crm-user', color: '#1ac23a', className: 'className1', content: 'CID: ' + (userInfo?.customInfo?.cId || '')
  52. },
  53. { name: t('wallet.item5'), icon: 'crm-wallet', color: '#0ea5e9', className: 'className2', content: '$ ' + formattedBalance.value },
  54. { name: t('wallet.pendingWithdraw'), icon: 'crm-wallet', color: '#ff9800', className: 'className3', content: '$ ' + formattedPendingWithdrawAmount.value }
  55. ])
  56. const fullName = computed(() => formatName(userInfo?.customInfo))
  57. //获取钱包信息
  58. const walletbalance = ref(0)
  59. const pendingWithdrawAmount = ref(0)
  60. // 使用计算属性
  61. const formattedBalance = computed(() => {
  62. const value = walletbalance.value || "0"
  63. const decimalValue = numberDecimal(value)
  64. return numberFormat(decimalValue)
  65. })
  66. const formattedPendingWithdrawAmount = computed(() => {
  67. const value = pendingWithdrawAmount.value || "0"
  68. const decimalValue = numberDecimal(value)
  69. return numberFormat(decimalValue)
  70. })
  71. const getWalletList = async () => {
  72. let res = await drawApi.walletbalance({});
  73. if (res.code == 200) {
  74. if (res.data != null) {
  75. walletbalance.value = res.data || 0
  76. }
  77. } else {
  78. // this.$pigeon.MessageError(res.msg);
  79. }
  80. }
  81. const getPendingWithdrawAmount = async () => {
  82. let res = await drawApi.pendingWithdrawAmount({});
  83. if (res.code == 200) {
  84. if (res.data != null) {
  85. pendingWithdrawAmount.value = res.data || 0
  86. }
  87. } else {
  88. // this.$pigeon.MessageError(res.msg);
  89. }
  90. }
  91. getWalletList()
  92. getPendingWithdrawAmount()
  93. </script>
  94. <style lang="scss" scoped>
  95. @import "@/uni.scss";
  96. .amount-wallet {
  97. width: 100%;
  98. position: relative;
  99. .content-title {
  100. display: flex;
  101. justify-content: space-between;
  102. align-items: center;
  103. font-size: px2rpx(20);
  104. font-weight: 500;
  105. color: var(--color-slate-800);
  106. background-color: rgba(255, 255, 255, 0);
  107. .content-title-btns {
  108. display: flex;
  109. align-items: center;
  110. justify-content: center;
  111. gap: px2rpx(12);
  112. .btn-primary {
  113. min-width: px2rpx(120);
  114. background-color: var(--color-error);
  115. color: var(--color-slate-150);
  116. padding: 0 px2rpx(12);
  117. border: none;
  118. font-size: px2rpx(14);
  119. text-align: center;
  120. cursor: pointer;
  121. display: flex;
  122. align-items: center;
  123. justify-content: center;
  124. gap: px2rpx(8);
  125. }
  126. .btn-primary1 {
  127. background-color: var(--color-navy-700);
  128. }
  129. }
  130. }
  131. .amount-wallet-content {
  132. width: 100%;
  133. display: flex;
  134. align-items: center;
  135. gap: px2rpx(20);
  136. }
  137. .amount-wallet-item {
  138. position: relative;
  139. margin-top: px2rpx(20);
  140. flex: 1;
  141. height: px2rpx(80);
  142. display: flex;
  143. align-items: flex-start;
  144. justify-content: space-between;
  145. overflow: hidden;
  146. padding: px2rpx(16);
  147. background-color: var(--color-white);
  148. .item-left {
  149. display: flex;
  150. flex-direction: column;
  151. justify-content: space-between;
  152. height: px2rpx(80);
  153. }
  154. .text {
  155. font-size: px2rpx(24);
  156. font-weight: 600;
  157. color: var(--color-slate-700);
  158. }
  159. .item-name {
  160. font-size: px2rpx(14);
  161. color: var(--color-slate-900);
  162. }
  163. .cwg-icon {
  164. width: px2rpx(40);
  165. height: px2rpx(40);
  166. border-radius: px2rpx(10);
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. background-color:
  171. color-mix(in oklab, var(--color-secondary) 10%, transparent);
  172. }
  173. .bg {
  174. position: absolute;
  175. width: px2rpx(40);
  176. height: px2rpx(40);
  177. border-radius: px2rpx(10);
  178. bottom: px2rpx(-8);
  179. right: px2rpx(-8);
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. z-index: 1;
  184. opacity: 0.25;
  185. }
  186. }
  187. .className2 {
  188. .cwg-icon {
  189. background-color:
  190. color-mix(in oklab, var(--color-info) 10%, transparent);
  191. }
  192. }
  193. .className3 {
  194. background-color:
  195. color-mix(in oklab, var(--color-warning) 10%, transparent);
  196. .cwg-icon {
  197. background-color:
  198. color-mix(in oklab, var(--color-warning) 10%, transparent);
  199. }
  200. }
  201. }
  202. </style>