// app.js import {host,cdn} from "./utils/config" import {http} from './utils/util' App({ onLaunch() { // 展示本地存储能力 const logs = wx.getStorageSync('logs') || [] logs.unshift(Date.now()) wx.setStorageSync('logs', logs) // 登录 wx.login({ success: res => { // this.setData({ // code: res.code // }) http("/user/login", "post", { code: res.code }).then(res => { if (res.msg === "未注册!") { // this.getUserProfile() wx.showToast({ title: '您尚未注册,请点击个人头像位置以注册登录', icon: 'none', duration: 2000 }) } else { getApp().globalData.token = res.data.token // this.setData({ // user_avatar:res.data.user.avatar, // user_name:res.data.user.name, // user_tip:'欢迎来到星途~' // }) wx.setStorage({ key: 'user', data: res.data.user }) wx.setStorage({ key: 'token', data: res.data.token }) // wx.getStorage({ // key: 'token', // success (res) { // } // }) } }) } }) }, globalData: { userInfo: null, host, cdn } })