activity.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view class="container activity">
  3. <tui-skeleton v-if="isRequest" loadingType="2"></tui-skeleton>
  4. <view class="activity-banner">
  5. <image class="activity-banner-image" :src="activityBanner" mode=""></image>
  6. </view>
  7. <!-- 商品列表 -->
  8. <view class="container-section tui-skeleton clearfix">
  9. <view class="product-list" v-for="(pro, index) in productList" :key="index" @click.stop="detail(pro)">
  10. <view class="product-list-image">
  11. <image class="product-image" :src="pro.mainImage" mode=""></image>
  12. </view>
  13. <view class="product-list-msg">
  14. <view class="product-msg-name">{{ pro.name }}</view>
  15. <view class="product-list-tag" v-if="pro.activeStatus === 1">
  16. <text class="tag tag-01">促销</text> <text class="tag tag-02">活动价</text>
  17. </view>
  18. <view class="product-list-pri">
  19. <view class="price">¥{{ pro.price | priceFormat }}</view>
  20. <view class="carts" @click.stop="handAddCarts(pro)">
  21. <view class="carts-add"> <text class="iconfont icon-gouwuche"></text> </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <template v-if="productList.length >= 6">
  28. <tui-loadmore :index="3" :visible="loadmore"></tui-loadmore>
  29. <tui-nomore :text="loadingText" :visible="!loadmore" backgroundColor="#ff457b"></tui-nomore>
  30. </template>
  31. <!-- 可拖动悬浮按钮 -->
  32. <cm-drag :cartNum="kindCount" :isDock="true" :existTabBar="true" @btnClick="btnClick"> </cm-drag>
  33. </view>
  34. </template>
  35. <script>
  36. import wxLogin from '@/services/wxLogin.js'
  37. import { mapGetters, mapActions } from 'vuex'
  38. import cmDrag from '@/components/cm-module/cm-drag/cm-drag'
  39. export default {
  40. components: {
  41. cmDrag
  42. },
  43. data() {
  44. return {
  45. StaticUrl: this.$Static,
  46. activityBanner: `${this.$Static}banner.png`,
  47. cartNum: 0,
  48. listQuery: {
  49. activityId: 0,
  50. userId: 0,
  51. pageNum: 1,
  52. pageSize: 6
  53. },
  54. activityName: '',
  55. hasNextPage: false,
  56. productList: [], //商品列表
  57. isRefresh: false,
  58. isRequest: true,
  59. loadmore: false // 正在加载更多
  60. }
  61. },
  62. onLoad(option) {
  63. this.listQuery.activityId = option.activityId
  64. this.listQuery.userId = this.userId
  65. this.activityName = option.name
  66. this.getProductActivityDetails()
  67. },
  68. filters: {
  69. //处理金额
  70. priceFormat: function(text) {
  71. return Number(text).toFixed(2)
  72. }
  73. },
  74. computed: {
  75. ...mapGetters(['hasLogin', 'userId', 'kindCount']),
  76. loadingText() {
  77. return this.hasNextPage ? '上拉加载更多' : '没有更多了'
  78. }
  79. },
  80. methods: {
  81. ...mapActions('cart', ['addToCart']),
  82. // 获取活动信息
  83. getProductActivityDetails() {
  84. this.loadmore = true
  85. this.ProductService.GetProductActivityDetails(this.listQuery)
  86. .then(response => {
  87. const data = response.data
  88. this.activityBanner = data.image
  89. this.hasNextPage = data.pageInfo.hasNextPage
  90. if (this.isRefresh) {
  91. this.productList = data.pageInfo.list
  92. } else {
  93. this.productList = [...this.productList, ...data.pageInfo.list]
  94. }
  95. this.isRequest = false
  96. this.loadmore = false
  97. })
  98. .catch(error => {
  99. this.$util.msg(error.msg, 2000)
  100. })
  101. .finally(() => {
  102. if (this.isRefresh) {
  103. setTimeout(() => {
  104. uni.stopPullDownRefresh()
  105. }, 500)
  106. this.isRefresh = false
  107. }
  108. })
  109. },
  110. detail(pro) {
  111. this.$api.navigateTo(`/pages/goods/product-activi?productId=${pro.productId}&heUserId=${this.userId}`)
  112. },
  113. handAddCarts(pro) {
  114. this.addToCart({ productId: pro.productId, heUserId: this.userId })
  115. },
  116. btnClick() {
  117. this.$api.navigateTo('/pages/goods/cart')
  118. }
  119. },
  120. onPullDownRefresh() {
  121. //下拉刷新
  122. this.isRefresh = true
  123. this.listQuery.pageNum = 1
  124. this.getProductActivityDetails()
  125. },
  126. onReachBottom() {
  127. if (this.hasNextPage) {
  128. this.listQuery.pageNum ++
  129. this.getProductActivityDetails()
  130. }
  131. },
  132. onShareAppMessage(res) {
  133. //分享转发
  134. if (res.from === 'button') {
  135. // 来自页面内转发按钮
  136. }
  137. return {
  138. title: `${this.activityName}`,
  139. path: `/pages/user/activity/activity?activityId=${this.listQuery.activityId}&userId=${this.userId}`,
  140. imageUrl: 'https://static.caimei365.com/app/mini-hehe/icon/icon-index-share.jpg'
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. page {
  147. height: auto !important;
  148. background-color: $color-system;
  149. }
  150. .activity-banner {
  151. width: 100%;
  152. height: 600rpx;
  153. float: left;
  154. margin-bottom: 64rpx;
  155. .activity-banner-image {
  156. width: 100%;
  157. height: 100%;
  158. display: block;
  159. }
  160. }
  161. .container-section {
  162. width: 100%;
  163. height: auto;
  164. box-sizing: border-box;
  165. padding: 0 24rpx;
  166. .product-list {
  167. width: 339rpx;
  168. height: 532rpx;
  169. float: left;
  170. margin-right: 24rpx;
  171. margin-bottom: 24rpx;
  172. background-color: #ffffff;
  173. border-radius: 16rpx;
  174. &:nth-child(2n) {
  175. margin-right: 0;
  176. }
  177. .product-list-image {
  178. width: 100%;
  179. height: 339rpx;
  180. float: left;
  181. position: relative;
  182. .product-image {
  183. width: 100%;
  184. height: 100%;
  185. display: block;
  186. border-radius: 16rpx 16rpx 0 0;
  187. }
  188. .product-icon {
  189. width: 68rpx;
  190. height: 55rpx;
  191. display: block;
  192. position: absolute;
  193. top: 0;
  194. left: 34rpx;
  195. }
  196. }
  197. .product-list-msg {
  198. width: 100%;
  199. height: 193rpx;
  200. box-sizing: border-box;
  201. padding: 16rpx 24rpx;
  202. float: left;
  203. position: relative;
  204. .product-msg-name {
  205. width: 100%;
  206. height: 72rpx;
  207. line-height: 35rpx;
  208. text-overflow: ellipsis;
  209. overflow: hidden;
  210. display: -webkit-box;
  211. -webkit-line-clamp: 2;
  212. line-clamp: 2;
  213. -webkit-box-orient: vertical;
  214. font-size: $font-size-26;
  215. color: #333333;
  216. text-align: justify;
  217. float: left;
  218. }
  219. .product-list-tag {
  220. position: relative;
  221. z-index: 9;
  222. width: 100%;
  223. height: 30rpx;
  224. margin-top: 8rpx;
  225. float: left;
  226. .tag {
  227. display: inline-block;
  228. height: 32rpx;
  229. font-size: 22rpx;
  230. line-height: 30rpx;
  231. text-align: center;
  232. color: #f83c6c;
  233. float: left;
  234. margin-right: 10rpx;
  235. &.tag-02 {
  236. width: 80rpx;
  237. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png) top center
  238. no-repeat;
  239. background-size: contain;
  240. }
  241. &.tag-01 {
  242. width: 56rpx;
  243. color: #fff;
  244. background-color: #f83c6c;
  245. border-radius: 4rpx;
  246. }
  247. }
  248. }
  249. .product-list-pri {
  250. width: 100%;
  251. height: 44rpx;
  252. float: left;
  253. position: absolute;
  254. bottom: 16rpx;
  255. left: 0;
  256. box-sizing: border-box;
  257. padding: 0 24rpx;
  258. .price {
  259. float: left;
  260. font-size: $font-size-26;
  261. color: #f83c6c;
  262. font-weight: bold;
  263. line-height: 44rpx;
  264. }
  265. .carts {
  266. float: right;
  267. .carts-add {
  268. width: 44rpx;
  269. height: 44rpx;
  270. text-align: center;
  271. line-height: 44rpx;
  272. background-color: #ff457b;
  273. border-radius: 50%;
  274. .iconfont {
  275. font-size: 32rpx;
  276. color: #ffffff;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. }
  283. }
  284. </style>