activity.vue 7.1 KB

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