ChoiceZone.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view
  3. class="hxbox u-skeleton-fillet"
  4. v-if="hxCateList.length || skeletonShow"
  5. >
  6. <view class="title">惠选专区</view>
  7. <view class="hxClassify">
  8. <view
  9. class="item"
  10. v-for="(item) in skeletonShow ? 1 : hxCateList.slice(0, 4)"
  11. @click="jumpHxCate(item)"
  12. :key="item.id"
  13. >
  14. <image
  15. mode="widthFix"
  16. :src="`${item.cover_image}?x-oss-process=style/w_350`"
  17. ></image>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. import { ref, onMounted } from "vue";
  24. const props = defineProps({
  25. skeletonShow: {
  26. type: Boolean,
  27. default: false
  28. }
  29. });
  30. const emit = defineEmits(['jumpHxCate']);
  31. const hxCateList = ref([]);
  32. const jumpHxCate = (item) => {
  33. emit('jumpHxCate', item);
  34. };
  35. const getHxCateList = () => {
  36. return
  37. uni.$uv.$http.get("/hxcategory/home/recommend/4").then((res) => {
  38. if (res && res.code == 200) {
  39. hxCateList.value = res.list;
  40. }
  41. });
  42. };
  43. // getHxCateList();
  44. onMounted(() => {
  45. getHxCateList();
  46. });
  47. defineExpose({
  48. init: getHxCateList,
  49. });
  50. </script>
  51. <style scoped lang="scss">
  52. .hxbox {
  53. padding: 30rpx 30rpx 0;
  54. margin: 0rpx 30rpx 30rpx;
  55. background: linear-gradient(139deg, #ffe9c4 1%, #edffe7 100%);
  56. border-radius: 10rpx;
  57. .title {
  58. font-size: 36rpx;
  59. font-weight: bold;
  60. color: #1a1a1a;
  61. }
  62. .hxClassify {
  63. display: flex;
  64. flex-wrap: wrap;
  65. justify-content: space-between;
  66. margin-top: 30rpx;
  67. color: #373737;
  68. .item {
  69. text-align: center;
  70. margin-bottom: 20rpx;
  71. image {
  72. width: 300rpx !important;
  73. height: 210rpx !important;
  74. }
  75. }
  76. .item:first-child {
  77. margin-left: 0;
  78. }
  79. .item:nth-child(5n + 1) {
  80. margin-left: 0;
  81. }
  82. }
  83. }
  84. </style>