App.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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,html {
  85. background-color: #f0f2f5;
  86. /* font-family: PingFang SC; */
  87. height: 100vh;
  88. width: 750rpx;
  89. }
  90. view {
  91. box-sizing: border-box;
  92. padding: 0;
  93. }
  94. /* 公共字体大小类 */
  95. .one-font {
  96. font-size: 48rpx;
  97. line-height: 72rpx;
  98. font-weight: 600;
  99. }
  100. .two-font {
  101. font-size: 40rpx;
  102. line-height: 56rpx;
  103. }
  104. .twoZ-font {
  105. font-size: 40rpx;
  106. line-height: 56rpx;
  107. font-weight: 500;
  108. }
  109. .three-font {
  110. font-size: 34rpx;
  111. line-height: 48rpx;
  112. font-weight: 500;
  113. }
  114. .num-font {
  115. font-size: 36rpx;
  116. line-height: 56rpx;
  117. font-weight: 700;
  118. }
  119. .bmTit-font {
  120. font-size: 36rpx;
  121. line-height: 44rpx;
  122. font-weight: 500;
  123. }
  124. .fNum-font {
  125. font-size: 44rpx;
  126. line-height: 56rpx;
  127. font-weight: 700;
  128. }
  129. .zw-font {
  130. font-size: 34rpx;
  131. line-height: 48rpx;
  132. }
  133. .btn-font {
  134. font-size: 28rpx;
  135. line-height: 40rpx;
  136. font-weight: 600;
  137. }
  138. .fwb-font {
  139. font-size: 28rpx;
  140. line-height: 40rpx;
  141. font-size: 400;
  142. }
  143. .sZw-font {
  144. font-size: 26rpx;
  145. line-height: 42rpx;
  146. font-size: 400;
  147. }
  148. .sBtn-font {
  149. font-size: 24rpx;
  150. line-height: 32rpx;
  151. font-weight: 600;
  152. }
  153. .fz-font {
  154. font-size: 24rpx;
  155. line-height: 32rpx;
  156. font-weight: 400;
  157. }
  158. .bq-font {
  159. font-size: 20rpx;
  160. line-height: 24rpx;
  161. }
  162. .bqZ-font {
  163. font-size: 20rpx;
  164. line-height: 24rpx;
  165. font-weight: 600;
  166. }
  167. </style>