| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //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.data !== undefined) {
- this.globalData.userInfo = res.result.data
- return wx.cloud.callFunction({
- name: 'listPublishers',
- data: {
- type: 'manage'
- }
- })
- }
- }).then(res => {
- if (res.result.list !== undefined) {
- this.globalData.pubInfo = res.result.list
- this.globalData.hasUserInfo = true
- if (this.onUserInfoReady) {
- this.onUserInfoReady()
- }
- }
- })
- }
- },
- globalData: {
- userInfo: null,
- hasUserInfo: false,
- openId: null,
- publisherId: null,
- noticeIndex: null,
- vibrate: null
- }
- })
|