Files
shanxia2.0/miniprogram/App.vue
T
2026-07-11 17:15:17 +08:00

106 lines
2.8 KiB
Vue

<script>
import {
mapMutations
} from 'vuex'
import {
version
} from './package.json'
import { initGlobalSafeArea } from '@/utils/safeArea'
// #ifdef APP
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
// #endif
export default {
onLaunch: function() {
initGlobalSafeArea()
// #ifdef H5
console.log(
`%c hello uniapp %c v${version} `,
'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
'background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold;'
)
// #endif
// 线上示例使用
// console.log('%c uni-app官方团队诚邀优秀前 端工程师加盟,一起打造更卓越的uni-app & uniCloud,欢迎投递简历到 hr2013@dcloud.io', 'color: red');
console.log('App Launch');
// #ifdef APP-PLUS
// App平台检测升级,服务端代码是通过uniCloud的云函数实现的,详情可参考:https://ext.dcloud.net.cn/plugin?id=4542
if (plus.runtime.appid !== 'HBuilder') { // 真机运行不需要检查更新,真机运行时appid固定为'HBuilder',这是调试基座的appid
checkUpdate()
}
// 一键登录预登陆,可以显著提高登录速度
uni.preLogin({
provider: 'univerify',
success: (res) => {
// 成功
this.setUniverifyErrorMsg();
console.log("preLogin success: ", res);
},
fail: (res) => {
this.setUniverifyLogin(false);
this.setUniverifyErrorMsg(res.errMsg);
// 失败
console.log("preLogin fail res: ", res);
}
})
// #endif
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
globalData: {
test: '',
safeArea: null
},
methods: {
...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin'])
}
}
</script>
<style lang="scss">
@import '@/uni_modules/uni-scss/index.scss';
@import '@/styles/index.scss';
/* #ifndef APP-PLUS-NVUE */
/* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
@import './common/uni.css';
uni-page-body {
background-color: #ffffff;
}
/* 全局按钮兜底:避免微信/uni 默认 button-hover 覆盖导致点击发白 */
button.button-hover:not([disabled]) {
background-color: transparent;
opacity: 1;
}
/* 保留原按钮边框策略,避免点击后出现系统默认描边 */
button::after {
border: none;
}
/* #ifdef H5 */
html,
body {
height: 100%;
margin: 0;
}
#app {
height: 100%;
}
/* H5 统一使用自定义 ClientTabBar,隐藏原生 tabBar,避免两套样式不一致 */
.uni-tabbar,
.uni-tabbar-border {
display: none !important;
}
/* #endif */
/* #endif*/
</style>