activity_list.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. {extend name="public/container"}
  2. {block name="title"}活动列表{/block}
  3. {block name="head_top"}
  4. <style>
  5. .loading {
  6. font-size: .4rem;
  7. text-align: center;
  8. color: #999;
  9. }
  10. .loaded {
  11. font-size: .28rem;
  12. line-height: .72rem;
  13. text-align: center;
  14. color: #999;
  15. }
  16. .nothing {
  17. position: absolute;
  18. top: 30%;
  19. left: 50%;
  20. width: 4rem;
  21. height: 4rem;
  22. background: url("{__WAP_PATH}zsff/images/nothing.png") center/contain no-repeat;
  23. -webkit-transform: translate(-50%, -50%);
  24. transform: translate(-50%, -50%);
  25. }
  26. </style>
  27. {/block}
  28. {block name="content"}
  29. <div v-cloak id="app">
  30. <div class="activity_list">
  31. <div class="list">
  32. <a v-for="(item, index) in activityList" :key="index" :href="activityDetails(item.id)" class="item">
  33. <div class="image">
  34. <img :src="item.image" class="img">
  35. </div>
  36. <div class="text">
  37. <div class="name">{{ item.title }}</div>
  38. <div class="time">
  39. <span class="knowledge iconshijian2"></span>{{ item.time }}
  40. </div>
  41. <div class="group">
  42. <div class="money">
  43. ¥<span class="num">{{ item.price }}</span>
  44. </div>
  45. {{ item.count }}人已报名
  46. </div>
  47. </div>
  48. </a>
  49. </div>
  50. <div v-show="loading" class="loading">
  51. <span class="fa fa-spinner"></span>
  52. </div>
  53. <div v-if="loadend" class="loaded">{{loadTitle}}</div>
  54. <div v-if="!activityList.length && !loading" class="nothing"></div>
  55. </div>
  56. <shortcut></shortcut>
  57. </div>
  58. <script>
  59. require(['vue', 'store', 'helper', '{__WAP_PATH}zsff/js/shortcut.js'], function (Vue, store, $h) {
  60. var app = new Vue({
  61. el: '#app',
  62. data: {
  63. activityList: [],
  64. loadTitle: '',
  65. loading: false,
  66. loadend: false,
  67. page: 1,
  68. limit: 20
  69. },
  70. mounted: function () {
  71. this.getActivityList();
  72. this.$nextTick(function () {
  73. this.init();
  74. });
  75. },
  76. methods: {
  77. init: function () {
  78. var that = this;
  79. window.addEventListener('scroll', function () {
  80. var clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  81. scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight,
  82. scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  83. if (clientHeight + scrollTop >= scrollHeight) {
  84. that.getActivityList();
  85. }
  86. });
  87. },
  88. activityDetails: function (id) {
  89. return $h.U({ c: 'special', a: 'activity_details', q: { id: id } });
  90. },
  91. // 获取活动列表
  92. getActivityList: function () {
  93. var that = this;
  94. if (that.loading) return;
  95. if (that.loadend) return;
  96. that.loadTitle = '';
  97. that.loading = true;
  98. store.baseGet($h.U({ c: 'activity', a: 'activityList', p: { page: that.page, limit: that.limit } }), function (res) {
  99. var list = res.data.data;
  100. that.activityList.push.apply(that.activityList, list);
  101. that.loadend = list.length < that.limit;
  102. that.loadTitle = that.loadend ? '已全部加载' : '上拉加载更多';
  103. that.page = that.page + 1;
  104. that.loading = false;
  105. that.$set(this, 'activityList', that.activityList);
  106. }, function (res) {
  107. that.loadTitle = '上拉加载更多';
  108. that.loading = false;
  109. });
  110. }
  111. }
  112. });
  113. });
  114. </script>
  115. {/block}