Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | 1x 1x 1x 1x 1x 11x 11x 11x 1x 11x 1x | <script setup lang="ts">
import { ref, watch } from "vue";
import { RouterLink } from "vue-router";
import { formatMoney, multiplyMoney } from "@plain-journal/foundation";
import {
PjButton,
PjResponsiveImage,
resolveCatalogImageDelivery,
} from "@plain-journal/ui";
import type { GuestBagItem } from "../model/guestBag";
const props = defineProps<{
item: GuestBagItem;
}>();
const emit = defineEmits<{
quantityChange: [skuId: string, quantity: number];
remove: [skuId: string];
}>();
const quantityDraft = ref(props.item.quantity);
watch(
() => props.item.quantity,
(quantity) => {
quantityDraft.value = quantity;
},
);
function commitQuantity() {
const quantity = Math.trunc(Number(quantityDraft.value));
if (!Number.isFinite(quantity) || quantity < 1 || quantity > 999) {
quantityDraft.value = props.item.quantity;
return;
}
emit("quantityChange", props.item.skuId, quantity);
}
</script>
<template>
<article class="guest-bag-row">
<div class="guest-bag-row__media">
<PjResponsiveImage
v-if="item.coverUrl"
v-bind="resolveCatalogImageDelivery(item.coverUrl)"
:alt="item.productTitle"
sizes="128px"
loading="lazy"
/>
<span v-else aria-hidden="true">{{ item.productTitle.slice(0, 1) }}</span>
</div>
<div class="guest-bag-row__content">
<RouterLink
:to="{ name: 'product-detail', params: { productId: item.productId } }"
>
<strong>{{ item.productTitle }}</strong>
</RouterLink>
<p>{{ item.skuName }}</p>
<label>
数量
<input
v-model.number="quantityDraft"
type="number"
min="1"
max="999"
inputmode="numeric"
@change="commitQuantity"
/>
</label>
</div>
<div class="guest-bag-row__aside">
<strong>{{ formatMoney(multiplyMoney(item.unitPrice, item.quantity)) }}</strong>
<PjButton variant="text" @click="emit('remove', item.skuId)">移出</PjButton>
</div>
</article>
</template>
<style scoped>
.guest-bag-row {
display: grid;
grid-template-columns: 8rem minmax(0, 1fr) auto;
gap: var(--pj-space-5);
padding-block: var(--pj-space-5);
border-bottom: 1px solid var(--pj-border-subtle);
}
.guest-bag-row__media {
aspect-ratio: 1;
display: grid;
place-items: center;
overflow: hidden;
background: var(--pj-surface-media);
color: var(--pj-brand-primary-hover);
font-size: var(--pj-font-size-xl);
}
.guest-bag-row__media img {
width: 100%;
height: 100%;
object-fit: cover;
}
.guest-bag-row__content p {
margin: var(--pj-space-2) 0 var(--pj-space-4);
color: var(--pj-text-secondary);
}
.guest-bag-row__content label {
color: var(--pj-text-secondary);
font-size: var(--pj-font-size-sm);
}
.guest-bag-row__content input {
width: 4rem;
margin-left: var(--pj-space-2);
border: 0;
border-bottom: 1px solid var(--pj-border-strong);
background: transparent;
color: inherit;
}
.guest-bag-row__aside {
display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: space-between;
gap: var(--pj-space-3);
}
.guest-bag-row__aside .pj-button {
color: var(--pj-text-secondary);
}
@media (max-width: 48rem) {
.guest-bag-row {
grid-template-columns: 5rem minmax(0, 1fr);
}
.guest-bag-row__aside {
grid-column: 2;
flex-direction: row;
align-items: center;
}
}
@media (max-width: 32rem) {
.guest-bag-row {
grid-template-columns: 4rem minmax(0, 1fr);
gap: var(--pj-space-4);
}
}
</style>
|