1 Star 1 Fork 0

阿超Bug便利店/lifeshow-minip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 1.69 KB
一键复制 编辑 原始数据 按行查看 历史
阿超Bug便利店 提交于 2020-05-07 11:44 . 修改登录部分的代码
const promise = require("./utils/promise.js");
const networkp = require("./utils/networkp.js");
const checkUserPasswordCache = promise(wx.getStorage);
const getUserId = networkp.get;
App({
globalData: {
userInfo: null,
auth: null,
id: -1,
statusBarHeight: wx.getSystemInfoSync()["statusBarHeight"],
windowHeight: 0,
},
/**
* 当小程序初始化完成时,会触发 onLaunch(全局只触发一次)
*/
onLaunch: function () {
wx.getSystemInfo({
success: (res) => {
this.globalData.windowHeight = res.windowHeight;
},
});
wx.getStorage({
key: 'auth',
success: (res)=>{
this.globalData.auth = res.data;
getUserId({
url: "/u/user/id",
data: { auth: res.data },
}).then((res) => {
if (res.success) {
this.globalData.id = res.data.id;
if (this.appReadyCallback) {
this.appReadyCallback();
}
}else{
wx.showToast({
title: '登录失败,请重新登录~',
icon: 'none',
image: '',
duration: 4000,
mask: false
});
}
}).catch(err=>{
});
},
fail: ()=>{
// 没有登录口令缓存
},
complete: ()=>{}
});
},
/**
* 当小程序启动,或从后台进入前台显示,会触发 onShow
*/
onShow: function (options) {},
/**
* 当小程序从前台进入后台,会触发 onHide
*/
onHide: function () {},
/**
* 当小程序发生脚本错误,或者 api 调用失败时,会触发 onError 并带上错误信息
*/
onError: function (msg) {},
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/woo_chaos/lifeshow-minip.git
git@gitee.com:woo_chaos/lifeshow-minip.git
woo_chaos
lifeshow-minip
lifeshow-minip
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385