<script>
|
import Vue from 'vue'
|
export default {
|
created() {
|
//plus.navigator.closeSplashscreen();
|
},
|
onLaunch: function() {
|
// plus.screen.lockOrientation('landscape');
|
// plus.screen.lockOrientation('portrait');
|
uni.getSystemInfo({
|
success: function(e) {
|
Vue.prototype.statusBar = e.statusBarHeight;
|
let height = 45;
|
if (e.platform == 'android')
|
height = 50;
|
Vue.prototype.CustomBar = e.statusBarHeight + height;
|
}
|
})
|
// #ifdef APP-PLUS
|
// console.log(plus.push.getClientInfo().clientid);
|
// const _self = this;
|
// const _handlePush = function(message) {
|
// };
|
// plus.push.addEventListener('click', function(message) {
|
// //plus.nativeUI.toast('push click');
|
// // uni.navigateTo({
|
// // url: "/pages/index/main"
|
// // })
|
// });
|
// plus.push.addEventListener('receive', function(message) {
|
// //plus.push.createMessage("您有新的消息");
|
// //plus.nativeUI.alert(message.content);
|
// // uni.navigateTo({
|
// // url: "/pages/index/main"
|
// // })
|
// });
|
var requestIP = this.$AjaxRequest.RequestUrl;
|
// 获取本地应用资源版本号
|
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
|
//console.log("当前应用版本:" + inf.version + "---" + plus.runtime.version);
|
var server = requestIP + "Dt_appVersionRecord/CheckVersion"; //检查更新地址
|
var req = { //升级检测数据
|
MainData: {
|
"appid": plus.runtime.appid,
|
"version": inf.version, //plus.runtime.version,
|
"Extra": 'APP',
|
'VerificationCode': 'App',
|
'UUID': 'App'
|
}
|
};
|
//console.log(req);
|
uni.request({
|
method: 'POST',
|
url: server,
|
data: req,
|
dataType: 'json',
|
header: {
|
'Content-Type': 'application/json; charset=utf-8',
|
'Authorization': 'Bearer '
|
},
|
success: (res) => {
|
if (res.statusCode == 200 && res.data.data.status && !res.data.data.latestVersion) {
|
var urls = res.data.data.url;
|
var downLoad = requestIP + "Dt_appVersionRecord/DownLoadWgt?filePath=" + urls;
|
uni.showModal({ //提醒用户更新
|
title: "更新提示",
|
content: "检测新版本,是否更新?",
|
showCancel: true,
|
success: (res) => {
|
if (res.confirm) {
|
var wgtWaiting = null;
|
wgtWaiting = plus.nativeUI.showWaiting("开始下载");
|
var down = plus.downloader.createDownload(downLoad, {}, function(download, status) {
|
plus.nativeUI.closeWaiting();
|
if (status == 200) {
|
//console.log(down.filename);
|
installApk(down.filename); // 更新应用资源
|
} else {
|
plus.downloader.clear();
|
}
|
});
|
down.start();
|
down.addEventListener("statechanged", function(download, status) {
|
switch (download.state) {
|
case 2:
|
wgtWaiting.setTitle("已连接到服务器");
|
break;
|
case 3:
|
var percent = download.downloadedSize / download.totalSize * 100;
|
wgtWaiting.setTitle("已下载 " + parseInt(percent) + "%");
|
break;
|
case 4:
|
wgtWaiting.setTitle("下载完成");
|
break;
|
}
|
});
|
}
|
}
|
});
|
}
|
}
|
})
|
// 更新应用资源
|
var installApk = function(path) {
|
plus.runtime.install(path, {}, function() {
|
plus.nativeUI.closeWaiting();
|
//console.log("安装文件成功!");
|
plus.runtime.restart();
|
}, function(e) {
|
plus.nativeUI.closeWaiting();
|
//console.log(JSON.stringify(e));
|
uni.showToast({
|
title: '安装失败',
|
mask: false,
|
icon: 'none',
|
duration: 2500
|
});
|
});
|
}
|
});
|
|
//#endif
|
}
|
};
|
</script>
|
|
<style lang="scss">
|
@import "uview-ui/index.scss";
|
@import "common/demo.scss";
|
/* #ifdef H5 */
|
@media screen and (min-width: 768px) {
|
body{
|
overflow-y: scroll;
|
}
|
}
|
|
/* 顶栏通栏样式 */
|
/* .uni-top-window {
|
left: 0;
|
right: 0;
|
} */
|
|
uni-page-body {
|
background-color: #F5F5F5 !important;
|
min-height: 100% !important;
|
height: auto !important;
|
}
|
|
.uni-top-window uni-tabbar .uni-tabbar {
|
background-color: #fff !important;
|
}
|
|
.uni-app--showleftwindow .hideOnPc {
|
display: none !important;
|
}
|
/* #endif */
|
body {
|
background: #FFFFFF !important;
|
}
|
</style>
|