index.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view class="lottie-bg">
  3. <view id="lottie">
  4. <image src="/static/img/live-logo.gif" rel="preload" />
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. import wechat from "@/libs/wechat";
  10. import {
  11. getUserInfo
  12. } from "@/api/user";
  13. export default {
  14. name: "Auth",
  15. mounted() {
  16. },
  17. onLoad(option) {
  18. const {
  19. code,
  20. state
  21. } = option;
  22. wechat.auth(code, state)
  23. .then(() => {
  24. getUserInfo().then(res => {
  25. location.href = decodeURIComponent(
  26. decodeURIComponent(option.back_url)
  27. );
  28. }).catch(res => {
  29. console.log('getUserInfo错误='+res);
  30. });
  31. })
  32. .catch((err) => {
  33. console.log('auth错误='+err);
  34. });
  35. }
  36. };
  37. </script>
  38. <style scoped lang="scss">
  39. .lottie-bg {
  40. position: fixed;
  41. left: 0;
  42. top: 0;
  43. background-color: #fff;
  44. width: 100%;
  45. height: 100%;
  46. z-index: 999;
  47. display: flex;
  48. align-items: center;
  49. justify-content: center;
  50. }
  51. #lottie {
  52. display: block;
  53. width: 100%;
  54. height: 100%;
  55. display: flex;
  56. align-items: center;
  57. justify-content: center;
  58. overflow: hidden;
  59. transform: translate3d(0, 0, 0);
  60. margin: auto;
  61. image {
  62. width: 200rpx;
  63. height: 200rpx;
  64. }
  65. }
  66. </style>