You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.2 KiB

4 years ago
<script>
/*每个页面公共css */
//app.js
var util = require("./utils/util.js");
export default {
onShow() {
this.globalData.checkUpdate();
},
onLaunch: function() {
this.globalData.getDevice();
},
globalData: {
onPageNotFound(res) {
// 重定向到404页面
uni.redirectTo({
url: '/pages/notFound/notFound'
});
},
getDevice: function() {
// 获取屏幕参数
try {
const res = uni.getSystemInfoSync();
if (res.platform == 'ios') {
this.platform = 'ios';
} else if (res.platform == 'android') {
this.platform = 'android';
} // 导航高度
let navHeight = res.statusBarHeight; // 屏幕宽度/高度单位px
this.screenWidth = res.screenWidth;
this.screenScale = res.screenWidth / 375;
this.screenHeight = res.screenHeight; // 状态栏的高度单位px
this.statusBarHeight = res.statusBarHeight; // 设备像素比
this.pixelRatio = res.pixelRatio; // 可使用窗口宽度单位px
this.winWidth = res.windowWidth; // 安卓时胶囊距离状态栏8pxiOS距离4px
if (res.system.indexOf('Android') !== -1) {
this.navHeight = navHeight + 14 + 32;
this.navTitleTop = navHeight + 8; // 视窗高度 顶部有占位栏时
this.winHeight = res.screenHeight - navHeight - 14 - 32; // tab主页视窗高度
this.winHeightTab = res.windowHeight - navHeight - 14 - 32;
} else {
this.navHeight = navHeight + 12 + 32;
this.navTitleTop = navHeight + 4; // 视窗高度 顶部有占位栏时
this.winHeight = res.screenHeight - navHeight - 12 - 32; // tab主页视窗高度
this.winHeightTab = res.windowHeight - navHeight - 12 - 32;
}
console.log(uni.getSystemInfoSync(), this.winHeightTab);
} catch (e) {
console.log(e);
}
},
// 检查更新
checkUpdate() {
// 每次进入前台,检查程序版本更新
const updateManager = uni.getUpdateManager();
updateManager.onUpdateReady(function() {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
res.confirm && updateManager.applyUpdate();
}
});
});
updateManager.onUpdateFailed(function() {
util.alert('新版本下载失败');
});
},
userInfo: null,
screenScale: 1,
screenWidth: 375,
platform: 'ios',
pixelRatio: 2,
statusBarHeight: 20,
navHeight: 64,
navTitleTop: 26,
winHeight: 655,
winWidth: 750,
screenWidth: 375,
screenHeight: 812,
selectProjectID: "1",
selectCarer: null,
selectedProject: null
},
onError(e) {
console.log('onError:' + e);
},
methods: {}
};
</script>
3 years ago
<style>
4 years ago
/* #ifndef APP-PLUS-NVUE */
@import url("/static/style/iconfont.css");
@import url("/static/style/common.css");
page {
background-color: #f2f2f2;
font-family: Microsoft YaHei;
color: #333333;
padding-top: 160rpx;
3 years ago
padding-bottom: 120rpx;
font-size: 28rpx !important;
4 years ago
}
/* #endif*/
</style>