import {
	http,
	toast
} from '@/uni_modules/uview-plus'

let prefix = '';
// #ifdef H5
prefix = '/api'
// #endif
// #ifndef H5
prefix = ''
// #endif

/**
 * 聊天
 */

//
// export const getChatHistory = (data) => http.get(prefix + '/blade_chat/customer-service/chat-history?userId=' + data
// 	.userId + '&asc=' + data.asc + '&current=' + data.current + '&size=' + data.size) //获取聊天历史
// export const unreadCount = (data) => http.get(prefix + '/blade_chat/user/unread-count?userId=' + data
// 	.userId) //获取搜索历史
// export const markMessagesRead = (data) => http.post(prefix + '/blade_chat/user/mark-messages-as-read?userId=' + data
// 	.userId) //标记消息已读
// export const getTopQuestions = () => http.get(prefix + '/blade_msg_template/getTopQuestions') //获取顶级问题列表
// export const getQuestionResponse = (id) => http.get(prefix + '/blade_msg_template/getQuestionResponse?id=' +
// 	id) //获取问题回复或子问题列表
// /**
//  * 搜索历史相关
//  */
// export const getHistorySearchList = (data) => http.get(prefix + '/blade-historySearch/getList?type=' + data
// 	.type) //获取搜索历史
// export const submitHistorySearch = (params) => http.post(prefix + '/blade-historySearch/submit', params) //增加搜索历史
// export const delHistorySearch = () => http.post(prefix + '/blade-historySearch/remove') //删除搜索历史

/**
 * 提交反馈
 */
// export const feedbackList = (data) => http.get(prefix + '/blade-feedback/page?current=' + data.current +
// 	'&size=' + data.size + '&type=' + data.type)
export const getDept = (data) => http.get(prefix + '/system/info/deptList?parentId=' + data.parentId)
export const selectUser = (data) => http.get(prefix + '/system/info/selectUser?deptId=' + data.deptId)
export const addVisit = (data) => http.post(prefix + '/system/info/addVisit', data) // 提交访客申请

export const getVisitList = (data) => {
	const queryString = [
		data.userId && `userId=${encodeURIComponent(data.userId)}`,
		data.visitStatus && `visitStatus=${encodeURIComponent(data.visitStatus)}`
	].filter(Boolean).join('&');
	
	const url = prefix + '/system/info/list' + (queryString ? '?' + queryString : '');
	
	return http.get(url);
};
// export const getVisitList = (data) => http.get(prefix + '/system/info/list' + (data.visitStatus ? '?visitStatus=' + data.visitStatus + '&userId=' + data.userId : '?userId=' + data.userId)) // 获取访客记录列表
export const updateVisitInfo = (data) => http.get(prefix + '/system/info/updateVisitInfo'+'?id=' + data.id + '&visitStatus=' + data.visitStatus)  // 更新访客状态（通过/拒绝）
// export const getFeedback = (data) => http.get(prefix + '/blade-feedback/getFeedback')
// export const feedbackSave = (params) => http.post(prefix + '//blade-feedback/save', params) // 意见反馈
/**
 * 购物车
 */
// export const productCartSave = (params) => http.post(prefix + '/blade-cart/submit', params) //加入/修改购物车
// export const productCartCount = (params) => http.get(prefix + '/blade-cart/count', params) //获取购物车数量
// export const productCartList = (data) => http.get(prefix + '/blade-cart/list?current=' + data.current +
// 	'&size=' + data.size) //获取购物车所有商品
// export const productCartRemoveIds = (ids) => http.post(prefix + '/blade-cart/remove?ids=' + ids) //删除购物车对应商品
// export const productCartTotalPrice = () => http.get(prefix + '/blade-cart/totalPrice') //获取购物车总价
// export const saveCartOrder = (params) => http.post(prefix + '/blade-order/saveCart', params) //购物车批量下单
// /**
//  * 订单
//  */
// export const getOrderStatusCounts = () => http.get(prefix + '/blade-order/status-counts') // 获取各订单状态的数量
// export const queryExpress = (data) => http.post(prefix + '/blade-order/queryExpress?number=' + data.number + (data
// 	.mobile ? '&mobile=' + data.mobile : '')) //查询物流信息
// export const orderAfterDetail = (data) => http.get(prefix + '/blade-order/after/detail?orderId=' + data.orderId) //售后详情
// export const orderAfterDetailById = (data) => http.get(prefix + '/blade-order/after/detailById?id=' + data.id) //售后详情
// export const submitOrder = (data) => http.post(prefix + '/blade-order/save', data) // 保存订单
// export const submitOrderAfter = (data) => http.post(prefix + '/blade-order/after/save', data) // 申请售后
// export const saveScore = (data) => http.post(prefix + '/blade-score/score/save', data) // 提交评价
// export const confirmReceipt = (data) => http.post(prefix + '/blade-order/confirmReceipt', data) // 确认收货
// export const cancelOrder = (data) => http.post(prefix + '/blade-order/cancel', data) // 取消订单
// export const cancelAfter = (data) => http.post(prefix + '/blade-order/after/cancel', data) // 取消售后
// export const updateExpressCode = (data) => http.post(prefix + '/blade-order/after/updateExpressCode', data) // 填写单号
// export const getOrderList = (data) => http.get(prefix + '/blade-order/page?current=' + data.current +
// 	'&size=' + data.size + '&status=' + data.status + '&orderCode=' + data.orderCode + '&isAfter=' + data.isAfter +
// 	'&isEvaluate=' + data.isEvaluate
// ) //获取订单列表
// export const getAfterList = (data) => http.get(prefix + '/blade-order/after/page?current=' + data.current +
// 	'&size=' + data.size + '&orderId=' + data.orderId) //售后记录
// export const orderDetail = (data) => http.get(prefix + '/blade-order/detail', {
// 	params: {
// 		id: data.id
// 	}
// });
// export const getOrderPayDetail = (orderId) => http.get(prefix + '/blade-order/payDetail?orderId=' + orderId);
//
// export const countPaidProducts = () => http.get(prefix + '/blade-order/countPaidProducts');
// export const getMemberOrderStatistics = (data) => http.get(prefix + '/blade-order/memberStatistics', {
// 	params: data
// }); //获取指定用户的订单统计信息
// export const getMemberOrderList = (data) => http.get(prefix + '/blade-order/memberOrderList', {
// 	params: data
// }); //获取指定用户的订单列表
// export const getMemberlazyList = (data) => http.post(prefix + '/blade-member/member/lazyList',
// 	data); //获取会员团队
// export const teamStatistics = (data) => http.get(prefix + '/blade-member/member/teamStatistics',
// 	data); //获取团队统计
// /**
//  * 收货地址
//  */
// export const updateAddress = (data) => http.post(prefix + '/blade-order/updateAddress', data) // 更改收货地址
// export const merchantAddressDetail = () => http.get(prefix + '/blade-merchantAddress/detail') //商家退货地址
// export const addressList = (data) => http.get(prefix + '/blade-address/getList') //收货地址
// export const getAddress = () => http.get(prefix + '/blade-address/getAddress') //获取客户地址
// export const addressDetail = (data) => http.get(prefix + '/blade-address/detail?id=' + data.id) //获取默认地址
// export const addressDel = (data) => http.post(prefix + '/blade-address/remove?ids=' + data.ids) // 删除地址
// export const addressSubmit = (data) => http.post(prefix + '/blade-address/submit', data) // 新增/修改地址
//
// /**
//  * 商城相关
//  */
// export const scoreList = (data) => http.get(prefix + '/blade-score/score/list?current=' + data.current +
// 	'&size=' + data.size + '&productId=' + data.productId + '&images=' + data.images) //评论
// export const productClearCollect = (params) => http.post(prefix + '/blade-product/product/clearCollect',
// 	params) // 产品取消收藏
// export const productAddCollect = (params) => http.post(prefix + '/blade-product/product/addCollect',
// 	params) // 产品收藏
// export const productCollectList = (data) => http.get(prefix + '/blade-product/product/collectList', {
// 	params: data
// }) // 收藏列表
//
// export const productDetail = (data) => http.get(prefix + '/blade-product/product/detail?id=' + data.id) //产品详情
//
// export const productList = (data) => {
// 	// 手动构建查询参数，过滤空值
// 	const params = [];
// 	if (data.current) params.push(`current=${encodeURIComponent(data.current)}`);
// 	if (data.size) params.push(`size=${encodeURIComponent(data.size)}`);
// 	if (data.categoriesId) params.push(`categoriesId=${encodeURIComponent(data.categoriesId)}`);
// 	if (data.name) params.push(`name=${encodeURIComponent(data.name)}`);
// 	if (data.sort) params.push(`sort=${encodeURIComponent(data.sort)}`);
// 	if (data.arrow) params.push(`arrow=${encodeURIComponent(data.arrow)}`);
//
// 	const queryString = params.length > 0 ? params.join('&') : '';
// 	const url = prefix + '/blade-product/product/list' + (queryString ? '?' + queryString : '');
// 	return http.get(url);
// }
//
// // 商品搜索接口
// export const productSearch = (data) => http.post(prefix + '/blade-product/product/productSearch', data)
//
// export const getShopIndexList = () => http.get(prefix + '/blade-product/product/getIndexList') // 获取商品首页列表
// export const getNewProducts = (data) => http.get(prefix + '/blade-product/product/getNewProducts', {
// 	params: {
// 		current: data.current || 1,
// 		size: data.size || 10,
// 		name: data.name || '',
// 		sort: data.sort || '',
// 		arrow: data.arrow || ''
// 	}
// }) // 获取新品上市商品列表
//
// // 获取代理商品列表(不分页)
// export const getAgentProducts = (data) => http.get(prefix + '/blade-product/product/getAgentProducts', {
// 	params: {
// 		name: data?.name || ''
// 	}
// })
//
// // 获取精选唐卡商品列表(分页)
// export const getSelectedProducts = (data) => http.get(prefix + '/blade-product/product/getSelectedProducts', {
// 	params: {
// 		current: data.current || 1,
// 		size: data.size || 6,
// 		name: data?.name || ''
// 	}
// })
//
// export const categoriesList = () => http.get(prefix + '/blade-categories/categories/getList') // 获取商品分类

/**
 * 家庭相关
 */
// export const getFamilyList = (data) => http.get(prefix + '/blade-family/family/getList', data) // 获取当前用户全部家庭
// export const getFamilyPetList = (data) => http.post(prefix + '/blade-family/family/getFamilyPetList',
// 	data) // 获取当前用户全部家庭的宠物
// export const saveFamily = (data) => http.post(prefix + '/blade-family/family/save', data) // 新建家庭
// export const updateFamily = (data) => http.post(prefix + '/blade-family/family/update', data) // 更新家庭
// export const getFamilyDetail = (id) => http.get(prefix + '/blade-family/family/getFamilyDetail?id=' +
// 	id) // 获取家庭详情
// export const getFamilyMemberList = (id) => http.get(prefix + '/blade-family/family/getFamilyMemberList?id=' +
// 	id) // 获取家庭成员
// export const dissolveFamily = (data) => http.post(prefix + '/blade-family/family/dissolveFamily', data) // 解散家庭
// export const familyDetailById = (id) => http.get(prefix + '/blade-family/family/detailById?id=' +
// 	id) // 根据ID获取家庭详情

/**
 * 宠物相关
 */
// export const getPetDetail = (id) => http.get(prefix + '/blade-memberPet/memberPet/detail?id=' +
// 	id) // 根据ID获取宠物信息
// export const memberPetList = (data) => http.post(prefix + '/blade-memberPet/memberPet/getList', data) // 获取所有宠物
// export const saveMemberPet = (data) => http.post(prefix + '/blade-memberPet/memberPet/save', data) // 保存宠物
// export const updateMemberPet = (data) => http.post(prefix + '/blade-memberPet/memberPet/update', data) // 更新宠物信息
// export const getBreedList = (data) => http.post(prefix + '/blade-breed/breed/getList', data) // 获取品种

/**
 * 
 *  登录相关
 */
export const register = (params) => http.post(prefix + '/blade-auth/oauth/register', params) // 注册
export const login = (params) => http.post(prefix + '/system/info/login', params) // 登录
export const logout = () => http.get(prefix + '/blade-auth/oauth/logout', ) // 退出登录
export const userLogin = (params) => http.post(prefix +
	'/blade-auth/oauth/tokenWeb', params
) // 登录、刷新token
export const getCode = (params) => http.post(prefix + '/blade-auth/oauth/email', params) // 获取邮箱验证码
export const updatePassword = (params) => http.post(prefix + '/blade-member/member/updatePassword',
	params) // 修改密码

export const wxLogin = (data) => http.post(prefix + '/system/link/login', {
	...data
})
export const phoneLogin = (data) => http.post(prefix + '/system/info/login', {
	...data
})
// 更新用户基本信息（昵称和头像）
export const updateProfile = (data) => http.post(prefix + '/blade-member/member/updateProfile', {
	...data
})
export const getUserInfo = () => http.get(prefix + '/getInfo')
// export const forgetPassword = (params) => http.post(prefix + '/blade-auth/forgetPassword', params) //忘记密码
// /**
//  * 用户相关
//  */
// export const memberUpdatePayPassword = (params) => http.post(prefix + '/blade-member/member/updatePayPassword',
// 	params) //修改交易密码
// /**
//  *  行情相关
//  */
// export const comlstkm = (params) => http.post(prefix + '/blade-quotes/quotesIndex/comlstkm',
// 	params) // K线-获取最新动态柱旧版
// export const comlstkmv2 = (params) => http.post(prefix + '/blade-quotes/quotesIndex/comlstkmv2',
// 	params) // K线-获取最新柱v2
// export const quotesList = (params) => http.post(prefix + '/blade-quotes/quotesIndex/quotesList',
// 	params) // 首页行情数据
// export const quotesIndexSearch = (params) => http.post(prefix + '/blade-quotes/quotesIndex/search',
// 	params) // 首页行情数据
// export const historyKData = (params) => http.post(prefix + '/blade-quotes/quotesIndex/comkm4v2', params) // 历史K线
// export const quotesDetail = (params) => http.post(prefix + '/blade-quotes/quotesIndex/get', params) // 历史K线
// export const optionalPage = (params) => http.post(prefix + '/blade-optional/optional/page', params) // 自选列表
// export const optionalAdd = (params) => http.post(prefix + '/blade-optional/optional/add', params) // 添加自选
// export const optionalCancel = (params) => http.post(prefix + '/blade-optional/optional/cancel', params) // 取消自选
// export const optionalDetail = (params) => http.post(prefix + '/blade-optional/optional/getDetail',
// 	params) // 自选信息
// /**
//  * 理财相关
//  */
// export const queryInvestAll = () => http.get(prefix + '/blade_invest/invest/queryInvestAll') // 理财页面详情
// export const queryInvestDetail = (data) => http.get(prefix + '/blade_invest/invest/detail?id=' + data) // 理财页面详情
// export const memberInvestBuy = (data) => http.post(prefix + '/blade-memberInvest/memberInvest/buy', data) // 买入
// export const memberInvestGetById = (data) => http.post(prefix + '/blade-memberInvest/memberInvest/getById',
// 	data) // 查询详情
// export const incomeSelectJanuary = (data) => http.post(prefix + '/blade_income/income/selectJanuary',
// 	data) // 走势图记录
// export const incomeList = (data) => http.get(prefix + '/blade_income/income/list', data) // 走势图记录分页
// export const investList = (data) => http.post(prefix + '/blade-memberInvest/memberInvest/investList',
// 	data) // 买入记录
// export const investDetail = (data) => http.post(prefix + '/blade-memberInvest/memberInvest/detail',
// 	data) // 买入详情
// export const statisticsMyBuyOrder = () => http.get(prefix +
// 	'/blade_investment_order/investmentorder/statisticsMyBuyOrder') // 理财详情
// /**
//  * 投资
//  */
// export const investmentList = (data) => http.get(prefix + '/blade_investment/investment/list?current=' + data
// 	.current +
// 	'&size=' + data.size + '&investTypeId=' + data.investTypeId + '&status=' + data.status) // 理财页面详情
// export const investmentDetail = (data) => http.get(prefix + '/blade_investment/investment/detail?id=' +
// 	data) // 买入详情
// export const investmentPayDetail = (data) => http.post(prefix +
// 	'/blade_investment_order/investmentorder/payDetail',
// 	data) // 购买成功详情
// export const investmentBuy = (data) => http.post(prefix + '/blade_investment_order/investmentorder/buy',
// 	data) // 购买成功详情
// export const investmentOrderDetail = (data) => http.get(prefix +
// 	'/blade_investment_order/investmentorder/detail?id=' +
// 	data) // 购买成功详情
// export const investmentStatistics = (data) => http.post(prefix +
// 	'/blade_investment_order/investmentorder/statistics',
// 	data) // 购买成功详情
// export const investmentSelectMyPage = (data) => http.post(prefix +
// 	'/blade_investment_order/investmentorder/selectMyPage', data) // 购买成功详情
// export const investmentSelectMyLogs = (data) => http.post(prefix +
// 	'/blade_investment_order/investmentorder/selectMyLogs', data) // 购买成功详情
// export const investmentSelectMyIncomePage = (data) => http.post(prefix +
// 	'/blade_investment_order_income/investmentorderincome/selectMyIncomePage', data) // 购买成功详情
// /**
//  * 用户等级
//  */
// export const memberLevelDetail = (data) => http.get(prefix + '/blade_member_level/memberlevel/detail?id=' +
// 	data) // 购买成功详情
/**
 * 钱包
 */
// export const memberWalletDetail = () => http.get(prefix + '/blade-memberWallet/memberWallet/detail') // 自选信息
// export const getBalance = (data) => http.get(prefix + '/blade-memberWallet/memberWallet/getBalance?type=' +
// 	data) // 获取用户余额
// export const getBalanceDetail = (data) => http.get(prefix + '/blade-memberWallet/memberWallet/detail?type=' +
// 	data) // 获取用户余额
// export const qrCodeAddress = () => http.get(prefix + '/blade-address/address/list') // 充币地址和充币二维码
// export const withdrawalSave = (data) => http.post(prefix + '/blade-withdrawal/memberwithdrawal/save',
// 	data) // 提币功能确认转出
// export const chargeMoneyRecord = (data) => http.post(prefix + '/blade-member/member/assets/log/charge/page',
// 	data) // 充币记录
// export const withdrawalRecord = (data) => http.post(prefix + '/blade-withdrawal/memberwithdrawal/log/list',
// 	data) // 提币记录
// export const memberWalletExchange = (params) => http.post(prefix + '/blade-memberWallet/memberWallet/exchange',
// 	params) // 钱包兑换
// export const walletWebDetail = () => http.get(prefix +
// 	'/blade-memberWallet/memberWallet/walletWebDetail') // 钱包兑换
// export const walletWebRecharge = (data) => http.post(prefix + '/blade-member/member/assets/log/recharge',
// 	data) // 钱包兑换

/**
 * 余额宝
 */
// export const memberprofitlogmemberProfitLogList = (data) => http.post(prefix +
// 	'/blade_member_profit_log/memberprofitlog/memberProfitLogList', data) // 钱包兑换
// export const memberprofitlogchange = (data) => http.post(prefix +
// 	'/blade_member_profit_log/memberprofitlog/change',
// 	data) // 钱包兑换
// export const memberprofitlogchangeout = (data) => http.post(prefix +
// 	'/blade_member_profit_log/memberprofitlog/changeOut', data) // 转出
// export const memberprofitlogmemberProfitDetail = (data) => http.post(prefix +
// 	'/blade_member_profit_log/memberprofitlog/memberProfitDetail', data) // 余额宝总额
/**
 *  新闻相关
 */
// export const newList = (params) => http.post(prefix + '/blade-quotes/quotesIndex/qnews', params) // 新闻列表

/**
 * 首页轮播图
 */
// export const carouselQueryAll = (params) => http.post(prefix + '/blade_carousel/carousel/queryAll',
// 	params) // 首页轮播图

/**
 * 在线留言
 */
// export const messageList = () => http.get(prefix + '/message_board/messageboard/list') // 留言列表
// export const messageSave = (params) => http.post(prefix + '/message_board/messageboard/save/describe',
// 	params) // 留言提交

/**
 * 实名认证
 */
// export const certification = (params) => http.post(prefix + '/blade-member/member/certification',
// 	params) // 留言提交
// export const memberDetail = () => http.get(prefix + '/blade-member/member/memberDetail') //
export const memberUpdate = (params) => http.post(prefix + '/blade-member/member/update', params) // 更新用户信息

/**
 * 银行卡系列
 */
// export const bankList = (params) => http.post(prefix + '/blade_bank/bank/bankList', params) // 银行卡列表
// export const bankSave = (params) => http.post(prefix + '/blade_bank/bank/save', params) // 添加银行卡
// export const bankUpdate = (params) => http.post(prefix + '/blade_bank/bank/update', params) // 修改银行卡
// export const bankRemove = (params) => http.post(prefix + '/blade_bank/bank/removeById', params) // 解绑银行卡
// export const bankDetail = () => http.get(prefix + '/blade_bank/bank/detail') // 银行卡详情

/**
 * 签到
 */
// export const sign = () => http.get(prefix + '/blade_sign_log/signlog/sign') // 每日签到
// export const signDetail = () => http.get(prefix + '/blade_sign_log/signlog/signDetail') // 获取当天签到信息
/**
 * 我的团队
 */
// export const selectMemberRelationList = () => http.get(prefix +
// 	'/blade-member/member/selectMemberRelationList') // 银行卡详情
/**
 * 首页菜单
 */
// export const indexmenuQueryAll = () => http.get(prefix + '/blade_index_menu/indexmenu/queryAll') // 首页数据列表
// export const indexmenuDetail = (data) => http.get(prefix + '/blade_index_menu/indexmenu/detail?id=' +
// 	data) // 菜单详情
// export const noticePage = (data) => http.get(prefix + '/blade-desk/notice/list?current=' + data.current +
// 	'&size=' +
// 	data.size) // 首页数据列表
// export const noticeDetail = (data) => http.get(prefix + '/blade-desk/notice/detail?id=' + data) // 菜单详情
/**
 * 二维码详情
 */
// export const downloadconfDetail = (data) => http.get(prefix + '/blade_download_conf/downloadconf/detail')
// export const awardDetail = (data) => http.get(prefix + '/blade_award/award/detail') //制度详情

// export const investmentOrderContract = (data) => http.post(prefix +
// 	'/blade_investment_order/investmentorder/getContract', data) //合同信息



// export const getWxPayParams = (orderId) => http.get(prefix + '/blade-order/wxpay/create', {
// 	params: {
// 		orderId
// 	}
// })

// 首页菜单查询
// export const getIndexMenu = () => http.get(prefix + '/blade_index_menu/indexmenu/queryAll')

/**
 * 订单相关
 */
// export const saveOrder = (data) => http.post(prefix + '/blade-order/order/save', data) // 提交订单
// export const orderList = (data) => http.post(prefix + '/blade-order/order/list', data) // 订单列表
// export const orderCancel = (data) => http.post(prefix + '/blade-order/order/cancel', data) // 取消订单
// export const orderPay = (data) => http.post(prefix + '/blade-order/order/pay', data) // 订单支付

// 获取文章详情
// export function getArticleDetail(id) {
// 	return http.get(prefix + '/blade-article/article/detail?id=' + id);
// }

/**
 * 邀请相关接口
 */
// 通过账号查询用户
// export const findByAccount = (account) => http.get(prefix + '/blade-member/member/findByAccount?account=' + account)
// 发送邀请
// export const sendInvitation = (inviteeMemberId) => http.post(prefix +
// 	'/blade-member/member/sendInvitation?inviteeMemberId=' + inviteeMemberId)
// 接受邀请
// export const acceptInvitation = (inviterMemberId) => http.post(prefix +
// 	'/blade-member/member/acceptInvitation?inviterMemberId=' + inviterMemberId)
// 获取邀请记录
// export const getMyInvitations = () => http.get(prefix + '/blade-member/member/getMyInvitations')
// 设置推荐人
// export const setReferrer = (data) => http.post(prefix + '/blade-member/member/setReferrer', data)
// 获取用户详情
// export const getMemberDetail = (id) => http.get(prefix + '/blade-member/member/detail/' + id)
/**
 * 首页获取用户详情
 */
// export const getIndexMemberDetail = (id) => http.get(prefix + '/blade-member/member/indexMemberDetail/' + id)
// 拒绝邀请
// export const rejectInvitation = (inviterMemberId) => http.post(prefix +
// 	'/blade-member/member/rejectInvitation?inviterMemberId=' + inviterMemberId)
// 获取我收到的待处理邀请
// export const getPendingInvitations = () => http.get(prefix + '/blade-member/member/getPendingInvitations')