初始化
This commit is contained in:
61
app.js
Normal file
61
app.js
Normal file
@@ -0,0 +1,61 @@
|
||||
// var devUrl = "http://39.106.44.112:8701"; //测试
|
||||
var devUrl = "https://oil-server.sxlyb.com"; // 生产
|
||||
// var devUrl = "http://192.168.10.250:8701"; // 开发
|
||||
var http = require("/utils/http.js");
|
||||
|
||||
//app.js
|
||||
App({
|
||||
onLaunch: function (options) {
|
||||
// 展示本地存储能力
|
||||
var logs = wx.getStorageSync("logs") || [];
|
||||
logs.unshift(Date.now());
|
||||
wx.setStorageSync("logs", logs);
|
||||
|
||||
// 获取小程序更新机制兼容
|
||||
if (wx.canIUse("getUpdateManager")) {
|
||||
const updateManager = wx.getUpdateManager();
|
||||
updateManager.onCheckForUpdate(function (res) {
|
||||
// 请求完新版本信息的回调
|
||||
if (res.hasUpdate) {
|
||||
updateManager.onUpdateReady(function () {
|
||||
updateManager.applyUpdate();
|
||||
});
|
||||
updateManager.onUpdateFailed(function () {
|
||||
// 新的版本下载失败
|
||||
wx.showModal({
|
||||
title: "已经有新版本了哟~",
|
||||
content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~",
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content:
|
||||
"当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。",
|
||||
});
|
||||
}
|
||||
|
||||
// 自定义导航
|
||||
if (options.scene == 1007 || options.scene == 1008) {
|
||||
this.globalData.share = true;
|
||||
} else {
|
||||
this.globalData.share = false;
|
||||
}
|
||||
wx.getSystemInfo({
|
||||
success: (res) => {
|
||||
this.globalData.height = res.statusBarHeight;
|
||||
},
|
||||
});
|
||||
|
||||
http.weChat();
|
||||
},
|
||||
globalData: {
|
||||
userInfo: null,
|
||||
devUrl: devUrl,
|
||||
share: false, // 分享默认为false
|
||||
height: 0,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user