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

23 lines
2.1 KiB
JavaScript

const { request } = require('../../utils/request');
const config = require('../../utils/config');
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 = brand.templateKey === 'food' ? { hero: '今天吃什么', heroSub: '现做家常饭', about: '品牌简介', description: '个人经营的家常小灶,套餐现做,也可预约小型聚餐和私厨定制。', primary: '预约套餐', secondary: '咨询私厨', timeLabel: '营业时间', time: '11:00—20:00', addressLabel: '摊位地址', address: '校园路社区便民点 12 号', noteLabel: '配送说明', note: '满 30 元周边配送,也可自取' } : { hero: brand.name || '个人品牌', heroSub: brand.tagline || '把专业能力,变成值得信赖的体验', about: '关于我', description: '这里展示你的专业背景、工作方式与品牌理念。', primary: '查看服务', secondary: '发起咨询', timeLabel: '服务时间', time: '工作日 10:00—18:00', addressLabel: '所在位置', address: '线上 / 线下均可沟通', noteLabel: '合作说明', note: '提交需求后,我会尽快与你联系' };
this.setData({ brand, 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' }); },
});