activity.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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 | priceFormat }}</text>
  24. <text class="delete">¥{{ pro.price | priceFormat }}</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. filters: {
  80. //处理金额
  81. priceFormat: function(text) {
  82. return Number(text).toFixed(2)
  83. }
  84. },
  85. computed: {
  86. ...mapGetters(['hasLogin', 'userId', 'kindCount']),
  87. loadingText() {
  88. return this.hasNextPage ? '上拉加载更多' : '没有更多了'
  89. }
  90. },
  91. methods: {
  92. ...mapActions('cart', ['addToCart']),
  93. // 获取活动信息
  94. getProductActivityDetails() {
  95. this.loadmore = true
  96. this.ProductService.GetProductActivityDetails(this.listQuery)
  97. .then(response => {
  98. const data = response.data
  99. this.activityBanner = data.image
  100. this.hasNextPage = data.pageInfo.hasNextPage
  101. if (this.isRefresh) {
  102. this.productList = data.pageInfo.list
  103. } else {
  104. this.productList = [...this.productList, ...data.pageInfo.list]
  105. }
  106. this.isRequest = false
  107. this.loadmore = false
  108. })
  109. .catch(error => {
  110. this.$util.msg(error.msg, 2000)
  111. })
  112. .finally(() => {
  113. if (this.isRefresh) {
  114. setTimeout(() => {
  115. uni.stopPullDownRefresh()
  116. }, 500)
  117. this.isRefresh = false
  118. }
  119. })
  120. },
  121. detail(pro) {
  122. this.$api.navigateTo(`/pages/goods/product-detail?productId=${pro.productId}&jumpState=2`)
  123. },
  124. handAddCarts(pro) {
  125. this.addToCart({ productId: pro.productId, heUserId: this.userId })
  126. },
  127. btnClick() {
  128. this.$api.navigateTo('/pages/goods/cart')
  129. }
  130. },
  131. onPullDownRefresh() {
  132. //下拉刷新
  133. this.isRefresh = true
  134. this.listQuery.pageNum = 1
  135. this.getProductActivityDetails()
  136. },
  137. onReachBottom() {
  138. if (this.hasNextPage) {
  139. this.listQuery.pageNum++
  140. this.getProductActivityDetails()
  141. }
  142. },
  143. onShareAppMessage(res) {
  144. // 加密参数
  145. const shareData = {
  146. type: 0,
  147. inviteUserId: this.userId,
  148. activityId: this.listQuery.activityId,
  149. userId: this.userId,
  150. }
  151. // 加密
  152. const state_str = encodeURIComponent(this.$crypto.encrypt(shareData))
  153. return {
  154. title: `${this.activityName}`,
  155. path: `/pages/tabBar/index/index?state_str=${state_str}`,
  156. imageUrl: 'https://static.caimei365.com/app/mini-hehe/icon/icon-index-share.jpg'
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="scss">
  162. page {
  163. height: auto !important;
  164. background-color: $color-system;
  165. }
  166. .activity-banner {
  167. width: 100%;
  168. height: 600rpx;
  169. float: left;
  170. margin-bottom: 64rpx;
  171. .activity-banner-image {
  172. width: 100%;
  173. height: 100%;
  174. display: block;
  175. }
  176. }
  177. .container-section {
  178. width: 100%;
  179. height: auto;
  180. box-sizing: border-box;
  181. padding: 0 24rpx;
  182. .product-list {
  183. width: 339rpx;
  184. height: 532rpx;
  185. float: left;
  186. margin-right: 24rpx;
  187. margin-bottom: 24rpx;
  188. background-color: #ffffff;
  189. border-radius: 16rpx;
  190. &:nth-child(2n) {
  191. margin-right: 0;
  192. }
  193. .product-list-image {
  194. width: 100%;
  195. height: 339rpx;
  196. float: left;
  197. position: relative;
  198. .product-image {
  199. width: 100%;
  200. height: 100%;
  201. display: block;
  202. border-radius: 16rpx 16rpx 0 0;
  203. }
  204. .product-icon {
  205. width: 68rpx;
  206. height: 55rpx;
  207. display: block;
  208. position: absolute;
  209. top: 0;
  210. left: 34rpx;
  211. }
  212. }
  213. .product-list-msg {
  214. width: 100%;
  215. height: 193rpx;
  216. box-sizing: border-box;
  217. padding: 16rpx 24rpx;
  218. float: left;
  219. position: relative;
  220. .product-msg-name {
  221. width: 100%;
  222. height: 72rpx;
  223. line-height: 35rpx;
  224. text-overflow: ellipsis;
  225. overflow: hidden;
  226. display: -webkit-box;
  227. -webkit-line-clamp: 2;
  228. line-clamp: 2;
  229. -webkit-box-orient: vertical;
  230. font-size: $font-size-26;
  231. color: #333333;
  232. text-align: justify;
  233. float: left;
  234. }
  235. .product-list-tag {
  236. position: relative;
  237. z-index: 9;
  238. width: 100%;
  239. height: 30rpx;
  240. margin-top: 8rpx;
  241. float: left;
  242. .tag {
  243. display: inline-block;
  244. height: 32rpx;
  245. font-size: 22rpx;
  246. line-height: 30rpx;
  247. text-align: center;
  248. color: #f83c6c;
  249. float: left;
  250. margin-right: 10rpx;
  251. &.tag-02 {
  252. width: 80rpx;
  253. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png) top center
  254. no-repeat;
  255. background-size: contain;
  256. }
  257. &.tag-01 {
  258. width: 56rpx;
  259. color: #fff;
  260. background-color: #f83c6c;
  261. border-radius: 4rpx;
  262. }
  263. &.tag-03 {
  264. width: 80rpx;
  265. background: linear-gradient(270deg, #ff457b 0%, #b03bb8 51%, #6431f2 100%);
  266. color: #fff;
  267. border-radius: 4rpx;
  268. }
  269. }
  270. }
  271. .product-list-pri {
  272. width: 100%;
  273. height: 44rpx;
  274. position: absolute;
  275. bottom: 16rpx;
  276. left: 0;
  277. box-sizing: border-box;
  278. padding: 0 24rpx;
  279. .price {
  280. font-size: $font-size-26;
  281. color: #f83c6c;
  282. font-weight: bold;
  283. line-height: 44rpx;
  284. .delete{
  285. font-size: 20rpx;
  286. color: #999999;
  287. text-decoration: line-through;
  288. font-weight: normal;
  289. margin-left: 10rpx;
  290. }
  291. }
  292. .carts {
  293. position: absolute;
  294. right: 24px;
  295. bottom: 0;
  296. .carts-add {
  297. width: 44rpx;
  298. height: 44rpx;
  299. text-align: center;
  300. line-height: 44rpx;
  301. background-color: #ff457b;
  302. border-radius: 50%;
  303. .iconfont {
  304. font-size: 32rpx;
  305. color: #ffffff;
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. }
  313. </style>