168 lines
4.3 KiB
Vue
168 lines
4.3 KiB
Vue
<script>
|
||
import {Config} from '@/utils/config'
|
||
|
||
export default {
|
||
onLaunch: function() {
|
||
// #ifdef APP-PLUS
|
||
// 检测升级
|
||
// console.log(Config.baseUrl+'/version/index')
|
||
uni.request({
|
||
url: Config.baseUrl+'/version/index', //检查更新的服务器地址
|
||
data: {
|
||
appid: plus.runtime.appid,
|
||
version: plus.runtime.version,
|
||
imei: plus.device.imei
|
||
},
|
||
success: (res) => {
|
||
if (res && res.data && res.data.code == 200 && res.data.data.isUpdate) {
|
||
let data = res.data.data
|
||
let openUrl = plus.os.name === 'iOS' ? data.iOS.url : data.Android.url;
|
||
let content = plus.os.name === 'iOS' ? data.iOS.describe : data.Android.describe;
|
||
let update_method = data.update_method ? false:true;
|
||
content = content === '' ? '有新版本更新,请及时更新软件!' : content;
|
||
uni.showModal({
|
||
title: '更新提示',
|
||
content: content,
|
||
showCancel:update_method,
|
||
success: (showResult) => {
|
||
if (showResult.confirm) {
|
||
plus.runtime.openURL(openUrl);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
})
|
||
// #endif
|
||
},
|
||
onShow: function() {
|
||
|
||
uni.onNetworkStatusChange(function(res) {
|
||
// 如果没有网络,提示用户
|
||
if (!res.isConnected) {
|
||
uni.showToast({
|
||
title: '检查到您当前没有网络,请先连接网络',
|
||
duration: 2000,
|
||
icon: 'none',
|
||
});
|
||
// 如果有网络了,但是网络较慢(2g,3g)也提示用户切换更快网络
|
||
} else {
|
||
uni.getNetworkType({
|
||
success: function (result) {
|
||
switch (result.networkType) {
|
||
case '2g':
|
||
uni.showToast({
|
||
title: '检查到您当前2G网络,为了您的使用体验建议切换4G或WIFI',
|
||
duration: 2000,
|
||
icon: 'none',
|
||
});
|
||
break;
|
||
case '3g':
|
||
uni.showToast({
|
||
title: '检查到您当前3G网络,为了您的使用体验建议切换4G或WIFI',
|
||
duration: 2000,
|
||
icon: 'none',
|
||
});
|
||
break;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
//
|
||
|
||
// void plus.push.createMessage( "content", "payload","" );
|
||
//Config.CID = plus.push.getClientInfo().clientid
|
||
// 监听plusready事件
|
||
// addEventListener( "plusready", function(){
|
||
// // 扩展API加载完毕,现在可以正常调用扩展API
|
||
// // 添加监听从系统消息中心点击某条消息启动应用事件
|
||
// plus.push.addEventListener( "click", function ( msg ) {
|
||
// // 分析msg.payload处理业务逻辑
|
||
// console.log( "You clicked: " + msg.content );
|
||
// }, false );
|
||
// }, false );
|
||
|
||
|
||
|
||
},
|
||
|
||
methods:{
|
||
|
||
},
|
||
onHide: function() {
|
||
|
||
},
|
||
}
|
||
</script>
|
||
<style>
|
||
/*每个页面公共css */
|
||
/* 官方ui库 */
|
||
/* @import "/common/uni.css"; */
|
||
/* 第三方动画库 */
|
||
@import "/common/animate.css";
|
||
/* 自定义图标库 */
|
||
@import "/common/icon.css";
|
||
/* UI基础库 */
|
||
@import "/common/zcm-main.css";
|
||
/* 公共css */
|
||
@import "/common/common.css";
|
||
|
||
html,
|
||
body,
|
||
page {
|
||
height: 100%;
|
||
margin: 0;
|
||
width: 100%;
|
||
padding: 0;
|
||
box-sizing: border-box;
|
||
}
|
||
view,text,label,button{
|
||
/* overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap; */
|
||
}
|
||
*{
|
||
/* overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap; */
|
||
}
|
||
.uni-tabbar__bd{
|
||
width: 100%;
|
||
}
|
||
.uni-tabbar__label{
|
||
width: 100%;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
|
||
}
|
||
|
||
/** 重写首页开屏弹窗广告样式 **/
|
||
.home .uni-popup__wrapper-box {
|
||
width: 60%;
|
||
text-align: center;
|
||
}
|
||
.home .uni-popup {
|
||
z-index: 999 !important;
|
||
}
|
||
|
||
/* uni-app 关于自定义标题栏时状态栏高度在不同手机的适配问题 */
|
||
@media only screen and (min-device-width : 375px) and (max-device-width : 821px) {
|
||
.h-22 {
|
||
height: 68upx !important;
|
||
}
|
||
.top {
|
||
top: 68upx !important;
|
||
}
|
||
}
|
||
.h-22 { // 状态栏高度
|
||
width: 100%;
|
||
height: var(--status-bar-height);
|
||
}
|
||
.top { // 自定义标题栏距离顶部的距离
|
||
top: var(--status-bar-height);
|
||
}
|
||
</style>
|