//index.js //获取应用实例 const app = getApp() const host = app.globalData.host; Page({ data: { act:6, openid:'', show:1, data:[], news: ['国家安全生产监督管理总局30号令'], animationData:{} }, //事件处理函数 bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, tabchange:function(e){ this.setData({ act: e.target.dataset.id }) }, onLoad: function () { wx.showLoading({ title: '', }) this.getData() this.setData({ openid: app.globalData.openid }) wx.getStorage({ key: 'userInfo', success: res=> { if(res.data){ this.setData({show:0}) } }, }) var animation = wx.createAnimation({ duration: 1000, timingFunction: 'ease', }) this.animation = animation animation.translateX(100).step() this.setData({ animationData: animation.export() }) }, onGotUserInfo: function (e) { wx.setStorage({ key: 'userInfo', data: e.detail.userInfo, }) console.log(app.globalData.openid) wx.request({ url: host+'/api/wx/auth', method:'POST', data:{ nickname: e.detail.userInfo.nickName, avatar: e.detail.userInfo.avatarUrl, openid: app.globalData.openid, }, success:res=>{ console.log(res) this.setData({ show:0 }) } }) }, getData:function(){ wx.request({ url: host +'/api/wx/index', method:'GET', success:res=>{ wx.hideLoading() let data=res.data.data; this.setData({ data:res.data.data }) for(let i=0;i{ wx.showToast({ title: '服务器开小差啦!', icon: 'none', duration: 2000 }) } }) } })