index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. location.href = decodeURIComponent(
  27. decodeURIComponent(option.back_url)
  28. );
  29. }).catch(res => {
  30. console.log('getUserInfo错误='+res);
  31. });
  32. })
  33. .catch((err) => {
  34. console.log('auth错误='+err);
  35. });
  36. }
  37. };
  38. </script>
  39. <style scoped lang="scss">
  40. .lottie-bg {
  41. position: fixed;
  42. left: 0;
  43. top: 0;
  44. background-color: #fff;
  45. width: 100%;
  46. height: 100%;
  47. z-index: 999;
  48. display: flex;
  49. align-items: center;
  50. justify-content: center;
  51. }
  52. #lottie {
  53. display: block;
  54. width: 100%;
  55. height: 100%;
  56. display: flex;
  57. align-items: center;
  58. justify-content: center;
  59. overflow: hidden;
  60. transform: translate3d(0, 0, 0);
  61. margin: auto;
  62. image {
  63. width: 200rpx;
  64. height: 200rpx;
  65. }
  66. }
  67. </style>