activity-list.vue 3.8 KB

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