//我的相关:
const {
	http
} = uni.$u


//用户相关
// 微信授权登陆
export const wxAuthLoginReq = (params, config = {}) => http.post('/api/auth/mnplogin', params, config)

// 获取用户信息
export const getUserInfoReq = (params, config = {}) => http.get('/api/users/getUserInfo', params, config)


// 更新用户信息
export const updateUserInfoReq = (params, config = {}) => http.post('/api/users/updateUserInfo', params, config)




// 首页相关
// 获取首页配置
export const getIndexConfigReq = (params, config = {}) => http.get('/api/getHomeData', params, config)



// 订单相关相关
// 提交订单
export const postOrderReq = (params, config = {}) => http.post('/api/order/submitOrder', params, config)

// 获取订单详细
export const getOrderDetailReq = (params, config = {}) => {
	let apiUrl = '/api/order/getOrderDetail'
	Object.keys(params).forEach((item, index) => {
		if (index == 0) {
			apiUrl += `?${item}=${params[item]}`
		} else {
			apiUrl += `&${item}=${params[item]}`
		}
	})
	console.log('处理后的apiUrl', apiUrl);

	return http.get(apiUrl, params, config)
}


// 获取商城分类数据
export const getMallCatReq = (params, config = {}) => http.get('/api/goods/getClassifyData', params, config)


// 获取商城数据
export const getMallReq = (params, config = {}) => {
	let apiUrl = '/api/goods/getGoodsData'
	Object.keys(params).forEach((item, index) => {
		if (index == 0) {
			apiUrl += `?${item}=${params[item]}`
		} else {
			apiUrl += `&${item}=${params[item]}`
		}
	})
	console.log('处理后的apiUrl', apiUrl);
	return http.get(apiUrl, params, config)
}


// 获取商城分类数据
export const getSerDocReq = (params, config = {}) => http.get('/api/server/getServerData', params, config)



// 获取各个身份的价格百分比
export const getPricePercentReq = (params, config = {}) => http.get('/api/common/getPriceConfig', params, config)


// 获取我的售后保障
export const getSerBackReq = (params, config = {}) => http.get('/api/users/getMyAfterSaleData', params, config)



// 获取我的服务流程
export const getSerStepReq = (params, config = {}) => http.get('/api/users/getMyServiceProcess', params, config)

// 获取我的售后商品
export const getSerBackGoodsReq = (params, config = {}) => {

	let apiUrl = '/api/users/getMyAfterSaleGoods'
	Object.keys(params).forEach((item, index) => {
		if (index == 0) {
			apiUrl += `?${item}=${params[item]}`
		} else {
			apiUrl += `&${item}=${params[item]}`
		}
	})
	console.log('处理后的apiUrl', apiUrl);
	return http.get(apiUrl, params, config)
}



//获取我的售后联系
export const getSerBackConReq = (params, config = {}) => http.get('/api/users/getMyAfterSaleContact', params, config)



// 提交邀请
export const postInviteReq = (params, config = {}) => http.post('/api/invite/submitInviteData', params, config)


//获取我的邀请
export const getMyInviteReq = (params, config = {}) => {

	let apiUrl = '/api/invite/getMyInviteData'
	Object.keys(params).forEach((item, index) => {
		if (index == 0) {
			apiUrl += `?${item}=${params[item]}`
		} else {
			apiUrl += `&${item}=${params[item]}`
		}
	})
	console.log('处理后的apiUrl', apiUrl);
	return http.get(apiUrl, params, config)
}


// 添加邀请
export const addInviteReq = (params, config = {}) => http.post('/api/invite/addInvite', params, config)

// 添加收藏
export const addCollReq = (params, config = {}) => http.post('/api/users/addCollect', params, config)


// 取消收藏
export const cancelCollReq = (params, config = {}) => http.post('/api/users/cancelCollect', params, config)



export const getGoodsPriceReq = (params, config = {}) => {
	let apiUrl = '/api/goods/getGoodsPrice'
	Object.keys(params).forEach((item, index) => {
		if (index == 0) {
			apiUrl += `?${item}=${JSON.stringify( params[item]) }`
		} else {
			apiUrl += `&${item}=${params[item]}`
		}
	})
	console.log('处理后的apiUrl', apiUrl);
	return http.get(apiUrl, params, config)
}

// export const getGoodsPriceReq = (params, config = {}) => http.post('/api/goods/getGoodsPrice', params, config)