//app.js var businessT = require('tool/business-tool.js') var sysT = require('tool/sys-tool.js') var publicData = require('constant/data.js') var key = require('constant/key.js') const updateManager = wx.getUpdateManager() App({ //根据跳转小程序appID获取对应名称 getflowAPP: function (flow_id) { switch (flow_id) { case "wx4882c703815c5602": { this.globalData.flow_name = "比心单身"; break } case "wxdb674acb1231c231": { this.globalData.flow_name = "趣健步"; break } case "wx6664983624b1a9aa": { this.globalData.flow_name = "开心小视频"; break } case "wx361bc43be556242b": { this.globalData.flow_name = "车行易"; break } case "wxffbb41ec9b99a969": { this.globalData.flow_name = "房天下"; break } case "wxf4b1c4ee0bc63893": { this.globalData.flow_name = "医启查"; break } case "wxe5bf8b2a2fe172ff": { this.globalData.flow_name = "职友集"; break } case "wx7ab08191e61478c5": { this.globalData.flow_name = "般若商城"; break } case "wxc18bff57483f5644": { this.globalData.flow_name = "查查信用"; break } case "wxeb95a70a8c8bbb6c": { this.globalData.flow_name = "土巴兔"; break } case "wxcb0ec6ae8c422c3b": { this.globalData.flow_name = "养老金计算器"; break } case "wx482c4fd36243ba7b": { this.globalData.flow_name = "退休养老金计算器"; break } case "wx7379ad24baaaf660": { this.globalData.flow_name = "个人所得税计算器新版"; break } case "wx9c2770b744d95f66": { this.globalData.flow_name = "个人所得税计算2019新版"; break } case "wx53e95e68996dbb50": { this.globalData.flow_name = "上海税后工资计算器"; break } case "wx6eed53ca3059904b": { this.globalData.flow_name = "北京税后工资计算器"; break } default: this.globalData.flow_id = "其他小程序ID" this.globalData.flow_name = "其他小程序名称"; } }, onLaunch: function (options) { sysT.adaptor() businessT.debugLog(sysT.isLongScreen()) businessT.debugLog(sysT.suffixOfClass()) this.judgeVersion() this.getUpdateReady() this.getNetworkStatus() this.handleData() }, onShow:function(e){ //console.log(e) this.globalData.scene = e.scene if (e.scene == 1037){ this.globalData.flow_id = e.referrerInfo.appId this.getflowAPP(e.referrerInfo.appId) }else{ this.globalData.flow_id = 1000 this.globalData.flow_name = "其他渠道来源" } }, handleData: function () { //购买城市 var d try { d = wx.getStorageSync(key.StorageKey.purchaseCity) } catch (e) { } if (!d) { d = { p: [{ name: '广东', id: 1000 }, { name: '北京市', id: 1100 }, { name: '上海市', id: 1200 }], 1000: [{ name: '广州', id: 1001 }, { name: '深圳', id: 1014 }], 1100: [{ name: '北京', id: 1101 }], 1200: [{ name: '上海', id: 1201 }] } } publicData.purchaseCity = d wx.setStorageSync(key.StorageKey.purchaseCity, d) businessT.debugLog(d) }, getUpdateReady: function () { updateManager.onUpdateReady(function () { wx.showModal({ title: '更新提示', content: '新版本已经准备好,是否重启应用?', showCancel: false, success: function (res) { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate() } } }) }) }, getNetworkStatus: function () { var that = this wx.getNetworkType({ success: function (res) { // 返回网络类型, 有效值: // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络) that.networkStatus.type = res.networkType if (that.networkStatus.type == 'none') { that.networkStatus.connected = false } else { that.networkStatus.connected = true } businessT.debugLog(that.networkStatus) } }) wx.onNetworkStatusChange(function(res){ that.networkStatus.type = res.networkType that.networkStatus.connected = res.isConnected businessT.debugLog(that.networkStatus) }) }, judgeVersion: function () { var version = wx.getStorageSync(key.StorageKey.localVersion) if (!version) { wx.removeStorageSync(key.StorageKey.userCode) wx.removeStorageSync(key.StorageKey.user) wx.removeStorageSync(key.StorageKey.userPhone) } else if (version < this.localVersion) { } else { } wx.setStorageSync(key.StorageKey.localVersion, this.localVersion) }, initRedDotArray: function () { this.redDotArray = ['0', '0', '0', '0', '0'] this.tabRedDot = '0' }, tabRedDot: '0', redDotArray: ['0', '0', '0', '0', '0'], bankCardTips:{}, loginStatus: { key: '', isLogin: false }, networkStatus: { type: 'none', connected: false }, purchase: { // normalPurchaseDataArray: [], // supplementaryPurchaseDataArray: [], purchaseDataArray: [], purchaseData: null, order: null }, globalData: { scene: null,//进入小程序场景 flow_id: 1000,//从其他平台跳转过来的appID flow_name: '其他渠道来源',//从其他平台跳转过来的平台名称 customerList: [], userInfo: { uid: '', phone: '' } }, localVersion: 1, })