integral.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {extend name="public/container"}
  2. {block name="title"}我的积分{/block}
  3. {extend name="public/container"}
  4. {block name="head"}
  5. <style>
  6. .loading-line{background-color: #fff;}
  7. </style>
  8. {/block}
  9. {block name="content"}
  10. <div id="user-integral" class="integral-content">
  11. <section>
  12. <header ref="head">
  13. <div class="con-cell">
  14. <span>我的积分</span>
  15. <p>{$userInfo.integral|floatval}</p>
  16. <?php /* <a href="">获取积分</a> */ ?>
  17. </div>
  18. </header>
  19. <?php /* <div class="entrance">
  20. <a href=""><i class="icon integral-mall"></i><span>进入积分商城</span></a>
  21. <a href=""><i class="icon address"></i><span>收货地址管理</span></a>
  22. </div> */ ?>
  23. <div class="details">
  24. <div class="titles" ref="nav"><i class="icon details-icon"></i>收支明细</div>
  25. <div ref="bsDom">
  26. <div style="-webkit-overflow-scrolling : touch; position: relative;">
  27. <ul>
  28. <li class="clearfix" v-for="item in group.list" v-cloak="">
  29. <div class="infos fl">
  30. <div class="con-cell">
  31. <p v-text="item.mark"></p>
  32. <span v-text="item.add_time"></span>
  33. </div>
  34. </div>
  35. <div class="count fr" :class="{increase:item.pm == 1}">
  36. <div class="con-cell"><span>{{item.pm == 1 ? '+' : '-'}}{{item.number}}</span>积分</div>
  37. </div>
  38. </li>
  39. </ul>
  40. <p class="loading-line" v-show="loading == true"><i></i><span>正在加载中</span><i></i></p>
  41. <p class="loading-line" v-show="loading == false && group.loaded == false" v-cloak=""><i></i><span>加载更多</span><i></i></p>
  42. <p class="loading-line" v-show="loading == false && group.loaded == true" v-cloak=""><i></i><span>没有更多了</span><i></i></p>
  43. </div>
  44. </div>
  45. </div>
  46. </section>
  47. </div>
  48. <script>
  49. (function(){
  50. requirejs(['vue','helper','better-scroll','store'],function(Vue,$h,BScroll,storeApi){
  51. var wxApi = mapleWx($jssdk());
  52. new Vue({
  53. el:'#user-integral',
  54. data:{
  55. group:{
  56. first:0,
  57. limit:20,
  58. list:[],
  59. loaded:false
  60. },
  61. loading: false,
  62. scroll:null,
  63. },
  64. methods:{
  65. getList:function(){
  66. if(this.loading) return;
  67. var that = this,type = 'group',group = that.group;
  68. if(group.loaded) return ;
  69. this.loading = true;
  70. storeApi.getUserIntegralList({
  71. first:group.first,
  72. limit:group.limit
  73. },function(res){
  74. var list = res.data.data,groupLength = group.list.length;
  75. that.scroll.stop();
  76. group.loaded = list.length < group.limit;
  77. group.first += list.length;
  78. group.list = group.list.concat(list);
  79. that.$set(that,type,group);
  80. that.loading = false;
  81. that.$nextTick(function(){
  82. if(list.length || !groupLength) that.scroll.refresh();
  83. if(!groupLength) setTimeout(function(){that.scroll.scrollTo(0,0,300);},0);
  84. that.scroll.finishPullUp();
  85. });
  86. },function(){that.loading = false});
  87. },
  88. bScrollInit:function () {
  89. var that = this;
  90. this.$refs.bsDom.style.height = (
  91. document.documentElement.clientHeight -
  92. this.$refs.head.offsetHeight -
  93. this.$refs.nav.offsetHeight - 6.5
  94. )+'px';
  95. this.$refs.bsDom.style.overflow = 'hidden';
  96. this.scroll = new BScroll(this.$refs.bsDom,{observeDOM:false,useTransition:false,click:true,probeType:1,cancelable:false,deceleration:0.005,snapThreshold:0.01});
  97. this.scroll.on('pullingUp',function(){
  98. that.loading == false && that.getList();
  99. })
  100. }
  101. },
  102. mounted:function(){
  103. this.bScrollInit();
  104. this.getList();
  105. }
  106. })
  107. });
  108. })();
  109. </script>
  110. {/block}