<template>
	<view class="p30 piles" style="padding: 30rpx">
		<view class="piles_card">
			<view class="piles_card_title">充电桩汇总</view>
			<view class="piles_card_view">
				<view>
					<text>{{ count.installDeviceNumber || 0 }}</text>
					<text>已安装</text>
				</view>
				<view>
					<text>{{ count.uninstallDeviceNumber || 0 }}</text>
					<text>未安装数量</text>
				</view>
				<view>
					<text>{{ count.deviceTotal || 0 }}</text>
					<text>团队</text>
				</view>
			</view>
		</view>
		<up-subsection activeColor="rgba(111, 162, 86, 1)" :list="list" keyName="name" :current="current" @change="upChange"></up-subsection>

		<view class="order_view" v-for="i in dataList" :key="i">
			<view class="piles_list" v-if="current == 0">
				<view class="piles_list_title">安装电站：{{ i.stationName || '-' }}</view>
				<view class="piles_list_view">
					<view>设备ID：</view>
					<view>{{ i.id }}</view>
				</view>
				<view class="piles_list_view">
					<view>设备功率：</view>
					<view>{{ i.deviceType }}KW</view>
				</view>
				<view class="piles_list_view" v-if="i.purposeType">
					<view>设备类型：</view>
					<view>{{ i.purposeType == 1 ? '商用运维版' : i.purposeType == 2 ? '商用合作版' : i.purposeType == 3 ? '家用专业版' : '' }}</view>
				</view>
				<view class="piles_list_view">地址：{{ i.stationAddress || '-' }}</view>
				<!-- 					<view class="piles_list_view">
						<view>电费费用：</view>
						<view>
							<text>1.00</text>
							/ 元
						</view>
					</view>
					<view class="piles_list_view">
						<view>昨日收益：</view>
						<view>
							<text>￥100.00 元</text>
						</view>
					</view> -->
				<view class="piles_list_view">
					<view>下单时间：</view>
					<view>{{ timeFormat(new Date(i.createTime).getTime(), 'yyyy-mm-dd hh:MM') }}</view>
				</view>
			</view>

			<view class="piles_list" v-if="current == 1">
				<view class="piles_list_view">
					<view>设备ID：</view>
					<view>{{ i.id }}</view>
				</view>
				<view class="piles_list_view">
					<view>设备功率：</view>
					<view>{{ i.deviceType }}KW</view>
				</view>
				<view class="piles_list_view" v-if="i.purposeType">
					<view>设备类型：</view>
					<view>{{ i.purposeType == 1 ? '商用运维版' : i.purposeType == 2 ? '商用合作版' : i.purposeType == 3 ? '家用专业版' : '' }}</view>
				</view>
				<view class="piles_list_view">
					<view>下单时间：</view>
					<view>{{ timeFormat(new Date(i.createTime).getTime(), 'yyyy-mm-dd hh:MM') }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { getDeviceInfo } from '@/api/api.js';
import { onMounted, reactive, ref } from 'vue';
import { onPullDownRefresh, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app';
import { timeFormat } from '@/uni_modules/uview-plus';
const paging = ref(null);
let dataList = ref([]);
let dataFrom = reactive({
	deviceStatus: 1
});
let count = ref({});

onMounted(() => {
	
	console.log(123456);
	getDeviceInfo().then((res) => {
		count.value = res;
		dataList.value = res.installDeviceList;
	});
});

const list = ref([
	{
		name: '已安装',
		id: 1
	},
	{
		name: '待安装',
		id: 0
	}
]);
const current = ref(0);

const upChange = (e) => {
	current.value = e;
	if (e == 0) {
		dataList.value = count.value.installDeviceList || [];
	} else {
		dataList.value = count.value.uninstallDeviceList || [];
	}
};
</script>

<style scoped lang="scss">
.piles {
	padding: 30rpx;
	&_card {
		width: 690rpx;
		height: 192rpx;
		background: linear-gradient( 179deg, #81BF63 0%, #6FA256 100%);
		border-radius: 8rpx 8rpx 0rpx 0rpx;
		padding: 30rpx;
		&_title {
			font-weight: bold;
			font-size: 28rpx;
			color: #ffffff;
			margin-bottom: 20rpx;
		}
		&_view {
			padding: 0 80rpx;
			flex-direction: column;
			@include flex($space: space-between);
			view {
				@include flex($direction: column, $space: space-between);
				text:nth-child(1) {
					font-weight: bold;
					font-size: 32rpx;
					color: #ffffff;
					margin-bottom: 15rpx;
				}
				text:nth-child(2) {
					font-size: 26rpx;
					color: #ffffff;
				}
			}
		}
	}

	&_list {
		padding: 25rpx;
		width: 690rpx;
		background: #ffffff;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin-top: 30rpx;
		&_title {
			font-weight: bold;
			font-size: 28rpx;
			color: #232323;
		}
		&_view {
			@include flex;
			color: #555555;
			font-size: 28rpx;
			margin-top: 15rpx;
			view:nth-child(2) {
				font-weight: bold;
				font-size: 28rpx;
				color: #232323;
			}
			text {
				color: #ff2727;
			}
		}
	}
}
</style>
