123456789101112131415161718192021222324252627282930313233 |
- // app.ts
- import api from "./api/index";
- App<IAppOption>({
- globalData: {},
- onLaunch() {
- // 登录
- !wx.getStorageSync("token") && this.wLogin();
- // 获取授权内容
- wx.getSetting({
- success: res =>{
- this.globalData.setting = res? res.authSetting : {}
- }
- });
- this.globalData.SystemInfo = wx.getSystemInfoSync();
- this.globalData.FileSystemManager = wx.getFileSystemManager();
- },
- wLogin(){
- wx.login({
- success: res => {
- // 发送 res.code 到后台换取 openId, sessionKey, unionId
- this.login({
- data: {
- code: res.code
- },
- success: (res: any) => {
- wx.setStorageSync("token", res.token);
- }
- })
- },
- })
- },
- ...api
- })
|