cultivationApp/pages/index/index.vue

436 lines
8.7 KiB
Vue
Raw Normal View History

2023-10-17 11:00:41 +08:00
<template>
2023-11-21 18:54:33 +08:00
<view class="" style="position: relative;">
<view class="top">
2023-11-22 14:08:24 +08:00
<view class="" style="height:var(--status-bar-height) ;">
</view>
<view class="nav">
<view class="">
2023-11-22 14:28:54 +08:00
<u-icon name="scan" @click="scanFn" color="white" :size="30"></u-icon>
2023-11-22 14:08:24 +08:00
</view>
<view class="" style="margin-left: 20rpx;">
2023-11-22 14:28:54 +08:00
<u-icon name="coupon-fill" color="white" @click="showModal=true" :size="28"></u-icon>
2023-11-22 14:08:24 +08:00
</view>
2023-11-22 14:28:54 +08:00
<view class="" style="margin-left: 20rpx;">
<u-icon name="plus-circle" color="white" @click="navto('/pages/addLand/addLand')"
:size="28"></u-icon>
</view>
2023-10-20 18:45:15 +08:00
</view>
2023-11-21 18:54:33 +08:00
</view>
2023-11-22 14:08:24 +08:00
<view class="">
<view class="" style="height:var(--status-bar-height) ;">
</view>
<view class="nav">
</view>
2023-11-21 18:54:33 +08:00
</view>
2023-11-22 14:08:24 +08:00
<view class="content" v-if="true">
2023-11-21 18:54:33 +08:00
<!-- 土地信息 -->
<view class="">
<view class="card">
<view class="">
<view class="">
土地名称: 土地信息1
</view>
<view class="" style="margin: 10rpx 0;">
农作物: 洋芋
</view>
<view class="">
面积: 20
</view>
2023-10-20 18:45:15 +08:00
</view>
2023-11-21 18:54:33 +08:00
<view class="changeLand" @click="show=true">
切换土地
</view>
2023-10-20 18:45:15 +08:00
</view>
</view>
2023-11-21 18:54:33 +08:00
<!-- 苗情监测 -->
<view class="">
<view class="live-video soil-monitor">
<view class="head">
<view class="tit">
苗情监测数据
</view>
<view class="flushed-time">
<u-icon name="clock"></u-icon>
<text>刷新时间: {{getNowTimeFn()}} </text>
</view>
</view>
</view>
2023-11-22 14:08:24 +08:00
<view class="video" @click="navto('/pages/live/live')">
2023-11-21 18:54:33 +08:00
<u--image :src="url" width="100%" height="300rpx"></u--image>
</view>
</view>
<!-- 土壤监测 -->
<view class="soil-monitor">
<view class="head">
<view class="tit">
土壤监测数据
</view>
<view class="flushed-time">
<u-icon name="clock"></u-icon>
<text>刷新时间: {{getNowTimeFn()}} </text>
</view>
</view>
<view class="monitor-content">
<view class="monitor-card" v-for="(item,index) in soilList" :key="index">
<view class="name">
<view class="">
<u--image :src="item.icon" width="38.55rpx" height="38.55rpx"></u--image>
</view>
<view class="" style="margin-left: 10rpx;">
{{item.name}}
</view>
2023-10-20 18:45:15 +08:00
2023-11-21 18:54:33 +08:00
</view>
<view class="num">
<text style="font-size: 70rpx;">{{item.num}}</text>
<text>{{item.unit}}</text>
</view>
</view>
</view>
2023-10-20 18:45:15 +08:00
</view>
2023-11-21 18:54:33 +08:00
<!-- 环境监测 -->
<view class="soil-monitor">
<view class="head">
<view class="tit">
环境监测数据
</view>
<view class="flushed-time">
<u-icon name="clock"></u-icon>
<text>刷新时间: {{getNowTimeFn()}} </text>
</view>
</view>
<view class="monitor-content">
<view class="monitor-card" v-for="(item,index) in environmentList" :key="index">
<view class="name">
<view class="">
<u--image :src="item.icon" width="38.55rpx" height="38.55rpx"></u--image>
</view>
<view class="" style="margin-left: 10rpx;">
{{item.name}}
</view>
2023-10-20 18:45:15 +08:00
2023-11-21 18:54:33 +08:00
</view>
<view class="num">
<text style="font-size: 70rpx;">{{item.num}}</text>
<text>{{item.unit}}</text>
</view>
</view>
</view>
2023-10-20 18:45:15 +08:00
</view>
2023-11-21 18:54:33 +08:00
<!-- 组件 -->
<u-loading-page :loading="showLoading"></u-loading-page>
<u-picker :show="show" :columns="columns" @cancel="show=false" @confirm="confirm"></u-picker>
2023-10-21 18:02:06 +08:00
2023-11-21 18:54:33 +08:00
</view>
<view class="empty" v-else>
<view class="addLand">
<view class="">
你还没有土地信息
</view>
<view class="addBtn" @click="navto('/pages/addLand/addLand')">
去添加
</view>
</view>
</view>
2023-11-22 14:28:54 +08:00
<!-- 组件 -->
2023-10-23 17:57:19 +08:00
2023-11-22 14:28:54 +08:00
<view class="">
<u-modal title="绑定设备" :show="showModal" @confirm='bindFn' @cancel="showModal=false" :showCancelButton='true'
:closeOnClickOverlay="true" @close="showModal=false" :title="title">
<view class="slot-content">
<view class="" style="display: flex;align-items: center;">
设备编号: <up-input style="margin-left: 20rpx;" placeholder="请输入设备编号" border="surround"
v-model="equipmentId"></up-input>
</view>
</view>
</u-modal>
</view>
2023-10-17 11:00:41 +08:00
</view>
</template>
2023-10-17 16:02:55 +08:00
<script setup>
import {
2023-10-20 18:45:15 +08:00
reactive,
2023-10-17 16:02:55 +08:00
ref
} from 'vue';
import {
onLoad
} from "@dcloudio/uni-app"
2023-11-22 14:28:54 +08:00
const showModal = ref(false)
2023-11-21 18:54:33 +08:00
// 土壤监测数据
const url = ref('https://ceshi-worker-task.lihaink.cn//uploads//images//20231121//202311211336582b7920656.jpg')
const soilList = reactive([{
icon: "/static/img/sj.png",
name: "土壤温度",
num: 20,
unit: "%",
2023-10-27 19:26:03 +08:00
2023-11-21 18:54:33 +08:00
}, {
icon: "/static/img/sj.png",
name: "土壤湿度",
num: 20,
unit: "%",
2023-10-27 19:26:03 +08:00
2023-11-21 18:54:33 +08:00
}, {
icon: "/static/img/sj.png",
name: "土壤导电率",
num: 20,
unit: "%",
2023-10-25 19:55:18 +08:00
2023-11-21 18:54:33 +08:00
}, {
icon: "/static/img/sj.png",
name: "土壤PH值",
num: 20,
unit: "",
2023-10-30 19:09:40 +08:00
2023-11-21 18:54:33 +08:00
}, {
icon: "/static/img/sj.png",
name: "土壤含氮量",
num: 20,
unit: "",
}, {
icon: "/static/img/sj.png",
name: "土壤含磷量",
num: 20,
unit: "",
}, {
icon: "/static/img/sj.png",
name: "土壤含钾量",
num: 20,
unit: "",
},
])
2023-11-22 14:28:54 +08:00
// 绑定设备
const equipmentId = ref("")
const bindFn = () => {
showModal.value = false
}
// 扫码
const scanFn = () => {
uni.scanCode({
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
}
});
}
2023-11-21 18:54:33 +08:00
const show = ref(false)
const showLoading = ref(false)
const columns = reactive([
['中国', '美国', '日本']
]);
// 环境监测数据
const environmentList = reactive([{
icon: "/static/img/sj.png",
name: "风速",
num: 20,
unit: "%",
}, {
icon: "/static/img/sj.png",
name: "风向",
num: 20,
unit: "%",
}, {
icon: "/static/img/sj.png",
name: "温度",
num: 20,
unit: "%",
}, {
icon: "/static/img/sj.png",
name: "湿度",
num: 20,
unit: "",
}, {
icon: "/static/img/sj.png",
name: "二氧化碳",
num: 20,
unit: "",
}, {
icon: "/static/img/sj.png",
name: "气压",
num: 20,
unit: "",
}, {
icon: "/static/img/sj.png",
name: "雨量",
num: 20,
unit: "",
}, {
icon: "/static/img/sj.png",
name: "光照量",
num: 20,
unit: "",
},
])
const confirm = (e) => {
console.log(e)
show.value = false
showLoading.value = true
setTimeout(() => {
showLoading.value = false
}, 1000)
}
const getNowTimeFn = () => {
const now = new Date();
const hour = now.getHours();
const minute = now.getMinutes();
const formattedHour = hour < 10 ? '0' + hour : hour;
const formattedMinute = minute < 10 ? '0' + minute : minute;
const currentTime = formattedHour + ':' + formattedMinute;
return currentTime
}
const navto = (url) => {
uni.navigateTo({
url
})
}
getNowTimeFn()
2023-10-20 18:45:15 +08:00
</script>
2023-11-21 18:54:33 +08:00
<style lang="scss" scoped>
.top {
2023-10-20 18:45:15 +08:00
background-color: #34D190;
position: fixed;
2023-11-21 18:54:33 +08:00
z-index: 999999;
width: 750rpx;
2023-11-22 14:08:24 +08:00
}
.nav {
height: 70rpx;
display: flex;
justify-content: flex-end;
box-sizing: border-box;
align-items: center;
padding-right: 40rpx;
2023-11-21 18:54:33 +08:00
}
2023-10-17 16:02:55 +08:00
2023-11-21 18:54:33 +08:00
.card {
display: flex;
justify-content: space-between;
2023-10-20 18:45:15 +08:00
2023-11-21 18:54:33 +08:00
.changeLand {
width: 200rpx;
height: 70rpx;
line-height: 70rpx;
text-align: center;
border-radius: 30rpx;
background-color: $theme-main-color;
color: white;
}
}
.content {
min-height: 92vh;
background-color: $theme-bg-color;
padding: 0 30rpx;
padding-top: 20rpx;
box-sizing: border-box;
}
.soil-monitor {
margin-top: 40rpx;
.head {
2023-10-20 18:45:15 +08:00
2023-11-21 18:54:33 +08:00
.tit {
2023-10-20 18:45:15 +08:00
font-size: 33.29rpx;
2023-11-21 18:54:33 +08:00
color: black;
}
.flushed-time {
display: flex;
font-size: 26.29rpx;
color: #737373;
margin-top: 10rpx;
}
}
.monitor-content {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
2023-10-20 18:45:15 +08:00
2023-11-21 18:54:33 +08:00
.monitor-card {
margin-top: 20rpx;
background-color: white;
padding: 30rpx 20rpx;
border-radius: 30rpx;
width: 332.94rpx;
box-sizing: border-box;
height: 212.03rpx;
.name {
font-size: 29.79rpx;
display: flex;
align-items: center;
}
.num {
margin-top: 30rpx;
color: $theme-main-color;
}
2023-10-20 18:45:15 +08:00
}
2023-11-21 18:54:33 +08:00
2023-10-20 18:45:15 +08:00
}
2023-11-21 18:54:33 +08:00
}
2023-10-17 11:00:41 +08:00
2023-11-21 18:54:33 +08:00
.video {
margin-top: 20rpx;
width: 100%;
height: 300rpx;
2023-10-17 11:00:41 +08:00
}
2023-10-21 18:02:06 +08:00
2023-11-21 18:54:33 +08:00
.empty {
height: 100vh;
background-color: $theme-bg-color;
position: relative;
.addLand {
width: auto;
height: 100rpx;
color: grey;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
.addBtn {
margin-top: 20rpx;
width: 250rpx;
height: 70rpx;
border: 1px solid $theme-main-color;
line-height: 70rpx;
border-radius: 50rpx;
text-align: center;
}
}
2023-10-21 18:02:06 +08:00
}
2023-10-20 18:45:15 +08:00
</style>