balanceDetail.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="detail">
  3. <!-- 顶部tab -->
  4. <view class="tab">
  5. <text :class="{ selected: selected == '' }" @click="swcthTab('')"
  6. >全部</text
  7. >
  8. <text
  9. :class="{ selected: selected == 'income' }"
  10. @click="swcthTab('income')"
  11. >收入</text
  12. >
  13. <text
  14. :class="{ selected: selected == 'consume' }"
  15. @click="swcthTab('consume')"
  16. >支出</text
  17. >
  18. </view>
  19. <!-- 顶部tab -->
  20. <view class="content">
  21. <!-- 余额明细 -->
  22. <MoneyDetail
  23. v-for="(item, index) in moneyDetail"
  24. :itemInfo="item"
  25. :key="index"
  26. />
  27. <!-- 余额明细 -->
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import MoneyDetail from "../mineComponent/moneyDetail/index.vue";
  33. export default {
  34. components: {
  35. MoneyDetail,
  36. },
  37. data() {
  38. return {
  39. selected: "", //判断选中某个tab栏
  40. page: 1,
  41. total: 0,
  42. //存放余额明细数据
  43. moneyDetail: [],
  44. type: "",
  45. };
  46. },
  47. onReachBottom() {
  48. //商品总数量小于当前获取到的商品数量
  49. if (this.total > this.moneyDetail.length) {
  50. this.page++;
  51. this.getMoneyList();
  52. }
  53. },
  54. onLoad(options) {
  55. this.type = options.type;
  56. },
  57. methods: {
  58. swcthTab(num) {
  59. this.selected = num;
  60. this.getMoneyList(1);
  61. },
  62. //获取余额明细
  63. getMoneyList(value) {
  64. uni.$u.http
  65. .get(
  66. `/api/finance?is_page=1&page=${this.page}&limit=10&account_type=${this.type}&type=${this.selected}`
  67. )
  68. .then((res) => {
  69. //判断是否为触底加载 不是直接赋值,是则连接两个数组,value存在则为筛选
  70. if (this.moneyDetail.length == 0 || value) {
  71. this.moneyDetail = res.data;
  72. } else {
  73. this.moneyDetail = this.moneyDetail.concat(res.data);
  74. }
  75. this.total = res.total;
  76. });
  77. },
  78. },
  79. mounted() {
  80. this.getMoneyList();
  81. },
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. .detail {
  86. width: 100%;
  87. background-color: #fff;
  88. .tab {
  89. display: flex;
  90. justify-content: space-around;
  91. align-items: center;
  92. color: rgba(34, 34, 34, 0.6);
  93. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  94. height: 90rpx;
  95. }
  96. .selected {
  97. color: #222;
  98. font-weight: 600;
  99. position: relative;
  100. }
  101. .selected::before {
  102. content: "";
  103. display: block;
  104. height: 4rpx;
  105. background-color: #f83224;
  106. width: 100%;
  107. position: absolute;
  108. bottom: -24rpx;
  109. }
  110. .content {
  111. padding: 0 32rpx;
  112. }
  113. }
  114. </style>