App.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <script>
  2. import {
  3. mapMutations
  4. } from 'vuex'
  5. import {
  6. version
  7. } from './package.json'
  8. import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
  9. export default {
  10. onLaunch: function() {
  11. // #ifdef H5
  12. console.log(
  13. `%c hello uniapp %c v${version} `,
  14. 'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
  15. 'background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold;'
  16. )
  17. // #endif
  18. // 线上示例使用
  19. // console.log('%c uni-app官方团队诚邀优秀前端工程师加盟,一起打造更卓越的uni-app & uniCloud,欢迎投递简历到 hr2013@dcloud.io', 'color: red');
  20. console.log('App Launch');
  21. // #ifdef APP-PLUS
  22. // App平台检测升级,服务端代码是通过uniCloud的云函数实现的,详情可参考:https://ext.dcloud.net.cn/plugin?id=4542
  23. if (plus.runtime.appid !== 'HBuilder') { // 真机运行不需要检查更新,真机运行时appid固定为'HBuilder',这是调试基座的appid
  24. checkUpdate()
  25. }
  26. // 一键登录预登陆,可以显著提高登录速度
  27. uni.preLogin({
  28. provider: 'univerify',
  29. success: (res) => {
  30. // 成功
  31. this.setUniverifyErrorMsg();
  32. console.log("preLogin success: ", res);
  33. },
  34. fail: (res) => {
  35. this.setUniverifyLogin(false);
  36. this.setUniverifyErrorMsg(res.errMsg);
  37. // 失败
  38. console.log("preLogin fail res: ", res);
  39. }
  40. })
  41. // #endif
  42. },
  43. onShow: function() {
  44. console.log('App Show')
  45. },
  46. onHide: function() {
  47. console.log('App Hide')
  48. },
  49. globalData: {
  50. test: ''
  51. },
  52. methods: {
  53. ...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin'])
  54. }
  55. }
  56. </script>
  57. <style>
  58. /* #ifndef APP-PLUS-NVUE */
  59. /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
  60. @import './common/uni.css';
  61. @import '@/static/customicons.css';
  62. /* H5 兼容 pc 所需 */
  63. /* #ifdef H5 */
  64. @media screen and (min-width: 768px) {
  65. body {
  66. overflow-y: scroll;
  67. }
  68. }
  69. /* 顶栏通栏样式 */
  70. /* .uni-top-window {
  71. left: 0;
  72. right: 0;
  73. } */
  74. uni-page-body {
  75. background-color: #F5F5F5 !important;
  76. min-height: 100% !important;
  77. height: auto !important;
  78. }
  79. .uni-top-window uni-tabbar .uni-tabbar {
  80. background-color: #fff !important;
  81. }
  82. .uni-app--showleftwindow .hideOnPc {
  83. display: none !important;
  84. }
  85. /* #endif */
  86. /* 以下样式用于 hello uni-app 演示所需 */
  87. page {
  88. background-color: #efeff4;
  89. height: 100%;
  90. font-size: 28rpx;
  91. /* line-height: 1.8; */
  92. }
  93. .fix-pc-padding {
  94. padding: 0 50px;
  95. }
  96. .uni-header-logo {
  97. padding: 30rpx;
  98. flex-direction: column;
  99. justify-content: center;
  100. align-items: center;
  101. margin-top: 10rpx;
  102. }
  103. .uni-header-image {
  104. width: 100px;
  105. height: 100px;
  106. }
  107. .uni-hello-text {
  108. color: #7A7E83;
  109. }
  110. .uni-hello-addfile {
  111. text-align: center;
  112. line-height: 300rpx;
  113. background: #FFF;
  114. padding: 50rpx;
  115. margin-top: 10px;
  116. font-size: 38rpx;
  117. color: #808080;
  118. }
  119. /* #endif*/
  120. </style>