feat: 增加小程序品牌首页
This commit is contained in:
1 parent
3b05df6edf
commit
255756c6dd
7 files changed
+36
-2
No files matched your search
@@ -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) }); },
|
||||
});
|
||||
Reference in new issue
Block a user