categoryShow.vue 6.7 KB

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