const util = require('utils/util.js'); App({ globalData: { info:{} }, onLaunch: function (options) { this.checkUpdate(); this.globalData.path = options.path; util.refreshCount(); }, onShow(options) { // console.log("领队小程序传参", options); this.globalData.info=options.referrerInfo.extraData // this.getSafeTips(); this.clearStorageData(); this.getNps(); this.clearCommentData() }, // 对弹窗广告的上次进入次数清零 clearStorageData(){ let tipData = wx.getStorageSync("safeTips"); if (tipData && !tipData.oldHours) { tipData.num = 0; wx.setStorageSync("safeTips", tipData); } }, getSafeTips(){ let newDate = util.getNowFormatDate('yyyy-MM-dd'), data = wx.getStorageSync("safeTips") || {},newHours = new Date().getHours(); if (util.isObjEmpty(data) || (util.datedifference(newDate, data.oldDate) > 0 && data.num < 9999)) { this.globalData.openTipsNum = 0; data.oldDate = newDate; data.num = (data.num ? data.num : 0) + 1; data.todayNum = 1; data.oldHours = newHours; data.show = true; } else if((newHours - data.oldHours) >2 && data.todayNum < 2 && data.num < 9999){ this.globalData.openTipsNum = 0; data.oldDate = newDate; data.num = (data.num ? data.num : 0) + 1; data.todayNum = 2; data.oldHours = newHours; data.show = true; }else data.show = false; wx.setStorageSync("safeTips", data); }, // 确认评论是否过期 clearCommentData(){ let newDate = util.getNowFormatDate('yyyy-MM-dd hh:mm:ss'), commentData=wx.getStorageSync("orderComment"); if (!util.isObjEmpty(commentData)&&util.datedifference(newDate, commentData.saveDate,true) > 86400) { //比较是否超出一天(精确至秒) wx.removeStorageSync('orderComment') } }, getNps() { let newDate = util.getNowFormatDate('yyyy-MM-dd hh:mm:ss'), npsData = wx.getStorageSync("nps") || {}; if (util.isObjEmpty(npsData) || (util.datedifference(newDate, npsData.oldDate) > 0)) { //比较天数是否大于一天 npsData.oldDate = newDate; npsData.timesSec=newDate; npsData.num = 0; } wx.setStorageSync("nps", npsData); }, checkUpdate(){ if (wx.canIUse("getUpdateManager")) { let updateManager = wx.getUpdateManager(); updateManager.onCheckForUpdate(function (res) { if (res.hasUpdate) { updateManager.onUpdateReady(function () { wx.showModal({ title: '更新提示', content: '新版本已经准备好,是否重启应用?', success(res) { if (res.confirm) { updateManager.applyUpdate() } } }) }); updateManager.onUpdateFailed(function () { wx.showModal({ title: '已经有新版本了哟!', content: '新版本已经上线啦,请您删除当前小程序,重新搜索打开。', showCancel: false }); }); } }); } else { wx.showModal({ title: '提示!', content: '当前微信版本过低,无法使用该功能,请升级至微信最新版本!', showCancel: false }); } }, // 底部导航栏 editTabbar: function () { let tabbar = this.globalData.tabBar; let currentPages = getCurrentPages(); let _this = currentPages[currentPages.length - 1]; let pagePath = _this.route; (pagePath.indexOf('/') != 0) && (pagePath = '/' + pagePath); for (let i in tabbar.list) { tabbar.list[i].selected = false; (tabbar.list[i].pagePath == pagePath) && (tabbar.list[i].selected = true); } _this.setData({ tabbar: tabbar }); }, globalData: { tabBar: { "backgroundColor": "#ffffff", "color": "#979795", "selectedColor": "#1c1c1b", "list": [{ "pagePath": "/pages/home/index", "iconPath": "https://img.bbztx.com/miniProgram/challengeFamily/homePageShort.jpg", "selectedIconPath": "https://img.bbztx.com/miniProgram/challengeFamily/homePageLong.jpg", "text": "首页" }, { "pagePath": "/pages/home/account", "iconPath": "https://img.bbztx.com/miniProgram/challengeFamily/accountShort.jpg", "selectedIconPath": "https://img.bbztx.com/miniProgram/challengeFamily/accountLong.jpg", "text": "我的" } ] }, userInfo: wx.getStorageSync("WXuserInfo"), city: {city:'永康'}, previous:'',//选择前一个城市 locationCity:'',//定位城市 path:'', openTipsNum: 0 }, });