activity.vue 10 KB

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