Commit 98dae48f authored by Smile's avatar Smile Committed by wux

bug318 googleplay自动升级问题处理 ,系统默认跳转Google Play应用商店,未安装应用商店才下载更新

parent d0831b0c
......@@ -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
},
......
......@@ -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
},
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment