App.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <script>
  2. // #ifdef APP-PLUS
  3. import {
  4. getUpApp
  5. } from './utils/upApp.js';
  6. // #endif
  7. import {
  8. mapActions,
  9. mapMutations
  10. } from 'vuex';
  11. import {
  12. getConfig
  13. } from '@/api/app';
  14. import {
  15. setTabbar,
  16. strToParams
  17. } from '@/utils/tools';
  18. import {
  19. bindSuperior
  20. } from '@/api/user';
  21. import {
  22. INVITE_CODE
  23. } from '@/config/cachekey';
  24. import Cache from '@/utils/cache';
  25. export default {
  26. onLaunch: function(options) {
  27. // #ifdef APP-PLUS
  28. // 判断是否升级
  29. getUpApp();
  30. // #endif
  31. // 获取配置
  32. this.getConfigFun();
  33. this.getUser();
  34. this.getSystemInfo();
  35. },
  36. onShow: function(options) {
  37. console.log(options);
  38. this.bindCode(options);
  39. },
  40. onHide: function() {},
  41. methods: {
  42. ...mapActions(['getSystemInfo', 'getUser', 'wxShare', 'initLocationFunc']),
  43. ...mapMutations(['setConfig']),
  44. async getConfigFun() {
  45. const {
  46. code,
  47. data
  48. } = await getConfig();
  49. if (code == 1) {
  50. this.setConfig(data);
  51. if (data.is_open_nearby) {
  52. // 获取定位
  53. this.initLocationFunc();
  54. }
  55. setTabbar();
  56. // 防止第一次调用时拿不到数据
  57. this.wxShare();
  58. }
  59. },
  60. async bindCode(options) {
  61. if (!options.query) return;
  62. let invite_code = options.query.invite_code || strToParams(decodeURIComponent(options.query.scene))
  63. .invite_code;
  64. if (invite_code) {
  65. const {
  66. data,
  67. code
  68. } = await bindSuperior({
  69. code: invite_code
  70. });
  71. if (code == -1) {
  72. Cache.set(INVITE_CODE, invite_code);
  73. }
  74. }
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="scss">
  80. @import 'styles/common.scss';
  81. @import 'components/uview-ui/index.scss';
  82. @import url('@/plugin/emoji-awesome/css/apple.css');
  83. @import url('static/font/iconfont.css');
  84. /*每个页面公共css */
  85. page {
  86. background: linear-gradient(180deg, rgba(243, 244, 246, 0.98) 0%, #f4e4e4 37%, #f4eced 69%, #f3eced 85%, #f3f4f6 100%);
  87. }
  88. .d-flex {
  89. display: flex;
  90. }
  91. .justify-content-between {
  92. justify-content: space-between;
  93. }
  94. .justify-content-center {
  95. justify-content: center;
  96. }
  97. .align-items-center {
  98. align-items: center;
  99. }
  100. .flex-wrap {
  101. flex-wrap: wrap;
  102. }
  103. .text-center {
  104. text-align: center;
  105. }
  106. .bg-white {
  107. background-color: #fff;
  108. }
  109. .radius10 {
  110. border-radius: 20upx;
  111. }
  112. .titColor {
  113. color: #040404;
  114. }
  115. .align-content-between {
  116. align-content: space-between;
  117. }
  118. </style>