diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index efe8c934fa7c9cdfc1343f0152daaa3ea0becc2c..9c3057b52d989440ad2f64b95c7ce05d5f3f6fb9 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -361,50 +361,68 @@ export default { if (platform == 'ios') { plus.runtime.openURL('https://apps.apple.com/us/app/e-c-logistics/id6466407990') } else { - uni.showLoading({ - title: this.$lang.lang.notices.startDown - }) - that.showdownLine = true - var dtask = plus.downloader.createDownload(that.appUrl, {}, (d, status) => { - uni.hideLoading() - if (status == 200) { - // that.closeVe() - that.showdownLine = false - console.log('下载æˆåŠŸå®‰è£…: ' + d.filename) - plus.runtime.install(d.filename) - } else { - that.showdownLine = false - // that.closeVe() - plus.nativeUI.alert(that.$lang.lang.notices.failDown) - } - }) - - // uni.navigateTo({ - // url:'../updateView/updateView?url='+this.appUrl - // }) - // 下载进度 - dtask.addEventListener('statechanged', function (download, status) { - if (that.downloadNum == 100) { + console.log('android直接跳转') + var Uri = plus.android.importClass("android.net.Uri"); + var Intent = plus.android.importClass('android.content.Intent'); + var main = plus.android.runtimeMainActivity(); + //https://play.google.com/store/apps/details?id=com.jiedao.app + var uri = Uri.parse("market://details?id=" + "com.jiedao.app"); + var intent = new Intent(Intent.ACTION_VIEW, uri); + const googlePlay = "com.android.vending" + // 选择进入商店 + intent.setPackage(googlePlay); + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK; + // 没有该商店应用 + if (intent.resolveActivity(main.getPackageManager()) !== null) { + console.log('android 跳转google play') + main.startActivity(intent); + } else { + console.log('android 直接下载') + uni.showLoading({ + title: this.$lang.lang.notices.startDown + }) + that.showdownLine = true + var dtask = plus.downloader.createDownload(that.appUrl, {}, (d, status) => { uni.hideLoading() - } - switch (download.state) { - case 2: - break - case 3: //进度æ¡ç™¾åˆ†æ¯” totalSize为总é‡ï¼Œbaifen为当å‰ä¸‹è½½çš„百分比 - if (that.totalSize == 0) { - that.totalSize = parseInt(download.totalSize) - } - if (parseInt((download.downloadedSize / that.totalSize) * 100) != that.downloadNum) { - that.downloadNum = parseInt((download.downloadedSize / that.totalSize) * 100) - } - break - case 4: - // mui.toast("下载完æˆ"); + if (status == 200) { + // that.closeVe() + that.showdownLine = false + console.log('下载æˆåŠŸå®‰è£…: ' + d.filename) + plus.runtime.install(d.filename) + } else { + that.showdownLine = false + // that.closeVe() + plus.nativeUI.alert(that.$lang.lang.notices.failDown) + } + }) + + // uni.navigateTo({ + // url:'../updateView/updateView?url='+this.appUrl + // }) + // 下载进度 + dtask.addEventListener('statechanged', function (download, status) { + if (that.downloadNum == 100) { uni.hideLoading() - break - } - }) - dtask.start() + } + switch (download.state) { + case 2: + break + case 3: //进度æ¡ç™¾åˆ†æ¯” totalSize为总é‡ï¼Œbaifen为当å‰ä¸‹è½½çš„百分比 + if (that.totalSize == 0) { + that.totalSize = parseInt(download.totalSize) + } + if (parseInt((download.downloadedSize / that.totalSize) * 100) != that.downloadNum) { + that.downloadNum = parseInt((download.downloadedSize / that.totalSize) * 100) + } + break + case 4: + // mui.toast("下载完æˆ"); + uni.hideLoading() + break + } + }) + dtask.start() + } } // #endif }, diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index f0cdf5fda6c1c01caac6bf098a9529c4776567a0..73c0518434729cc435dddd54514090bdc12ef627 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -373,50 +373,68 @@ export default { if (platform == 'ios') { plus.runtime.openURL('https://apps.apple.com/us/app/e-c-logistics/id6466407990') } else { - uni.showLoading({ - title: this.$lang.lang.notices.startDown - }) - that.showdownLine = true - var dtask = plus.downloader.createDownload(that.appUrl, {}, (d, status) => { - uni.hideLoading() - if (status == 200) { - // that.closeVe() - that.showdownLine = false - console.log('下载æˆåŠŸå®‰è£…: ' + d.filename) - plus.runtime.install(d.filename) - } else { - that.showdownLine = false - // that.closeVe() - plus.nativeUI.alert(that.$lang.lang.notices.failDown) - } - }) - - // uni.navigateTo({ - // url:'../updateView/updateView?url='+this.appUrl - // }) - // 下载进度 - dtask.addEventListener('statechanged', function (download, status) { - if (that.downloadNum == 100) { + console.log('android直接跳转') + var Uri = plus.android.importClass("android.net.Uri"); + var Intent = plus.android.importClass('android.content.Intent'); + var main = plus.android.runtimeMainActivity(); + //https://play.google.com/store/apps/details?id=com.jiedao.app + var uri = Uri.parse("market://details?id=" + "com.jiedao.app"); + var intent = new Intent(Intent.ACTION_VIEW, uri); + const googlePlay = "com.android.vending" + // 选择进入商店 + intent.setPackage(googlePlay); + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK; + // 没有该商店应用 + if (intent.resolveActivity(main.getPackageManager()) !== null) { + console.log('android 跳转google play') + main.startActivity(intent); + } else { + console.log('android 直接下载') + uni.showLoading({ + title: this.$lang.lang.notices.startDown + }) + that.showdownLine = true + var dtask = plus.downloader.createDownload(that.appUrl, {}, (d, status) => { uni.hideLoading() - } - switch (download.state) { - case 2: - break - case 3: //进度æ¡ç™¾åˆ†æ¯” totalSize为总é‡ï¼Œbaifen为当å‰ä¸‹è½½çš„百分比 - if (that.totalSize == 0) { - that.totalSize = parseInt(download.totalSize) - } - if (parseInt((download.downloadedSize / that.totalSize) * 100) != that.downloadNum) { - that.downloadNum = parseInt((download.downloadedSize / that.totalSize) * 100) - } - break - case 4: - // mui.toast("下载完æˆ"); + if (status == 200) { + // that.closeVe() + that.showdownLine = false + console.log('下载æˆåŠŸå®‰è£…: ' + d.filename) + plus.runtime.install(d.filename) + } else { + that.showdownLine = false + // that.closeVe() + plus.nativeUI.alert(that.$lang.lang.notices.failDown) + } + }) + + // uni.navigateTo({ + // url:'../updateView/updateView?url='+this.appUrl + // }) + // 下载进度 + dtask.addEventListener('statechanged', function (download, status) { + if (that.downloadNum == 100) { uni.hideLoading() - break - } - }) - dtask.start() + } + switch (download.state) { + case 2: + break + case 3: //进度æ¡ç™¾åˆ†æ¯” totalSize为总é‡ï¼Œbaifen为当å‰ä¸‹è½½çš„百分比 + if (that.totalSize == 0) { + that.totalSize = parseInt(download.totalSize) + } + if (parseInt((download.downloadedSize / that.totalSize) * 100) != that.downloadNum) { + that.downloadNum = parseInt((download.downloadedSize / that.totalSize) * 100) + } + break + case 4: + // mui.toast("下载完æˆ"); + uni.hideLoading() + break + } + }) + dtask.start() + } } // #endif }, diff --git a/src/pages/site/site.vue b/src/pages/site/site.vue index aa14fe8148487461a311260801db08ccd8617ddb..5f0b28f8460ce89d5903793ff28e90dfee1169ec 100644 --- a/src/pages/site/site.vue +++ b/src/pages/site/site.vue @@ -312,88 +312,108 @@ export default { if (platform == 'ios') { plus.runtime.openURL('https://apps.apple.com/us/app/e-c-logistics/id6466407990') } else { - // uni.showLoading({ - // title: this.$lang.lang.notices.startDown, - // }) - that.showdownLine = true - uni.showLoading({ - title: this.$lang.lang.notices.startDown - }) - var dtask = plus.downloader.createDownload( - that.appUrl, - { - timeout: 60, - retry: 1, - retryInterval: 3 - }, - (d, status) => { - if (status == 200) { - uni.hideLoading() - that.closeVe() - that.showdownLine = false - console.log('下载æˆåŠŸå®‰è£…: ' + d.filename) - plus.runtime.install( - d.filename, - {}, - () => {}, - function (error) { - uni.showToast({ - title: that.$lang.lang.notices.failDown, - duration: 1500, - icon: 'none' - }) + + console.log('android直接跳转') + var Uri = plus.android.importClass("android.net.Uri"); + var Intent = plus.android.importClass('android.content.Intent'); + var main = plus.android.runtimeMainActivity(); + //https://play.google.com/store/apps/details?id=com.jiedao.app + var uri = Uri.parse("market://details?id=" + "com.jiedao.app"); + var intent = new Intent(Intent.ACTION_VIEW, uri); + const googlePlay = "com.android.vending" + // 选择进入商店 + intent.setPackage(googlePlay); + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK; + // 没有该商店应用 + if (intent.resolveActivity(main.getPackageManager()) !== null) { + console.log('android 跳转google play') + main.startActivity(intent); + } else { + console.log('android直接跳转') + // uni.showLoading({ + // title: this.$lang.lang.notices.startDown, + // }) + that.showdownLine = true + uni.showLoading({ + title: this.$lang.lang.notices.startDown + }) + var dtask = plus.downloader.createDownload( + that.appUrl, + { + timeout: 60, + retry: 1, + retryInterval: 3 + }, + (d, status) => { + if (status == 200) { + uni.hideLoading() + that.closeVe() + that.showdownLine = false + console.log('下载æˆåŠŸå®‰è£…: ' + d.filename) + plus.runtime.install( + d.filename, + {}, + () => { + }, + function (error) { + uni.showToast({ + title: that.$lang.lang.notices.failDown, + duration: 1500, + icon: 'none' + }) + } + ) + } else { + that.showdownLine = false + that.closeVe() + plus.nativeUI.alert(that.$lang.lang.notices.failDown) } - ) - } else { - that.showdownLine = false - that.closeVe() - plus.nativeUI.alert(that.$lang.lang.notices.failDown) - } - } - ) + } + ) - // uni.navigateTo({ - // url:'../updateView/updateView?url='+this.appUrl - // }) + // uni.navigateTo({ + // url:'../updateView/updateView?url='+this.appUrl + // }) - try { - dtask.start() - // 下载进度 - dtask.addEventListener('statechanged', function (download, status) { - if (that.downloadNum == 100) { - uni.hideLoading() - } - switch (download.state) { - case 1: - showLoading.setTitle('æ£åœ¨ä¸‹è½½') - break - case 2: - break - case 3: //进度æ¡ç™¾åˆ†æ¯” totalSize为总é‡ï¼Œbaifen为当å‰ä¸‹è½½çš„百分比 - if (that.totalSize == 0) { - that.totalSize = parseInt(download.totalSize) - } - if ( - parseInt((download.downloadedSize / that.totalSize) * 100) != that.downloadNum - ) { - that.downloadNum = parseInt((download.downloadedSize / that.totalSize) * 100) - } - break - case 4: - // mui.toast("下载完æˆ"); + try { + dtask.start() + // 下载进度 + dtask.addEventListener('statechanged', function (download, status) { + if (that.downloadNum == 100) { uni.hideLoading() - break - } - }) - } catch (err) { - uni.hideLoading() - that.showdownLine = false - that.closeVe() - uni.showToast({ - title: that.$lang.lang.notices.failDown, - duration: 1500, - icon: 'none' - }) + } + switch (download.state) { + case 1: + showLoading.setTitle('æ£åœ¨ä¸‹è½½') + break + case 2: + break + case 3: //进度æ¡ç™¾åˆ†æ¯” totalSize为总é‡ï¼Œbaifen为当å‰ä¸‹è½½çš„百分比 + if (that.totalSize == 0) { + that.totalSize = parseInt(download.totalSize) + } + if ( + parseInt((download.downloadedSize / that.totalSize) * 100) != that.downloadNum + ) { + that.downloadNum = parseInt((download.downloadedSize / that.totalSize) * 100) + } + break + case 4: + // mui.toast("下载完æˆ"); + uni.hideLoading() + break + } + }) + } catch (err) { + uni.hideLoading() + that.showdownLine = false + that.closeVe() + uni.showToast({ + title: that.$lang.lang.notices.failDown, + duration: 1500, + icon: 'none' + }) + } } } // #endif