Files
persionalBrand/apps/miniapp/pages/index/index.js
T

22 lines
1.1 KiB
JavaScript

const { request } = require('../../utils/request');
const config = require('../../utils/config');
Page({
data: { loading: true, error: '', brand: {}, services: [] },
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 || '个人品牌' });
this.setData({ brand, services, 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' }); },
});