const http = uni.$u.http
/**
 * 登录
 * @param {
	 account: 用户名,
	 password: 密码
 }
 */
export const userLogin = (data, config= {}) => http.post('/login', data, config)


/**
 * 注册
 * @param {
	 account: 用户名,
	 password: 密码
 }
 */
export const userReg = (data, config= {}) => http.post('/users/register', data, config)

/**
 * 微信登陆授权
 * @param {
	 returnUrl: 请求地址
	}
 */
export const userWXLogin = (data) => http.get('/weChatLogin/authorize', {params: data })

/**
 * 通过openid登陆
 * @param {
	 openid: 前端传入用户openid
	 type: 0公众号授权1小程序授权
 }
 */
export const userOpenIdLogin = (data) => http.get('/weChatLogin/authorize', {params: data })

/**
 * 获取用户信息
 */
export const getUserInfo = () => http.get('/system/user/profile', {custom: {auth: true}})

/**
 * 修改用户信息
 */
export const updateUserInfo = (data) => http.put('/system/user/profile', data, {custom: {auth: true}})

/**
 * 修改用户密码
 */
export const updateUserPwd = (data) => http.put('/system/user/profile/updatePwd', {}, {params: data, custom: {auth: true}})


/**
 * 商家注册
 * @param {
		username: "用户名",
		password: "密码",
		businessName: "商家名称",
		businessLicenseNo: "统一社会信用代码",
		gymName: "球馆名称",
		contacts: "联系人",
		contactsPhone: "联系人电话",
		province: "省",
		city: "市",
		county: "县",
		address: "地址",
		gymPicture: "球馆图片"
 }
 */
export const businessReg = (data, config={}) => http.post('/ground-business/business/register',data, config)

/**
 * 查询可提现金额
 * * @returns 返回信息对象:{msg, code, data}
 */
export const getAmount = (data, config= {}) => http.get('/ground-business/cash/cashAvaliable', {params: data, custom: {auth: true} })

/**
 * 申请提现
 * * @param {
	 cashoutAmount: 提现金额
 }
 */
export const cashAmout = (data) => http.post('/ground-business/cash/cashApply', data, {custom: {auth: true}})

/**
 * 添加提现账户
 * * @param {
		account: "卡号",
		accountName: "开户名称",
		accountBank: "开户行"
 }
 */
export const addBank = (data) => http.post('/ground-business/account', data, {custom: {auth: true} })

/**
 * 修改提现账户
 * * @param {
		account: "卡号",
		accountName: "开户名称",
		accountBank: "开户行"
 }
 */
export const updateBank = (data) => http.put('/ground-business/account', data, {custom: {auth: true} })

/**
 * 删除提现账户(解除绑定银行卡)
 * * @param {
		account: "卡号",
		accountName: "开户名称",
		accountBank: "开户行"
 }
 */
export const deleteBank = (accountIds) => http.delete(`/ground-business/account/${accountIds}`,{}, {custom: {auth: true} })

/**
 * 根据businessId获取商家提现账户信息
 * * @param {
		businessId: "商家ID"
 }
 */
export const getBank = (businessId) => http.get(`/ground-business/account/${businessId}`, {custom: {auth: true} })

/**
 * 查询当前用户钱包余额
 * @returns 返回信息对象:{msg, code, data: {walletId, money: '金额', username: '用户名'}}
 */
export const getUserAmout = () => http.get('/ground-business/wallet/balance', {custom: {auth: true} })

/**
 * 钱包充值
 * @param {
	 amount:充值金额,
	 type: 0公众号1小程序
 }
 * @returns 返回信息对象:{appId, nonceStr, paySign, signType, prepayId, timeStamp, packageValue	}
 */
export const recharge = (data) => http.get('/ground-business/wallet/charge', {params: data, custom: {auth: true} })

/**
 * 获取当前商家
 * @returns 返回信息对象:{
		businessId: "商家ID",
		businessName: "商家名称",
		businessLicenseNo: "统一社会信用代码",
		gymName: "球馆名称",
		contacts: "联系人",
		contactsPhone: "联系人电话",
		province: "省",
		city: "市",
		county: "县",
		address: "地址",
		gymNum: "球馆号",
		serviceCharge: "支付手续费",
		commission: "佣金",
		username: "用户名",
		businessLicensePicture: "商家许可证照片"
		gymPicture: "球馆图片",
		latitude: null
		longitude: null
		order: null
		orderDate: null
		orderEndTime: null
		orderStartTime: null
		params: {}
		province: "广西壮族自治区"
		remark: null
		searchValue: null
		serviceCharge: 0
		sportsRange: "篮球,足球"
		updateBy: null
		updateTime: null
		username: "我是测试"
 * }
*/
export const getBusinessInfo = (data) => http.get('/ground-business/business/currentBusiness', {params: data, custom: {auth: true} })

/**
 * 修改当前商家信息
 * @param {
		businessId: "商家ID",
		businessName: "商家名称",
		businessLicenseNo: "统一社会信用代码",
		gymName: "球馆名称",
		contacts: "联系人",
		contactsPhone: "联系人电话",
		province: "省",
		city: "市",
		county: "县",
		address: "地址",
		gymNum: "球馆号",
		serviceCharge: "支付手续费",
		commission: "佣金",
		username: "用户名",
		businessLicensePicture: "商家许可证照片"
		gymPicture: "球馆图片",
		latitude: null
		longitude: null
		order: null
		orderDate: null
		orderEndTime: null
		orderStartTime: null
		params: {}
		province: "广西壮族自治区"
		remark: null
		searchValue: null
		serviceCharge: 0
		sportsRange: "篮球,足球"
		updateBy: null
		updateTime: null
		username: "我是测试"
	}
*/
export const updateBusinessInfo = (data) => http.put('/ground-business/business', data, {custom: {auth: true} })