// app.js import { myhttp } from "./utils/service"; import { getCode } from "./utils/login"; App({ onLaunch() { //获取token, 判断token是否有值 const token = wx.getStorageSync('token') || ''; if (token) { console.log('请求其他数据'); } else { this.handlerLogin() } }, async handlerLogin() { //获取code getCode().then(res => { const code = res //将code发给后端请求token // myhttp({ // url: "https://text2model.kooldns.cn/receive_text", // data: code, // method: "POST" // }) // .then((res) => { // const token = res.data.token // //将token保存本地 // wx.setStorageSync('token', token) // console.log(res); // }) }) }, globalData: { userInfo: null } })