activity-area.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="activity">
  3. <template v-if="activityList.length > 0">
  4. <view class="activity-content">
  5. <view
  6. class="activity-list"
  7. v-for="(activity, index) in activityList"
  8. :key="index"
  9. @click="handleToDetail(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. <cm-loadmore
  27. :hasMore="hasNextPage"
  28. :isLoading="isLoading"
  29. :visiable="visiable"
  30. backgroundColor="#ff457b"
  31. ></cm-loadmore>
  32. </template>
  33. <template v-else>
  34. <tui-no-data :imgUrl="staticUrl + 'icon-empty-activity.png'" :imgHeight="230" :imgWidth="290">
  35. <view class="empty-tip">您还没有活动哟~</view> <view class="empty-tip">可联系采美帮您设置活动~</view>
  36. </tui-no-data>
  37. </template>
  38. </view>
  39. </template>
  40. <script>
  41. import { fetchProductActivityAreaList } from '@/services/api/goods.js'
  42. import { mapGetters } from 'vuex'
  43. export default {
  44. data() {
  45. return {
  46. activityList: [],
  47. hasNextPage: false,
  48. listQuery: {
  49. userId: 0,
  50. pageNum: 1,
  51. pageSize: 10
  52. },
  53. isRefresh: false,
  54. isLoading: true
  55. }
  56. },
  57. computed: {
  58. ...mapGetters(['userId']),
  59. visiable() {
  60. return this.activityList.length > this.listQuery.pageSize
  61. }
  62. },
  63. onLoad() {
  64. this.listQuery.userId = this.userId
  65. this.getActivityAreaList()
  66. },
  67. methods: {
  68. async getActivityAreaList() {
  69. this.isLoading = true
  70. try {
  71. //初始化活动列表数据
  72. const { data } = await fetchProductActivityAreaList(this.listQuery)
  73. this.hasNextPage = data.hasNextPage
  74. if (this.isRefresh) {
  75. this.activityList = data.results
  76. } else {
  77. this.activityList = [...this.activityList, ...data.results]
  78. }
  79. } catch (e) {
  80. console.log(e)
  81. } finally {
  82. this.isLoading = false
  83. if (this.isRefresh) {
  84. setTimeout(() => {
  85. uni.stopPullDownRefresh()
  86. }, 500)
  87. }
  88. }
  89. },
  90. handleToDetail(item) {
  91. this.$router.navigateTo(`activity/activity-detail?activityId=${item.activityId}&name=${item.name}`)
  92. }
  93. },
  94. //下拉刷新
  95. onPullDownRefresh() {
  96. this.isRefresh = true
  97. this.listQuery.pageNum = 1
  98. this.activityList = []
  99. this.getActivityAreaList()
  100. },
  101. // 加载更多
  102. onReachBottom() {
  103. if (this.hasNextPage) {
  104. this.getActivityAreaList()
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .activity-content {
  111. width: 100%;
  112. min-height: 100vh;
  113. background-color: #f83c6c;
  114. box-sizing: border-box;
  115. padding: 24rpx;
  116. .activity-list {
  117. width: 100%;
  118. height: 228rpx;
  119. box-sizing: border-box;
  120. padding: 24rpx 20rpx;
  121. background-color: #ffffff;
  122. border-radius: 16rpx;
  123. margin-bottom: 24rpx;
  124. .activity-list-pic {
  125. width: 180rpx;
  126. height: 180rpx;
  127. float: left;
  128. box-sizing: border-box;
  129. border: 1px solid #e1e1e1;
  130. border-radius: 8rpx;
  131. .activity-image {
  132. width: 178rpx;
  133. height: 178rpx;
  134. display: block;
  135. border-radius: 8rpx;
  136. }
  137. }
  138. .activity-list-msg {
  139. width: 460rpx;
  140. height: 100%;
  141. float: right;
  142. position: relative;
  143. .activity-title {
  144. width: 100%;
  145. height: auto;
  146. line-height: 36rpx;
  147. text-overflow: ellipsis;
  148. overflow: hidden;
  149. display: -webkit-box;
  150. -webkit-line-clamp: 2;
  151. line-clamp: 2;
  152. -webkit-box-orient: vertical;
  153. font-size: 26rpx;
  154. color: #333333;
  155. text-align: justify;
  156. float: left;
  157. }
  158. .activity-numbe {
  159. width: 100%;
  160. height: 28rpx;
  161. float: left;
  162. margin-top: 4rpx;
  163. text-align: left;
  164. line-height: 28rpx;
  165. font-size: 24rpx;
  166. color: #999999;
  167. .color {
  168. color: #666666;
  169. }
  170. }
  171. .activity-times {
  172. width: 100%;
  173. height: 44rpx;
  174. position: absolute;
  175. bottom: 0;
  176. left: 0;
  177. font-size: 18rpx;
  178. color: #666666;
  179. line-height: 44rpx;
  180. .label {
  181. display: inline-block;
  182. float: left;
  183. }
  184. .color {
  185. display: inline-block;
  186. float: left;
  187. color: #f83c6c;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. .activity-content-empty {
  194. position: relative;
  195. }
  196. </style>