feat: 按林境门作原型完善静态小程序
This commit is contained in:
1 parent
4afb6bbbe8
commit
8489c8ca79
26 files changed
+92
-964
No files matched your search
@@ -1,54 +1,6 @@
|
||||
const { request } = require("../../utils/request");
|
||||
const { getTemplate } = require("../../utils/templates");
|
||||
const { offerings } = require("../../utils/linjing-data");
|
||||
Page({
|
||||
data: { loading: true, error: "", services: [], filtered: [], category: "package", labels: {} },
|
||||
onLoad() {
|
||||
this.load();
|
||||
},
|
||||
load() {
|
||||
this.setData({ loading: true, error: "" });
|
||||
Promise.all([request("/public/offerings"), request("/public/brand")])
|
||||
.then(([offerings, brand]) => {
|
||||
const labels = getTemplate(brand.templateKey);
|
||||
const source = offerings;
|
||||
const mapped = source.map((item) => ({
|
||||
...item,
|
||||
coverUrl:
|
||||
item.coverUrl ||
|
||||
(item.name.includes("红烧肉")
|
||||
? "/assets/brand/service-red-braised-pork.jpg"
|
||||
: item.name.includes("小炒鸡")
|
||||
? "/assets/brand/service-chicken.jpg"
|
||||
: item.name.includes("私厨")
|
||||
? "/assets/brand/service-private-chef.jpg"
|
||||
: ""),
|
||||
}));
|
||||
this.setData({
|
||||
services: mapped,
|
||||
labels,
|
||||
filtered: mapped.filter((item) => item.priceAmount !== null),
|
||||
loading: false,
|
||||
});
|
||||
})
|
||||
.catch(() => this.setData({ loading: false, error: "服务加载失败" }));
|
||||
},
|
||||
switchCategory(e) {
|
||||
const category = e.currentTarget.dataset.category;
|
||||
const filtered =
|
||||
category === "package"
|
||||
? this.data.services.filter((item) => item.priceAmount !== null)
|
||||
: this.data.services.filter((item) => item.priceAmount === null);
|
||||
this.setData({ category, filtered });
|
||||
},
|
||||
book(e) {
|
||||
if (e.currentTarget.dataset.offeringId) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/offering/detail?id=" + encodeURIComponent(e.currentTarget.dataset.offeringId),
|
||||
});
|
||||
return;
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: "/pages/booking/index?offeringId=" + encodeURIComponent(e.currentTarget.dataset.id),
|
||||
});
|
||||
},
|
||||
data: { loading: false, error: "", offerings, filtered: offerings, category: "全部" },
|
||||
switchCategory(e) { const category = e.currentTarget.dataset.category; this.setData({ category, filtered: category === "全部" ? offerings : offerings.filter((item) => item.category === category) }); },
|
||||
open(e) { wx.navigateTo({ url: "/pages/offering/detail?id=" + e.currentTarget.dataset.id }); },
|
||||
});
|
||||
@@ -1 +1 @@
|
||||
<view class="page"><view class="heading"><text>服务列表</text><text class="sub">{{labels.sub}}</text></view><view class="categories"><view class="category package {{category === 'package' ? 'selected' : ''}}" data-category="package" bindtap="switchCategory"><text class="category-title">● {{labels.first}}</text><text>{{labels.firstSub}}</text></view><view class="category chef {{category === 'private_chef' ? 'selected' : ''}}" data-category="private_chef" bindtap="switchCategory"><text class="category-title">● {{labels.second}}</text><text>{{labels.secondSub}}</text></view></view><brand-loading wx:if="{{loading}}" /><view wx:elif="{{error}}" class="inline-error"><text>{{error}}</text><button size="mini" bindtap="load">重新加载</button></view><brand-empty wx:elif="{{!filtered.length}}" description="{{labels.empty}}" /><view wx:else><view wx:for="{{filtered}}" wx:key="id" class="card" data-id="{{item.id}}" data-offering-id="{{item.kind ? item.id : ''}}" bindtap="book"><view class="dish-image"><image wx:if="{{item.coverUrl}}" src="{{item.coverUrl}}" mode="aspectFill"/><view wx:else class="dish-placeholder"></view></view><view class="card-content"><view class="card-head"><view class="name">{{item.name}}</view><text class="available">{{item.isEnabled !== false ? labels.available : labels.unavailable}}</text></view><text class="desc">{{item.description || item.summary}}</text><view class="card-bottom"><text class="price">{{item.priceText || '面议'}}</text><button size="mini">查看详情</button></view></view></view></view></view>
|
||||
<view class="page"><view class="head"><text class="eyebrow">LINJING ATELIER</text><text class="title">作品与系统</text><text class="sub">每一扇门,都是建筑秩序的一部分。</text></view><scroll-view scroll-x class="tabs"><text wx:for="{{['全部','入户大门','庭院围墙门','室内户内门','装饰隐形门']}}" wx:key="*this" class="tab {{category===item?'active':''}}" data-category="{{item}}" bindtap="switchCategory">{{item}}</text></scroll-view><view class="list"><view wx:for="{{filtered}}" wx:key="id" class="card" data-id="{{item.id}}" bindtap="open"><image src="{{item.image}}" mode="aspectFill"/><view class="card-body"><text class="category">{{item.category}} · {{item.tag}}</text><text class="name">{{item.name}}</text><text class="series">{{item.series}}</text><text class="desc">{{item.desc}}</text><view class="foot"><text>{{item.area}}</text><text class="arrow">查看详情 →</text></view></view></view></view></view>
|
||||
@@ -1,173 +1 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 24rpx 32rpx 60rpx;
|
||||
background: #fbf7f1;
|
||||
color: #2b2b2b;
|
||||
}
|
||||
.heading {
|
||||
margin: 12rpx 0 28rpx;
|
||||
}
|
||||
.heading text:first-child {
|
||||
display: block;
|
||||
font-size: 48rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.sub {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
.categories {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
.category {
|
||||
flex: 1;
|
||||
padding: 28rpx 22rpx;
|
||||
border-radius: 16rpx;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
.category text {
|
||||
display: block;
|
||||
}
|
||||
.category-title {
|
||||
font-weight: 700;
|
||||
}
|
||||
.category text + text {
|
||||
margin-top: 12rpx;
|
||||
font-size: 25rpx;
|
||||
}
|
||||
.package {
|
||||
background: #b54a2c;
|
||||
color: #fff;
|
||||
}
|
||||
.chef {
|
||||
background: #f4ebd9;
|
||||
color: #2b2b2b;
|
||||
}
|
||||
.category.selected {
|
||||
box-shadow: 0 0 0 4rpx #e8a75f;
|
||||
}
|
||||
.card {
|
||||
display: flex;
|
||||
gap: 22rpx;
|
||||
align-items: stretch;
|
||||
margin-bottom: 16rpx;
|
||||
padding: 20rpx;
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
.dish-image {
|
||||
width: 230rpx;
|
||||
min-width: 230rpx;
|
||||
height: 230rpx;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.dish-image image,
|
||||
.dish-placeholder {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
background: #d6b27c;
|
||||
}
|
||||
.card-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.card-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8rpx;
|
||||
}
|
||||
.name {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.available {
|
||||
padding: 6rpx 12rpx;
|
||||
border: 1rpx solid #c79555;
|
||||
border-radius: 24rpx;
|
||||
color: #7a4a2b;
|
||||
font-size: 21rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.desc {
|
||||
display: block;
|
||||
margin: 14rpx 0;
|
||||
color: #7a4a2b;
|
||||
font-size: 27rpx;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.card-bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: end;
|
||||
margin-top: auto;
|
||||
}
|
||||
.price {
|
||||
display: block;
|
||||
color: #b54a2c;
|
||||
font-size: 38rpx;
|
||||
}
|
||||
.card button {
|
||||
background: #b54a2c;
|
||||
color: #fff;
|
||||
border-radius: 36rpx;
|
||||
}
|
||||
.state {
|
||||
text-align: center;
|
||||
padding: 80rpx;
|
||||
color: #7a4a2b;
|
||||
}
|
||||
.categories {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
.category {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
.category:before,
|
||||
.category:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: -28rpx;
|
||||
bottom: -48rpx;
|
||||
width: 160rpx;
|
||||
height: 104rpx;
|
||||
border: 5rpx solid rgba(255, 255, 255, 0.16);
|
||||
border-radius: 50% 50% 44% 44%;
|
||||
transform: rotate(-16deg);
|
||||
pointer-events: none;
|
||||
}
|
||||
.category:after {
|
||||
right: 8rpx;
|
||||
bottom: -34rpx;
|
||||
width: 110rpx;
|
||||
height: 70rpx;
|
||||
border-width: 4rpx;
|
||||
border-color: rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
.chef:before {
|
||||
border-color: rgba(181, 74, 44, 0.16);
|
||||
}
|
||||
.chef:after {
|
||||
border-color: rgba(181, 74, 44, 0.12);
|
||||
}
|
||||
.inline-error {
|
||||
padding: 72rpx 32rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
color: var(--brand-color-muted);
|
||||
}
|
||||
.inline-error button {
|
||||
margin-top: 24rpx;
|
||||
color: var(--brand-color-primary);
|
||||
background: var(--brand-color-subtle);
|
||||
}
|
||||
.page{background:#f7f5f1;min-height:100vh;color:#252525}.head{background:#252827;color:#fff;padding:70rpx 40rpx 55rpx}.eyebrow{font-size:20rpx;letter-spacing:3rpx;color:#d9c8b2;display:block;margin-bottom:18rpx}.title{font-size:52rpx;font-family:serif;display:block}.sub{font-size:26rpx;color:#c6c2ba;display:block;margin-top:16rpx}.tabs{white-space:nowrap;padding:28rpx 32rpx;background:#f7f5f1}.tab{display:inline-block;font-size:25rpx;color:#77736b;margin:0 14rpx;padding-bottom:12rpx}.tab.active{color:#8a6846;border-bottom:2px solid #8a6846}.list{padding:0 32rpx 40rpx}.card{background:#fff;margin-bottom:30rpx}.card image{width:100%;height:380rpx;display:block}.card-body{padding:28rpx}.category{font-size:20rpx;color:#8a6846;display:block}.name{display:block;font-size:34rpx;line-height:1.45;margin:12rpx 0 6rpx}.series{display:block;color:#77736b;font-size:24rpx}.desc{display:block;color:#77736b;font-size:25rpx;line-height:1.7;margin-top:18rpx}.foot{display:flex;justify-content:space-between;border-top:1px solid #eee7de;margin-top:24rpx;padding-top:20rpx;color:#999;font-size:22rpx}.arrow{color:#8a6846}
|
||||
Reference in new issue
Block a user