多租户商城-商户小程序端
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.

352 lines
8.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <view class="goodRecommend">
  3. <ProductSkeleton :loading="loading" :isFirst="isFirst" />
  4. <template v-if="!isFirst">
  5. <view class="product-list">
  6. <view class="product-list-box">
  7. <view
  8. class="product-list-item-warp"
  9. v-for="(item,index) in productList"
  10. :key="index"
  11. >
  12. <view
  13. class="product-list-item"
  14. >
  15. <view
  16. class="product-list-img"
  17. @click="handleJumpProductDetail(item)"
  18. >
  19. <img
  20. v-show="item.image"
  21. class="img"
  22. :src="item.image"
  23. >
  24. </view>
  25. <view class="product-list-info u-skeleton-fillet">
  26. <view class="product-name">{{ item.productName }}</view>
  27. <view class="flex">
  28. <view
  29. class="shop-box"
  30. @click.stop="handleJumpStore(item)"
  31. >
  32. <view
  33. class="shop-name"
  34. @click="handleJumpProductDetail(item)"
  35. >{{ item.shopName }}
  36. </view>
  37. </view>
  38. <view class="buy-count">{{ item.users ? item.users : 0 }}{{$t('common.payticktip')}}</view>
  39. </view>
  40. <div class="price-warp">
  41. <image
  42. class="iconImg"
  43. :src="getPriceActivity(item.activityType)"
  44. />
  45. <div class="price">
  46. ¥ {{ item.price }}
  47. </div>
  48. <div class="original-price">
  49. ¥ {{ item.originalPrice }}
  50. </div>
  51. </div>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view >
  57. <!-- 空状态 -->
  58. <Empty
  59. background="#fff"
  60. :show="!loading && productList.length<0"
  61. src="https://ceres.zkthink.com/static/img/bgnull.png"
  62. >
  63. {{$t('client.emptydata')}}
  64. </Empty>
  65. <!-- 底部提示 -->
  66. <ListBottomTips
  67. v-show="loading || total!==0&&total===productList.length"
  68. :loading="loading"
  69. :type="productList.length<total?1:0"
  70. />
  71. </template>
  72. </view>
  73. </template>
  74. <script>
  75. import Empty from "@/components/Empty";
  76. import ProductSkeleton from "./components/ProductSkeleton";
  77. import ListBottomTips from "@/components/ListBottomTips";
  78. const NET = require('@/utils/request')
  79. const API = require('@/config/api')
  80. export default {
  81. name: "categoryShow",
  82. components: {
  83. Empty,
  84. ListBottomTips,
  85. ProductSkeleton
  86. },
  87. props: {
  88. classifyId: {
  89. type: Number,
  90. default: 0
  91. }
  92. },
  93. computed: {
  94. // 获取活动小图标
  95. getPriceActivity() {
  96. return (activityType) => {
  97. switch (activityType) {
  98. case 1:
  99. return require('../canvasShow/static/images/groupBuyIcon.png')
  100. case 2:
  101. return require('../canvasShow/static/images/spikeIcon.png')
  102. case 3:
  103. return require('../canvasShow/static/images/discountListIcon.png')
  104. case 4:
  105. return require('../canvasShow/static/images/spikeIcon.png')
  106. case 5:
  107. return require('../canvasShow/static/images/discountListIcon.png')
  108. case 8:
  109. return require('../canvasShow/static/images/memberCenterIcon.png')
  110. }
  111. }
  112. }
  113. },
  114. data() {
  115. return {
  116. page: 1,
  117. pageSize: 10,
  118. total: 0,
  119. productList: [],
  120. isFirst:true,
  121. loading: true // 是否正在请求
  122. }
  123. },
  124. mounted() {
  125. this.handleResetList()
  126. this.handleResetPage()
  127. this.handleGetProductData();
  128. },
  129. methods: {
  130. // 重设苏族
  131. handleResetList() {
  132. uni.pageScrollTo({
  133. scrollTop: 0,
  134. duration: 0
  135. });
  136. this.isFirst = true
  137. this.productList = []
  138. },
  139. handleResetPage() {
  140. this.total = 0
  141. this.page = 1
  142. },
  143. // 获取商品数据
  144. handleGetProductData() {
  145. if (this.total !== 0 && this.productList.length >= this.total) {
  146. return
  147. }
  148. this.loading = true
  149. NET.request(API.getProductsV2, {
  150. classifyId: this.classifyId,
  151. page: this.page,
  152. pageSize: this.pageSize
  153. }, 'GET').then(res => {
  154. this.productList = [...this.productList, ...res.data.list]
  155. this.total = res.data.total
  156. }).catch(err => {
  157. throw Error(err)
  158. }).finally(() => {
  159. this.loading = false
  160. this.isFirst = false
  161. })
  162. },
  163. // 跳转到店铺主页
  164. handleJumpStore(item) {
  165. uni.navigateTo({
  166. url: `/pages_category_page1/store/index?storeId=${ item.shopId }`
  167. })
  168. },
  169. // 跳转到商品详情
  170. handleJumpProductDetail(item) {
  171. uni.navigateTo({
  172. url: '/pages_category_page1/goodsModule/goodsDetails?shopId=' + item.shopId + '&productId=' + item.productId + '&skuId=' + item
  173. .skuId
  174. })
  175. }
  176. },
  177. watch: {
  178. 'classifyId': {
  179. handler() {
  180. this.handleResetList()
  181. this.handleResetPage()
  182. this.handleGetProductData()
  183. },
  184. deep: true
  185. }
  186. },
  187. }
  188. </script>
  189. <style
  190. lang="scss"
  191. scoped
  192. >
  193. .goodRecommend {
  194. padding-top: 20rpx;
  195. .product-list {
  196. position: relative;
  197. padding: 0 13upx;
  198. width: 100%;
  199. //min-height: 60vh;
  200. &-box {
  201. display: flex;
  202. flex-wrap: wrap;
  203. flex-direction: row;
  204. &.swiper {
  205. height: 620upx;
  206. }
  207. }
  208. &.product-swiper .product-list-box {
  209. padding-left: 0;
  210. }
  211. &-item-warp {
  212. margin: 0 0 20upx 0;
  213. }
  214. &-item {
  215. width: 348upx;
  216. padding: 0 7upx;
  217. box-sizing: content-box;
  218. }
  219. &-img {
  220. width: 348upx;
  221. height: 348upx;
  222. background-color: white;
  223. border-radius: 10upx 10upx 0 0;
  224. .img {
  225. width: 100%;
  226. height: 100%;
  227. object-fit: contain;
  228. }
  229. }
  230. &-info {
  231. background-color: #FFFFFF;
  232. //box-shadow: 0px 0px 15px 0px rgba(52, 52, 52, 0.15);
  233. border-radius: 0 0 10upx 10upx;
  234. padding: 20upx;
  235. label {
  236. font-weight: normal;
  237. }
  238. .product-name {
  239. font-size: 28upx;
  240. color: #333;
  241. display: block;
  242. overflow: hidden;
  243. text-overflow: ellipsis;
  244. white-space: nowrap;
  245. margin-bottom: 18upx;
  246. line-height: 40upx;
  247. }
  248. .flex {
  249. display: flex;
  250. align-items: center;
  251. }
  252. .shop-box {
  253. background-color: #333333;
  254. border-radius: 0upx 20upx 20upx 0upx;
  255. line-height: 40upx;
  256. display: flex;
  257. align-items: center;
  258. height: 40upx;
  259. margin-right: 10upx;
  260. float: left;
  261. .shop-name {
  262. font-size: 20upx;
  263. color: #FFEBC4;
  264. padding: 0 8upx 0 12upx;
  265. line-height: 40upx;
  266. display: inline-block;
  267. float: left;
  268. max-width: 170rpx;
  269. white-space: nowrap;
  270. overflow: hidden;
  271. text-overflow: ellipsis;
  272. }
  273. .shop-logo {
  274. border: 2upx solid #707070;
  275. border-radius: 50%;
  276. overflow: hidden;
  277. float: right;
  278. img {
  279. width: 34upx;
  280. height: 34upx;
  281. display: block;
  282. }
  283. }
  284. }
  285. .buy-count {
  286. color: #C5AA7B;
  287. font-size: 20upx;
  288. border: 2upx solid #E4E5E6;
  289. line-height: 36upx;
  290. padding: 0 5upx;
  291. }
  292. .price-warp {
  293. display: flex;
  294. align-items: baseline;
  295. line-height: 56upx;
  296. .iconImg {
  297. width: 58rpx;
  298. height: 36rpx;
  299. margin-right: 10rpx;
  300. }
  301. .price {
  302. color: #C83732;
  303. font-size: 40upx;
  304. margin-right: 20upx;
  305. }
  306. .original-price {
  307. font-size: 24upx;
  308. color: #ccc;
  309. text-decoration: line-through;
  310. }
  311. }
  312. }
  313. }
  314. .emptyCart-box {
  315. margin-top: 70rpx;
  316. .emptyCart-img {
  317. width: 216rpx;
  318. height: 156rpx;
  319. }
  320. }
  321. }
  322. </style>