integral-detail.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <app-layout>
  3. <app-tab-nav :tabList="tabList" :activeItem="activeTab" @click="setTab" :theme="getTheme"></app-tab-nav>
  4. <view v-for="(item, index) in list" :key="index" :style="{'color': getTheme.color}" class="u-item" >
  5. <view class='u-desc'>{{item.desc}}</view>
  6. <view class='u-integral'>{{item.integral}}积分</view>
  7. <view class="u-info">
  8. <text>时间: {{item.created_at}}</text>
  9. </view>
  10. </view>
  11. </app-layout>
  12. </template>
  13. <script>
  14. import { mapGetters, mapState } from "vuex";
  15. import appTabNav from "../../../components/basic-component/app-tab-nav/app-tab-nav.vue";
  16. export default {
  17. data() {
  18. return {
  19. tabList: [{id:1, name: '收入'}, {id:2, name: '支出'}],
  20. activeTab: 1,
  21. page: 1,
  22. list: [],
  23. page_count: 1
  24. }
  25. },
  26. components: {
  27. "app-tab-nav": appTabNav
  28. },
  29. computed: {
  30. ...mapState({
  31. userInfo: state => state.user.info
  32. }),
  33. ...mapGetters('mallConfig', {
  34. getTheme: 'getTheme'
  35. })
  36. },
  37. onLoad() { this.$commonLoad.onload();
  38. uni.showLoading({
  39. title: '加载中...'
  40. });
  41. this.getList();
  42. },
  43. onReachBottom() {
  44. if (this.page_count >= this.page) {
  45. this.getList();
  46. }
  47. },
  48. methods: {
  49. setTab(e) {
  50. uni.showLoading({
  51. title: '加载中...'
  52. });
  53. this.activeTab = +e.currentTarget.dataset.id;
  54. this.list = [];
  55. this.page = 1;
  56. this.getList();
  57. },
  58. async getList() {
  59. try {
  60. const res = await this.$request({
  61. url: this.$api.integral_mall.log,
  62. data: {
  63. type: this.activeTab,
  64. page: this.page
  65. }
  66. });
  67. let { code, data, msg } = res;
  68. uni.hideLoading();
  69. if (code === 0) {
  70. if (this.page !== 1) {
  71. this.list = this.list.concat(data.list);
  72. } else {
  73. this.list = data.list;
  74. this.page_count = data.pagination.page_count;
  75. }
  76. this.page = data.list.length ? this.page + 1 : this.page;
  77. } else {
  78. uni.showToast({
  79. title: msg,
  80. icon: 'none',
  81. duration: 1000
  82. });
  83. }
  84. } catch (e) {
  85. this.$event.on(this.$const.EVENT_USER_LOGIN).then(()=>{
  86. this.getList();
  87. });
  88. }
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped lang="scss">
  94. .u-item {
  95. font-size: 28upx;
  96. padding: 36upx 24upx;
  97. border-bottom: 1upx solid #e2e2e2;
  98. background-color: #ffffff;
  99. }
  100. .u-desc {
  101. color: #353535;
  102. margin-bottom: 6upx;
  103. }
  104. .u-integral {
  105. width: 25%;
  106. display: inline-block;
  107. }
  108. .u-info {
  109. font-size: 22upx;
  110. float: right;
  111. color: #999999;
  112. }
  113. </style>