33 lines
765 B
JavaScript
33 lines
765 B
JavaScript
const { apiBase } = require("./utils/config");
|
|
|
|
App({
|
|
globalData: {
|
|
apiBase,
|
|
token: "",
|
|
child: null,
|
|
},
|
|
|
|
onLaunch() {
|
|
this.globalData.token = wx.getStorageSync("ql_token") || "";
|
|
this.globalData.child = wx.getStorageSync("ql_child") || null;
|
|
},
|
|
|
|
setToken(token, guardian) {
|
|
this.globalData.token = token || "";
|
|
wx.setStorageSync("ql_token", this.globalData.token);
|
|
if (guardian) wx.setStorageSync("ql_guardian", guardian);
|
|
},
|
|
|
|
setChild(child) {
|
|
this.globalData.child = child || null;
|
|
wx.setStorageSync("ql_child", this.globalData.child);
|
|
},
|
|
|
|
clearAuth() {
|
|
this.globalData.token = "";
|
|
this.globalData.child = null;
|
|
wx.removeStorageSync("ql_token");
|
|
wx.removeStorageSync("ql_child");
|
|
},
|
|
});
|