activity-list.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="container activity">
  3. <tui-skeleton v-if="isRequest" loadingType="2"></tui-skeleton>
  4. <view class="activity-content" v-if="activityList.length > 0">
  5. <view
  6. class="activity-list"
  7. v-for="(activity, index) in activityList"
  8. :key="index"
  9. @click="NavigatorPath(activity)"
  10. >
  11. <view class="activity-list-pic">
  12. <image class="activity-image" :src="activity.listImage" mode=""></image>
  13. </view>
  14. <view class="activity-list-msg">
  15. <view class="activity-title">{{ activity.name }}</view>
  16. <view class="activity-numbe"
  17. >商品数:<text class="color">{{ activity.productCount }}</text>
  18. </view>
  19. <view class="activity-times">
  20. <text class="label">活动时间:</text>
  21. <text class="color">{{ activity.beginTime }} ~ {{ activity.endTime }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view v-else class="activity-content-empty">
  27. <view class="empty-container">
  28. <image
  29. class="empty-container-image"
  30. :src="StaticUrl + 'icon-empty-activity.png'"
  31. mode="aspectFit"
  32. ></image>
  33. <text class="error-text">您还没有活动哟~</text> <text class="error-text">可联系采美帮您设置活动~</text>
  34. </view>
  35. </view>
  36. <template v-if="activityList.length >= 6">
  37. <tui-loadmore :index="3" :visible="loadmore"></tui-loadmore>
  38. <tui-nomore :text="loadingText" :visible="!loadmore" backgroundColor="#ff457b"></tui-nomore>
  39. </template>
  40. </view>
  41. </template>
  42. <script>
  43. import { mapGetters } from 'vuex'
  44. export default {
  45. data() {
  46. return {
  47. StaticUrl: this.$Static,
  48. activityList: [],
  49. hasNextPage: false,
  50. listQuery: {
  51. userId: 0,
  52. pageNum: 1,
  53. pageSize: 10
  54. },
  55. isRefresh: false,
  56. isRequest: true,
  57. loadmore: false // 正在加载更多
  58. }
  59. },
  60. computed: {
  61. ...mapGetters(['userId']),
  62. loadingText() {
  63. return this.hasNextPage ? '上拉加载更多' : '没有更多了'
  64. }
  65. },
  66. onLoad() {
  67. this.listQuery.userId = this.userId
  68. this.getActivityAreaList()
  69. },
  70. methods: {
  71. getActivityAreaList() {
  72. this.loadmore = true
  73. //初始化活动列表数据
  74. this.ProductService.GetProductActivityAreaList(this.listQuery)
  75. .then(response => {
  76. const data = response.data
  77. this.hasNextPage = data.hasNextPage
  78. if (this.isRefresh) {
  79. this.activityList = data.list
  80. } else {
  81. this.activityList = [...this.activityList, ...data.list]
  82. }
  83. this.loadmore = false
  84. this.isRequest = false
  85. })
  86. .catch(error => {
  87. this.$util.msg(error.msg, 2000)
  88. })
  89. .finally(() => {
  90. if (this.isRefresh) {
  91. setTimeout(() => {
  92. uni.stopPullDownRefresh()
  93. }, 500)
  94. this.isLoadMore = false
  95. }
  96. })
  97. },
  98. NavigatorPath(item) {
  99. this.$api.navigateTo(`/pages/user/activity/activity?activityId=${item.activityId}&name=${item.name}`)
  100. }
  101. },
  102. //下拉刷新
  103. onPullDownRefresh() {
  104. this.isRefresh = true
  105. this.listQuery.pageNum = 1
  106. this.activityList = []
  107. this.getActivityAreaList()
  108. },
  109. // 加载更多
  110. onReachBottom() {
  111. if (this.hasNextPage) {
  112. this.getActivityAreaList()
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. page {
  119. height: auto !important;
  120. background-color: $color-system;
  121. }
  122. .activity-content {
  123. width: 100%;
  124. height: auto;
  125. box-sizing: border-box;
  126. padding: 24rpx;
  127. .activity-list {
  128. width: 100%;
  129. height: 228rpx;
  130. box-sizing: border-box;
  131. padding: 24rpx 20rpx;
  132. background-color: #ffffff;
  133. border-radius: 16rpx;
  134. margin-bottom: 24rpx;
  135. .activity-list-pic {
  136. width: 180rpx;
  137. height: 180rpx;
  138. float: left;
  139. box-sizing: border-box;
  140. border: 1px solid #e1e1e1;
  141. border-radius: 8rpx;
  142. .activity-image {
  143. width: 178rpx;
  144. height: 178rpx;
  145. display: block;
  146. border-radius: 8rpx;
  147. }
  148. }
  149. .activity-list-msg {
  150. width: 460rpx;
  151. height: 100%;
  152. float: right;
  153. position: relative;
  154. .activity-title {
  155. width: 100%;
  156. height: auto;
  157. line-height: 36rpx;
  158. text-overflow: ellipsis;
  159. overflow: hidden;
  160. display: -webkit-box;
  161. -webkit-line-clamp: 2;
  162. line-clamp: 2;
  163. -webkit-box-orient: vertical;
  164. font-size: $font-size-26;
  165. color: #333333;
  166. text-align: justify;
  167. float: left;
  168. }
  169. .activity-numbe {
  170. width: 100%;
  171. height: 28rpx;
  172. float: left;
  173. margin-top: 4rpx;
  174. text-align: left;
  175. line-height: 28rpx;
  176. font-size: $font-size-24;
  177. color: #999999;
  178. .color {
  179. color: #666666;
  180. }
  181. }
  182. .activity-times {
  183. width: 100%;
  184. height: 44rpx;
  185. position: absolute;
  186. bottom: 0;
  187. left: 0;
  188. font-size: 18rpx;
  189. color: #666666;
  190. line-height: 44rpx;
  191. .label {
  192. display: inline-block;
  193. float: left;
  194. }
  195. .color {
  196. display: inline-block;
  197. float: left;
  198. color: $color-system;
  199. }
  200. }
  201. }
  202. }
  203. }
  204. .activity-content-empty {
  205. position: relative;
  206. }
  207. </style>