activity.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. console.log('查询购物车数量错误信息',error)
  101. })
  102. }
  103. },
  104. GetCartNumber(){//查询购物车数量
  105. this.ProductService.QueryShoppingQuantity(
  106. {
  107. userId:this.listQuery.userId,
  108. }
  109. )
  110. .then(response => {
  111. this.$store.commit('updateAllNum',response.data)
  112. this.skeletonShow = false;
  113. })
  114. .catch(error =>{
  115. console.log('查询购物车数量错误信息',error)
  116. })
  117. }
  118. },
  119. onPullDownRefresh() {//下拉刷新
  120. this.listQuery.pageNum = 1
  121. THIS.GetProductActivityDetails()
  122. uni.stopPullDownRefresh()
  123. },
  124. onReachBottom(){
  125. if(this.hasNextPage){
  126. this.GetOnReachBottomData()
  127. }
  128. },
  129. onShow() {
  130. wxLogin.wxLoginQuick()
  131. this.$api.getStorage().then((resolve) => {
  132. this.UserId = resolve.userId ? resolve.userId : '';
  133. })
  134. },
  135. onShareAppMessage(res){//分享转发
  136. if (res.from === 'button') {
  137. // 来自页面内转发按钮
  138. }
  139. return {
  140. title: '活动名称活动名称活动名称活动名称活动名称活动名称',
  141. path: `/pages/user/activity/activity?activityId=${this.listQuery.activityId}&userId=${this.listQuery.userId}`,
  142. imageUrl:'https://static.caimei365.com/app/mini-hehe/icon/icon-index-share.jpg'
  143. }
  144. },
  145. }
  146. </script>
  147. <style lang="scss">
  148. page{
  149. height: auto !important;
  150. background-color: $color-system;
  151. }
  152. .activity-banner{
  153. width: 100%;
  154. height: 600rpx;
  155. float: left;
  156. margin-bottom: 64rpx;
  157. .activity-banner-image{
  158. width: 100%;
  159. height: 100%;
  160. display: block;
  161. }
  162. }
  163. .container-section{
  164. width: 100%;
  165. height: auto;
  166. box-sizing: border-box;
  167. padding: 0 24rpx;
  168. .product-list{
  169. width: 339rpx;
  170. height: 532rpx;
  171. float: left;
  172. margin-right: 24rpx;
  173. margin-bottom: 24rpx;
  174. background-color: #FFFFFF;
  175. border-radius: 16rpx;
  176. &:nth-child(2n){
  177. margin-right: 0;
  178. }
  179. .product-list-image{
  180. width: 100%;
  181. height: 339rpx;
  182. float: left;
  183. position: relative;
  184. .product-image{
  185. width: 100%;
  186. height: 100%;
  187. display: block;
  188. border-radius: 16rpx 16rpx 0 0;
  189. }
  190. .product-icon{
  191. width: 68rpx;
  192. height: 55rpx;
  193. display: block;
  194. position: absolute;
  195. top: 0;
  196. left: 34rpx;
  197. }
  198. }
  199. .product-list-msg{
  200. width: 100%;
  201. height: 193rpx;
  202. box-sizing: border-box;
  203. padding: 16rpx 24rpx;
  204. float: left;
  205. position: relative;
  206. .product-msg-name{
  207. width: 100%;
  208. height: 72rpx;
  209. line-height: 35rpx;
  210. text-overflow: ellipsis;
  211. overflow: hidden;
  212. display: -webkit-box;
  213. -webkit-line-clamp: 2;
  214. line-clamp: 2;
  215. -webkit-box-orient: vertical;
  216. font-size: $font-size-26;
  217. color: #333333;
  218. text-align: justify;
  219. float: left;
  220. }
  221. .product-list-tag{
  222. width: 100%;
  223. height: 30rpx;
  224. margin-top: 8rpx;
  225. float: left;
  226. .tag{
  227. display: inline-block;
  228. width: 80rpx;
  229. height: 30rpx;
  230. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png)top center no-repeat;
  231. background-size: contain;
  232. font-size: 22rpx;
  233. line-height: 30rpx;
  234. text-align: center;
  235. color: #f83c6c;
  236. float: left;
  237. }
  238. }
  239. .product-list-pri{
  240. width: 100%;
  241. height: 44rpx;
  242. float: left;
  243. position: absolute;
  244. bottom: 16rpx;
  245. left: 0;
  246. box-sizing: border-box;
  247. padding: 0 24rpx;
  248. .price{
  249. float: left;
  250. font-size:$font-size-26;
  251. color: #f83c6c;
  252. font-weight: bold;
  253. line-height: 44rpx;
  254. }
  255. .carts{
  256. float: right;
  257. .carts-add{
  258. width: 44rpx;
  259. height: 44rpx;
  260. text-align: center;
  261. line-height: 44rpx;
  262. background-color: #ff457b;
  263. border-radius: 50%;
  264. .iconfont{
  265. font-size: 32rpx;
  266. color: #FFFFFF;
  267. }
  268. }
  269. }
  270. }
  271. }
  272. }
  273. }
  274. </style>