<template>
  <page-loading :loading="loading">
    <view class="product-page">
      <view class="logo logo-black" />
      <u-search
        v-model="keywords"
        placeholder="搜索展厅"
        :show-action="false"
        shape="square"
        bg-color="#fff"
        border-color="#ccc"
        height="84rpx"
        @search="handleSearch"
      />

      <view
        class="cases-list dir-left-wrap"
      >
        <view
          v-for="(item,index) in lists"
          :key="index"
          class="cases-item main-left"
          @click="$u.route({url:`/pages/case/detail?id=${item.id}`})"
        >
          <view class="detail dir-top-wrap">
            <text>热销展厅排名</text>
            <view class="name"> {{ item.name }}</view>
          </view>
          <view class="cover-img">
            <image :src="item.cover_img" mode="aspectFill" />
          </view>
        </view>
      </view>
    </view>
  </page-loading>
</template>

<script>
import PageLoading from '../../components/PageLoading'
export default {
  name: 'Product',
  components: { PageLoading },
  data() {
    return {
      loading: false,
      keywords: '',
      limit: 3,
      page: 1,
      lists: []
    }
  },
  computed: {},
  methods: {
    handleSearch() {
      this.$u.route({ url: `/pages/case/list?keywords=${this.keywords}` })
    },
    getLists() {
      this.$api.cases.search({
        limit: this.limit,
        page: this.page
      }).then(res => {
        this.loading = false
        this.lists = res.data
      })
    }
  },
  onLoad() {
    this.loading = true
    this.getLists()
  },
  onShow() {
    this.getLists()
  }
}
</script>

<style lang="scss" scoped>
.product-page {
  padding: 0 30rpx;
  overflow: hidden;
  height: 100vh;
  .logo{
    margin: 30rpx auto;
  }
  .cases-list{
    margin-top: 80rpx;
    .cases-item{
      width: 690rpx;
      margin-bottom: 10rpx;
      &:last-child{
        margin-bottom: 0;
      }
      .detail{
        padding: 50rpx 0 20rpx 50rpx;
        font-size: 24rpx;
        color: #333333;
        background: #F2F2F2;
        flex: 1;
        text{
          color: #b4936d;
        }
        .name{
          margin-top: 16rpx;
          font-size: 42rpx;
        }
      }
      .cover-img{
        width: 355rpx;
        height: 250rpx;
        image{
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
</style>
