categoryShow.vue 5.4 KB

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