App.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <script>
  2. import Vue from 'vue'
  3. // import app from './utils/api.js'
  4. export default {
  5. onLaunch: function() {
  6. uni.getSystemInfo({
  7. success: function (res) {
  8. Vue.prototype.screenHeight=res.screenHeight
  9. Vue.prototype.screenWidth=res.screenWidth
  10. console.log(res);
  11. const tabBarHeight = res.screenHeight - res.windowHeight;
  12. Vue.prototype.tabBarHeight=tabBarHeight
  13. if (uni.getMenuButtonBoundingClientRect()) {
  14. console.log('小程序');
  15. // 小程序状态栏是指显示电量的那一小部分
  16. thisWechat(res.statusBarHeight)
  17. }else{
  18. console.log('app');
  19. thisApp(res.statusBarHeight)
  20. }
  21. }
  22. });
  23. function thisWechat(statusBarHeight){
  24. // 获取胶囊位置
  25. let meunButtonInfo=uni.getMenuButtonBoundingClientRect()
  26. // console.log(meunButtonInfo);
  27. Vue.prototype.meunButtonInfo=meunButtonInfo.height
  28. // 计算出导航栏高度+动态栏
  29. let allHeight = meunButtonInfo.bottom + (meunButtonInfo.top - statusBarHeight )*2;
  30. // console.log(allHeight);
  31. let navheight;
  32. Vue.prototype.navheight=allHeight
  33. // 按钮离顶
  34. let alltop = meunButtonInfo.top
  35. Vue.prototype.navTop=alltop
  36. // 动态栏高度
  37. let statusHeight
  38. Vue.prototype.statusHeight=statusBarHeight
  39. };
  40. function thisApp(statusBarHeight){
  41. // console.log(uni.getSystemInfoSync());
  42. // 导航栏高度
  43. // let appAllHeight;console.log();
  44. // Vue.prototype.appAllHeight=statusBarHeight+44+'px';
  45. // console.log(statusBarHeight);
  46. let customBarHeight;
  47. if (uni.getSystemInfoSync().platform === 'android') {
  48. customBarHeight = statusBarHeight + 50;
  49. } else if (uni.getSystemInfoSync().platform === 'ios') {
  50. // iOS 平台
  51. // 在这里根据 iOS 平台的特性计算自定义状态栏高度
  52. // ...
  53. customBarHeight = statusBarHeight + 45;
  54. } else {
  55. // 其他平台
  56. // ...
  57. customBarHeight = statusBarHeight;
  58. }
  59. // console.log(customBarHeight);
  60. Vue.prototype.customBar = customBarHeight;
  61. }
  62. },
  63. onLoad() {
  64. }
  65. }
  66. </script>
  67. <style>
  68. /*每个页面公共css */
  69. body{
  70. background-color: #f0f2f5;
  71. /* font-family: PingFang SC; */
  72. }
  73. view{
  74. box-sizing: border-box;
  75. padding: 0;
  76. }
  77. /* 公共字体大小类 */
  78. .one-font{
  79. font-size: 48rpx;
  80. line-height: 72rpx;
  81. font-weight: 600;
  82. }
  83. .two-font{
  84. font-size: 40rpx;
  85. line-height: 56rpx;
  86. }
  87. .twoZ-font{
  88. font-size: 40rpx;
  89. line-height: 56rpx;
  90. font-weight: 500;
  91. }
  92. .three-font{
  93. font-size: 34rpx;
  94. line-height: 48rpx;
  95. font-weight: 500;
  96. }
  97. .num-font{
  98. font-size: 36rpx;
  99. line-height: 56rpx;
  100. font-weight: 700;
  101. }
  102. .bmTit-font{
  103. font-size: 36rpx;
  104. line-height: 44rpx;
  105. font-weight: 500;
  106. }
  107. .fNum-font{
  108. font-size: 44rpx;
  109. line-height: 56rpx;
  110. font-weight: 700;
  111. }
  112. .zw-font{
  113. font-size: 34rpx;
  114. line-height: 48rpx;
  115. }
  116. .btn-font{
  117. font-size: 28rpx;
  118. line-height: 40rpx;
  119. font-weight: 600;
  120. }
  121. .fwb-font{
  122. font-size: 28rpx;
  123. line-height: 40rpx;
  124. font-size: 400;
  125. }
  126. .sZw-font{
  127. font-size: 26rpx;
  128. line-height: 42rpx;
  129. font-size: 400;
  130. }
  131. .sBtn-font{
  132. font-size: 24rpx;
  133. line-height: 32rpx;
  134. font-weight: 600;
  135. }
  136. .fz-font{
  137. font-size: 24rpx;
  138. line-height: 32rpx;
  139. font-weight: 400;
  140. }
  141. .bq-font{
  142. font-size: 20rpx;
  143. line-height: 24rpx;
  144. }
  145. .bqZ-font{
  146. font-size: 20rpx;
  147. line-height: 24rpx;
  148. font-weight: 600;
  149. }
  150. </style>