<template>
    <view class="ant-layout page">
		<page-header></page-header>
        <head-title title="设备信息"></head-title>
        <view class="ant-layout-content content">
            <view>[基本信息]</view>
            <view>设备名称：{{ deviceName }}</view>
            <view>设备序列号：{{ deviceSn }}</view>
            <view>设备IP：{{ deviceIp }}</view>
            <view>&nbsp;</view>
            <view>[存储信息]</view>
            <view>内镜：{{ endo }}</view>
            <view>人员：{{ person }}</view>
            <view>日志：{{ log }}</view>
            <view>&nbsp;</view>
            <view>[运行信息]</view>
            <view>紫外线灯累计工作时长：{{ UIlamp }}</view>
            <view>HEPA累计工作时长：{{ HEPA }}</view>
        </view>

        <notice ref="notice"/>
    </view>  
</template>

<script>
import PageHeader from '@/components/PageHeader.vue'
import Notice from '@/components/Notice.vue';
import HeadTitle from '@/components/HeadTitle.vue'
import storage from '@/utils/storage.js'
import { getMacAddress } from '@/js_sdk/zw-devicemac/devicemac.js'
import * as db from '@/db/sqlite.js'
export default {
    components: {
        PageHeader,Notice, HeadTitle
    },
    data() {
        return {
            deviceName: '储镜柜',
            deviceSn: '',
            deviceIp: '192.168.1.1',

            endo: 0,
            person: 0,
            log: 0,
            UIlamp: 0, //紫外线灯累计工作时长
            HEPA: 0
        }
    },
    async onLoad() {
        let info = uni.getDeviceInfo()
            console.log(info)
        uni.getNetworkType({
            success(res) {
                console.log(res)
                // 网络状态
                let net = res.networkType
            }
        })
        this.deviceSn = getMacAddress()

        let config = storage.get('config', '')
        this.deviceIp = config ? config.ip +':'+config.port : '未设置'

        this.UIlamp = storage.get('disinfectRun', '0')
        this.HEPA = storage.get('windRun', '0')

        let user = await db.getCount('user')
        this.person = user[0].num
        let log = await db.getCount('log')
        this.log = log[0].num
        let endo = await db.getCount('endo')
        this.endo = endo[0].num
    },
    methods: {
        back() {
            uni.navigateBack({
                delta: 1
            })
        }
    },

}
</script>

<style scoped>
.page{
	background: transparent;
    height: 100%;
}
.content{
	margin: 20px;
    height: 100%;
    background: #2F3242;
    border-radius: 10px;
    padding: 20px 40px;
    color: #747A8D;
    font-size: 18px;
    text-align: left;
    line-height: 2em;
}
</style>