1.html
<div onclick="Version()" style="width:100%;height:60px;display:flex;justify-content:center;align-items:center;color:#999;font-size:12px;">
应用版本号:{{appVersion}} 检查更新
</div>
js
apiready = function() {
var config = {
domain: 'http://sly.eacase.com', //项目域名
};
var header = document.querySelector('.emp1Top');
setStatusBar(header);
var token = api.getPrefs({
key: 'token',
sync: true
});
//点击版本号 更新
Version = function() {
var mam = api.require('mam');
mam.checkUpdate(function(ret, err) {
if (ret) {
// document.getElementById("msg").innerHTML = JSON.stringify(ret)
var result = ret.result;
if (ret.status == 1 && result.update == true) {
api.confirm({
title: '版本更新提示',
msg: '发现新版本:' +result.version + ',请立即更新!',
buttons: ['立即更新', '取消']
}, function(ret, err) {
var index = ret.buttonIndex;
if (index == 1) {
// document.getElementById("msg").innerHTML = "点击了立即更新--------" + JSON.stringify(api.systemType)
if (api.systemType == "android") {
api.download({
url:result.source,
report: true
}, function(retdownload, err) {
// document.getElementById("msg").innerHTML = "正在下载应用" + retdownload.percent + "%"
if (retdownload && 0 == retdownload.state) { /* 下载进度 */
api.toast({
msg: "正在下载应用" + retdownload.percent + "%",
duration: 4000,
location: 'middle'
});
}
if (retdownload && 1 == retdownload.state) { /* 下载完成 */
var savePath = retdownload.savePath;
api.installApp({
appUri: savePath
});
// document.getElementById("msg").innerHTML = "ok1"
}
});
}
}
});
} else {
// document.getElementById("msg").innerHTML = "当前已是最新版本"
api.toast({
msg: '当前已是最新版本',
duration: 2000,
location: 'middle'
});
return;
}
} else {
api.toast({
msg: '服务器繁忙,请稍后再试',
duration: 2000,
location: 'middle'
});
return;
}
});
};
// 水工页面的数据 展示
var empty4 = new Vue({
el: '#empty4',
data: {
appVersion: '', // 版本号
},
created: function() {
that.appVersion = api.appVersion;
},
});
}
网友评论