// const BASE_URL = "/carstop/carbook"
const BASE_URL = "/testingServertomcat/carbook/"
export const myRequest = (options) => {
	uni.showLoading({
		title: "加载中",
		mask: true,
	});
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASE_URL + options.url,
			method: options.method || "GET",
			data: options.data || {},
			header: options.header,
			success: (res) => {
				uni.hideLoading();
				if (res.data.code === 200) {
					resolve(res.data.data)
				} else if (res.data.message == "未查到用户信息") {
					uni.removeStorageSync("bus_card_number")
					uni.navigateTo({
						url: "/pages/index/index"
					})
				} else {
					uni.showToast({
						title: res.data.message,
						icon: "none"
					})
				}
			},
			fail: (err) => {
				uni.hideLoading();
				uni.showToast({
					title: "请求数据失败",
					icon: "none"
				})
				reject(err)
			}
		})
	})
}