 
 export const api_url = 'https://admin.dbcdq.cn/'
 
const post = (url, data, returndata) => { 
 
 	var token =uni.getStorageSync('userToken'); 
	uni.request({
		url: api_url + url+"?token="+token	,
		data: data,
		header: {
			'Accept': 'application/json',
			'Content-Type': 'application/json',  
		},
		method: 'POST',
		success: (response) => { 
			const result = response.data; 
			if (result.code == 401) { 
			 	uni.removeStorageSync('userToken');   
				uni.showToast({
					title: result.msg,
					icon: 'none'
				})
				setTimeout(function() { 
					uni.navigateTo({
						url: '/pages/login/login'
					}) 
				}, 1000)
			}
			returndata(result);
		}, 
		fail: (error) => {
			uni.showLoading({
				title: '网络错误'
			}); 
				uni.hideLoading(); 
			if (error && error.response) {
				uni.showToast({ title: error.response , icon: 'none' })  
			} else {
				
			}
			
		},
	});

}
 const upload = (url, data, returndata) => {
 	console.log(data)
  	var token =uni.getStorageSync('userToken'); 
 	uni.uploadFile({
 		url: api_url + url+"?token="+token,
 		filePath: data,
 		name: "file",
 		// data: data.formData,
 		success: (response) => { 
 			const result = response.data; 
 			if (result.code == 401) { 
 			 	uni.removeStorageSync('userToken');   
 				uni.showToast({
 					title: result.msg,
 					icon: 'none'
 				})
 				setTimeout(function() { 
 					uni.navigateTo({
 						url: '/pages/login/login'
 					}) 
 				}, 1000)
 			}
 			console.log(result,'kkkkkkkkk')
 			returndata(JSON.parse(result));
 		}, 
 		fail: (error) => {
 			uni.showLoading({
 				title: '网络错误'
 			}); 
 				uni.hideLoading(); 
 			if (error && error.response) {
 				uni.showToast({ title: error.response , icon: 'none' })  
 			} else {
 				
 			}
 			
 		},
 	});
 
 }

 
 
 
 
 


export const login = (data, callback) => post('api/recover/wxuser/login', data, callback); 
export const wxapplogin = (data, callback) => post('api/recover/wxuser/wxapplogin', data, callback);
export const getPhoneNumber = (data, callback) => post('api/recover/wxuser/getphonenumber', data, callback);
export const userInfo = (data, callback) => post('api/recover/person/user_info', data, callback); 
export const edituser = (data, callback) => post('api/recover/wxuser/edituser', data, callback); 
export const balancelist = (data, callback) => post('api/recover/wxuser/balancelist', data, callback); 
export const indexpage = (data, callback) => post('api/recover/recover/indexpage', data, callback); 
export const typeinit = (data, callback) => post('api/recover/recover/typeinit', data, callback); 
export const config = (data, callback) => post('api/recover/recover/config', data, callback); 
export const useraddress = (data, callback) => post('api/recover/address/getlist', data, callback); 

export const userOrder = (data, callback) => post('api/recover/order/orderlist', data, callback); 
export const addorder = (data, callback) => post('api/recover/order/addorder', data, callback); 
export const orderdetail = (data, callback) => post('api/recover/order/orderdetail', data, callback); 
export const cancelorder = (data, callback) => post('api/recover/order/cancelorder', data, callback); 
export const finishorder = (data, callback) => post('api/recover/order/finishorder', data, callback); 

export const addperson = (data, callback) => post('api/recover/person/addperson', data, callback); 
export const editperson = (data, callback) => post('api/recover/person/editperson', data, callback); 
export const orderlist = (data, callback) => post('api/recover/person/orderlist', data, callback); 
export const personbalancelist = (data, callback) => post('api/recover/person/balancelist', data, callback); 
export const personorderdetail = (data, callback) => post('api/recover/person/orderdetail', data, callback);  
export const qiangdanlist = (data, callback) => post('api/recover/person/qiangdanlist', data, callback); 
export const setorder = (data, callback) => post('api/recover/person/setorder', data, callback); 
export const detail = (data, callback) => post('api/recover/address/detail', data, callback); 
export const removeAddress = (data, callback) => post('api/recover/address/removeaddress', data, callback);
export const editaddress = (data, callback) => post('api/recover/address/editaddress', data, callback); 
export const userDefaultAddress = (data, callback) => post('api/recover/address/userdefaultaddress', data, callback);  
export const getareaid = (data, callback) => post('api/recover/address/getareaid', data, callback); 
export const getarealist = (data, callback) => post('api/recover/address/getarealist', data, callback);  

 

export const pointlist = (data, callback) => post('api/recover/wxuser/pointlist', data, callback); 
export const exchangegoodslists = (data, callback) => post('api/recover/exchange/goodslist', data, callback);  
export const exchangegoodsinfo = (data, callback) => post('api/recover/exchange/goodsinfo', data, callback);  
export const createorderExchange = (data, callback) => post('api/recover/exchange/createorder', data, callback);  
export const exchangePay = (data, callback) => post('api/recover/exchange/pay', data, callback); 
export const exchangeOrderlist = (data, callback) => post('api/recover/exchange/orderlist', data, callback); 
export const exchangeOrderinfo = (data, callback) => post('api/recover/exchange/orderinfo', data, callback); 
export const exchangeFinish = (data, callback) => post('api/recover/exchange/finishorder', data, callback); 
export const exchangeCancelorder = (data, callback) => post('api/recover/exchange/cancelorder', data, callback);  
export const exchangeRefund = (data, callback) => post('api/recover/exchange/refund', data, callback);  
export const question_list = (data, callback) => post('api/recover/recover/question_list', data, callback);  
export const recycleOrderList = (data, callback) => post('api/recover/person/orderlist', data, callback); 
// export const qiangdanlist = (data, callback) => post('api/recover/person/qiangdanlist', data, callback); 
export const personlogin = (data, callback) => post('api/recover/person/personlogin', data, callback);
export const applyCertification = (data, callback) => post('api/recover/person/applyCertification', data, callback);
export const checkPayPassword = (data, callback) => post('api/recover/person/checkPayPassword', data, callback);
export const verifyPayPassword = (data, callback) => post('api/recover/person/verifyPayPassword', data, callback);
export const priceList = (data, callback) => post('api/recover/personmoneylog/index', data, callback);
export const uploadImg = (data, callback) => upload('api/feedback/upload', data, callback); 
export const allarealist = (data, callback) => post('api/recover/area/allarealist', data, callback); 
export const qrcode = (data, callback) => post('api/promotion/qrcode', data, callback); 
