123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <script>
- import { config } from '@/common/config.js';
- export default {
- data() {
- return {
- downloadUrl: ''
- };
- },
- onLaunch: function() {
- console.log('App Launch');
- },
- onShow: function() {
- console.log('App Show');
- this.getDownloadUrl();
- },
- methods: {
-
- getVersion() {
- const _this = this;
- uni.$u.api
- .getParameterApi({
- key: 'parking.operation.version'
- })
- .then(res => {
- if (res.code === 200) {
- if (res.msg !== config.version) {
- uni.getNetworkType({
- success: function(res) {
- if (res.networkType === 'wifi') {
- uni.showModal({
- title: '版本发布更新',
- content: '发现新版本且您使用的是无限网络,是否进行更新?',
- confirmText: '更新',
- confirmColor: '#EE8F57',
- success: res => {
- if (res.confirm) {
-
- _this.downloadAppFileByBrowser();
- }
- }
- });
- } else {
- uni.showModal({
- title: '版本发布更新',
- content: '发现新版本,是否继续消耗流量进行更新?',
- confirmText: '更新',
- confirmColor: '#EE8F57',
- success: res => {
- if (res.confirm) {
-
- _this.downloadAppFileByBrowser();
- }
- }
- });
- }
- }
- });
- }
- }
- });
- },
-
- getDownloadUrl() {
- uni.$u.api
- .getParameterApi({
- key: 'parking.operation.package'
- })
- .then(res => {
- if (res.code === 200) {
- this.downloadUrl = res?.msg;
- this.getVersion();
- }
- });
- },
-
- downloadAppFile() {
- const _this = this
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const dtask = plus.downloader.createDownload(_this.downloadUrl, { force: true }, function(d, status) {
-
- if (status == 200) {
- var path = d.filename;
- plus.runtime.install(
- path,
- {},
- function() {
- plus.nativeUI.closeWaiting();
- if (name == 'wgt') {
- console.log('安装wgt文件成功!');
- } else {
- console.log('安装apk文件成功!');
- }
- plus.nativeUI.alert('安装成功!', function() {
- plus.runtime.restart();
- });
- },
- function(e) {
- plus.nativeUI.closeWaiting();
- if (name == 'wgt') {
- console.log('安装wgt文件失败[' + e.code + ']:' + e.message);
- plus.nativeUI.alert('安装wgt文件失败[' + e.code + ']:' + e.message);
- } else {
- console.log('安装apk文件失败[' + e.code + ']:' + e.message);
- plus.nativeUI.alert('安装apk文件失败[' + e.code + ']:' + e.message);
- }
- }
- );
- } else {
- alert('下载失败:' + status);
- }
- });
-
- },
-
- downloadAppFileByBrowser() {
-
- plus.runtime.openURL(this.downloadUrl);
-
- }
- },
- onHide: function() {
- console.log('App Hide');
- }
- };
- </script>
- <style lang="scss">
- @import '@/uni_modules/uview-ui/index.scss';
- </style>
|