17 lines
811 B
JavaScript
17 lines
811 B
JavaScript
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) }); },
|
|
});
|