feat(mall): classic B2B2C PC storefront with fixed mock API layer
- Mock adapter implementing @vmall/shared ApiClient (localStorage-persisted cart/orders/invoices), runtime switch via mockApi flag (default on) - Fixed bilingual mock catalog: 3-level categories, 24 products w/ SKUs, stores, brands, banners, floors, seckill/collective/integral, comments, coupons, addresses, seeded orders/shipments/invoices - B2B2C mall shell: top bar, logo/search/cart header, dark nav + category mega-menu, value-prop footer, back-to-top; 1200px grid, #ca151e theme - UI primitives replacing element-plus: carousel, pagination, breadcrumb, qty stepper, rating stars, modal, tabs, step bar, product card - Pages: home floors, search (filters/sort/paging), goods detail (SKU picker, store rail, review tabs), cart -> checkout -> pay -> success, auth pages, user center (dashboard/orders/addresses/favorites/coupons/ invoices), stores, seckill, collective, integral - i18n split into per-domain locale modules (en+zh) - OpenSpec change mall-pc-storefront-replica archived; all specs green
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{ page: number; total: number; perPage: number }>();
|
||||
const emit = defineEmits<{ change: [page: number] }>();
|
||||
|
||||
const pages = computed(() => Math.max(1, Math.ceil(props.total / props.perPage)));
|
||||
const window_ = computed(() => {
|
||||
const p = props.page;
|
||||
const n = pages.value;
|
||||
const start = Math.max(1, Math.min(p - 2, n - 4));
|
||||
const out: number[] = [];
|
||||
for (let i = start; i <= Math.min(n, start + 4); i++) out.push(i);
|
||||
return out;
|
||||
});
|
||||
|
||||
function go(p: number): void {
|
||||
if (p >= 1 && p <= pages.value && p !== props.page) emit("change", p);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<nav v-if="pages > 1" class="pager">
|
||||
<button type="button" :disabled="page <= 1" @click="go(page - 1)">{{ $t("common.prev") }}</button>
|
||||
<button
|
||||
v-for="p in window_"
|
||||
:key="p"
|
||||
type="button"
|
||||
:class="{ on: p === page }"
|
||||
@click="go(p)"
|
||||
>{{ p }}</button>
|
||||
<button type="button" :disabled="page >= pages" @click="go(page + 1)">{{ $t("common.next") }}</button>
|
||||
</nav>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.pager {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
margin: 30px 0;
|
||||
}
|
||||
button {
|
||||
min-width: 34px;
|
||||
height: 34px;
|
||||
border: 1px solid var(--mall-line-dark);
|
||||
background: #fff;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
border-radius: var(--mall-radius);
|
||||
}
|
||||
button.on {
|
||||
background: var(--mall-red);
|
||||
border-color: var(--mall-red);
|
||||
color: #fff;
|
||||
}
|
||||
button:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user