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

// export const token = '';
export const token = '96ba3c924394934f7d30fa869a94ce0d';
// export const token = '9db42d9fe9c9635c85e6fc04f08e898f';
// export const token = '39de263745caccbb183703987b1c21eb';
// export const token = 'd4dd6b57a15b4abaccf6cb6adcd4fd44';

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

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

// 卡片对应线上赛多个活动查询
export const apiMatchRsDetailQuery = apiServer + 'MatchRsDetailQuery';

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

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

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

// 用户在卡片对应赛事是否新用户
export const apiIsNewUserInCardComp = apiServer + 'IsNewUserInCardComp';

// 线上赛报名页面信息详情
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 apiUserConfigQuery = apiServer + 'UserConfigQuery';

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

// 月挑战排名查询
export const apiMonthRankDetailQuery = apiServer + 'MonthRankDetailQuery';

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

// 玩家兑换记录查询
export const apiExchangeListQuery = apiServer + 'ExchangeListQuery';

// 玩家兑换详情查询
export const apiExchangeDetailQuery = apiServer + 'ExchangeDetailQuery';

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

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

// 卡片对应地图列表详情查询
export const apiMapListQuery = apiServer + 'MapListQuery';

// 赛事总成绩统计查询
export const apiCompStatisticQuery = apiServer + 'CompStatisticQuery';

// 警告列表查询
export const apiWarnMessageQuery = apiServer + 'WarnMessageQuery';

// 查询电子证书样式
export const apiCertStyleQuery = apiServer + 'CertStyleQuery';

// 查询电子证书成就对应用户基本信息
export const apiUserBaseQueryInCertificate = apiServer + 'UserBaseQueryInCertificate';

// 根据成就信息确认生成电子证书
export const apiCertificateCreateByUserAi = apiServer + 'CertificateCreateByUserAi';

// 卡片内可用积分查询
export const apiOnlineScoreQuery = apiServer + 'OnlineScoreQuery';

// 积分可兑换商品列表查询
export const apiCanExchangeGoodsList = apiServer + 'CanExchangeGoodsList';

// 积分可兑换商品详情
export const apiCanExchangeGoodsDetail = apiServer + 'CanExchangeGoodsDetail';

// 积分兑换商品
export const apiScoreExchangeGoods = apiServer + 'ScoreExchangeGoods';

// 用户基本信息查询
export const apiUserBasicInformationQuery = apiServer + 'UserBasicInformationQuery';

// 网格卡片信息查询
export const apiGridsQuery = apiServer + 'GridsQuery';



import tools from '/common/tools';

// 检测request的返回值
export function checkResCode(res, failLabel='') {
	if (res.data.code == 0) {
		return true;
	} else if (res.statusCode == 401) { // 未登录
		uni.showToast({
			title: `您尚未登录`,
			icon: 'none',
			duration: 3000
		});
		
		const url = `action://to_login/`;
		tools.appAction(url);
		return false;
	} else {
		uni.showToast({
			title: `${failLabel}${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
		});
		
		const url = `action://to_login/`;
		tools.appAction(url);
		return false;
	}
};
