activity_list.html 5.0 KB

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