| | |
| | | <script> |
| | | export default { |
| | | globalData: { |
| | | isFocus: false |
| | | }, |
| | | onLaunch: function() { |
| | | console.log('App Launch') |
| | | //#ifdef APP-PLUS |
| | | setTimeout(()=>{ |
| | | plus.navigator.closeSplashscreen(); |
| | | }, 2000); |
| | | this.update(); |
| | | //#endif |
| | | }, |
| | | onShow: function() { |
| | | console.log('App Show') |
| | | }, |
| | | onHide: function() { |
| | | console.log('App Hide') |
| | | }, |
| | | methods: { |
| | | isIos(){ |
| | | return uni.getSystemInfoSync().platform == 'ios'; |
| | | }, |
| | | update() { |
| | | this.$httpUtils.request('/api/common/findAppVersion').then((res) => { |
| | | if (res.status!=200 || !res.rows){ |
| | | return; |
| | | } |
| | | let result = this.isIos() ? res.rows[1] : res.rows[0]; |
| | | plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{ |
| | | if(!this.$utils.compare(wgtinfo.version, result.version)){ |
| | | uni.showModal({ |
| | | title: "发现新版本", |
| | | content: "确认下载更新", |
| | | showCancel:false, |
| | | success: (res) => { |
| | | if (res.confirm == true) { |
| | | if(this.isIos()){ |
| | | this.openAppStore(); |
| | | } else { |
| | | this.doUpData(result.address); |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | }, |
| | | doUpData(url) { |
| | | let showLoading = plus.nativeUI.showWaiting("正在下载"); |
| | | const downloadTask = uni.downloadFile({ |
| | | url: url, |
| | | success: downloadResult => { |
| | | if (downloadResult.statusCode == 200) { |
| | | showLoading.setTitle("下载完成"); |
| | | plus.nativeUI.closeWaiting(); |
| | | plus.runtime.install( |
| | | downloadResult.tempFilePath, { |
| | | force: true |
| | | }, |
| | | function(res) { |
| | | plus.runtime.restart(); |
| | | } |
| | | ); |
| | | } |
| | | } |
| | | }); |
| | | downloadTask.onProgressUpdate((res) => { |
| | | showLoading.setTitle(" 正在下载 " + res.progress + "% "); |
| | | }); |
| | | }, |
| | | openAppStore(){ |
| | | let appleId= 1548845238; |
| | | plus.runtime.launchApplication({ |
| | | action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8` |
| | | }); |
| | | plus.runtime.restart();; |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | |
| | | <style> |
| | | /*每个页面公共css */ |
| | | @import url("./common/styles/index"); |
| | | @import url("//at.alicdn.com/t/font_2263696_lohq5qfkgkq.css"); |
| | | @import url("./static/iconfont/iconfont.css"); |
| | | /* @import url("//at.alicdn.com/t/font_2263696_xstpgfieur.css"); */ |
| | | </style> |