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