Files
Wx_AUTS_Prod/Web/app.js
2025-11-26 17:42:45 +08:00

100 lines
2.5 KiB
JavaScript

//app.js
import {
LoginToken
} from '/lib/RequestingCenter.js'
import {
Toastsuccess,
ToastError
} from '/lib/Toast.js'
let sum = 0;
App({
onLaunch: function () {
wx.removeStorage({
key: 'oldHotelinfo',
})
// 获取系统状态栏信息
wx.getSystemInfo({
success: e => {
this.globalData.StatusBar = e.statusBarHeight;
let capsule = wx.getMenuButtonBoundingClientRect();
if (capsule) {
this.globalData.Custom = capsule;
this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
} else {
this.globalData.CustomBar = e.statusBarHeight + 50;
}
}
})
// 登录
this.userLogin();
},
globalData: {
ImgUrl: "https://auth.blv-oa.com/ImgServer/FileImage?url=ImgUrl&&ftp=11",
userinfo: null,
MapKey: '6JMBZ-BSAWP-D2NDJ-LFL4J-QJQQ3-3TBTV',
MapSk: 'MHAGZ4S3aYeAD1pFoMTy6HAFL7nG18',
autho: null,
authotype: {
no: 1,
ok: 3
}
},
toast: function (type, title, success, time) {
if (type == 1) {
Toastsuccess(title, success, time)
}
if (type == 2) {
ToastError(title, success, time)
}
// Toast(title,icon,success,time)
},
//TOKEN登录
userLogin: async function (back) {
let that = this;
// 读取本地信息尝试登录
const xiaoxi_token = wx.getStorageSync('xiaoxi_token') || null
const sqlid = wx.getStorageSync('sqlid') || 0
if (xiaoxi_token != null && xiaoxi_token != "") {
await LoginToken({
token: xiaoxi_token
}).then(res => {
// console.log(res)
if (res.Status != 200) {
that.toast(2, res.Message || "网络繁忙", function () {
wx.reLaunch({
url: "../login/login",
})
})
return;
} else {
wx.setStorageSync('xiaoxi_token', res.Data.token)
wx.reLaunch({
url: "/pages/index/index?Sqlid="+sqlid,
})
}
},
err => {
that.toast(2, '网络繁忙', function () {
wx.reLaunch({
url: "/pages/login/login",
})
})
}
).catch(
err => {
// console.log(err)
that.toast(2, '网络繁忙', () => {
wx.reLaunch({
url: "/pages/login/login",
})
})
}
);
} else {
wx.reLaunch({
url: "/pages/login/login",
})
}
},
})