import {
	JumpType,
	jump
} from ".";
import {
	useUserStore
} from "../stores/user";

export function checkLogin(back) {
	const userStore = useUserStore();
	const memberInfo = userStore.memberInfo;

	if (!memberInfo?.memberId || memberInfo?.memberId == "not_login") { //未登录
		jump({
			type: JumpType.INNER,
			url: "/pages/activity/register"
		})

		// 监听用户信息更新
		uni.$once('updateUserInfo', () => {
			if (back) {
				back();
			}
		})
		return
	}
	if (back) {
		back();
	}
}