activity.vue 9.3 KB

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