App.vue 3.6 KB

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