useGlobalShare.js 659 B

1234567891011121314151617181920212223242526272829303132
  1. import { ref } from 'vue';
  2. import { onLoad } from '@dcloudio/uni-app';
  3. import { useUserStore } from '@/common/stores/user';
  4. const userStore = useUserStore();
  5. export function useGlobalShare() {
  6. const isLogin = () => {
  7. if(uni.getStorageSync('token')){
  8. return true
  9. }else {
  10. uni.showModal({
  11. title:'温馨提示',
  12. content:'当前功能需要登录后使用,是否登录?',
  13. success: (res) => {
  14. if(res.confirm){
  15. userStore.openLoginModal();
  16. }else{
  17. return false
  18. }
  19. }
  20. })
  21. }
  22. }
  23. onLoad(() => {
  24. console.log('--- Composable onLoad 触发 (仅页面) ---');
  25. });
  26. return {
  27. isLogin
  28. };
  29. }