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


//用户相关
export const getAfterSaleCon = (params, config = {}) => http.post('/api/users/bindingAfterSale', params, config)

// 请求首页顶部轮播
export const getIndexTopPics = (params, config = {}) => http.post('/api/users/bindingAfterSale', params, config)



// 微信授权登陆
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 getActivityDataReq = (params, config = {}) => http.get('/api/getActivityData', params, config)
// 更新用户信息
export const updateUserInfoReq = (params, config = {}) => http.post('/api/users/updateUserInfo', params, config)

// 获取邀请详情页背景图
export const getInviteDetailBg = (params, config = {}) => http.post('/api/invite/getSharePicTrue', params, config)







// 更新用户信息
export const getUserPhone = (params, config = {}) => http.post('/api/invite/getUserPhone', params, config)
// 更新用户信息
export const addAward = (params, config = {}) => http.post('/api/invite/addAward', params, config)

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

// 获取首页配置2
export const getHomeDataNextReq = (params, config = {}) => {
	let apiUrl = '/api/getHomeDataNext'
	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 getActivityDataDetailReq = (params, config = {}) => {
	let apiUrl = '/api/users/getActivityDataDetail'
	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 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 getMallCatReq = (params, config = {}) => {
	let apiUrl = '/api/goods/getClassifyData'
	if (params) {
		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 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 getChangeStepReq = (params, config = {}) => http.get('/api/users/getRenewFlow', 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 = {}) => http.post('/api/goods/getGoodsPrice', params, config)




//获取服务文档
export const getServerDataReq = (params, config = {}) => http.get('/api/server/getServerData', params, config)

// 提交反馈
export const submitFeedbackReq = (params, config = {}) => http.post('/api/users/submitFeedback', params, config)


//获取兑奖信息
export const getAwardDataReq = (params, config = {}) => http.get('/api/users/getAwardData', params, config)


export const getConfigTextByTypeReq = (params, config = {}) => {

	let apiUrl = '/api/common/getConfigTextByType'
	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 getWxQrCodeReq = (params, config = {}) => http.post('/api/common/getWxQrCode', params, config)



export const getConfigTextByIdReq = (params, config = {}) => {

	let apiUrl = '/api/common/getConfigTextById'
	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 getMyGoodsDetailReq = (params, config = {}) => {

	let apiUrl = '/api/goods/getGoodsDetail'
	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)
}