// pages/buy/buy.js import { goodsList } from '../../api/index' Page({ /** * 页面的初始数据 */ data: { activeIndex: -1, goodsList: [] }, /** * 生命周期函数--监听页面显示 */ onShow() { this.getGoodsList() }, //获取套餐列表 getGoodsList () { wx.showLoading({ title: '加载中...', mask: true }) goodsList({}).then(res => { wx.hideLoading() var response = res.data response.map((item, index) => { if (item.isRecommend) { this.setData({ activeIndex: index }) } }) this.setData({ goodsList: response }) }).catch(e => { wx.hideLoading() wx.showModal({ content: e, confirmColor: '#333', showCancel: false }) }) }, handlePayType (e) { var index = Number(e.currentTarget.dataset.index) this.setData({ activeIndex: index }) }, // 调用微信支付 handleWXPay () { }, handleAppointment () { wx.navigateTo({ url: '/pages/appointment/appointment', }) } })