index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <layout-page>
  3. <scroll-view class="scrollBox defaultBgc" scroll-y="true" @scrolltolower="loadingMore">
  4. <view class="panel">
  5. <view>
  6. <uni-icons color="#f30" type="icon-renminbi1688" size="16" custom-prefix="iconfont"></uni-icons>
  7. <text class="text">{{ balance.balance > 0 ? (balance?.balance / 100.0).toFixed(2) : 0 }}</text>
  8. </view>
  9. <view>
  10. <button class="btn">充值</button>
  11. </view>
  12. </view>
  13. <view class="list">
  14. <uni-list border-full>
  15. <uni-list-item
  16. v-for="item in items"
  17. :key="item.id"
  18. :title="item._payPrice"
  19. :note="item._payTime"
  20. :rightText="item.payChannelName"
  21. />
  22. </uni-list>
  23. </view>
  24. </scroll-view>
  25. </layout-page>
  26. </template>
  27. <!-- balance 余额 -->
  28. <script setup>
  29. import { ref } from 'vue'
  30. import {
  31. getAccountBalance,
  32. getUserWalletRechargePage
  33. } from '@/api/sign'
  34. import { timesTampChange } from '@/utils/date'
  35. const balance = ref({})
  36. const items = ref([])
  37. const pageInfo = ref({
  38. pageNo: 1,
  39. pageSize: 20
  40. })
  41. const total = ref(0)
  42. const more = ref('more')
  43. getBalance()
  44. getList()
  45. // 获取积分余额
  46. async function getBalance() {
  47. const { data } = await getAccountBalance()
  48. if (!data) {
  49. return
  50. }
  51. balance.value = data
  52. }
  53. async function getList () {
  54. try {
  55. const { data } = await getUserWalletRechargePage(pageInfo.value)
  56. if (!data || !data.list || !data.list.length) {
  57. if (pageInfo.value.pageNo === 1) {
  58. return
  59. }
  60. pageInfo.value.pageNo--
  61. more.value = 'more'
  62. return
  63. }
  64. items.value.push(...data.list.map(e => {
  65. return {
  66. ...e,
  67. _payPrice: (e.payPrice / 100.0).toFixed(2),
  68. _payTime: timesTampChange(e.payTime)
  69. }
  70. }))
  71. total.value = +data.total
  72. more.value = total.value === items.value.length ? 'noMore' : 'more'
  73. } catch (error) {
  74. if (pageInfo.value.pageNo === 1) {
  75. return
  76. }
  77. pageInfo.value.pageNo--
  78. more.value = 'more'
  79. }
  80. }
  81. function loadingMore () {
  82. if (more.value === 'noMore') {
  83. return
  84. }
  85. more.value = 'loading'
  86. pageInfo.value.pageNo++
  87. getList()
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .scrollBox {
  92. width: 100vw;
  93. padding: 20rpx;
  94. box-sizing: border-box;
  95. .panel {
  96. width: 100%;
  97. padding: 20rpx;
  98. margin-bottom: 20rpx;
  99. box-sizing: border-box;
  100. background: #FFF;
  101. display: flex;
  102. justify-content: space-between;
  103. .text {
  104. color: #F30;
  105. font-size: 54rpx;
  106. }
  107. .btn {
  108. width: 180rpx;
  109. height: 60rpx;
  110. line-height: 60rpx;
  111. font-size: 28rpx;
  112. text-align: center;
  113. background: #00897B;
  114. color: #FFF;
  115. border-radius: 30rpx;
  116. }
  117. }
  118. .list {
  119. padding: 20rpx;
  120. }
  121. }
  122. </style>