App.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. console.log(options, "onLaunch系统信息");
  29. let params = {};
  30. if (options.query) {
  31. // #ifdef MP-WEIXIN
  32. if (options.query.scene) {
  33. // 对 scene 进行解码
  34. const decodeScene = decodeURIComponent(options.query.scene);
  35. // 拆分参数
  36. const paramPairs = decodeScene.split('&');
  37. paramPairs.forEach((pair) => {
  38. const [key, value] = pair.split('=');
  39. params[key] = value;
  40. });
  41. let keys = Object.keys(params)
  42. if (keys.length > 0) {
  43. this.slientLogin(params);
  44. if (params.inviteCode) {
  45. uni.setStorageSync('inviteCode', params.inviteCode)
  46. }
  47. } else {
  48. this.slientLogin();
  49. }
  50. }
  51. // #endif
  52. // 如果链接参数中有一个名为 inviteCode 的参数
  53. this.slientLogin(options.query);
  54. // 如果链接参数中有一个名为 upsellCode 的参数
  55. if (options.query.upsellCode) {
  56. uni.setStorageSync('upsellCode', options.query.upsellCode)
  57. }
  58. } else {
  59. this.slientLogin()
  60. }
  61. },
  62. onUnload() {
  63. uni.removeStorageSync('loginType')
  64. },
  65. methods: {
  66. slientLogin(params = {}) {
  67. uni.login({
  68. success(res) {
  69. //plat integer($int32)平台 1-微信 2-支付宝
  70. let platform = uni.getSystemInfoSync().uniPlatform
  71. let data = { code: res.code, plat: platform === 'mp-alipay' ? 2 : 1 }
  72. data = { ...data, ...params }
  73. uni.setStorageSync('loginType', data)
  74. console.log('登录参数:', data)
  75. uni.$u.http
  76. .post("/user/miniLogin", data)
  77. .then((response) => {
  78. if (response.code == 200) {
  79. console.log(response.data, data, "登录成功");
  80. uni.setStorageSync("loginSuccess", response.data);
  81. uni.setStorageSync("token", response.data.token);
  82. }
  83. });
  84. },
  85. fail: (err) => {
  86. console.log(err, "wx.login登录失败");
  87. },
  88. });
  89. },
  90. },
  91. };
  92. </script>
  93. <style lang="scss">
  94. // ===
  95. // === 注意:此处导入的css,会作用于全部.vue文件,请适量导入
  96. // ===
  97. body {
  98. font-family: PingFang-SC-Regular, PingFang-SC;
  99. }
  100. page {
  101. background-color: $app-theme-bg-gray-deep-color;
  102. }
  103. @import "uview-ui/index.scss";
  104. @import "./static/css/common.scss";
  105. /* 解决小程序和app滚动条的问题 */
  106. /* #ifdef MP-WEIXIN || APP-PLUS */
  107. ::-webkit-scrollbar {
  108. display: none;
  109. width: 0 !important;
  110. height: 0 !important;
  111. -webkit-appearance: none;
  112. background: transparent;
  113. color: transparent;
  114. }
  115. /* #endif */
  116. /* 解决H5 的问题 */
  117. /* #ifdef H5 */
  118. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  119. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  120. display: none;
  121. width: 0 !important;
  122. height: 0 !important;
  123. -webkit-appearance: none;
  124. background: transparent;
  125. color: transparent;
  126. }
  127. /* #endif */
  128. .shu-elip-1 {
  129. overflow: hidden;
  130. text-overflow: ellipsis;
  131. white-space: nowrap;
  132. }
  133. .shu-elip-2 {
  134. display: -webkit-box;
  135. overflow: hidden;
  136. text-overflow: ellipsis;
  137. word-wrap: break-word;
  138. white-space: normal !important;
  139. -webkit-line-clamp: 2;
  140. -webkit-box-orient: vertical;
  141. }
  142. // 导出 scss 变量用于在 script 下使用
  143. .price_color {
  144. color: $app-theme-text-money-color;
  145. }
  146. .color_blue {
  147. color: $app-theme-blue;
  148. }
  149. .btnGroup {
  150. display: flex;
  151. align-items: center;
  152. .btn {
  153. margin: 0 10rpx;
  154. }
  155. }
  156. .mallbtn {
  157. min-width: 200rpx;
  158. line-height: 66rpx;
  159. padding: 0 20rpx;
  160. border-radius: 36rpx;
  161. color: #ffffff;
  162. margin-right: 20rpx;
  163. text-align: center;
  164. flex: 1;
  165. padding: 0 30rpx;
  166. }
  167. .soldOutBtn {
  168. @extend .mallbtn;
  169. background-color: $app-theme-nobuy-bg-color;
  170. }
  171. .joinCartBtn {
  172. @extend .mallbtn;
  173. background-color: $app-theme-joincart-bg-color;
  174. }
  175. .buyBtn {
  176. @extend .mallbtn;
  177. background-color: $app-theme-buybtn-bg-color;
  178. }
  179. </style>