index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="bg-[#f5f5f5]">
  3. <div class="main-container">
  4. <div class="pt-[10px] flex justify-between mt-[25px]">
  5. <div class="w-[224px] flex flex-col">
  6. <info />
  7. <category @categoryClick="categoryClick"/>
  8. </div>
  9. <div class="flex-1 ml-[18px] pb-[30px]">
  10. <el-carousel :interval="3000" height="330px" arrow="never">
  11. <el-carousel-item v-for="(item,index) in advInfo.adv_list" :key="index">
  12. <NuxtLink :to="item.adv_url && item.adv_url.url ? item.adv_url.url : '' ">
  13. <div class="h-full index-carousel">
  14. <img :src="img(item.adv_image)" alt="" class="w-full h-full">
  15. </div>
  16. </NuxtLink>
  17. </el-carousel-item>
  18. </el-carousel>
  19. <div class="pt-[40px] pb-[30px] text-center">
  20. <h1 class="font-700 text-[24px]">{{ t('shopRecommend') }}</h1>
  21. <div class="mt-[15px] text-[#999] text-[14px]">{{ t('shopTips') }}</div>
  22. </div>
  23. <div class="flex flex-wrap items-center">
  24. <div class="bg-[#fff] w-[224px] cursor-pointer rounded-[var(--rounded-big)] overflow-hidden mb-[20px]" :class="{'mr-[20px]':(index + 1) % 4}" v-for="(item,index) in goodsTableData.data" :key="index" @click="toDetail(item.goods_id)">
  25. <div class="w-[224px] h-[224px]">
  26. <el-image class="w-[224px] h-[224px]" :src="img(item.goods_cover_thumb_mid ? item.goods_cover_thumb_mid : '')" fit="cover">
  27. <template #error>
  28. <img src="@/assets/images/goods_default.png" class="w-[224px] h-[224px]">
  29. </template>
  30. </el-image>
  31. </div>
  32. <div class="p-[15px]">
  33. <div class="mb-[8px] text-[22px] text-[var(--el-color-primary)] price-font">¥{{ item.goodsSku.price }}</div>
  34. <div class="mb-[12px] text-[#333] h-[40px] multi-hidden text-[14px] leading-[20px]">{{ item.goods_name }}</div>
  35. <div class="text-[#999] text-[12px] leading-[16px]">
  36. <div>{{item.sale_num}}{{ t('saleNum') }}</div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script lang="ts" setup>
  47. import { ref,reactive } from 'vue'
  48. import category from './components/category/index.vue'
  49. import info from './components/info/index.vue'
  50. import { getGoodsPages} from '@/addon/mall/api/goods'
  51. import { useRouter, useRoute } from 'vue-router'
  52. import { getAdvInfo } from '@/app/api/index'
  53. const router = useRouter()
  54. const route = useRoute()
  55. const detail = ref([])
  56. const goodsTableData = reactive({
  57. page: 1,
  58. limit: 15,
  59. total: 0,
  60. loading: true,
  61. data: [],
  62. searchParam: {
  63. site_id:'',
  64. }
  65. })
  66. goodsTableData.searchParam = Object.assign(goodsTableData.searchParam,route.query)
  67. //获取广告位
  68. // 广告位
  69. const advInfo = ref({})
  70. const getAdvInfoFn = () =>{
  71. getAdvInfo({ap_key:'ADV_INDEX'}).then(res =>{
  72. advInfo.value = res.data
  73. })
  74. }
  75. getAdvInfoFn()
  76. //获取店铺商品列表
  77. const loadGoodsList = (page = 1) => {
  78. goodsTableData.page = page
  79. goodsTableData.loading = true
  80. getGoodsPages({
  81. page: goodsTableData.page,
  82. limit: goodsTableData.limit,
  83. ...goodsTableData.searchParam
  84. }).then(res =>{
  85. goodsTableData.data = res.data.data,
  86. goodsTableData.total = res.data.total
  87. })
  88. }
  89. const toDetail = (goods_id) => {
  90. router.push(`/goods/detail?id=${goods_id}`)
  91. }
  92. const categoryClick = (id:any)=>{
  93. router.push({path:'/shop/detail',query:{site_id:route.query.site_id,goods_category:id}})
  94. }
  95. loadGoodsList()
  96. </script>
  97. <style lang="scss" scoped>
  98. </style>