| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <template>
- <view class="checkout-goods">
- <image-preview class="checkout-goods__pic" :src="goods.mainPic" />
- <view class="checkout-goods__info">
- <text class="checkout-goods__name">{{ goods.goodsName }}</text>
- <view v-if="goods.specList && goods.specList.length" class="checkout-goods__specs">
- <text
- v-for="(spec, index) in goods.specList"
- :key="index"
- class="checkout-goods__spec"
- >{{ spec }}</text>
- </view>
- <text v-if="goods.serviceDesc" class="checkout-goods__service">{{ goods.serviceDesc }}</text>
- <view class="checkout-goods__price-row">
- <text class="checkout-goods__price">¥{{ goods.priceText }}</text>
- <view class="checkout-goods__qty">
- <view class="qty-btn" @click="onMinus">-</view>
- <text class="qty-num">{{ goods.quantity }}</text>
- <view class="qty-btn" @click="onPlus">+</view>
- </view>
- </view>
- <text class="checkout-goods__subtotal">小计 ¥{{ goods.subtotalText }}</text>
- </view>
- </view>
- </template>
- <script setup>
- const props = defineProps({
- goods: {
- type: Object,
- required: true
- }
- })
- const emit = defineEmits(['quantity-change'])
- function onMinus() {
- const next = Math.max(1, props.goods.quantity - 1)
- if (next !== props.goods.quantity) {
- emit('quantity-change', next)
- }
- }
- function onPlus() {
- const max = props.goods.maxStock || 999999
- const next = props.goods.quantity + 1
- if (next > max) {
- uni.showToast({ title: '库存不足', icon: 'none' })
- return
- }
- emit('quantity-change', next)
- }
- </script>
- <style lang="scss" scoped>
- .checkout-goods {
- display: flex;
- padding: 20rpx 24rpx;
- background: #fff;
- }
- .checkout-goods__pic {
- width: 160rpx;
- height: 160rpx;
- border-radius: 8rpx;
- background: #eee;
- flex-shrink: 0;
- }
- .checkout-goods__info {
- flex: 1;
- margin-left: 16rpx;
- min-width: 0;
- }
- .checkout-goods__name {
- font-size: 28rpx;
- color: #333;
- line-height: 1.4;
- }
- .checkout-goods__specs {
- margin-top: 8rpx;
- display: flex;
- flex-direction: column;
- gap: 4rpx;
- }
- .checkout-goods__spec {
- font-size: 24rpx;
- color: #999;
- }
- .checkout-goods__service {
- display: block;
- margin-top: 8rpx;
- font-size: 22rpx;
- color: #2e7d32;
- }
- .checkout-goods__price-row {
- margin-top: 12rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .checkout-goods__price {
- font-size: 30rpx;
- color: #e53935;
- font-weight: 600;
- }
- .checkout-goods__qty {
- display: flex;
- align-items: center;
- border: 1rpx solid #e0e0e0;
- border-radius: 8rpx;
- overflow: hidden;
- }
- .qty-btn {
- width: 52rpx;
- height: 52rpx;
- line-height: 52rpx;
- text-align: center;
- font-size: 32rpx;
- color: #333;
- background: #f5f5f5;
- }
- .qty-num {
- min-width: 56rpx;
- text-align: center;
- font-size: 26rpx;
- }
- .checkout-goods__subtotal {
- display: block;
- margin-top: 8rpx;
- font-size: 24rpx;
- color: #666;
- text-align: right;
- }
- </style>
|