feat: 增加小程序品牌首页

This commit is contained in:
que01 committed 2026-09-19 10:14:30 +08:00
1 parent 3b05df6edf
commit 255756c6dd
7 files changed
+36 -2

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
{
"pages": ["pages/index/index"],
"window": { "navigationBarTitleText": "品牌首页", "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black" }
}
+16
View File
@@ -0,0 +1,16 @@
const API_BASE_URL = 'http://localhost:3001';
Page({
data: { loading: true, error: '', brand: {}, services: [] },
onLoad() { this.load(); },
load() {
this.setData({ loading: true, error: '' });
Promise.all([this.request('/public/brand'), this.request('/public/services')]).then(([brand, services]) => {
this.setData({ brand, services, loading: false });
}).catch(() => this.setData({ loading: false, error: '暂时无法加载内容' }));
},
request(path) {
return new Promise((resolve, reject) => wx.request({ url: API_BASE_URL + path, success: (res) => res.statusCode < 400 ? resolve(res.data) : reject(res), fail: reject }));
},
selectService(event) { wx.navigateTo({ url: '/pages/booking/index?serviceId=' + encodeURIComponent(event.currentTarget.dataset.id) }); },
});
+1
View File
@@ -0,0 +1 @@
{ "navigationBarTitleText": "品牌首页" }
+9
View File
@@ -0,0 +1,9 @@
<view class="page">
<view wx:if="{{loading}}" class="state">加载中...</view>
<view wx:elif="{{error}}" class="state error">{{error}}<button bindtap="load">重试</button></view>
<block wx:else>
<view class="brand"><text class="name">{{brand.name}}</text><text class="tagline">{{brand.tagline}}</text><text>{{brand.description}}</text></view>
<view class="section-title">服务</view>
<view wx:for="{{services}}" wx:key="id" class="service" data-id="{{item.id}}" bindtap="selectService"><view><text class="service-name">{{item.name}}</text><text class="description">{{item.description}}</text></view><text class="price">{{item.priceText}}</text></view>
</block>
</view>
+1
View File
@@ -0,0 +1 @@
.page{padding:32rpx;background:#FBF7F1;min-height:100vh;color:#2B2B2B}.brand{padding:40rpx 32rpx;background:#F4EBD9;border-radius:32rpx}.name{display:block;font-size:44rpx;font-weight:700}.tagline,.description{display:block;color:#7A4A2B;margin-top:12rpx}.section-title{font-size:36rpx;font-weight:700;margin:36rpx 0 16rpx}.service{display:flex;justify-content:space-between;gap:20rpx;margin-bottom:16rpx;padding:28rpx 24rpx;background:#fff;border-radius:32rpx}.service-name{display:block;font-size:32rpx;font-weight:600}.price{white-space:nowrap;color:#B54A2C;font-size:34rpx}.state{padding:80rpx 20rpx;text-align:center}.error{color:#B54A2C}.state button{margin-top:24rpx;background:#B54A2C;color:#fff;border-radius:24rpx}