export const ossUrl = process.env.OSS_URL;
export const apiServer = process.env.API_BASE_URL;

export const token = '';
// export const token = '96ba3c924394934f7d30fa869a94ce0d';

// 根据游戏id查询卡片信息
export const apiCardUrlQuery = apiServer + 'CardUrlQuery';


import tools from '/common/tools';

// 检测request的返回值
export function checkResCode(res) {
	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: `${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;
	}
};
