3 lines
640 B
JavaScript
3 lines
640 B
JavaScript
const API = 'http://localhost:3001';
|
|
Page({data:{loading:true,services:[],filtered:[],category:'package'},onLoad(){wx.request({url:API+'/public/services',success:res=>this.setData({services:res.data,filtered:res.data.filter(x=>x.priceAmount!==null),loading:false}),fail:()=>this.setData({loading:false})})},switchCategory(e){const category=e.currentTarget.dataset.category;const filtered=category==='package'?this.data.services.filter(x=>x.priceAmount!==null):this.data.services.filter(x=>x.priceAmount===null);this.setData({category,filtered})},book(e){wx.navigateTo({url:'/pages/booking/index?serviceId='+e.currentTarget.dataset.id})}});
|