App.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <script>
  2. export default {
  3. globalData: {
  4. // 胶囊距上距离
  5. menuTop: 0,
  6. // 导航栏高度
  7. navBarHeight: 0,
  8. // 胶囊距右方间距(方保持左、右间距一致)
  9. menuRight: 0,
  10. // 胶囊距底部间距(保持底部间距一致)
  11. menuBotton: 0,
  12. // 胶囊高度(自定义内容可与胶囊高度保证一致)
  13. menuHeight: 0,
  14. // 状态栏高度
  15. statusBarHeight: 0,
  16. // 安全距离
  17. safeAreaHeight: 0,
  18. // 胶囊宽度
  19. menuWidth: 0,
  20. // 窗口宽度
  21. windowWidth:0,
  22. // 窗口宽度高度
  23. windowHeight:0,
  24. // 常规子页面可操作区域高度
  25. pageContentHeight:0,
  26. },
  27. onLaunch(options) {
  28. const that = this;
  29. // 获取系统信息
  30. const systemInfo = uni.getSystemInfoSync();
  31. // 胶囊按钮位置信息
  32. const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
  33. console.log(menuButtonInfo);
  34. // 导航栏高度 = 状态栏到胶囊的间距(胶囊距上距离-状态栏高度) * 2 + 胶囊高度 + 状态栏高度
  35. that.globalData.menuTop = menuButtonInfo.top - systemInfo.statusBarHeight;
  36. that.globalData.menuBotton = menuButtonInfo.top - systemInfo.statusBarHeight;
  37. that.globalData.menuWidth = menuButtonInfo.width;
  38. that.globalData.navBarHeight = (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height + systemInfo.statusBarHeight;
  39. that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
  40. that.globalData.menuHeight = menuButtonInfo.height;
  41. that.globalData.statusBarHeight = systemInfo.statusBarHeight;
  42. that.globalData.safeAreaHeight = systemInfo.safeAreaInsets.bottom;
  43. that.globalData.windowWidth = systemInfo.windowWidth;
  44. that.globalData.windowHeight = systemInfo.windowHeight;
  45. that.globalData.pageContentHeight = systemInfo.windowHeight - (that.globalData.navBarHeight+that.globalData.menuTop+that.globalData.menuBotton);
  46. console.log(that.globalData);
  47. }
  48. };
  49. </script>
  50. <style lang="scss">
  51. // ===
  52. // === 注意:此处导入的css,会作用于全部.vue文件,请适量导入
  53. // ===
  54. body{
  55. font-family: PingFang-SC-Regular, PingFang-SC;
  56. }
  57. page{
  58. background-color: $app-theme-bg-gray-deep-color
  59. }
  60. @import 'uview-ui/index.scss';
  61. /* 解决小程序和app滚动条的问题 */
  62. /* #ifdef MP-WEIXIN || APP-PLUS */
  63. ::-webkit-scrollbar {
  64. display: none;
  65. width: 0 !important;
  66. height: 0 !important;
  67. -webkit-appearance: none;
  68. background: transparent;
  69. color: transparent;
  70. }
  71. /* #endif */
  72. /* 解决H5 的问题 */
  73. /* #ifdef H5 */
  74. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  75. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  76. display: none;
  77. width: 0 !important;
  78. height: 0 !important;
  79. -webkit-appearance: none;
  80. background: transparent;
  81. color: transparent;
  82. }
  83. /* #endif */
  84. .shu-elip-1{
  85. overflow:hidden;
  86. text-overflow:ellipsis;
  87. white-space:nowrap;
  88. }
  89. .shu-elip-2 {
  90. display: -webkit-box;
  91. overflow: hidden;
  92. text-overflow: ellipsis;
  93. word-wrap: break-word;
  94. white-space: normal !important;
  95. -webkit-line-clamp: 2;
  96. -webkit-box-orient: vertical;
  97. }
  98. // 导出 scss 变量用于在 script 下使用
  99. .price_color{
  100. color: $app-theme-text-money-color;
  101. }
  102. .color_blue{
  103. color: $app-theme-blue;
  104. }
  105. .btnGroup{
  106. display: flex;
  107. align-items: center;
  108. .btn{
  109. margin: 0 10rpx;
  110. }
  111. }
  112. .mallbtn {
  113. min-width: 200rpx;
  114. line-height: 66rpx;
  115. padding: 0 20rpx;
  116. border-radius: 36rpx;
  117. color: #ffffff;
  118. margin-right: 20rpx;
  119. text-align: center;
  120. flex: 1;
  121. padding: 0 30rpx;
  122. }
  123. .soldOutBtn{
  124. @extend .mallbtn;
  125. background-color: $app-theme-nobuy-bg-color;
  126. }
  127. .joinCartBtn {
  128. @extend .mallbtn;
  129. background-color: $app-theme-joincart-bg-color;
  130. }
  131. .buyBtn {
  132. @extend .mallbtn;
  133. background-color: $app-theme-buybtn-bg-color;
  134. }
  135. </style>