diff --git a/apps/miniapp/app.json b/apps/miniapp/app.json index 08eab5c..73d0a37 100644 --- a/apps/miniapp/app.json +++ b/apps/miniapp/app.json @@ -3,7 +3,8 @@ "pages/index/index", "pages/services/index", "pages/booking/index", - "pages/bookings/index" + "pages/bookings/index", + "pages/offering/detail" ], "window": { "navigationBarTitleText": "个人品牌", diff --git a/apps/miniapp/pages/offering/detail.js b/apps/miniapp/pages/offering/detail.js new file mode 100644 index 0000000..dafc987 --- /dev/null +++ b/apps/miniapp/pages/offering/detail.js @@ -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 || ""), + }); + }, +}); diff --git a/apps/miniapp/pages/offering/detail.json b/apps/miniapp/pages/offering/detail.json new file mode 100644 index 0000000..16f7d47 --- /dev/null +++ b/apps/miniapp/pages/offering/detail.json @@ -0,0 +1,5 @@ +{ + "navigationBarTitleText": "服务详情", + "navigationBarBackgroundColor": "#FBF7F1", + "navigationBarTextStyle": "black" +} diff --git a/apps/miniapp/pages/offering/detail.wxml b/apps/miniapp/pages/offering/detail.wxml new file mode 100644 index 0000000..ece53a8 --- /dev/null +++ b/apps/miniapp/pages/offering/detail.wxml @@ -0,0 +1 @@ +加载中...{{error}}{{item.name}}{{item.summary}}{{item.priceText || '沟通报价'}}{{section.title}}{{section.content}}{{sectionItem}} diff --git a/apps/miniapp/pages/offering/detail.wxss b/apps/miniapp/pages/offering/detail.wxss new file mode 100644 index 0000000..830fb86 --- /dev/null +++ b/apps/miniapp/pages/offering/detail.wxss @@ -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; +} diff --git a/apps/miniapp/pages/services/index.js b/apps/miniapp/pages/services/index.js index a5276fa..882346c 100644 --- a/apps/miniapp/pages/services/index.js +++ b/apps/miniapp/pages/services/index.js @@ -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), }); diff --git a/apps/miniapp/pages/services/index.wxml b/apps/miniapp/pages/services/index.wxml index 0c306b1..098bc0e 100644 --- a/apps/miniapp/pages/services/index.wxml +++ b/apps/miniapp/pages/services/index.wxml @@ -1 +1 @@ -服务列表{{labels.sub}}● {{labels.first}}{{labels.firstSub}}● {{labels.second}}{{labels.secondSub}}加载中...{{error}}{{labels.empty}}{{item.name}}{{item.bookingEnabled ? labels.available : labels.unavailable}}{{item.description}}{{item.priceText || '面议'}} +服务列表{{labels.sub}}● {{labels.first}}{{labels.firstSub}}● {{labels.second}}{{labels.secondSub}}加载中...{{error}}{{labels.empty}}{{item.name}}{{item.isEnabled !== false ? labels.available : labels.unavailable}}{{item.description || item.summary}}{{item.priceText || '面议'}}