index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. let that = this
  19. const {
  20. code,
  21. state
  22. } = option;
  23. wechat.auth(code, state)
  24. .then(() => {
  25. getUserInfo().then(res => {
  26. that.$store.commit("SETUID", res.data.uid);
  27. location.href = decodeURIComponent(
  28. decodeURIComponent(option.back_url)
  29. );
  30. }).catch(res => {
  31. alert(res)
  32. });
  33. })
  34. .catch(() => {
  35. location.replace("/");
  36. });
  37. }
  38. };
  39. </script>
  40. <style scoped lang="scss">
  41. .lottie-bg {
  42. position: fixed;
  43. left: 0;
  44. top: 0;
  45. background-color: #fff;
  46. width: 100%;
  47. height: 100%;
  48. z-index: 999;
  49. display: flex;
  50. align-items: center;
  51. justify-content: center;
  52. }
  53. #lottie {
  54. display: block;
  55. width: 100%;
  56. height: 100%;
  57. display: flex;
  58. align-items: center;
  59. justify-content: center;
  60. overflow: hidden;
  61. transform: translate3d(0, 0, 0);
  62. margin: auto;
  63. image {
  64. width: 200rpx;
  65. height: 200rpx;
  66. }
  67. }
  68. </style>