App.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <script>
  2. import {
  3. mapMutations
  4. } from 'vuex'
  5. import {
  6. version
  7. } from './package.json'
  8. import { initGlobalSafeArea } from '@/utils/safeArea'
  9. // #ifdef APP
  10. import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
  11. // #endif
  12. export default {
  13. onLaunch: function() {
  14. initGlobalSafeArea()
  15. // #ifdef H5
  16. console.log(
  17. `%c hello uniapp %c v${version} `,
  18. 'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
  19. 'background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold;'
  20. )
  21. // #endif
  22. // 线上示例使用
  23. // console.log('%c uni-app官方团队诚邀优秀前 端工程师加盟,一起打造更卓越的uni-app & uniCloud,欢迎投递简历到 hr2013@dcloud.io', 'color: red');
  24. console.log('App Launch');
  25. // #ifdef APP-PLUS
  26. // App平台检测升级,服务端代码是通过uniCloud的云函数实现的,详情可参考:https://ext.dcloud.net.cn/plugin?id=4542
  27. if (plus.runtime.appid !== 'HBuilder') { // 真机运行不需要检查更新,真机运行时appid固定为'HBuilder',这是调试基座的appid
  28. checkUpdate()
  29. }
  30. // 一键登录预登陆,可以显著提高登录速度
  31. uni.preLogin({
  32. provider: 'univerify',
  33. success: (res) => {
  34. // 成功
  35. this.setUniverifyErrorMsg();
  36. console.log("preLogin success: ", res);
  37. },
  38. fail: (res) => {
  39. this.setUniverifyLogin(false);
  40. this.setUniverifyErrorMsg(res.errMsg);
  41. // 失败
  42. console.log("preLogin fail res: ", res);
  43. }
  44. })
  45. // #endif
  46. },
  47. onShow: function() {
  48. console.log('App Show')
  49. },
  50. onHide: function() {
  51. console.log('App Hide')
  52. },
  53. globalData: {
  54. test: '',
  55. safeArea: null
  56. },
  57. methods: {
  58. ...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin'])
  59. }
  60. }
  61. </script>
  62. <style lang="scss">
  63. @import '@/uni_modules/uni-scss/index.scss';
  64. @import '@/styles/index.scss';
  65. /* #ifndef APP-PLUS-NVUE */
  66. /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
  67. @import './common/uni.css';
  68. uni-page-body {
  69. background-color: #ffffff;
  70. }
  71. /* 全局按钮兜底:避免微信/uni 默认 button-hover 覆盖导致点击发白 */
  72. button.button-hover:not([disabled]) {
  73. background-color: transparent;
  74. opacity: 1;
  75. }
  76. /* 保留原按钮边框策略,避免点击后出现系统默认描边 */
  77. button::after {
  78. border: none;
  79. }
  80. /* #ifdef H5 */
  81. html,
  82. body {
  83. height: 100%;
  84. margin: 0;
  85. }
  86. #app {
  87. height: 100%;
  88. }
  89. /* H5 统一使用自定义 ClientTabBar,隐藏原生 tabBar,避免两套样式不一致 */
  90. .uni-tabbar,
  91. .uni-tabbar-border {
  92. display: none !important;
  93. }
  94. /* #endif */
  95. /* #endif*/
  96. </style>