App.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 =
  39. (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height + systemInfo.statusBarHeight;
  40. that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
  41. that.globalData.menuHeight = menuButtonInfo.height;
  42. that.globalData.statusBarHeight = systemInfo.statusBarHeight;
  43. that.globalData.safeAreaHeight = systemInfo.safeAreaInsets.bottom;
  44. that.globalData.windowWidth = systemInfo.windowWidth;
  45. that.globalData.windowHeight = systemInfo.windowHeight;
  46. that.globalData.pageContentHeight =
  47. systemInfo.windowHeight -
  48. (that.globalData.navBarHeight + that.globalData.menuTop + that.globalData.menuBotton);
  49. const scene = options.query.scene ? decodeURIComponent(options.query.scene) : "";
  50. const inviteCode = scene ? scene.split("=")[1] : "";
  51. console.log(inviteCode, "inviteCode");
  52. if (inviteCode) {
  53. wx.setStorageSync('inviteCode', inviteCode)
  54. }
  55. this.slientLogin(inviteCode);
  56. },
  57. methods: {
  58. slientLogin(inviteCode) {
  59. uni.login({
  60. success(res) {
  61. uni.$u.http
  62. .post("/user/wxLogin", {
  63. code: res.code,
  64. inviteCode,
  65. })
  66. .then((response) => {
  67. if (response.code == 200) {
  68. uni.setStorageSync("token", response.data.token);
  69. }
  70. });
  71. },
  72. fail: (err) => {
  73. console.log(err, "wx.login登录失败");
  74. },
  75. });
  76. },
  77. },
  78. };
  79. </script>
  80. <style lang="scss">
  81. // ===
  82. // === 注意:此处导入的css,会作用于全部.vue文件,请适量导入
  83. // ===
  84. body {
  85. font-family: PingFang-SC-Regular, PingFang-SC;
  86. }
  87. page {
  88. background-color: $app-theme-bg-gray-deep-color;
  89. }
  90. @import "uview-ui/index.scss";
  91. @import "./static/css/common.scss";
  92. /* 解决小程序和app滚动条的问题 */
  93. /* #ifdef MP-WEIXIN || APP-PLUS */
  94. ::-webkit-scrollbar {
  95. display: none;
  96. width: 0 !important;
  97. height: 0 !important;
  98. -webkit-appearance: none;
  99. background: transparent;
  100. color: transparent;
  101. }
  102. /* #endif */
  103. /* 解决H5 的问题 */
  104. /* #ifdef H5 */
  105. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  106. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  107. display: none;
  108. width: 0 !important;
  109. height: 0 !important;
  110. -webkit-appearance: none;
  111. background: transparent;
  112. color: transparent;
  113. }
  114. /* #endif */
  115. .shu-elip-1 {
  116. overflow: hidden;
  117. text-overflow: ellipsis;
  118. white-space: nowrap;
  119. }
  120. .shu-elip-2 {
  121. display: -webkit-box;
  122. overflow: hidden;
  123. text-overflow: ellipsis;
  124. word-wrap: break-word;
  125. white-space: normal !important;
  126. -webkit-line-clamp: 2;
  127. -webkit-box-orient: vertical;
  128. }
  129. // 导出 scss 变量用于在 script 下使用
  130. .price_color {
  131. color: $app-theme-text-money-color;
  132. }
  133. .color_blue {
  134. color: $app-theme-blue;
  135. }
  136. .btnGroup {
  137. display: flex;
  138. align-items: center;
  139. .btn {
  140. margin: 0 10rpx;
  141. }
  142. }
  143. .mallbtn {
  144. min-width: 200rpx;
  145. line-height: 66rpx;
  146. padding: 0 20rpx;
  147. border-radius: 36rpx;
  148. color: #ffffff;
  149. margin-right: 20rpx;
  150. text-align: center;
  151. flex: 1;
  152. padding: 0 30rpx;
  153. }
  154. .soldOutBtn {
  155. @extend .mallbtn;
  156. background-color: $app-theme-nobuy-bg-color;
  157. }
  158. .joinCartBtn {
  159. @extend .mallbtn;
  160. background-color: $app-theme-joincart-bg-color;
  161. }
  162. .buyBtn {
  163. @extend .mallbtn;
  164. background-color: $app-theme-buybtn-bg-color;
  165. }
  166. </style>