export const ossUrl = process.env.OSS_URL;
export const apiServer = process.env.VUE_APP_BASE_URL;
// console.log("ossUrl", ossUrl);
// console.log("apiServer", apiServer);

export const token = '';
// export const token = '5c654da466ad325c6a1121e6d9e18f21';

// 卡片基本信息查询
export const apiCardBaseQuery = apiServer + 'CardBaseQuery';

// 卡片对应活动或赛事详情查询
export const apiCardDetailQuery = apiServer + 'CardDetailQuery';

// 排名查询
export const apiCardRankDetailQuery = apiServer + 'CardRankDetailQuery';

// 卡片用户当前排名查询
export const apiUserCurrentRankNumQuery = apiServer + 'UserCurrentRankNumQuery';

// 用户是否已经报名卡片对应赛事查询
export const apiUserJoinCardQuery = apiServer + 'UserJoinCardQuery';

// 线上赛报名页面信息详情
export const apiOnlineMcSignUpDetail = apiServer + 'OnlineMcSignUpDetail';

// 线上赛报名(重新分组)
export const apiOnlineMcSignUp = apiServer + 'OnlineMcSignUp';

// 是否允许重新分组（报名）
export const apiIsAllowMcSignUp = apiServer + 'IsAllowMcSignUp';

// 玩家当前月挑战记录查询
export const apiCurrentMonthlyChallengeQuery = apiServer + 'CurrentMonthlyChallengeQuery';

// 卡片配置信息查询
export const apiCardConfigQuery = apiServer + 'CardConfigQuery';

// 玩家所有月挑战记录查询
export const apiMonthlyChallengeQuery = apiServer + 'MonthlyChallengeQuery';

// 玩家活动成就查询
export const apiAchievementQuery = apiServer + 'AchievementQuery';

// 未读消息列表查询
export const apiUnReadMessageQuery = apiServer + 'UnReadMessageQuery';

// 标记消息已读
export const apiReadMessage = apiServer + 'ReadMessage';



// 检测request的返回值
export function checkResCode(res) {
	if (res.data.code == 0) {
		return true;
	} else if (res.statusCode == 401) { // 未登录
		uni.showToast({
			title: `您尚未登录`,
			icon: 'none',
			duration: 3000
		});
		window.location.href = `action://to_login/`;
		return false;
	} else {
		uni.showToast({
			title: `${res.data.message}`,
			icon: 'none',
			duration: 3000
		});
		return false;
	}
};

// 检测token
export function checkToken(token) {
	const regex = /^[0-9A-Za-f]{32}$/;
	if (regex.test(token)) {
		return true;
	} else { // 未登录
		console.log('checkToken err: ', token);
		uni.showToast({
			title: `您尚未登录`,
			icon: 'none',
			duration: 3000
		});
		window.location.href = `action://to_login/`;
		return false;
	}
};
