import config, {
	baseUrl,
	loginUrl,
	usertoken
} from '@/config'
import {parseXML} from '@/utils/transUtil.js'
let timeout = 5000
const request = config => {

	console.log("数据接口----" + baseUrl + config.url)
	
	return new Promise((resolve, reject) => {
		      uni.request({
		      	method: config.method,
		      	header: {
		      		"Content-Type": "application/x-www-form-urlencoded"
		      	},
		      	url: baseUrl + config.url,
		      	timeout: config.timeout || timeout,
		      	data: config.data,
		      	success: (res) => {
		      		// console.log("----then----" + res.data); 
					let str = parseXML(res.data)
		      		resolve(str)
		      	},
		      	fail(error) {
		      		reject(error)
		      	}
		      })
		
	})

}


export default request