import request from '@/utils/request'

// 获取充值记录,表格数据
export function getTableData(forData) {
	let data = new FormData()
	data.append('page', forData.page)
	data.append('rows', forData.rows)
	
	if (forData.search_datatime !== undefined && forData.search_datatime !== null) {
		data.append('start_date', forData.search_datatime[0])
		data.append('end_date', forData.search_datatime[1])
	}
	
	if (typeof forData.keyword !== 'undefined') {
		data.append('key', forData.keyword)
	}
	
	if (typeof forData.is_top !== 'undefined') {
		data.append('is_top', forData.is_top)
	}
	
	return request({
		url: '/mhotel/appnewlist.action',
		method: 'post',
		data
	})
}

// 获取文章
export function getArticle() {
	
	return request({
		url: '/mhotel/appautoInsertNews.action',
		method: 'post'
	})
}

// 更新文章
export function updateArticle(forData) {
	let data = new FormData()
	data.append('id', forData[0])
	
	return request({
		url: '/mhotel/appupdateNews.action',
		method: 'post',
		data
	})
}

// 删除文章
export function delArticle(forData) {
	let data = new FormData()
	data.append('id', forData[0])
	
	return request({
		url: '/mhotel/appdelNews.action',
		method: 'post',
		data
	})
}

// 置顶/取消置顶
export function topArticle(forData) {
	let data = new FormData()
	data.append('id', forData[0])
	data.append('is_top', forData[1])
	
	return request({
		url: '/mhotel/appupdateTop.action',
		method: 'post',
		data
	})
}