import request from '../utils/request.js';
import requestWhite from '../utils/requestWhite.js';
import Qs from 'qs';
 import  carhelp from '@/utils/mixin.js'
 
export function codeOperation(url) {
	//http://localhost:8080/#/?jpcode=jp_team51_charge_id:A_111
	var res=url
	
	
	if(url&&url.indexOf("#/?jpcode=")>-1){
		res=url.split("#/?jpcode=")[1]
	}
	if(url&&url.indexOf("#/?gunId=")>-1){
		var gunId=url.split("#/?gunId=")[1].trim()
		res="jp_team51_charge_id:A_"+gunId
	}
	
	if(url&&url.indexOf("&gunId=")>-1){
		var gunId=url.split("&gunId=")[1].trim()
		res="jp_team51_charge_id:A_"+gunId
	}
	
	if(res&&res.length>22){
		
	}else if(res == 'toLogin') {
		return	'/pages/login/login'
	}else{
		return false
	}
	var str1 = res.slice(0,19);
	var str2 = res.slice(20,21);
	var id = res.slice(22);
	
	if(str1 == 'jp_team51_charge_id') {
		if(str2 == 'A') {
			//carhelp.setGunId(id)
			return	 '/pages/searchPile/stationAndPile/chargingPileDetails?id=' + id	
		}
		if(str2 == 'B') {
			return	'/pages/user/finance/rechargeRes?id=' + id
		}
		if(str2 == 'C') {
			return	'/pages/discountCard/paymentSuccess?id=' + id
		}
		if(str2 == 'D') {
			return	'/pages/store/paymentSuccess?id=' + id
		}
	} else {
		return false;
	}
}
export function scanCode(res) {
	var url=codeOperation(res);
	if(url){
		uni.navigateTo({
			url:url
		})
	}else{
		uni.showToast({
			title: '请扫描充电桩上的二维码'
		})
	}
}

export function activityInfoList(data) {
	return requestWhite({
		method: 'post',
		data: data,
		url: '/mobile/activityInfo/activityInfoList'
	})
}


export function userChargingAmount(data) {
	return requestWhite({
		method: 'post',
		data: data,
		url: '/mobile/regUser/userChargingAmount'
	})
}

export function test(data) {
	return request({
		method: 'post',
		data: data,
		url: '/test/post'
	})
}


export function chargingData(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/charging/chargingData'
	})
}

export function marketingData(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/charging/marketingData'
	})
}
export function findChargeData(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/chargingCar/findChargeData'
	})
}


export function personalCenter(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/regUser/personalCenter'
	})
}
export function logout(data) {
	return request({
		method: 'get',
		data: data,
		url: '/mobile/regUser/logout'
	})
}


export function stopCharging(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/command/stopCharging'
	})
}
export function startCharging(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/command/startCharging'
	})
}
export function accountRecordData(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/accountRecord/accountRecordData'
	})
}
export function accountDetail(id) {
	return request({
		method: 'get',
		 
		url: '/mobile/accountRecord/accountDetail?id='+id
	})
}


export function chargingRecordData(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/chargingCar/chargingRecordData'
	})
}
export function chargingDetail(id) {
	return request({
		method: 'get',
		 
		url: '/mobile/chargingRecord/chargingDetail?id='+id
	})
}

export function passengerMessageNoReadNum(data) {
	
	return request({
		url: '/mobile/passengerApi/passengerMessageNoReadNum',
		data:data,
		method: 'post',
	})
}
  
  export function chargingDeviceData(data) {
  	return request({
  		method: 'post',
  		data: data,
  		url: '/mobile/charging/chargingDeviceData'
  	})
  }
  
  export function findActivity(data) {
  	return requestWhite({
  		method: 'post',
  		data: data,
  		url: '/mobile/chargingCouponApi/findActivity'
  	})
  } 
	
	export function changeFont(data) {
		return request({
			method: 'get',
			data: data,
			url: '/mobile/regUser/changeFont'
		})
	}
  
	export function getTips(data) {
		return requestWhite({
			method: 'post',
			data: data,
			url: '/mobile/dataDictionary/getTips'
		})
	}
	
	export function readCoupon(data) {
		return request({
			method: 'post',
			data: data,
			url: '/mobile/chargingCouponApi/readCoupon'
		})
	}
	
	
	export function personCardList(data) {
		return request({
			method: 'post',
			data: data,
			url: '/mobile/regUser/personCardList'
		})
	}
	
	
	
export function changeQuickCharging(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/regUser/changeQuickCharging'
	})
}


export function rechargeAmountRecordList(data) {
	return request({
		method: 'post',
		data: data,
		url: '/mobile/accountRecord/rechargeAmountRecordList'
	})
}
export function rechargeAmountRecordDetail(data) {
	return request({
		method: 'get',
		data: data,
		url: '/mobile/accountRecord/rechargeAmountRecordDetail'
	})
}