/**
 *@des 协销模块接口管理
 *@author zhengjinyi
 *@date 2020/03/19 14:56:57
 *@param registerByPass
 */
import request from '@/common/config/caimeiApi.js'
import $reg from '@/common/config/common.js'

/**
 *@协销微信授权登录
 *@param code 微信Code
 */
export function sellerWxLogin(params) {
	return new Promise(function(resolve,reject) {
		request.post('/seller/wxLogin',params, true,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销登录
 *@param mobile 手机号
 *@param password 密码
 */
export function sellerLogin(params) {
	return new Promise(function(resolve,reject) {
		request.post('/seller/login',params, true,res => {
			resolve(res)
		})
	})
}

/**
 *@协销账户中心
 *@param userID 协销ID
 */
export function getSellerHome(params) {
	return new Promise(function(resolve,reject) {
		request.get('/seller/home',params,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销拉机构上线
 *@param userID 协销ID
 */
export function sellerClubRegister(params) {
	return new Promise(function(resolve,reject) {
		request.post('/seller/club/register',params,true,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销拉机构上线检测手机号和邮箱
 *@param mobileOrEmail 手机号和邮箱
 */
export function sellerClubCheck(params) {
	return new Promise(function(resolve,reject) {
		request.post('/seller/club/check',params,true,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销修改机构资料
 *@param userID 协销ID
 */
export function sellerClubUpdate(params) {
	return new Promise(function(resolve,reject) {
		request.post('/seller/club/update',params,true,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销机构列表
 *@param name 	  机构名字关键字（搜索用）
 *@param pageNum  页码
 *@param pageSize 条数
 *@param spId 	  协销ID
 *@param status   机构状态
 */
export function getSellerClubList(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/seller/club/list',params,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销机构列表
 *@param name 	  机构名字关键字（搜索用）
 *@param pageNum  页码
 *@param pageSize 条数
 */
export function getFindAllClubList(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/seller/findAllClub',params,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}

/**
 *@协销订单列表（搜索订单）
 *@param listType 订单类型
 *@param orderNo  订单号
 *@param pageNum  页码
 *@param pageSize 条数
 *@param serviceProviderId 协销ID
 */
export function getSellerOrderList(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/seller/order/list',params,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销下机构订单列表
 *@param clubID   机构ID
 *@param pageNum  页码
 *@param pageSize 条数
 */
export function getSellerClubOrderList(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/seller/clubOrder',params,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销帮机构下单商品搜索
 *@param clubUserId 机构的userID
 *@param pageNum 	页码
 *@param pageSize 	条数
 *@param searchWord 搜索关键词
 */
export function getSellerProduct(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/seller/product/search',params,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销帮机构下单组合商品搜索
 *@param clubUserId 机构的userID
 *@param pageNum 	页码
 *@param pageSize 	条数
 *@param searchWord 搜索关键词
 */
export function getcombinationProduct(params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet('/seller/combinationProduct/search',params,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销购物车删除商品
 *@param clubId 会所ID
 *@param serviceProviderId 页码
 */
export function shoppingCartDelete(params) {
	return new Promise(function(resolve,reject) {
		request.post('/shoppingCart/delete',params, true,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销购物车商品增减
 *@param clubId 会所ID
 *@param serviceProviderId 页码
 */
export function shoppingCartUpdate(params) {
	return new Promise(function(resolve,reject) {
		request.post('/shoppingCart/update',params,true,res => {
			if(res.code == 0){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}
/**
 *@协销邀请运营人员
 *@param userID  机构userID
 */
export function sellerBindingOperation(params) {
	return new Promise(function(resolve,reject) {
		request.post('/seller/bindingOperation',params,true,res => {
			if(res.code == 0 || res.code == 4){
				resolve(res)
			}else{
				reject(res)
			}
		})
	})
}


