import {
	POST
} from "./Request.js";
let app = getApp();

let base = app.globalData.url;
// let base = "http://192.168.1.16:9301/crest/";


// let orderbase = "http://192.168.1.16:9304/order"
let orderbase = app.globalData.orderurl;

// let userbase = app.globalData.userurl;
// let v1base = app.globalData.v1url;
// let brestBase = app.globalData.brestUrl;
// let payBase = app.globalData.payurl;


// 查询分类树
export const getGoodsTypeTree = params => {
	return POST('GET', `${base}/goods/getGoodsTypeTree`, params).then(res => res.data);
}

// 查询商品列表
export const getListGoodsDetail = params => {
	return POST('GET', `${base}/goods/getListGoodsDetail`, params).then(res => res.data);
}

//根据商品id查询商品详情
export const findGoodsDetailById = params => {
	return POST('GET', `${base}/goods/findGoodsDetailById`, params).then(res => res.data);
}
// 查询商品规格
export const findGoodsSkuByGoodsId = params => {
	return POST('GET', `${base}/goods/findGoodsSkuByGoodsId`, params).then(res => res.data);
}


// 新增购物车内容
export const insertShoppingCart = params => {
	
	return POST('POST', `${base}/shoppingCart/insertShoppingCart`, params).then(res => res.data);
}

// 增加商品数量
export const goodsEditNum = params => {
	return POST('GET', `${base}/shoppingCart/goodsEditNum`, params).then(res => res.data);
}
// 删除购物车商品
export const deleteShoppingCart = params => {
	return POST('GET', `${base}/shoppingCart/deleteShoppingCart`, params).then(res => res.data);
}

// 修改购物车选中状态
export const whetherCheckUpdate = params => {
	return POST('GET', `${base}/shoppingCart/whetherCheck`, params).then(res => res.data);
}

// 查询购物车列表
export const getShoppingCartList = params => {
	return POST('GET', `${base}/shoppingCart/getShoppingCartList`, params).then(res => res.data);
}

// 查询区域列表
export const getRegional = params => {
	return POST('GET', `${base}/common/getRegional`, params).then(res => res.data);
}

// 新增收获地址
export const insertDeliveryAddress = params => {
	return POST('POST', `${base}/deliveryAddress/insertDeliveryAddress`, params).then(res => res.data);
}


export const baiduApiMapSearch = params => {
	return POST('GET', `${base}/common/gaoDeApiMapSearch`, params).then(res => res.data);
}
// 更新收货地址
export const updateDeliveryAddress = params => {
	return POST('POST', `${base}/deliveryAddress/updateDeliveryAddress`, params).then(res => res.data);
}

// 查询收货地址列表
export const getDeliveryAddressList = params => {
	return POST('GET', `${base}/deliveryAddress/getDeliveryAddressList`, params).then(res => res.data);
}

// 根据id 查询收货地址详情
export const findDeliveryAddressById = params => {
	return POST('GET', `${base}/deliveryAddress/findDeliveryAddressById`, params).then(res => res.data);
}

// 根据id 删除收货地址
export const deleteAddress = params => {
	return POST('GET', `${base}/deliveryAddress/deleteDeliveryAddress`, params).then(res => res.data);
}

// 查询物流信息
export const getLogisticsMsg = params => {
	return POST('GET', `${base}/goods/getLogisticsMsg`, params).then(res => res.data);
}
// 根据区域查询运费和包邮价格
export const getRegionFreight = params => {
	return POST('GET', `${base}/common/getRegionFreight`, params).then(res => res.data);
}

// 查询收货地址包邮金额和运费金额
export const getAddressPrice = params => {
	return POST('GET', `${base}/deliveryAddress/getAddressPrice`, params).then(res => res.data);
}

//查询可用优惠券
export const getUserExclusiveDiscount = params => {
	return POST('GET', `${base}/userDiscount/getUserExclusiveDiscount`, params).then(res => res.data);
}

//下单
export const createOrder = params => {
	return POST('POST', `${orderbase}/create`, params).then(res => res.data);
}

//查询用户相关内容，积分
export const findUser = params => {
	return POST('GET', `${base}/highUser/findUser`, params).then(res => res.data);
}