import apiUrl from './api.js'
import request from '@/utils/baozhengRequest.js'
const login = (param)=>{ 
	return request({
	    url: apiUrl.baozheng.login,
	    method: 'post',
	    data: param
	})
}
const getCustomerInfo = (param)=>{ 
	return request({
	    url: apiUrl.baozheng.getCustomerInfo,
	    method: 'get',
	    params: param
	})
}
const getPersonStatistics = (param)=>{ 
	return request({
	    url: apiUrl.baozheng.getPersonStatistics,
	    method: 'get',
	    params: param
	})
}
const personTodo = (param)=>{ 
	return request({
	    url: apiUrl.baozheng.personTodo,
	    method: 'get',
	    params: param
	})
}
const speechSort = (param)=>{ 
	return request({
	    url: apiUrl.baozheng.speechSort,
	    method: 'get',
	    params: param
	})
}
const searchBiaoqingbao = (param)=>{
	return request({
		url:apiUrl.baozheng.searchBiaoqingbao,
		method:'get',
		params:param
	})
}
const getScriptTags = (param)=>{
	return request({
		url:apiUrl.baozheng.getScriptTags,
		method:'get',
		params:param
	})
}
const getScriptCatgary = (param)=>{
	return request({
		url:apiUrl.baozheng.getScriptCatgary,
		method:'get',
		params:param
	})
}
const apis = [
	[apiUrl.baozheng.speechSort],
	[apiUrl.baozheng.getPersonStatistics],
	[apiUrl.baozheng.personTodo],
	[apiUrl.baozheng.getScriptTags],
	[apiUrl.baozheng.searchBiaoqingbao],
	[apiUrl.baozheng.teamTodo],
	[apiUrl.baozheng.getScriptCatgary],
	[apiUrl.baozheng.bindChatUser,'post'],
	[apiUrl.baozheng.findByMobile,'post']
]
const reMap = new Map()
const baseService = (()=>{
	for(let ap of apis){
		let temp = ({resolve, reject,param,isComplete = true})=>{
			return isComplete?request({
			    url: ap[0],
			    method: ap[1]||'get',
			    params: param,
			    data:param
			}).then(response=>{
                if(response.code==200){
                    resolve(response.data)
                }else{
                    reject(response)
                }
            }).catch(error => {
              reject(error)
            }):request({
			    url: ap[0],
			    method: ap[1]||'get',
			    params: param,
			    data:param
			})
		}
		reMap.set(ap[0],temp)
	}
	return reMap
})()
export  default {
	login,
	personTodo,
	baseService,
	getCustomerInfo,
	getPersonStatistics
}