//app.js App({ onLaunch: function () { // 展示本地存储能力 var logs = wx.getStorageSync('logs') || [] logs.unshift(Date.now()) wx.setStorageSync('logs', logs) // // 登录 // wx.login({ // success: res => { // // 发送 res.code 到后台换取 openId, sessionKey, unionId // } // }) if (!wx.cloud) { console.error('请使用 2.2.3 或以上的基础库以使用云能力') } else { wx.cloud.init({ // env 参数说明: // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 // 如不填则使用默认环境(第一个创建的环境) env: "msg-push-9ga0xxc9c4aa5242", traceUser: true, }) wx.cloud.callFunction({ name: 'getUser' }).then(res => { if (res.result.status !== 'OK') { return res.result } this.globalData.userInfo = res.result.data return wx.cloud.callFunction({ name: 'listPublishers', data: { user_id: this.globalData.userInfo._id, page_token: 0, page_size: 25 } }) }).then(res => { if (res.result.status !== 'OK') { return } this.globalData.pubInfo = res.result.list this.globalData.hasUserInfo = true if (this.onUserInfoReady) { this.onUserInfoReady() } }) } }, globalData: { userInfo: {}, pubInfo: [], hasUserInfo: false, openId: null, noticeIndex: null, vibrate: null } })