AmountWallet.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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.uni.showToast({ title: res.msg, icon: 'none' })
  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.uni.showToast({ title: res.msg, icon: 'none' })
  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: #cf1322;
  128. ;
  129. }
  130. }
  131. }
  132. .amount-wallet-content {
  133. width: 100%;
  134. display: flex;
  135. align-items: center;
  136. gap: px2rpx(20);
  137. }
  138. .amount-wallet-item {
  139. position: relative;
  140. margin-top: px2rpx(20);
  141. flex: 1;
  142. height: px2rpx(80);
  143. display: flex;
  144. align-items: flex-start;
  145. justify-content: space-between;
  146. overflow: hidden;
  147. padding: px2rpx(16);
  148. background-color: var(--color-white);
  149. .item-left {
  150. display: flex;
  151. flex-direction: column;
  152. justify-content: space-between;
  153. height: px2rpx(80);
  154. }
  155. .text {
  156. font-size: px2rpx(24);
  157. font-weight: 600;
  158. color: var(--color-slate-700);
  159. }
  160. .item-name {
  161. font-size: px2rpx(14);
  162. color: var(--color-slate-900);
  163. }
  164. .cwg-icon {
  165. width: px2rpx(40);
  166. height: px2rpx(40);
  167. border-radius: px2rpx(10);
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. background-color:
  172. color-mix(in oklab, var(--color-secondary) 10%, transparent);
  173. }
  174. .bg {
  175. position: absolute;
  176. width: px2rpx(40);
  177. height: px2rpx(40);
  178. border-radius: px2rpx(10);
  179. bottom: px2rpx(-8);
  180. right: px2rpx(-8);
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. z-index: 1;
  185. opacity: 0.25;
  186. }
  187. }
  188. .className2 {
  189. .cwg-icon {
  190. background-color:
  191. color-mix(in oklab, var(--color-info) 10%, transparent);
  192. }
  193. }
  194. .className3 {
  195. background-color:
  196. color-mix(in oklab, var(--color-warning) 10%, transparent);
  197. .cwg-icon {
  198. background-color:
  199. color-mix(in oklab, var(--color-warning) 10%, transparent);
  200. }
  201. }
  202. }
  203. </style>