在项目中遇到这样的需求,首先看下页面效果
点击检查设置实现版本更新
首先需要请求后台接口 获取版本的一些信息,然后调用方法,代码如下:
fetchgetLatestApp({
//调用后台接口获取版本信息
params: {
//司机1
type: '1'
}
}).then(data => {
console.log(data) //调用后台接口获取版本信息
let update_info = {
version: data.result[0].version, //线上版本
now_url: baseUrl + 'sys/common/static/' + encodeURI(data.result[0]
.download_url), //更新链接
silent: 0, //是否是静默更新
force: 0, //是否是强制更新
net_check: 1, //非WIfi是否提示
note: data.result[0].note, //更新内容
}
console.log('hhhhh');
console.log(baseUrl + 'sys/common/static/' + data.result[0].download_url);
console.log(data.result[0].version);
checkUpdate(update_info, type).then(res => {
if (res.msg) {
plus.nativeUI.toast(res.msg);
}
}); ///检查更新
})