var app = getApp() Page({ data: { DOMAIN_NAME: app.IMG_NAME, bannerList: [], noticeList: [], indicatorDots: true, autoplay: true, interval: 3000, duration: 1000, }, onLoad() { let that = this app.AjaxRequest('get', { 'content-type': 'application/json', 'Authorization': 'Bearer ' + app.Getopenid() }, '/dj/bannerList', {}, function (res) { if (res.code == 0) { that.setData({ bannerList: res.data }) } }) app.AjaxRequest('get', { 'content-type': 'application/json', 'Authorization': 'Bearer ' + app.Getopenid() }, '/dj/list', {}, function (res) { if (res.code == 0) { that.setData({ noticeList: res.data }) } }) }, //轮播高度自适应——获取图片高度 imgHeight: function (e) { var winWid = wx.getSystemInfoSync().windowWidth; //获取当前屏幕的宽度 var imgh = e.detail.height; //图片高度 var imgw = e.detail.width; //图片宽度 var swiperH = winWid * imgh / imgw + "px" this.setData({ Height: swiperH //设置高度 }) }, navdetail(e) { let that = this let index = e.currentTarget.dataset.index app.AjaxRequest('POST', { 'content-type': 'application/json', 'Authorization': 'Bearer ' + app.Getopenid() }, '/dj/addHits?id=' + that.data.bannerList[index].id, {}, function (res) { wx.navigateTo({ url: '../party/detail/detail', success(res) { res.eventChannel.emit('toHome', { data: that.data.bannerList[index] }) } }) }) }, navdetaillist(e) { let that = this let index = e.currentTarget.dataset.index wx.navigateTo({ url: '../party/detail/detail', success(res) { res.eventChannel.emit('toHome', { data: that.data.noticeList[index] }) } }) } })