activity.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. import wxLogin from "@/services/wxLogin.js"
  31. import { mapState,mapMutations} from 'vuex';
  32. export default{
  33. data(){
  34. return{
  35. activityBanner:`${this.$Static}banner.png`,
  36. listQuery:{
  37. activityId:0,
  38. userId:0,
  39. pageNum:1,
  40. pageSize:10
  41. },
  42. UserId:0,//存储普通用户ID
  43. hasNextPage:false,
  44. productList:[],//商品列表
  45. }
  46. },
  47. onLoad(option) {
  48. this.listQuery.activityId = option.activityId
  49. this.listQuery.userId = option.userId
  50. this.GetProductActivityDetails();
  51. },
  52. filters: {
  53. //处理金额
  54. PriceFormat: function(text) {
  55. return Number(text).toFixed(2)
  56. }
  57. },
  58. computed: {
  59. ...mapState(['hasLogin','userInfo','identity','isActivity'])
  60. },
  61. methods:{
  62. GetProductActivityDetails(){//初始化活动详情
  63. this.ProductService.GetProductActivityDetails(this.listQuery).then(response => {
  64. const data = response.data
  65. this.activityBanner = data.image
  66. this.hasNextPage = data.pageInfo.hasNextPage
  67. this.productList = data.pageInfo.list
  68. }).catch(error =>{
  69. this.$util.msg(error.msg,2000);
  70. })
  71. },
  72. GetOnReachBottomData(){//上滑加载更多
  73. this.listQuery.pageNum+=1
  74. this.ProductService.GetProductActivityDetails(this.listQuery).then(response => {
  75. const data = response.data
  76. this.hasNextPage = data.pageInfo.hasNextPage
  77. this.productList = this.productList.concat(data.pageInfo.list)
  78. }).catch(error =>{
  79. this.$util.msg(error.msg,2000);
  80. })
  81. },
  82. Details(pro){
  83. this.$api.navigateTo(`/pages/goods/product-activi?productId=${pro.productId}&heUserId=${this.listQuery.userId}`)
  84. },
  85. handAddCarts(pro){
  86. if(!this.hasLogin){
  87. this.$api.navigateTo(`/pages/login/login`)
  88. }else{
  89. this.ProductService.shoppingAddCart(
  90. {
  91. productId:pro.productId,
  92. userId:this.UserId*1,
  93. productCount:1,
  94. heUserId:this.listQuery.userId*1,
  95. }
  96. ).then(response => {
  97. this.$util.msg('加入购物车成功',1500,true,'success')
  98. this.GetCartNumber()
  99. }).catch(error =>{
  100. this.$util.msg(error.msg,2000);
  101. })
  102. }
  103. },
  104. },
  105. onPullDownRefresh() {//下拉刷新
  106. this.listQuery.pageNum = 1
  107. THIS.GetProductActivityDetails()
  108. uni.stopPullDownRefresh()
  109. },
  110. onReachBottom(){
  111. if(this.hasNextPage){
  112. this.GetOnReachBottomData()
  113. }
  114. },
  115. onShow() {
  116. wxLogin.wxLoginQuick()
  117. this.$api.getStorage().then((resolve) => {
  118. this.UserId = resolve.userId ? resolve.userId : '';
  119. })
  120. },
  121. onShareAppMessage(res){//分享转发
  122. if (res.from === 'button') {
  123. // 来自页面内转发按钮
  124. }
  125. return {
  126. title: '活动名称活动名称活动名称活动名称活动名称活动名称',
  127. path: `/pages/user/activity/activity?activityId=${this.listQuery.activityId}&userId=${this.listQuery.userId}`,
  128. imageUrl:'https://static.caimei365.com/app/mini-hehe/icon/icon-index-share.jpg'
  129. }
  130. },
  131. }
  132. </script>
  133. <style lang="scss">
  134. page{
  135. height: auto !important;
  136. background-color: $color-system;
  137. }
  138. .activity-banner{
  139. width: 100%;
  140. height: 600rpx;
  141. float: left;
  142. margin-bottom: 64rpx;
  143. .activity-banner-image{
  144. width: 100%;
  145. height: 100%;
  146. display: block;
  147. }
  148. }
  149. .container-section{
  150. width: 100%;
  151. height: auto;
  152. box-sizing: border-box;
  153. padding: 0 24rpx;
  154. .product-list{
  155. width: 339rpx;
  156. height: 532rpx;
  157. float: left;
  158. margin-right: 24rpx;
  159. margin-bottom: 24rpx;
  160. background-color: #FFFFFF;
  161. border-radius: 16rpx;
  162. &:nth-child(2n){
  163. margin-right: 0;
  164. }
  165. .product-list-image{
  166. width: 100%;
  167. height: 339rpx;
  168. float: left;
  169. position: relative;
  170. .product-image{
  171. width: 100%;
  172. height: 100%;
  173. display: block;
  174. border-radius: 16rpx 16rpx 0 0;
  175. }
  176. .product-icon{
  177. width: 68rpx;
  178. height: 55rpx;
  179. display: block;
  180. position: absolute;
  181. top: 0;
  182. left: 34rpx;
  183. }
  184. }
  185. .product-list-msg{
  186. width: 100%;
  187. height: 193rpx;
  188. box-sizing: border-box;
  189. padding: 16rpx 24rpx;
  190. float: left;
  191. position: relative;
  192. .product-msg-name{
  193. width: 100%;
  194. height: 72rpx;
  195. line-height: 35rpx;
  196. text-overflow: ellipsis;
  197. overflow: hidden;
  198. display: -webkit-box;
  199. -webkit-line-clamp: 2;
  200. line-clamp: 2;
  201. -webkit-box-orient: vertical;
  202. font-size: $font-size-26;
  203. color: #333333;
  204. text-align: justify;
  205. float: left;
  206. }
  207. .product-list-tag{
  208. width: 100%;
  209. height: 30rpx;
  210. margin-top: 8rpx;
  211. float: left;
  212. .tag{
  213. display: inline-block;
  214. width: 80rpx;
  215. height: 30rpx;
  216. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png)top center no-repeat;
  217. background-size: contain;
  218. font-size: 22rpx;
  219. line-height: 30rpx;
  220. text-align: center;
  221. color: #f83c6c;
  222. float: left;
  223. }
  224. }
  225. .product-list-pri{
  226. width: 100%;
  227. height: 44rpx;
  228. float: left;
  229. position: absolute;
  230. bottom: 16rpx;
  231. left: 0;
  232. box-sizing: border-box;
  233. padding: 0 24rpx;
  234. .price{
  235. float: left;
  236. font-size:$font-size-26;
  237. color: #f83c6c;
  238. font-weight: bold;
  239. line-height: 44rpx;
  240. }
  241. .carts{
  242. float: right;
  243. .carts-add{
  244. width: 44rpx;
  245. height: 44rpx;
  246. text-align: center;
  247. line-height: 44rpx;
  248. background-color: #ff457b;
  249. border-radius: 50%;
  250. .iconfont{
  251. font-size: 32rpx;
  252. color: #FFFFFF;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. </style>