activity-list.vue 6.0 KB

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