import request from './request'
import storage from './storage'

//获取code
export function wxgetCode(params) {
    return new Promise((resolve, reject) => {
		// let spread_id = parseInt(storage.get('spread_id'));
		// if(spread_id > 0){
		// 	params.spread_id = spread_id;
		// }
        request.post("/user/session",params).then(result=>{
            resolve(result)
        }).catch(err=>{
            reject(err)
        });
    })
}
//登录
export function wxLogin(params) {
    return new Promise((resolve, reject) => {
		// let spread_id = parseInt(storage.get('spread_id'));
		// if(spread_id > 0){
		// 	params.spread_id = spread_id;
		// }
        request.post("/user/login",params).then(result=>{
            resolve(result)
        }).catch(err=>{
            reject(err)
        });
    })
}
//个人中心首页
export function ucenterData(){
	return request.post("/inquire/myData")
}
//个人中心联系客服
export function getService(){
	return request.post("/inquire/contact/service")
}
//个人中心换电记录
export function exchangeRecord(params){
	return request.post("/inquire/exchangeRecord",params)
}
//换电记录详情
export function exchangeRecordShow(id){
	return request.post(`/inquire/exchangeDetail/${id}`)
}
//个人中心我的车辆
export function exchangeHistoryCar(){
	return request.post("/inquire/exchangeHistorical")
}
//个人中心我的车辆详情
export function exchangeCarDetail(plate){
	return request.post(`/inquire/vehDetail?plate=${plate}`)
}
//用stationCode获取换电编号
export function getStationExchange(params){
	return request.post("/swap/getStationExchange",params)
}
//首页车辆信息
export function homepage(params){
	return request.post("/inquire/homepage",params)
}