App.vue 797 B

123456789101112131415161718192021222324252627282930313233
  1. <script>
  2. import cache from '@/utils/cache';
  3. import { userLogin } from '@/api/common.js';
  4. import { LOGIN_TOKEN } from '@/config/cache';
  5. export default {
  6. // 全局获取token
  7. async onLaunch(option) {
  8. // c测试数据
  9. // cache.set(LOGIN_TOKEN,'XB5TDFmqD/EFLD7Bmsfp11vkfOjrNGqvcGEnWIAIGaE=');
  10. let token = option.query.token;
  11. // 登录token
  12. if (!token) {
  13. token = 'test-token';
  14. }
  15. this.$api.loading('登陆中...');
  16. const res = await userLogin({
  17. pp_token: token,
  18. });
  19. this.$api.hide();
  20. let session_key = res?.session_key ?? '';
  21. cache.set(LOGIN_TOKEN, session_key);
  22. await this.$isResolve(); //调用
  23. },
  24. onShow() {},
  25. onHide() {},
  26. };
  27. </script>
  28. <style lang="scss">
  29. /*每个页面公共css */
  30. @import '@/styles/common.scss';
  31. </style>