// 引入 request 文件
import request from '@/common/api/request.js'
import {
	prveUrl
} from './config.js'

const orderPrveUrl = '/order'

let platformType = '';
let payType = '';
// #ifdef MP-WEIXIN
platformType = 'wechat'
payType = 'WECHAT'
// #endif
// #ifdef MP-ALIPAY
platformType = 'alipay'
payType = 'ALIPAY'
// #endif

export const getPackage = (data) => {
	return request({
		url: prveUrl + '/user/package',
		method: 'get',
		data: data
	})
}


export const getPackageDetail = (data) => {
	return request({
		url: prveUrl + '/user/package/detail/' + data.id,
		method: 'get',
		data
	})
}

export const helpPage = (data) => {
	return request({
		url: prveUrl + '/user/package/help/page',
		method: 'get',
		data: data
	})
}




export const order = (data) => {
	return request({
		url: prveUrl + '/user/package/order',
		method: 'get',
		data: data
	})
}


export const createOrder = (data) => {
	return request({
		url: prveUrl + '/user/package/order',
		method: 'post',
		data: data
	})
}



export const cancel = (data) => {
	return request({
		url: prveUrl + '/user/package/cancel',
		method: 'get',
		data: data
	})
}

export const help = (data) => {
	return request({
		url: prveUrl + '/user/package/help',
		method: 'get',
		data: data
	})
}

export const orderDetail = (data) => {
	return request({
		url: prveUrl + '/user/package/order/detail',
		method: 'get',
		data: data
	})
}


export const ppOrderPay = (data) => {

	// #ifdef MP-WEIXIN
	const openId = uni.cache.get('userInfo').wechatOpenId;
	// #endif
	// #ifdef MP-ALIPAY
	const openId = uni.cache.get('userInfo').alipayOpenId;
	// #endif
	return request({
		url: orderPrveUrl + '/user/ppOrder/pay',
		method: 'post',
		data: {
			platformType,
			payType,
			openId,
			...data
		}
	})

}
export const applyRefund = (data) => {
	return request({
		url: orderPrveUrl + '/user/ppOrder/applyRefund',
		method: 'post',
		data: data
	})
}
export const cancelRefund = (data) => {
	return request({
		url: orderPrveUrl + '/user/ppOrder/cancelRefund',
		method: 'post',
		data: data
	})
}

export const exchange=()=>{}