//index.js //获取应用实例 const app = getApp() Page({ data: { ShopList: [], value: '', height: 0, SwiperList: ['../../static/banner.jpg', '../../static/banner.jpg','../../static/banner.jpg'], typeList: [ { id: 1, text: '限时白嫖', href: '/list', icon: '../../static/type_1.png' }, { id: 2, text: '新品推荐', href: '/list', icon: '../../static/type_2.png' }, { id: 3, text: '低价高配', href: '/list', icon: '../../static/type_3.png' }, { id: 4, text: '超值特卖', href: '/list', icon: '../../static/type_4.png' } ] }, onLoad: function () { this.getHomeList() this.setData({ height: app.globalData.statusBarHeight }) }, onClickLeft() { wx.showToast({ title: '点击返回', icon: 'none' }); }, onClickRight() { wx.showToast({ title: '点击按钮', icon: 'none' }); }, async getHomeList() { var data = await global.$api.post({ url: "/home/index", data: {} }); console.log("index:",data) data.result.forEach((val) => { val.wares_info = val.wares_info.substring(0,10) + '..'; val.wares_masterimg = JSON.parse(val.wares_masterimg)[0] }) this.setData({ ShopList: data.result }) console.log(data.result); }, enterInfo(item) { console.log("item: ", item.currentTarget.dataset.list.wares_id) wx.navigateTo({ url: `/pages/info/info?id=${item.currentTarget.dataset.list.wares_id}` }) }, enterlist(e) { var a = e.currentTarget.dataset.id+1 console.log(a) wx.navigateTo({ url: `/pages/list/list?id=${a}` }) }, })