import request from '@/utils/request'
import requestWhite from '../utils/requestWhite.js';
 import requestAli from '../utils/requestParking.js';
 
import Qs from 'qs';

//微信支付
export function wxpay(data) {
	if(data){
		data.type="E"
	}
	if(data&&!data.recordId){
		data.recordId=''
	}
	return request({
		url: '/wxPay/wxJsapiPay',
		data: data,
		method: 'post',
	})
}


export function alpay(data) {
	if(data&&!data.recordId){
		data.recordId=''
	}
	return request({
		url: '/aliPay/tradePrecreatePay',
		data: data,
		method: 'post',
	})
}

//根据code换取openid
export function getDataByCode(code) {
	var url = process.car.wechatUrl+'/findUserInfo/' + code
	
	return request({
		url: url,
		params: {},
		method: 'get',
	})
}

export function getDataByCodeALI(code) {
	return requestAli({
		url: '/aliPay/findUserInfo/' + code,
		params: {},
		method: 'get',
	})
}


//获得配置
export function getConfig() {
	return requestWhite({
		url: process.car.wechatUrl+'/getConfig',
		data: {
			url: window.location.href.split('#')[0]
		},
		method: 'get',
	})
}

export function checkSubscribe(data) {
	return requestWhite({
		url: process.car.wechatUrl+'/checkSubscribe',
		data: data,
		method: 'post',
	})
}