| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <template>
- <view class="book-card" @click="handleClick">
- <view class="book-cover">
- <image :src="cover" mode="aspectFill" class="cover-image"></image>
- </view>
- <view class="book-info">
- <text class="book-title">{{ title }}</text>
- <view class="price-row">
- <text class="current-price">¥{{ currentPrice }}</text>
- <text class="original-price">¥{{ originalPrice }}</text>
- </view>
- <view class="buy-button">
- <text class="button-text">加入购物车</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'BookCard',
- props: {
- cover: {
- type: String,
- required: true
- },
- title: {
- type: String,
- required: true
- },
- currentPrice: {
- type: [String, Number],
- required: true
- },
- originalPrice: {
- type: [String, Number],
- required: true
- }
- },
- methods: {
- handleClick() {
- this.$emit('click');
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .book-card {
- display: flex;
- flex-direction: column;
- width: 220rpx;
-
- .book-cover {
- width: 220rpx;
- height: 300rpx;
- border-radius: 8rpx;
- overflow: hidden;
- margin-bottom: 16rpx;
-
- .cover-image {
- width: 100%;
- height: 100%;
- }
- }
-
- .book-info {
- .book-title {
- font-size: 28rpx;
- color: #333333;
- font-weight: 500;
- margin-bottom: 12rpx;
- display: block;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .price-row {
- display: flex;
- align-items: center;
- margin-bottom: 16rpx;
-
- .current-price {
- font-size: 32rpx;
- color: #FF3B30;
- font-weight: bold;
- margin-right: 12rpx;
- }
-
- .original-price {
- font-size: 24rpx;
- color: #999999;
- text-decoration: line-through;
- }
- }
-
- .buy-button {
- width: 100%;
- height: 56rpx;
- background: linear-gradient(90deg, #5DD466 0%, #38C148 100%);
- border-radius: 28rpx;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .button-text {
- font-size: 24rpx;
- color: #FFFFFF;
- }
- }
- }
- }
- </style>
|