<!--
    @name: 新品首发
    @author: kahu4
    @date: 2023-10-27 14:42
    @description：index
    @update: 2023-10-27 14:42
-->
<script setup>
import { onLoad } from '@dcloudio/uni-app'
import { usePage } from "@/hooks";
import { getProductList } from "@/api/product";
import Empty from "@/components/Empty/index.vue"
import ListLoadOver from "@/components/ListLoadOver/index.vue"
import ListLoadLoading from "@/components/ListLoadLoading/index.vue"
import { useRouter } from "@/hooks/useRouter";

const {refresh, dataList, loadend, loading, listEmpty} = usePage(getProductList)
const {push} = useRouter()
onLoad(() => {
  refresh()
})


</script>

<template>
  <blank size="15"></blank>

  <activity
      title="商品推荐"
      more="查看更多"
      @moreClick="push({ url: '/pages/goodsList/goodsList' })"
  >
    <view class="card goods-row">
      <template v-if="!listEmpty">
        <uv-grid
            :border="false"
            :col="2"
            :gutter="10"
        >
          <uv-grid-item
              v-for="(item, index) in dataList"
              :key="index"
          >
            <goods
                class="item"
                link
                card
                :data="item"
                :storeName="item.storeName"
                :price="item.price"
                :stock="true"
            >
            </goods>
          </uv-grid-item>
        </uv-grid>
      </template>
      <Empty
          v-else
          :iconSrc="emptyIcon"
      >
        这里空空如也~
      </Empty>
      <!-- 加载中 -->
      <ListLoadLoading v-if="loading" />
      <!-- 加载完毕-->
      <ListLoadOver v-if="loadend" />
    </view>

  </activity>
</template>

<style
    scoped
    lang="scss"
>
@import "@/style/main.scss";

.goods-row {
  @include usePadding(20, 20);
  border-radius: 15rpx;

  .item {
    width: 100%;
    margin: 0 10rpx;
  }
}
</style>
