import http from '@/http/api.js'

// 获取token
const token = (tenantId, username, password, type) => {
	return http.request({
		url: '/api/blade-auth/oauth/token',
		method: 'POST',
		header: {
			'Tenant-Id': tenantId
		},
		params: {
			tenantId,
			username,
			password,
			grant_type: "password",
			scope: "all",
			type
		}
	})
}
export const getXqgk = () => {
	return http.request({
		url: '/blade-system/user/getXqgk',
		method: 'get',
	})
}
const refreshToken = (refresh_token, tenantId) => {
	return http.request({
		url: '/api/blade-auth/oauth/token',
		method: 'post',
		headers: {
			'Tenant-Id': tenantId
		},
		params: {
			tenantId,
			refresh_token,
			grant_type: "refresh_token",
			scope: "all",
		}
	})
}

// 获取用户信息
export const userInfo = () => {
	 return http.request({
	 	url: '/api/blade-system/user/getUserInfo',
	 	method: 'GET',
	})
}

// 获取用户信息
export const getUser = (id) => {
	 return http.request({
	 	url: '/api/blade-system/user/detail',
		method: 'GET',
	 	params: { id }
	})
}
// 获取用户信息
export const wxlogin = (row) => {	
	 return http.request({
	 	url: '/api/blade-system/user/wxlogi_qs',
	 	method: 'POST',
	 	header: {
				// 'Content-Type': 'application/x-www-form-urlencoded'
	 			 'Content-Type': 'application/x-www-form-urlencoded'
	 		},
	 	data: row
	 })
}
//blade-auth/oauth/token
export const weblogin = (row) => {	
	 return http.request({
	 	url: '/api/blade-auth/oauth/token',
	 	method: 'POST',
	 	header: {
				// 'Content-Type': 'application/x-www-form-urlencoded'
	 			 'Content-Type': 'application/x-www-form-urlencoded'
	 		},
	 	data: row
	 })
}




// 获取帐户信息
export const getzhxx = (yhbh) => {

		
	 return http.request({
	 	url: '/api/miaos/zhxx/detail',
	 	method: 'GET',
	 	params: { yhbh }
	 })
}


//blade-system/user/registerUser

// 用户注册
export const registerUser = (row) => {
	return wx.cloud.callContainer({
		  "path": "/blade-system/user/registerUser_qs",
		  "header": {
			"X-WX-SERVICE": "msserver",
			'Content-Type': 'application/x-www-form-urlencoded'
		  },
		  "method": "POST",
		 "data":row
		})
	// return http.request({
	// 	url: '/api/blade-system/user/registerUser_qs',
	// 	method: 'POST',
	// 	header: {
	// 			// 'Content-Type': 'application/x-www-form-urlencoded'
	// 			 'Content-Type': 'application/x-www-form-urlencoded'
	// 		},
	// 	data: row
	// })
}
// 用户手机号码
export const getPhoneNumbers = (row) => {
	 return http.request({
	 	url: '/api/blade-system/user/getPhoneNumber_qs',
	 	method: 'POST',
		header: {
	 				// 'Content-Type': 'application/x-www-form-urlencoded'
	 				 'Content-Type': 'application/x-www-form-urlencoded'
	 			},
	 	data: row
	 })
}


export const updateinfo = (row) => {
	return http.request({
		url: '/api/blade-system/user/update-info',
		method: 'POST',
		data: row
	})
}
//个人信息
export const updateinfos = (row) => {
	return http.request({
		url: '/api/blade-system/user/update',
		method: 'POST',
		data: row
	})
}


// 部门
//1、学校列表

export const university_list = () => {
	return wx.cloud.callContainer({
		  "path": "/blade-system/dept/university-list",
		  "header": {
			"X-WX-SERVICE": "msserver"
		  },
		  "method": "GET",
		 "data":{}
		})
	// return http.request({
	// 	url: '/api/blade-system/dept/university-list',
	// 	method: 'GET'
	// })
}

export const college_list = (deptId) => {
	return wx.cloud.callContainer({
		  "path": "/blade-system/dept/college-list",
		  "header": {
			"X-WX-SERVICE": "msserver"
		  },
		  "method": "GET",
		 "data":{deptId}
		})
		
	// return http.request({
	// 	url: '/api/blade-system/dept/college-list',
	// 	method: 'GET',
	// 	params:{
	// 		deptId
	// 	}
	// })
}
export const specialty_list = (deptId) => {
	return wx.cloud.callContainer({
		  "path": "/blade-system/dept/specialty-list",
		  "header": {
			"X-WX-SERVICE": "msserver"
		  },
		  "method": "GET",
		 "data":{deptId}
		})
	// return http.request({
	// 	url: '/api/blade-system/dept/specialty-list',
	// 	method: 'GET',
	// 	params:{
	// 		deptId
	// 	}
	// })
}
export const grade_list = (deptId) => {
	return wx.cloud.callContainer({
		  "path": "/blade-system/dept/grade-list",
		  "header": {
			"X-WX-SERVICE": "msserver"
		  },
		  "method": "GET",
		 "data":{deptId}
		})
	// return http.request({
	// 	url: '/api/blade-system/dept/grade-list',
	// 	method: 'GET',
	// 	params:{
	// 		deptId
	// 	}
	// })
}
export default {
	token,
	wxlogin,
	userInfo,
	updateinfos,
	refreshToken
}
