24 lines
1.3 KiB
JavaScript
24 lines
1.3 KiB
JavaScript
const { request } = require('../../utils/request');
|
|
const config = require('../../utils/config');
|
|
const { getTemplate } = require('../../utils/templates');
|
|
|
|
Page({
|
|
data: { loading: true, error: '', brand: {}, services: [], copy: {} },
|
|
onLoad() { this.load(); },
|
|
load() {
|
|
this.setData({ loading: true, error: '' });
|
|
Promise.all([request('/public/brand'), request('/public/services')]).then(([brand, services]) => {
|
|
getApp().globalData.brand = brand;
|
|
wx.setNavigationBarTitle({ title: brand.name || '个人品牌' });
|
|
const copy = getTemplate(brand.templateKey);
|
|
this.setData({ brand: { ...brand, coverUrl: brand.coverUrl || '/assets/brand/home-hero.jpg' }, services, copy, loading: false });
|
|
}).catch(() => this.setData({ loading: false, error: '暂时无法加载内容' }));
|
|
},
|
|
selectService(event) { wx.navigateTo({ url: '/pages/booking/index?serviceId=' + encodeURIComponent(event.currentTarget.dataset.id) }); },
|
|
goServices() { wx.navigateTo({ url: '/pages/services/index' }); },
|
|
goPrivateChef() { wx.navigateTo({ url: '/pages/booking/index?type=private_chef' }); },
|
|
goBooking() { wx.navigateTo({ url: '/pages/booking/index' }); },
|
|
goBookings() { wx.navigateTo({ url: '/pages/bookings/index' }); },
|
|
goHome() { wx.reLaunch({ url: '/pages/index/index' }); },
|
|
});
|