import request from '../utils/request.js';
import requestWhite from '../utils/requestWhite.js';
import Qs from 'qs';
 import  carhelp from '@/utils/mixin.js'


export function getChargingStationDetail(data){
	return requestWhite({
		method: 'post',
		data: data,
		url: '/mobile/chargingStation/chargingStationDetail'
	})
}

export function getChargingStationPrice(data){
		return getChargingStationPrice3(data)
}
export function getChargingStationPrice2(data){
	return getChargingStationPrice3(data)
}
export function getChargingStationPrice3(data){
	if(!data.recordId){
		data.recordId=""
	}
	var info=carhelp.getPersonInfo()
	return requestWhite({
		method: 'post',
		data: data,
		url: '/mobile/chargingStation/chargingStationPrice2'
	})

}
export function getChargingStationData(data){
	return requestWhite({
		method: 'post',
		data: data,
		url: '/mobile/chargingStation/chargingStationData'
	})
}

export function searchStationData(data){
	console.log('搜索站点数据')
	return requestWhite({
		method: 'post',
		data: data,
		url: '/mobile/chargingStation/searchStationData'
	})
}



export function getPileDetails(data){
	var p = new Promise(function(resolve,rejct){
		if(data != null)
		{
			let pile = {
				no:'A00666',
				interface:'国际直流',
				type:'快充',
				power:60000,
				price:[
					{time:'00:00-07:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'07:00-09:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'09:00-15:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'15:00-20:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'20:00-22:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'22:00-23:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'23:00-23:59',single_price:1.0,service_price:0.25,price:1.25},
				]
			}; 
			resolve(pile)
		}
		reject(data);
			
	})
	return p;
}

export function getPriceDetails(data){
	var p = new Promise(function(resolve,rejct){
		if(data != null)
		{
			let list = [{
				name: '直流快充',
				items:[
					{time:'00:00-07:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'07:00-09:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'09:00-15:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'15:00-20:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'20:00-22:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'22:00-23:00',single_price:1.0,service_price:0.25,price:1.25},
					{time:'23:00-23:59',single_price:1.0,service_price:0.25,price:1.25},
				]
			}, {
				name: '交流慢充',
				items:[
					{time:'00:00-07:00',single_price:0.5,service_price:0.25,price:0.75},
					{time:'07:00-09:00',single_price:0.7,service_price:0.25,price:1.00},
					{time:'09:00-15:00',single_price:0.7,service_price:0.25,price:1.00},
					{time:'15:00-20:00',single_price:0.7,service_price:0.25,price:1.00},
					{time:'20:00-22:00',single_price:0.6,service_price:0.25,price:0.90},
					{time:'22:00-23:00',single_price:0.5,service_price:0.25,price:0.75},
					{time:'23:00-23:59',single_price:0.5,service_price:0.25,price:0.75},
				]
			}];
			resolve(list)
		}
		reject(data);
			
	})
	return p;
}
export function getChargerInfoById(data) {
	//var url='/mobile/regUser/findByOpenId';
	/*return requestWhite({
		method: 'get',
		data: data,
		url: url
	})*/
	
	var p = new Promise(function(resolve,rejct){
		if(data != null)
			resolve(data)
		reject(data);
			
	})
	return p;
}