activity.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. <image class="product-icon" :src="StaticUrl+'icon-hot.png'" mode="" v-if="pro.activeStatus == 1"></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"><text class="tag">活动价</text></view>
  16. <view class="product-list-pri">
  17. <view class="price">¥{{ pro.price | PriceFormat}}</view>
  18. <view class="carts" @click.stop="handAddCarts(pro)">
  19. <view class="carts-add">
  20. <text class="iconfont icon-gouwuche"></text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default{
  31. data(){
  32. return{
  33. activityBanner:`${this.$Static}banner.png`,
  34. listQuery:{
  35. activityId:0,
  36. userId:0,
  37. pageNum:1,
  38. pageSize:10
  39. },
  40. hasNextPage:false,
  41. productList:[],//商品列表
  42. }
  43. },
  44. onLoad(option) {
  45. this.listQuery.activityId = option.activityId
  46. this.listQuery.userId = option.userId
  47. this.GetProductActivityDetails();
  48. },
  49. filters: {
  50. //处理金额
  51. PriceFormat: function(text) {
  52. return Number(text).toFixed(2)
  53. }
  54. },
  55. methods:{
  56. GetProductActivityDetails(){//初始化活动详情
  57. this.ProductService.GetProductActivityDetails(this.listQuery).then(response => {
  58. const data = response.data
  59. this.activityBanner = data.image
  60. this.hasNextPage = data.pageInfo.hasNextPage
  61. this.productList = data.pageInfo.list
  62. }).catch(error =>{
  63. this.$util.msg(error.msg,2000);
  64. })
  65. },
  66. GetOnReachBottomData(){//上滑加载更多
  67. this.listQuery.pageNum+=1
  68. this.ProductService.GetProductActivityDetails(this.listQuery).then(response => {
  69. const data = response.data
  70. this.hasNextPage = data.pageInfo.hasNextPage
  71. this.productList = this.productList.concat(data.pageInfo.list)
  72. }).catch(error =>{
  73. this.$util.msg(error.msg,2000);
  74. })
  75. },
  76. Details(pro){
  77. this.$api.navigateTo(`/pages/goods/product?productId=${pro.productId}`)
  78. },
  79. handAddCarts(pro){
  80. this.ProductService.shoppingAddCart({productId:pro.productId,userId:this.listQuery.userId,productCount:1}).then(response => {
  81. this.$util.msg('加入购物车成功',1500,true,'success')
  82. this.GetCartNumber()
  83. }).catch(error =>{
  84. this.$util.msg(error.msg,2000);
  85. })
  86. },
  87. },
  88. onPullDownRefresh() {//下拉刷新
  89. this.listQuery.pageNum = 1
  90. THIS.GetProductActivityDetails()
  91. uni.stopPullDownRefresh()
  92. },
  93. onReachBottom(){
  94. if(this.hasNextPage){
  95. this.GetOnReachBottomData()
  96. }
  97. },
  98. onShow() {
  99. }
  100. }
  101. </script>
  102. <style lang="scss">
  103. page{
  104. height: auto !important;
  105. background-color: $color-system;
  106. }
  107. .activity-banner{
  108. width: 100%;
  109. height: 600rpx;
  110. float: left;
  111. margin-bottom: 64rpx;
  112. .activity-banner-image{
  113. width: 100%;
  114. height: 100%;
  115. display: block;
  116. }
  117. }
  118. .container-section{
  119. width: 100%;
  120. height: auto;
  121. box-sizing: border-box;
  122. padding: 0 24rpx;
  123. .product-list{
  124. width: 339rpx;
  125. height: 532rpx;
  126. float: left;
  127. margin-right: 24rpx;
  128. margin-bottom: 24rpx;
  129. background-color: #FFFFFF;
  130. border-radius: 16rpx;
  131. &:nth-child(2n){
  132. margin-right: 0;
  133. }
  134. .product-list-image{
  135. width: 100%;
  136. height: 339rpx;
  137. float: left;
  138. position: relative;
  139. .product-image{
  140. width: 100%;
  141. height: 100%;
  142. display: block;
  143. border-radius: 16rpx 16rpx 0 0;
  144. }
  145. .product-icon{
  146. width: 68rpx;
  147. height: 55rpx;
  148. display: block;
  149. position: absolute;
  150. top: 0;
  151. left: 34rpx;
  152. }
  153. }
  154. .product-list-msg{
  155. width: 100%;
  156. height: 193rpx;
  157. box-sizing: border-box;
  158. padding: 16rpx 24rpx;
  159. float: left;
  160. position: relative;
  161. .product-msg-name{
  162. width: 100%;
  163. height: 72rpx;
  164. line-height: 35rpx;
  165. text-overflow: ellipsis;
  166. overflow: hidden;
  167. display: -webkit-box;
  168. -webkit-line-clamp: 2;
  169. line-clamp: 2;
  170. -webkit-box-orient: vertical;
  171. font-size: $font-size-26;
  172. color: #333333;
  173. text-align: justify;
  174. float: left;
  175. }
  176. .product-list-tag{
  177. width: 100%;
  178. height: 30rpx;
  179. margin-top: 8rpx;
  180. float: left;
  181. .tag{
  182. display: inline-block;
  183. width: 80rpx;
  184. height: 30rpx;
  185. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png)top center no-repeat;
  186. background-size: contain;
  187. font-size: 22rpx;
  188. line-height: 30rpx;
  189. text-align: center;
  190. color: #f83c6c;
  191. float: left;
  192. }
  193. }
  194. .product-list-pri{
  195. width: 100%;
  196. height: 44rpx;
  197. float: left;
  198. position: absolute;
  199. bottom: 16rpx;
  200. left: 0;
  201. box-sizing: border-box;
  202. padding: 0 24rpx;
  203. .price{
  204. float: left;
  205. font-size:$font-size-26;
  206. color: #f83c6c;
  207. font-weight: bold;
  208. line-height: 44rpx;
  209. }
  210. .carts{
  211. float: right;
  212. .carts-add{
  213. width: 44rpx;
  214. height: 44rpx;
  215. text-align: center;
  216. line-height: 44rpx;
  217. background-color: #ff457b;
  218. border-radius: 50%;
  219. .iconfont{
  220. font-size: 32rpx;
  221. color: #FFFFFF;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }
  228. }
  229. </style>