Page({ /** * 页面的初始数据 */ data: { indicatorDots: true, autoplay: true, baseUrl: 'http://192.168.0.111:8888/volunteer/', token: '', key: '' }, doLogin: function() { var self = this; wx.login({ success(res) { console.log(res) if(res.code) { var WechatMiniAppLoginVO = {jsCode: res.code}; wx.request({ url: self.data.baseUrl + 'wxminiapp/auth/login', method: 'post', data: WechatMiniAppLoginVO, success: function(res) { self.setData({ token: res.data.data }) wx.setStorage({ data: res.data.data, key: 'token' }) } }) }else { console.log('登陆失败!' + res.errMsg); } } }) }, goNewsDetail: function () { wx.navigateTo({ url: '../newsDetail/newsDetail', }) }, goVolunteer: function () { wx.navigateTo({ url: '../volunteer/volunteer', }) }, goBroadcast: function () { wx.navigateTo({ url: '../broadcast/broadcast', }) }, goVenue: function () { wx.switchTab({ url: '../venue/venue', }) }, goBroadcastDetail: function () { wx.navigateTo({ url: '../broadcastDetail/broadcastDetail', }) }, goActivity: function () { wx.switchTab({ url: '../activity/activity', }) }, goHeritage: function () { wx.switchTab({ url: '../heritage/heritage', }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var self = this; self.doLogin(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })