App.vue 3.8 KB

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