categoryShow.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="goodRecommend">
  3. <!-- 骨架屏 -->
  4. <view class="product-list">
  5. <view class="product-list-box" >
  6. <view class="product-list-item-warp" v-for="(item,index) in productList" :key="index">
  7. <view class="product-list-item" v-if="JSON.stringify(item)!=='{}'">
  8. <view class="product-list-img" @click="jumpProductDetail(item)">
  9. <img v-show="item.image" class="img" :src="item.image">
  10. </view>
  11. <view class="product-list-info u-skeleton-fillet">
  12. <view class="product-name">{{item.productName}}</view>
  13. <view class="flex">
  14. <view class="shop-box" @click.stop="jumpStore(item)">
  15. <view class="shop-name" @click="jumpProductDetail(item)">{{item.shopName}}</view>
  16. <view class="shop-logo">
  17. <img :src="item.shopLogo">
  18. </view>
  19. </view>
  20. <view class="buy-count">{{item.users?item.users: 0}}人付款</view>
  21. </view>
  22. <div class="price-warp">
  23. <!-- #ifdef MP-WEIXIN -->
  24. <img class="iconImg" v-if="item.activityType == 1" src="../canvasShow/static/images/groupBuyIcon.png">
  25. <img class="iconImg" v-if="item.activityType == 2" src="../canvasShow/static/images/spikeIcon.png">
  26. <img class="iconImg" v-if="item.activityType == 4" src="../canvasShow/static/images/spikeIcon.png">
  27. <img class="iconImg" v-if="item.activityType == 3" src="../canvasShow/static/images/discountListIcon.png">
  28. <img class="iconImg" v-if="item.activityType == 5" src="../canvasShow/static/images/discountListIcon.png">
  29. <img class="iconImg" v-if="item.activityType == 8" src="../canvasShow/static/images/memberCenterIcon.png">
  30. <!-- #endif -->
  31. <!-- #ifdef H5 || APP-PLUS -->
  32. <image class="iconImg" v-if="item.activityType == 1" src="../canvasShow/static/images/groupBuyIcon.png"></image>
  33. <image class="iconImg" v-if="item.activityType == 2" src="../canvasShow/static/images/spikeIcon.png"></image>
  34. <image class="iconImg" v-if="item.activityType == 4" src="../canvasShow/static/images/spikeIcon.png"></image>
  35. <image class="iconImg" v-if="item.activityType == 3" src="../canvasShow/static/images/discountListIcon.png"></image>
  36. <image class="iconImg" v-if="item.activityType == 5" src="../canvasShow/static/images/discountListIcon.png"></image>
  37. <image class="iconImg" v-if="item.activityType == 8" src="../canvasShow/static/images/memberCenterIcon.png"></image>
  38. <!-- #endif -->
  39. <div class="price">
  40. ¥ {{item.price}}
  41. </div>
  42. <div class="original-price">
  43. ¥ {{item.originalPrice}}
  44. </div>
  45. </div>
  46. </view>
  47. </view>
  48. <view class="product-list-item ske-loading" v-else>
  49. <view class="product-list-img child-loading">
  50. <img v-show="item.image" class="img" :src="item.image">
  51. </view>
  52. <view class="product-list-info">
  53. <view class="product-name child-loading" style="border-radius: 5rpx; margin-top: 10rpx;width: 100%;padding: 20rpx 0"></view>
  54. <view class="product-name child-loading" style="border-radius: 5rpx; margin-top: 10rpx;width: 100%;padding: 20rpx 0"></view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view v-if="ifShow" class="emptyCart-box flex-items-plus flex-column">
  61. <image class="emptyCart-img" src="https://ceres.zkthink.com/static/img/bgnull.png" mode="widthFix" />
  62. <label class="font-color-999 fs26 mar-top-30">这里空空如也~</label>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. const NET = require('@/utils/request')
  68. const API = require('@/config/api')
  69. export default {
  70. name: "categoryShow",
  71. props: {
  72. categoryid: {
  73. type: Number,
  74. default: 0
  75. }
  76. },
  77. data () {
  78. return {
  79. activeTab: 0,
  80. page:1,
  81. pageSize:10,
  82. total: 0,
  83. productList: [],
  84. ifShow: false
  85. }
  86. },
  87. mounted () {
  88. this.productList = [{},{},{},{},{},{},{},{}]
  89. this.getData();
  90. },
  91. methods:{
  92. getData(){
  93. console.log('加载了getData')
  94. // uni.showLoading({
  95. // mask: true,
  96. // title:'加载中...'
  97. // })
  98. if (this.total!=0&&this.productList.length>=this.total){
  99. console.log("加载完了")
  100. return
  101. }
  102. NET.request(API.getProducts, {
  103. classifyId: this.categoryid,
  104. page:this.page,
  105. pageSize:this.pageSize
  106. }, 'GET').then(res => {
  107. this.productList = [...this.productList,...res.data.list]
  108. this.productList = this.productList.filter(item=>JSON.stringify(item)!=='{}')
  109. this.total = res.data.total
  110. uni.hideLoading()
  111. if (this.productList.length ===0) {
  112. this.ifShow = true
  113. }
  114. }).catch(res => {
  115. uni.hideLoading()
  116. })
  117. },
  118. // 跳转到店铺主页
  119. jumpStore(item){
  120. uni.navigateTo({
  121. url: `/pages_category_page1/store/index?storeId=${item.shopId}`
  122. })
  123. },
  124. // 跳转到商品详情
  125. jumpProductDetail(item){
  126. uni.navigateTo({
  127. url: '/pages_category_page1/goodsModule/goodsDetails?shopId=' + item.shopId + '&productId=' + item.productId + '&skuId=' + item
  128. .skuId
  129. })
  130. }
  131. },
  132. watch: {
  133. 'categoryid': {
  134. handler(newVal, oldVal) {
  135. this.ifShow = false
  136. this.getData()
  137. },
  138. deep: true
  139. }
  140. },
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .goodRecommend {
  145. padding-top: 20rpx;
  146. .product-list {
  147. position: relative;
  148. padding: 0 13upx;
  149. width: 100%;
  150. //min-height: 60vh;
  151. &-box {
  152. display: flex;
  153. flex-wrap: wrap;
  154. flex-direction: row;
  155. &.swiper{
  156. height: 620upx;
  157. }
  158. }
  159. &.product-swiper .product-list-box{
  160. padding-left: 0;
  161. }
  162. &-item-warp{
  163. margin: 0 0 20upx 0;
  164. }
  165. &-item {
  166. width: 348upx;
  167. padding: 0 7upx;
  168. box-sizing: content-box;
  169. }
  170. &-img {
  171. width: 348upx;
  172. height: 348upx;
  173. background-color: #d0d0d0;
  174. border-radius: 10upx 10upx 0 0;
  175. .img {
  176. width: 100%;
  177. height: 100%;
  178. object-fit: contain;
  179. }
  180. }
  181. &-info {
  182. background-color: #FFFFFF;
  183. //box-shadow: 0px 0px 15px 0px rgba(52, 52, 52, 0.15);
  184. border-radius: 0 0 10upx 10upx;
  185. padding: 20upx;
  186. label{
  187. font-weight: normal;
  188. }
  189. .product-name{
  190. font-size: 28upx;
  191. color: #333;
  192. display: block;
  193. overflow: hidden;
  194. text-overflow:ellipsis;
  195. white-space: nowrap;
  196. margin-bottom: 18upx;
  197. line-height: 40upx;
  198. }
  199. .flex{
  200. display: flex;
  201. align-items: center;
  202. }
  203. .shop-box{
  204. background-color: #333333;
  205. border-radius: 0upx 20upx 20upx 0upx;
  206. line-height: 40upx;
  207. display: flex;
  208. align-items: center;
  209. height: 40upx;
  210. margin-right: 10upx;
  211. float: left;
  212. .shop-name{
  213. font-size: 20upx;
  214. color: #FFEBC4;
  215. padding: 0 8upx 0 12upx;
  216. line-height: 40upx;
  217. display: inline-block;
  218. float: left;
  219. }
  220. .shop-logo{
  221. border: 2upx solid #707070;
  222. border-radius: 50%;
  223. overflow: hidden;
  224. float: right;
  225. img{
  226. width: 34upx;
  227. height: 34upx;
  228. display: block;
  229. }
  230. }
  231. }
  232. .buy-count{
  233. color: #C5AA7B;
  234. font-size: 20upx;
  235. border: 2upx solid #E4E5E6;
  236. line-height: 36upx;
  237. padding: 0 5upx;
  238. }
  239. .price-warp{
  240. display: flex;
  241. align-items: baseline;
  242. line-height: 56upx;
  243. .iconImg {
  244. width: 58rpx;
  245. height: 36rpx;
  246. margin-right: 10rpx;
  247. }
  248. .price{
  249. color: #C83732;
  250. font-size: 40upx;
  251. margin-right: 20upx;
  252. }
  253. .original-price{
  254. font-size: 24upx;
  255. color: #ccc;
  256. text-decoration: line-through;
  257. }
  258. }
  259. }
  260. }
  261. .emptyCart-box {
  262. margin-top: 70rpx;
  263. .emptyCart-img {
  264. width: 216rpx;
  265. height: 156rpx;
  266. }
  267. }
  268. }
  269. </style>