activity.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 } 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. GetProductActivityDetails() {
  80. //初始化活动详情
  81. this.ProductService.GetProductActivityDetails(this.listQuery)
  82. .then(response => {
  83. const data = response.data
  84. this.activityBanner = data.image
  85. this.hasNextPage = data.pageInfo.hasNextPage
  86. this.productList = data.pageInfo.list
  87. })
  88. .catch(error => {
  89. this.$util.msg(error.msg, 2000)
  90. })
  91. },
  92. GetOnReachBottomData() {
  93. //上滑加载更多
  94. this.listQuery.pageNum += 1
  95. this.ProductService.GetProductActivityDetails(this.listQuery)
  96. .then(response => {
  97. const data = response.data
  98. this.hasNextPage = data.pageInfo.hasNextPage
  99. this.productList = this.productList.concat(data.pageInfo.list)
  100. })
  101. .catch(error => {
  102. this.$util.msg(error.msg, 2000)
  103. })
  104. },
  105. Details(pro) {
  106. this.$api.navigateTo(
  107. `/pages/goods/product-activi?productId=${pro.productId}&heUserId=${this.listQuery.userId}`
  108. )
  109. },
  110. handAddCarts(pro) {
  111. this.addToCart({ productId: pro.productId })
  112. },
  113. btnClick() {
  114. this.$emit('goCartPage')
  115. },
  116. btnTouchstart() {
  117. // console.log('btnTouchstart');
  118. },
  119. btnTouchend() {
  120. // console.log('btnTouchend');
  121. }
  122. },
  123. onPullDownRefresh() {
  124. //下拉刷新
  125. this.listQuery.pageNum = 1
  126. THIS.GetProductActivityDetails()
  127. uni.stopPullDownRefresh()
  128. },
  129. onReachBottom() {
  130. if (this.hasNextPage) {
  131. this.GetOnReachBottomData()
  132. }
  133. },
  134. onShow() {
  135. wxLogin.wxLoginQuick()
  136. this.$api.getStorage().then(resolve => {
  137. this.UserId = resolve.userId ? resolve.userId : ''
  138. })
  139. },
  140. onShareAppMessage(res) {
  141. //分享转发
  142. if (res.from === 'button') {
  143. // 来自页面内转发按钮
  144. }
  145. return {
  146. title: `${this.activityName}`,
  147. path: `/pages/user/activity/activity?activityId=${this.listQuery.activityId}&userId=${
  148. this.listQuery.userId
  149. }`,
  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. }
  258. }
  259. .product-list-pri {
  260. width: 100%;
  261. height: 44rpx;
  262. float: left;
  263. position: absolute;
  264. bottom: 16rpx;
  265. left: 0;
  266. box-sizing: border-box;
  267. padding: 0 24rpx;
  268. .price {
  269. float: left;
  270. font-size: $font-size-26;
  271. color: #f83c6c;
  272. font-weight: bold;
  273. line-height: 44rpx;
  274. }
  275. .carts {
  276. float: right;
  277. .carts-add {
  278. width: 44rpx;
  279. height: 44rpx;
  280. text-align: center;
  281. line-height: 44rpx;
  282. background-color: #ff457b;
  283. border-radius: 50%;
  284. .iconfont {
  285. font-size: 32rpx;
  286. color: #ffffff;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. }
  293. }
  294. </style>