<template>
  <view class="card item" @tap="open">
    <image v-if="project.cover" class="cover" :src="project.cover" mode="aspectFill" />
    <view class="name">{{ project.name }}</view>
    <view class="muted meta">{{ project.durationMin }} 分钟</view>
    <view class="row between bottom">
      <view class="price">
        <text class="yen">¥</text>
        <text class="num">{{ project.price }}</text>
        <text class="ori muted" v-if="project.originPrice">¥{{ project.originPrice }}</text>
      </view>
      <view class="go">查看</view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'ProjectGridCard',
  props: {
    project: {
      type: Object,
      required: true
    }
  },
  methods: {
    open() {
      uni.navigateTo({ url: `/pages/projects/detail?id=${this.project.id}` })
    }
  }
}
</script>

<style lang="scss" scoped>
.item {
  padding: 20rpx;
  height: 360rpx;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.cover {
  width: 100%;
  height: 180rpx;
  border-radius: 18rpx;
}
.name {
  font-size: 30rpx;
  font-weight: 950;
  line-height: 1.2;
  max-height: 72rpx;
  overflow: hidden;
}
.meta {
  margin-top: 8rpx;
  font-size: 24rpx;
}
.bottom {
  margin-top: 8rpx;
}
.price {
  display: flex;
  align-items: baseline;
}
.yen {
  font-size: 22rpx;
  opacity: 0.8;
}
.num {
  font-size: 36rpx;
  font-weight: 950;
}
.ori {
  margin-left: 8rpx;
  font-size: 22rpx;
  text-decoration: line-through;
}
.go {
  padding: 10rpx 14rpx;
  border-radius: 999rpx;
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
  font-size: 24rpx;
  font-weight: 900;
}
</style>

