categoryShow.vue 7.3 KB

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