App.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. console.log('code:'+code);
  10. uni.request({
  11. url:'http://localhost:3001/login2',
  12. method:'POST',
  13. data:{code}
  14. }).then(res=>{
  15. console.log(res.data);
  16. uni.setStorageSync('SESSION',res.data)
  17. })
  18. }
  19. })
  20. uni.setStorageSync('login', '0');
  21. // uni.setStorageSync('msgLogin', '0');
  22. uni.getSystemInfo({
  23. success: function(res) {
  24. Vue.prototype.screenHeight = res.screenHeight
  25. Vue.prototype.screenWidth = res.screenWidth
  26. // console.log(res);
  27. const tabBarHeight = res.screenHeight - res.windowHeight;
  28. Vue.prototype.tabBarHeight = tabBarHeight
  29. if (uni.getMenuButtonBoundingClientRect()) {
  30. console.log('小程序');
  31. // 小程序状态栏是指显示电量的那一小部分
  32. thisWechat(res.statusBarHeight)
  33. } else {
  34. console.log('app');
  35. thisApp(res.statusBarHeight)
  36. }
  37. }
  38. });
  39. function thisWechat(statusBarHeight) {
  40. // 获取胶囊位置
  41. let meunButtonInfo = uni.getMenuButtonBoundingClientRect()
  42. // console.log(meunButtonInfo);
  43. Vue.prototype.meunButtonInfo = meunButtonInfo.height
  44. // 计算出导航栏高度+动态栏
  45. let allHeight = meunButtonInfo.bottom + (meunButtonInfo.top - statusBarHeight) * 2;
  46. // console.log(allHeight);
  47. let navheight;
  48. Vue.prototype.navheight = allHeight
  49. // 按钮离顶
  50. let alltop = meunButtonInfo.top
  51. Vue.prototype.navTop = alltop
  52. // 动态栏高度
  53. let statusHeight
  54. Vue.prototype.statusHeight = statusBarHeight
  55. };
  56. function thisApp(statusBarHeight) {
  57. // console.log(uni.getSystemInfoSync());
  58. // 导航栏高度
  59. // let appAllHeight;console.log();
  60. // Vue.prototype.appAllHeight=statusBarHeight+44+'px';
  61. // console.log(statusBarHeight);
  62. let customBarHeight;
  63. if (uni.getSystemInfoSync().platform === 'android') {
  64. customBarHeight = statusBarHeight + 50;
  65. } else if (uni.getSystemInfoSync().platform === 'ios') {
  66. // iOS 平台
  67. // 在这里根据 iOS 平台的特性计算自定义状态栏高度
  68. // ...
  69. customBarHeight = statusBarHeight + 45;
  70. } else {
  71. // 其他平台
  72. // ...
  73. customBarHeight = statusBarHeight;
  74. }
  75. // console.log(customBarHeight);
  76. Vue.prototype.customBar = customBarHeight;
  77. }
  78. },
  79. onShow() {},
  80. onLoad() {
  81. }
  82. }
  83. </script>
  84. <style>
  85. /*每个页面公共css */
  86. body {
  87. background-color: #f0f2f5;
  88. /* font-family: PingFang SC; */
  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>