import httpRequest from '@/module/request/http-request.js'
import ipConfig from '@/config/ip.config.js'
import { okSpin } from '@/module/third/okspin.js'

const api = {
	getChargeInfo: ipConfig.api_app + '/recharge/getChargeInfo',
	createTransferOrder: ipConfig.api_app + '/recharge/createTransferOrder',
	createRechargeOrder: ipConfig.api_app + '/recharge/createRechargeOrder',
	getRecordList: ipConfig.api_app + '/recharge/record',
	orderDetail: ipConfig.api_app + '/recharge/orderDetail',
	getPayChannel: ipConfig.api_app + '/recharge/getPayChannel'
}

/**
 * 获取充值页信息
 */
export const requestChargeInfo = (params) => {
	return httpRequest.post({
		url: api.getChargeInfo,
		data: params
	})
}

/**
 * 创建转账订单
 */
export const requestCreateTransferOrder = (params) => {
	return httpRequest.post({
		url: api.createTransferOrder,
		data: params
	})
}

/**
 * 创建充值订单
 */
export const requestCreateRechargeOrder = (params) => {
	okSpin.purchase()
	return httpRequest.post({
		url: api.createRechargeOrder,
		data: params
	})
}

/**
 * 获取充值记录
 */
export const requestRecordList = (params) => {
	return httpRequest.post({
		url: api.getRecordList,
		data: params
	})
}

/**
 * 订单详情
 */
export const requestOrderDetail = (params) => {
	return httpRequest.post({
		url: api.orderDetail,
		data: params
	})
}

/**
 * 充值渠道
 */
export const requestGetPayChannel = (params) => {
	return httpRequest.post({
		url: api.getPayChannel,
		data: params
	})
}
