App.vue 4.0 KB

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