categoryShow.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 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. <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. mask: true,
  67. title:'加载中...'
  68. })
  69. NET.request(API.getProducts, {
  70. classifyId: this.categoryid,
  71. page:this.page,
  72. pageSize:this.pageSize
  73. }, 'GET').then(res => {
  74. this.productList = res.data.list
  75. uni.hideLoading()
  76. }).catch(res => {
  77. uni.hideLoading()
  78. })
  79. },
  80. // 跳转到店铺主页
  81. jumpStore(item){
  82. uni.navigateTo({
  83. url: `/pages_category_page1/store/index?storeId=${item.shopId}`
  84. })
  85. },
  86. // 跳转到商品详情
  87. jumpProductDetail(item){
  88. uni.navigateTo({
  89. url: '/pages_category_page1/goodsModule/goodsDetails?shopId=' + item.shopId + '&productId=' + item.productId + '&skuId=' + item
  90. .skuId
  91. })
  92. }
  93. },
  94. watch: {
  95. 'categoryid': {
  96. handler(newVal, oldVal) {
  97. this.getData()
  98. },
  99. deep: true
  100. }
  101. },
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .goodRecommend {
  106. padding-top: 20rpx;
  107. .product-list {
  108. position: relative;
  109. padding: 0 13upx;
  110. &-box {
  111. display: flex;
  112. flex-wrap: wrap;
  113. flex-direction: row;
  114. &.swiper{
  115. height: 620upx;
  116. }
  117. }
  118. &.product-swiper .product-list-box{
  119. padding-left: 0;
  120. }
  121. &-item-warp{
  122. margin: 0 0 20upx 0;
  123. }
  124. &-item {
  125. width: 348upx;
  126. padding: 0 7upx;
  127. box-sizing: content-box;
  128. }
  129. &-img {
  130. width: 348upx;
  131. height: 348upx;
  132. background-color: #d0d0d0;
  133. border-radius: 10upx 10upx 0 0;
  134. .img {
  135. width: 100%;
  136. height: 100%;
  137. object-fit: contain;
  138. }
  139. }
  140. &-info {
  141. background-color: #FFFFFF;
  142. //box-shadow: 0px 0px 15px 0px rgba(52, 52, 52, 0.15);
  143. border-radius: 0 0 10upx 10upx;
  144. padding: 20upx;
  145. label{
  146. font-weight: normal;
  147. }
  148. .product-name{
  149. font-size: 28upx;
  150. color: #333;
  151. display: block;
  152. overflow: hidden;
  153. text-overflow:ellipsis;
  154. white-space: nowrap;
  155. margin-bottom: 18upx;
  156. line-height: 40upx;
  157. }
  158. .flex{
  159. display: flex;
  160. align-items: center;
  161. }
  162. .shop-box{
  163. background-color: #333333;
  164. border-radius: 0upx 20upx 20upx 0upx;
  165. line-height: 40upx;
  166. display: flex;
  167. align-items: center;
  168. height: 40upx;
  169. margin-right: 10upx;
  170. float: left;
  171. .shop-name{
  172. font-size: 20upx;
  173. color: #FFEBC4;
  174. padding: 0 8upx 0 12upx;
  175. line-height: 40upx;
  176. display: inline-block;
  177. float: left;
  178. }
  179. .shop-logo{
  180. border: 2upx solid #707070;
  181. border-radius: 50%;
  182. overflow: hidden;
  183. float: right;
  184. img{
  185. width: 34upx;
  186. height: 34upx;
  187. display: block;
  188. }
  189. }
  190. }
  191. .buy-count{
  192. color: #C5AA7B;
  193. font-size: 20upx;
  194. border: 2upx solid #E4E5E6;
  195. line-height: 36upx;
  196. padding: 0 5upx;
  197. }
  198. .price-warp{
  199. display: flex;
  200. align-items: baseline;
  201. line-height: 56upx;
  202. .price{
  203. color: #C83732;
  204. font-size: 40upx;
  205. margin-right: 20upx;
  206. }
  207. .original-price{
  208. font-size: 24upx;
  209. color: #ccc;
  210. text-decoration: line-through;
  211. }
  212. }
  213. }
  214. }
  215. .emptyCart-box {
  216. margin-top: 70rpx;
  217. .emptyCart-img {
  218. width: 216rpx;
  219. height: 156rpx;
  220. }
  221. }
  222. }
  223. </style>