Directamente en el código, fácil de entender
uni.getSystemInfo({
success: function (res) {
console.log(res.osName, "系统信息");
console.log(res, "系统信息1");
if (res.osName == "android") {
uni.showLoading({ title: "下载中" });
uni.downloadFile({
url: `https://tk.xingyuncm.cn/apk/大喇叭拓客_v1.0.1.apk`, //仅为示例,并非真实的资源
success: (res) => {
console.log(res, "下载成功");
if (res.statusCode === 200) {
console.log("下载成功");
uni.hideLoading();
uni.showToast({ title: "下载成功", icon: "success" });
uni.saveFile({
tempFilePath: res.tempFilePath,
success: function (res) {
uni.openDocument({
filePath: res.savedFilePath,
success: function (res) {
console.log(res, "打开安装包");
},
});
},
fail: (err) => {
console.log(err, "打开安装包-失败");
},
});
}
},
fail: (err) => {
console.log(err, "下载失败");
uni.hideLoading();
uni.showToast({
title: "下载失败,请检查网络",
icon: "none",
duration: 1500,
});
},
});
} else {
uni.showToast({
title: "当前手机系统不支持",
icon: "none",
mask: true,
});
}
},
});
Obtenga la información del sistema primero, solo Android puede descargar este software