import carhelp from '@/utils/mixin.js'


var baseUrl = process.car.PARK_URL;


const request = (options) => {

	
	return new Promise((resolve, reject) => {
		//如果特殊链接需要传入token

		uni.request({
			method: options.method ? options.method : 'get',
			url: baseUrl + options.url,
			data: options.data ?{
				... options.data ,
				branchParameter:process.car.branchParameter
			}: {
				branchParameter:process.car.branchParameter
			},
			timeout:options.timeout?options.timeout:60*1000,
			header: options.header ? {
				...options.header,

			} : {
				'Content-Type': 'application/x-www-form-urlencoded',
				'X-Requested-With': 'XMLHttpRequest',
				// 'Authorization':token
			}
		}).then((response) => {

			 
			//防止连续请求多个接口时loading闪现
			let [error, res] = response;


			if (res.data.code != 200) {
				reject(res.data.message)
			} else {
				if (!res.data.result) {

					reject(res.data.message);
				} else {
					resolve(res.data);
				}

			}
		}).catch(error => {
			 

			let [err, res] = error;
			reject(err)
		})
	});
}
export default request
