网站首页
uniapp 热更新~
发布时间:2020-11-06 06:13查看次数:2502
<script> let _this; export default { onLaunch: function() { _this = this; _this.upStyle = { width: '100%', height: '100%', background: '#00000' }; console.log('App Launch'); // #ifdef APP-PLUS plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) { let tempUrl = 'https://shipin.5884.com/api/app/up/' + widgetInfo.version + '/xxdz'; uni.request({ url: tempUrl, success: result => { var data = result.data; if (data.code == 200) { let updata = data.data; if (updata.isup) { _this.downFile(updata.down); } } } }); }); // #endif }, onShow: function() { console.log('App Show'); }, onHide: function() { console.log('App Hide'); }, methods: { downFile: function(url) { plus.nativeUI.showWaiting('亲!升级中...请稍后',_this.upStyle); uni.downloadFile({ url: url, success: downloadResult => { if (downloadResult.statusCode === 200) { plus.runtime.install( downloadResult.tempFilePath, { force: false }, function() { plus.nativeUI.closeWaiting(); console.log('install success...'); plus.runtime.restart(); }, function(e) { plus.nativeUI.closeWaiting(); console.error('install fail...', e); } ); } } }); } } }; </script>
关键字词:unia##