多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
8.4 KiB

2 years ago
  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. max-width: 170rpx;
  220. white-space: nowrap;
  221. overflow:hidden;
  222. text-overflow:ellipsis;
  223. }
  224. .shop-logo{
  225. border: 2upx solid #707070;
  226. border-radius: 50%;
  227. overflow: hidden;
  228. float: right;
  229. img{
  230. width: 34upx;
  231. height: 34upx;
  232. display: block;
  233. }
  234. }
  235. }
  236. .buy-count{
  237. color: #C5AA7B;
  238. font-size: 20upx;
  239. border: 2upx solid #E4E5E6;
  240. line-height: 36upx;
  241. padding: 0 5upx;
  242. }
  243. .price-warp{
  244. display: flex;
  245. align-items: baseline;
  246. line-height: 56upx;
  247. .iconImg {
  248. width: 58rpx;
  249. height: 36rpx;
  250. margin-right: 10rpx;
  251. }
  252. .price{
  253. color: #C83732;
  254. font-size: 40upx;
  255. margin-right: 20upx;
  256. }
  257. .original-price{
  258. font-size: 24upx;
  259. color: #ccc;
  260. text-decoration: line-through;
  261. }
  262. }
  263. }
  264. }
  265. .emptyCart-box {
  266. margin-top: 70rpx;
  267. .emptyCart-img {
  268. width: 216rpx;
  269. height: 156rpx;
  270. }
  271. }
  272. }
  273. </style>