export default {
	timeYMDFilter(timestamp) { // 时间戳转为yyyy-mm-dd hh:mm:ss
		// console.log(timestamp)
		if (timestamp !== undefined && timestamp !== null) {
			let date = new Date(timestamp); // 时间戳为10位需*1000，时间戳为13位的话不需乘1000
			let Y = date.getFullYear() + '-';
			let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
			let D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
			// let h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
			// let m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
			// let s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
			return Y + M + D;
		} else {
			return ''
		}
	},
	timeYMFilter(timestamp) { // 时间戳转为yyyy-mm-dd hh:mm:ss
		// console.log(timestamp)
		if (timestamp !== undefined && timestamp !== null) {
			let date = new Date(timestamp); // 时间戳为10位需*1000，时间戳为13位的话不需乘1000
			let Y = date.getFullYear() + '-';
			let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
			// let D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
			// let h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
			// let m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
			// let s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
			return Y + M;
		} else {
			return ''
		}
	},
	timeYMDHMSFilter(timestamp) { // 时间戳转为yyyy-mm-dd hh:mm:ss
		// console.log(timestamp)
		if (timestamp !== undefined && timestamp !== null) {
			let date = new Date(timestamp); // 时间戳为10位需*1000，时间戳为13位的话不需乘1000
			let Y = date.getFullYear() + '-';
			let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
			let D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
			let h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
			let m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
			let s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
			return Y + M + D + h + m + s;
		} else {
			return ''
		}
	},
	statusName(val) {
		let name;
		if (val === 'unpublished') {
			name = '未发布'
		} else if (val === 'ongoing') {
			name = '进行中'
		} else if (val === 'audit') {
			name = '待审核'
		} else if (val === 'review') {
			name = '待考评'
		} else if (val === 'finished') {
			name = '已完结'
		} else {
			name = '已删除'
		}
		return name;
	},
	getAllUser() {
		this.$axios.getUser().then((res) => {
			console.log(res)
			if (res.data.code === 200) {
				return res.data.data;
			}
		})
	},
	getRole() {
		this.$axios.getRole().then((res) => {
			console.log(res)
		})
	},
}
