import {
	http
} from './service.js'

const formHeader = {
	header: {
		'Content-Type': 'application/x-www-form-urlencoded'
	}
}

//文件上传
const uploadFile = {
	submit: p => http.upload('/blade-resource/oss/endpoint/put-pic-md5', {
		name: 'file',
		filePath: p
	}),
}

//短信api
const SMSApi = {
	sendSms: p => http.post('/park-app-service/huawei/sms/sendSms' + p),
	validCode: p => http.post('/park-app-service/huawei/sms/validCode' + p),
}

//字典
const dict = p => http.get('/blade-system/dict-biz/dictionary', {
	params: p
})


//微信基本参数
let wxData = {
	//国信的
	// appId:'wx988577c5a9061283',
	// secret:'5013c82bf72e6266dfb2720757433e74',
	//园区的
	appId: 'wxcfb2b48079ca59e4',
	secret: '30f9cf566aa57892e55aee0406356b9e',
	subscribe_grant_type: 'client_credential', //订阅消息的grant_type
}

//微信api
const wxApi = {
	subscribe: p => http.post('/park-app-service/app/msgSend', p),
	getAccessToken: p => http.get('/park-app-service/app/getAccessToken', {
		params: p
	}),
	getOpenId: p => http.get('/park-app-service/app/getOpenId', {
		params: p
	}),
	//获取小程序的audit状态
	getAppletStatus: p => http.get('/park-app-service/app/wxConf/getById', {
		params: p
	}),
}

//登录
const login = p => http.post('/park-app-service/app/login/login', p)

//修改密码
const updatePassword = p => http.post('community/enterprisestaff/app/updatePassword' + p)

//获取管理员的openid集合
const getManagerOpenList = p => http.get('/cyzh-enterprise/staff/app/getManagerList', {
	params: p
})


//获取token
const getToken = p => http.post('blade-auth/oauth/token' + p, {}, {
	header: {
		"Authorization": "Basic c2FiZXI6c2FiZXJfc2VjcmV0"
	}
})

//园区api
const agency = {
	getAgencyTenantList: p => http.get('/park-app-service/agency/getAgencyTenantList', {
		params: p
	}),
	getAgency: p => http.get('/park-app-service/agency/getAgency', {
		params: p
	}),
	page: p => http.get('/cyzh-community/agency/list', {
		params: p
	}),
	submit: p => http.post('/agency/agency/submit', p),
}
//区域api
const residential = {
	page: p => http.get('/cyzh-community/residential/list', {
		params: p
	}),
	selectPage: p => http.get('/community/residential/select', {
		params: p
	}),
}




//楼栋
const building = {
	page: p => http.get('/building/building/list', {
		params: p
	})
}


//企业api
const enterprise = {
	page: p => http.get('/cyzh-enterprise/enterprise/list', {
		params: p
	}),
	detail: p => http.get('/cyzh-enterprise/enterprise/detail', {
		params: p
	}),
	submit: p => http.post('/cyzh-enterprise/enterprise/submit', p),
}

//企业员工
const enterprisestaff = {
	page: p => http.get('/cyzh-enterprise/staff/list', {
		params: p
	}),
	detail: p => http.get('/cyzh-enterprise/staff/detail', {
		params: p
	}),
	submit: p => http.post('/cyzh-enterprise/staff/submit', p),
}

//CMS
const CMS = {
	page: p => http.get('/cyzh-estate/article/list', {
		params: p
	}),
	detail: p => http.get('/cyzh-estate/article/detail', {
		params: p
	}),
	addReaderCount: p => http.post('/cyzh-estate/article/addReaderCount', p),
}

//banner 轮播图
const banner = {
	page: p => http.get('/cyzh-estate/banners/list', {
		params: p
	}),
}

//消防设备
const fireDevice = {
	//企业角色的设备列表接口
	page: p => http.get('/park-app-service/iotdevice/list', {
		params: p
	}),
	//园区角色的设备列表接口
	agencyPage: p => http.get('/park-app-service/iotdevice/list', {
		params: p
	}),
	//报警记录接口
	alarmRecord: p => http.get('/cyzh-smart-device/iotalarm/list', {
		params: p
	}),
	//电表抄表记录
	electricmeterrecord: p => http.get('/cyzh-smart-device/electricmeterrecord/list', {
		params: p
	}),
}
//用户反馈
const feedback = {
	submit: p => http.post('/estate/feedback/submit', p),
}
//园区公告
const notice = {
	page: p => http.get('/cyzh-estate/noticepushrecord/listReturnNotice', {
		params: p
	}),
	remove: p => http.post('/park-app-service/parknotice/remove?ids=' + p),
	submit: p => http.post('/park-app-service/parknotice/save', p),
}

//测温记录
const temperatureRecord = {
	page: p => http.get('/cyzh-smart-device/temperaturerecord/list', {
		params: p
	}),
}

//健康码
const healthCode = {
	getCode: p => http.post('/health/getCode', p)
}

const car = {
	//出入记录
	condition: p => http.get('/cyzh-estate/carenterrecord/queryRecord', {
		params: p
	}),
	//入场记录
	enterPage: p => http.get('/cyzh-estate/carenterrecord/list', {
		params: p
	}),
	//出场记录
	outPage: p => http.get('/cyzh-estate/caroutrecord/list', {
		params: p
	}),

	//车辆列表
	carList: p => http.get('/cyzh-estate/car/parkapp/list', {
		params: p
	}),
	//添加车辆
	carAdd: p => http.post('/cyzh-estate/car/submit', p),
	//删除车辆
	carRemove: p => http.post('/cyzh-estate/car/remove?ids=' + p),
	//车辆审核
	carAudit: p => http.post('/cyzh-estate/car/audit', p),
}

//开门设备
const device = {
	page: p => http.get('/cyzh-smart-device/doordevice/list', {
		params: p
	}),
	open: p => http.post('/park-app-service/doordevice/remoteOpenDoor', p,formHeader)
}

//园区统计
const statistical = {
	//园区信息统计
	agencyStatistical: p => http.get('/park-app-service/statistics/agency', {
		params: p
	}),
	//当日动态数据
	todayData: p => http.get('/park-app-service/statistics/todayData', {
		params: p
	}),
	//人员进出记录
	carTendency: p => http.get('/park-app-service/statistics/carTendency', {
		params: p
	}),
	//三十天内用电量
	electricMeterStatic: p => http.get('/park-app-service/statistics/electricMeterStatic', {
		params: p
	}),
	//消防设备数据统计
	getGateStatic: p => http.get('/park-app-service/statistics/getFireStatic', {
		params: p
	}),
	//消防场景告警事件统计
	getDeviceJobStaticByApp: p => http.get('/park-app-service/statistics/getDeviceJobStaticByApp', {
		params: p
	}),
}

//出入记录
const accessrecord = {
	page: p => http.get('/cyzh-estate/accessrecord/list', {
		params: p
	}),
}

//访客授权
const guest = {
	submit: p => http.post('/park-app-service/guestrecord/submit', p),
	page: p => http.get('/park-app-service/guestrecord/page', {
		params: p
	}),
	getByGuestOpenId: p => http.get('/cyzh-estate/guest/getByGuestOpenId', {
		params: p
	}),
	audit: p => http.post('/park-app-service/guestrecord/audit', p),
}

//企业项目
const enterpriseproject = {
	submit: p => http.post('/cyzh-enterprise/project/submit', p),
	page: p => http.get('/cyzh-enterprise/project/list', {
		params: p
	}),
	remove: p => http.post('/cyzh-enterprise/project/remove?ids=' + p),
}

//视频监控
const live = {
	page: p => http.get('yc_video_cloud_device/videoclouddevice/getByResidentialAndDeviceName', {
		params: p
	}),
}

//智慧党建
const party = {
	//党支部列表
	page: p => http.get('party/branch/app/getListForAgency', {
		params: p
	}),
	//党支部详情
	branchDetail: p => http.get('party/branch/detail', {
		params: p
	}),
	//查看员工属于哪个党支部 enterpriseStaffId
	branch: p => http.get('party/branch/app/list/', {
		params: p
	}),
	isPartyMember: p => http.get('/park-app-service/party/member/isPartyMember', {
		params: p
	}),
	//党员认证
	apply: p => http.post('party/member/apply', p),
	//三会一课
	meetinglist: p => http.get('party/meetinglist/list', {
		params: p
	}),
	//三会一课详情
	meetingDetail: p => http.get('party/meetinglist/detail', {
		params: p
	}),
	//评论
	comment: p => http.post('party/comment/save', p),
	//评论列表
	commentList: p => http.get('party/comment/list', {
		params: p
	}),
	//党内资讯
	partyInfoList: p => http.get('party/newslist/list', {
		params: p
	}),
	//资讯详情
	partyInfoDetail: p => http.get('party/newslist/detail', {
		params: p
	}),
	//党内活动
	activityList: p => http.get('party/activity/list', {
		params: p
	}),
	//党资讯详情
	activityDetail: p => http.get('party/activity/detail', {
		params: p
	}),
	//活动报名
	activityenroll: p => http.post('party/activityenroll/save', p),
	//查看是否已报名
	checkIsEnroll: p => http.get('party/activityenroll/list', {
		params: p
	}),
	//取消报名
	cancelEnroll: p => http.post('party/activityenroll/cancel', p),
}


const punch = {
	getRule: p => http.get('attence/ruleperson/getRule', {
		params: p
	}),
	save: p => http.post('attence/record/save', p),
	getLocation: p => http.get('attence/location/getLocation', {
		params: p
	}),
	getNecessaryData: p => http.post('attence/rule/getNecessaryData', p),
	getMarkDays: p => http.get('attence/record/getMarkDays', {
		params: p
	}),
	getRecordsByDate: p => http.get('attence/record/getRecordsByDate', {
		params: p
	}),
	getRuleByDate: p => http.get('attence/rule/getRuleByDate', {
		params: p
	}),
}

export const api = {
	//上传文件
	uploadFile,
	//短信
	SMSApi,
	//字典
	dict,
	//微信基本参数
	wxData,
	//微信api
	wxApi,
	//登录
	login,
	//修改密码
	updatePassword,
	//获取管理员的openid集合
	getManagerOpenList,
	//获取token
	getToken,
	//园区
	agency,
	//区域
	residential,
	//楼栋
	building,
	//企业
	enterprise,
	//企业员工
	enterprisestaff,
	//CMS
	CMS,
	//banner 轮播图
	banner,
	//消防设备
	fireDevice,
	//用户反馈
	feedback,
	//园区公告
	notice,
	//测温记录
	temperatureRecord,
	//健康码
	healthCode,
	//车辆出入
	car,
	//开门设备
	device,
	//统计
	statistical,
	//出入记录
	accessrecord,
	//访客授权
	guest,
	//企业项目
	enterpriseproject,
	//视频监控
	live,
	//智慧党建
	party,
	//打卡
	punch
}
