integral_gift_log.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <style lang="scss">
  2. .app{padding: 10px;}
  3. .list{border-radius: 0 0 15px 15px;background: #fff;padding: 0 10px; }
  4. .list .item{border-bottom: 1px solid #F1F1F1; padding:10px 0;}
  5. .list .item:last-child{border-bottom: 0;}
  6. .list .item .avatar image{width: 40px;height: 40px;}
  7. .list .item .info{width: calc(100% - 140px); margin-left: 10px;}
  8. .list .item .info .text{font-size: 12px;}
  9. .list .item .price{text-align: right;}
  10. .list .item .price .pricex{background: #F7F7F7;border-radius: 12px;font-size: 14px;padding: 2px 12px;text-align: center;color: #696ecc;}
  11. .list .item .price .time{color: #999;font-size: 12px; margin-top: 4px;}
  12. .not-img{}
  13. .not-img image{width: 80%;}
  14. </style>
  15. <template>
  16. <view class="app">
  17. <view class="not-img fx-h fx-bc fx-ac" v-if="data.length == 0 && page.isLoad == false && page.isFirst">
  18. <image src="/static/img/no-empty.png" mode="widthFix"></image>
  19. </view>
  20. <view class="list" v-else>
  21. <view class="item fx-r" v-for="item in data">
  22. <view class="info">
  23. <view class="title">{{item.title}}</view>
  24. <view class="text">{{item.content}}</view>
  25. </view>
  26. <view class="fx-g1"></view>
  27. <view class="price fx-h fx-be fx-ae">
  28. <view class="pricex" v-if="item.type == 1">+{{item.v}}</view>
  29. <view class="pricex" v-if="item.type == 2">-{{item.v}}</view>
  30. <view class="time">{{item.time}}</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="loading fx-r fx-ac fx-bc" v-if="page.isFrite && !page.isFoot">
  35. <image src="/static/img/xloading-white.png"></image>
  36. <text>正在载入更多...</text>
  37. </view>
  38. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  39. </view>
  40. </template>
  41. <script>
  42. import {mapState,mapMutations} from 'vuex';
  43. var page = 0;//页码
  44. var isLoad = false;//加载
  45. var isFoot = false;//是否到底
  46. export default {
  47. computed: mapState(['user']),
  48. data() {
  49. return {
  50. barHeight:20,
  51. topViewHeight:90,
  52. navActive:0,
  53. page:{
  54. page:1,
  55. isLoad:false,
  56. isFoot:false,
  57. isFirst : false
  58. },
  59. navList:[
  60. {name:"全部","type":"all"},
  61. {name:"收入","type":"income"},
  62. {name:"支出","type":"disburse"}
  63. ],
  64. data:[]
  65. }
  66. },
  67. onShow(options) {
  68. this.checkUserLogin({page:this,isLogion:false,fn:this.initView});
  69. },
  70. onLoad(option) {
  71. if(option.type != null) {
  72. for(var i in this.navList) {
  73. if(this.navList[i].type == option.type){
  74. this.navActive = i;
  75. }
  76. }
  77. }
  78. uni.getSystemInfo({
  79. success:(res) => {
  80. this.barHeight = res.statusBarHeight;
  81. }
  82. });
  83. },
  84. onReachBottom() {
  85. if(this.page.isFoot || this.page.isLoad) {
  86. return;
  87. }
  88. this.page.page ++;
  89. this.getData();
  90. },
  91. methods: {
  92. ...mapMutations(['checkUserLogin']),
  93. /**
  94. * initView数据
  95. */
  96. initView:function(){
  97. this.getData(true);
  98. },
  99. tapNav:function(index){
  100. this.navActive = index;
  101. this.getData(true);
  102. },
  103. loadMoreData:function() {
  104. if(this.page.isFoot || this.page.isLoad) {
  105. return;
  106. }
  107. this.page.page ++;
  108. this.getData();
  109. },
  110. /**
  111. * 获取数据
  112. */
  113. getData:function(isPull = false){
  114. if(this.page.isLoad) return;
  115. this.page.isLoad = true;
  116. if(isPull) {
  117. this.page.page = 1;
  118. this.page.isLoad = false;
  119. this.page.isFoot = false;
  120. }
  121. uni.showLoading({ title: '获取数据中..' });
  122. var post = {};
  123. post.page = this.page.page;
  124. post.code = "give_jdd";
  125. this
  126. .request
  127. .post("userIntegral",post)
  128. .then(res => {
  129. uni.hideLoading();
  130. this.page.isFirst = true;
  131. this.page.isLoad = false;
  132. if(isPull) {
  133. this.data = res.data.list;
  134. } else {
  135. this.data = this.data.concat(res.data.list);
  136. }
  137. //是否到底
  138. if(res.data.list.length != res.data.pageSize) {
  139. this.page.isFoot = true;
  140. }
  141. })
  142. .catch((res)=>{
  143. console.log(res);
  144. uni.hideLoading();
  145. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  146. });
  147. }
  148. },
  149. }
  150. </script>