index.vue 3.3 KB

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