//index.js //获取应用实例 const app = getApp() var util = require('../../utils/util.js'); var api = require('../../utils/service-api.js'); Page({ data: { banners: [ ], iconUrls: [ ], indexAds: [ ], }, onLoad: function () { util.userLogin(function () { console.log("登录成功"); }); this.getLbt(); this.getNav(); this.getIndexAds(); }, getIndexAds: function () { var _this = this; util.request({ method: 'GET', api: api.ad.getByType + "indexAds", callback: function (data) { console.log(data.rows); _this.setData({ indexAds: data.rows }); } }); }, getNav: function () { var _this = this; util.request({ method: 'GET', api: api.ad.getByType + "indexNav", callback: function (data) { console.log(data.rows); _this.setData({ iconUrls: data.rows }); } }); }, getLbt:function(){ var _this = this; util.request({ method: 'GET', api: api.ad.getByType + "sylbt", callback: function (data) { console.log(data.rows); _this.setData({ banners: data.rows }); } }); }, goAd(e){ var title = e.currentTarget.dataset.title; var jumppath = e.currentTarget.dataset.jumppath; if (jumppath == '/pages/service/service' || jumppath == '/pages/yuyue/khyuyue' ){ wx.switchTab({ url: jumppath, fail:function(e){ console.log(e); }, }); } else{ wx.navigateTo({ url: jumppath, }) } }, })