App.vue 3.8 KB

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