123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- import { HTTP_REQUEST_URL, CACHE_USERINFO, CACHE_TOKEN, CACHE_EXPIRES_TIME } from './config.js';
- import Server from './utils/Server.js';
- import util from './utils/util.js';
- App({
- onLaunch: function (option) {
- if (HTTP_REQUEST_URL==''){
- console.error("请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret");
- return false;
- }
- let that = this;
- let token = wx.getStorageSync(CACHE_TOKEN);
- let expiresTime = wx.getStorageSync(CACHE_EXPIRES_TIME);
- let userInfo = wx.getStorageSync(CACHE_USERINFO);
- this.globalData.isLog = !!userInfo && util.checkLogin(token, expiresTime,true);
- if (this.globalData.isLog) {
- this.globalData.token = token;
- this.globalData.expiresTime = expiresTime;
- this.globalData.userInfo = userInfo ? JSON.parse(userInfo) : {};
- }
- if (option.query.hasOwnProperty('scene')){
- switch (option.scene) {
-
- case 1047:
- that.globalData.code = option.query.scene;
- break;
-
- case 1048:
- that.globalData.code = option.query.scene;
- break;
-
- case 1049:
- that.globalData.code = option.query.scene;
- break;
-
- case 1001:
- that.globalData.spid = option.query.scene;
- break;
- }
- }
-
- wx.getSystemInfo({
- success: res => {
-
- this.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 97;
- }, fail(err) {}
- });
- const updateManager = wx.getUpdateManager();
- updateManager.onCheckForUpdate(function (res) {
-
-
- })
- updateManager.onUpdateReady(function () {
- wx.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success: function (res) {
- if (res.confirm) {
-
- updateManager.applyUpdate()
- }
- }
- })
- });
- updateManager.onUpdateFailed(function () {
- return that.Tips({title:'新版本下载失败'});
- })
-
- this.$chat = new Server(this);
- },
- $chat:null,
- globalData: {
- navHeight: 0,
- routineStyle: '#ffffff',
- openPages: '',
- spid: 0,
- code:0,
- urlImages: '',
- url: HTTP_REQUEST_URL,
- token: '',
- isLog:false,
- expiresTime:0,
- MyMenus:[],
- userInfo:{},
- loginType:'routine'
- },
-
- $on: function (name, action){
- this.$chat.$on(name,action);
- },
-
- Tips: function (opt, to_url) {
- return util.Tips(opt, to_url);
- },
-
- help:function()
- {
- return util.$h;
- },
-
- SplitArray: function (list, sp) { return util.SplitArray(list, sp)},
- })
|