login.vue 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <!-- 空登陆页 -->
  3. <view></view>
  4. </template>
  5. <script setup>
  6. import { isEmpty } from 'lodash';
  7. import sheep from '@/sheep';
  8. import { onLoad, onShow } from '@dcloudio/uni-app';
  9. onLoad(async (options) => {
  10. // #ifdef H5
  11. let event = '';
  12. new URLSearchParams(location.search).forEach((value, key) => {
  13. options[key] = value;
  14. });
  15. if (options.code) {
  16. event = 'login';
  17. const { error } = await sheep.$platform.useProvider().login(options.code, options.state);
  18. if (error === 0) {
  19. sheep.$store('user').getInfo();
  20. }
  21. }
  22. if (options.bind_code) {
  23. event = 'bind';
  24. const { error } = await sheep.$platform.useProvider().bind(options.bind_code);
  25. }
  26. // 检测H5登录回调
  27. let returnUrl = uni.getStorageSync('returnUrl');
  28. if (returnUrl) {
  29. uni.removeStorage('returnUrl');
  30. location.replace(returnUrl);
  31. } else {
  32. uni.switchTab({
  33. url: '/',
  34. });
  35. }
  36. // #endif
  37. });
  38. </script>