categoryShow.vue 7.5 KB

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