// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)
let hotSearchUrl = '/ebapi/store_api/hot_search';
let indexUrl = '/ebapi/public_api/index';

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	// 此处没有使用传入的params参数
	let getSearch = (params = {}) => vm.$u.get(hotSearchUrl, {
		id: 2
	});
	// 此处使用了传入的params参数，一切自定义即可
	let getUserInfo = (params = {}) => vm.$u.get('/system/user/info/', params); //获取用户信息

	let getCode = (data = {}) => vm.$u.post('/auth/sms_code/', data); //获取短信验证码

	let codeLogin = (data = {}) => vm.$u.post('/auth/login_sms_code/', data); //短信验证码登录

	let login = (data = {}) => vm.$u.post('auth/token/', data); //账户密码登录
	let loginOut = () => vm.$u.post('/auth/logout/'); //账户密码退出
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下

	let wxmplogin = (data = {}) => vm.$u.post('auth/login_wxmp/', data); //微信登录

	let bindmp = (data = {}) => vm.$u.post('/system/user/bind_wxmp/', data); //微信小程序绑定

	let unbindmp = (data = {}) => vm.$u.post('/system/user/unbind_wxmp/', data); //微信小程序解绑
	let getDickey = (params = {}) => vm.$u.get('/system/dict/', params); //查询字典
	let userList = (params = {}) => vm.$u.get('/system/user/', params); //
	let deptList = (params = {}) => vm.$u.get('/system/dept/', params); //
	
	let getTickets = (params = {}) => vm.$u.get('/wf/ticket/', params); //工单查询/wf/ticket/{id}/
	let ticketCreate = (data = {}) => vm.$u.post('/wf/ticket/', data); //工单
	let getTicketItem = (id) => vm.$u.get(`/wf/ticket/${id}/`); //工单详情
	let getTicketTransitions = (id) => vm.$u.get(`/wf/ticket/${id}/transitions/`); //工单按钮查询
	let workflowInit = (key) => vm.$u.get(`/wf/workflow/${key}/init_key/`); //工单按钮查询
	

	let addNode = (id, data = {}) => vm.$u.get(`/wf/ticket/${id}/add_node/`, data); //加签
	let addNodeEnd = (id, data = {}) => vm.$u.get(`/wf/ticket/${id}/add_node_end/`, data); //加签处理
	let deliver = (id, data = {}) => vm.$u.get(`/wf/ticket/${id}/deliver/`, data); //转交工单
	let ticketHandle = (id, data = {}) => vm.$u.post(`/wf/ticket/${id}/handle/`, data); //工单处理

	let operationList = (data = {}) => vm.$u.get('/opm/operation/', data); //作业列表
	let operationItem = (id) => vm.$u.get(`/opm/operation/${id}/`); //作业详情
	let operationCreat = (data = {}) => vm.$u.post('/opm/operation/', data); //作业新建
	let operationUpdate = (id, data = {}) => vm.$u.get(`/opm/operation/${id}/`, data); //作业编辑
	let oplItem = (id) => vm.$u.get(`/opm/opl/${id}/`); //opl作业许可证查询
	let oplLists = (data = {}) => vm.$u.get('/opm/opl/', data); //作业许可证
	let oplCate = (data = {}) => vm.$u.get('/opm/opl_cate/', data); //作业许可证类型
	let oplCateItem = (id) => vm.$u.get(`/opm/opl_cate/${id}/`); //作业许可证类型详情

	let rpjList = (data = {}) => vm.$u.get(`/rpm/rpj/`, data); //rpj查询
	let rpjItem = (id) => vm.$u.get(`/rpm/rpj/${id}`); //rpj查询

	let areaLists = (data = {}) => vm.$u.get('/am/area/', data); //作业区域

	let visitList = (data = {}) => vm.$u.get(`/vm/visit/`, data); //来访项目查询
	let visitItem = (id) => vm.$u.get(`/vm/visit/${id}/`); //来访项目详情
	let visitCreate = (data = {}) => vm.$u.post(`/vm/visit/`, data); //新增来访项目
	let visitUpdate = (id, data = {}) => vm.$u.put(`/vm/visit/${id}/`, data); //编辑来访项目
	let vmVisitor = (data = {}) => vm.$u.get(`/vm/visitor/`, data); //来访人员列表
	let visitorCreate = (data = {}) => vm.$u.post(`vm/visitor/`, data); //来访人员添加
	let visitorUpdate = (data = {}) => vm.$u.put(`vm/visitor/${id}/`, data); //来访人员编辑
	let vmVpeople = (data = {}) => vm.$u.get(`/vm/vpeople/`, data); //来访人员列表
	let vpeopleCreate = (data = {}) => vm.$u.post(`vm/vpeople/`, data); //来访人员添加
	let vpeopleUpdate = (data = {}) => vm.$u.put(`vm/vpeople/${id}/`, data); //来访人员编辑
	
	vm.$u.api = {
		getUserInfo,
		getCode,
		codeLogin,
		login,
		loginOut,
		wxmplogin,
		bindmp,
		unbindmp,
		userList,
		deptList,
		ticketCreate,
		getDickey,
		getTickets,
		getTicketItem,
		workflowInit,
		getTicketTransitions,

		visitList,
		visitItem,
		visitCreate,
		visitUpdate,
		vmVisitor,
		visitorCreate,
		visitorUpdate,
		vmVpeople,
		vpeopleCreate,
		vpeopleUpdate,
		
		rpjItem,
		rpjList,

		oplCateItem,
		operationItem,
		operationCreat,
		operationUpdate,
		operationList,
		oplLists,
		oplItem,
		oplCate,

		areaLists
	};
}

export default {
	install
}
