feat: 接入小程序业务提供项详情渲染
This commit is contained in:
1 parent
5e26999c72
commit
8fd399f4c2
7 files changed
+92
-5
No files matched your search
@@ -3,7 +3,8 @@
|
||||
"pages/index/index",
|
||||
"pages/services/index",
|
||||
"pages/booking/index",
|
||||
"pages/bookings/index"
|
||||
"pages/bookings/index",
|
||||
"pages/offering/detail"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTitleText": "个人品牌",
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
const { request } = require("../../utils/request");
|
||||
Page({
|
||||
data: { loading: true, error: "", item: null },
|
||||
onLoad(options) {
|
||||
request("/public/offerings/" + encodeURIComponent(options.id))
|
||||
.then((item) => this.setData({ item, loading: false }))
|
||||
.catch(() => this.setData({ loading: false, error: "详情加载失败" }));
|
||||
},
|
||||
submit() {
|
||||
wx.navigateTo({
|
||||
url: "/pages/booking/index?serviceId=" + encodeURIComponent(this.data.item?.id || ""),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": "服务详情",
|
||||
"navigationBarBackgroundColor": "#FBF7F1",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<view class="page"><view wx:if="{{loading}}" class="state">加载中...</view><view wx:elif="{{error}}" class="state">{{error}}</view><view wx:else><image wx:if="{{item.coverUrl}}" class="cover" src="{{item.coverUrl}}" mode="aspectFill"/><view class="title">{{item.name}}</view><view class="summary">{{item.summary}}</view><view class="price">{{item.priceText || '沟通报价'}}</view><view wx:for="{{item.sections}}" wx:for-item="section" wx:key="title" class="section"><view class="section-title">{{section.title}}</view><view class="section-content">{{section.content}}</view><view wx:for="{{section.items}}" wx:for-item="sectionItem" wx:key="*this" class="section-item">{{sectionItem}}</view></view><button class="cta" bindtap="submit">{{item.cta.label || '立即咨询'}}</button></view></view>
|
||||
@@ -0,0 +1,55 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 32rpx;
|
||||
background: #fbf7f1;
|
||||
color: #2b2b2b;
|
||||
}
|
||||
.cover {
|
||||
width: 100%;
|
||||
height: 360rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
.title {
|
||||
margin-top: 28rpx;
|
||||
font-size: 48rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.summary {
|
||||
margin-top: 14rpx;
|
||||
color: #7a4a2b;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
.price {
|
||||
margin-top: 20rpx;
|
||||
color: #b54a2c;
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.section {
|
||||
margin-top: 28rpx;
|
||||
padding: 24rpx;
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.section-content {
|
||||
margin-top: 14rpx;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.section-item {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.cta {
|
||||
margin-top: 36rpx;
|
||||
background: #b54a2c;
|
||||
color: #fff;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
.state {
|
||||
text-align: center;
|
||||
padding: 120rpx;
|
||||
color: #7a4a2b;
|
||||
}
|
||||
@@ -3,10 +3,15 @@ const { getTemplate } = require("../../utils/templates");
|
||||
Page({
|
||||
data: { loading: true, error: "", services: [], filtered: [], category: "package", labels: {} },
|
||||
onLoad() {
|
||||
Promise.all([request("/public/services"), request("/public/brand")])
|
||||
.then(([services, brand]) => {
|
||||
Promise.all([
|
||||
request("/public/offerings"),
|
||||
request("/public/services"),
|
||||
request("/public/brand"),
|
||||
])
|
||||
.then(([offerings, services, brand]) => {
|
||||
const labels = getTemplate(brand.templateKey);
|
||||
const mapped = services.map((item) => ({
|
||||
const source = offerings.length ? offerings : services;
|
||||
const mapped = source.map((item) => ({
|
||||
...item,
|
||||
coverUrl:
|
||||
item.coverUrl ||
|
||||
@@ -36,6 +41,12 @@ Page({
|
||||
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?serviceId=" + encodeURIComponent(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><view wx:if="{{loading}}" class="state">加载中...</view><view wx:elif="{{error}}" class="state">{{error}}</view><view wx:elif="{{!filtered.length}}" class="state">{{labels.empty}}</view><view wx:else><view wx:for="{{filtered}}" wx:key="id" class="card" data-id="{{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.bookingEnabled ? labels.available : labels.unavailable}}</text></view><text class="desc">{{item.description}}</text><view class="card-bottom"><text class="price">{{item.priceText || '面议'}}</text><button size="mini">{{item.priceAmount ? '预约' : '咨询'}}</button></view></view></view></view></view>
|
||||
<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><view wx:if="{{loading}}" class="state">加载中...</view><view wx:elif="{{error}}" class="state">{{error}}</view><view wx:elif="{{!filtered.length}}" class="state">{{labels.empty}}</view><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>
|
||||
Reference in new issue
Block a user