mkm
/
yanzhiAPP
Template
2
0
Fork 0
yanzhiAPP/pages/index/massif.vue

663 lines
13 KiB
Vue

<template>
<view class="" style="position: relative;">
<view class="top">
<view class="" style="height:var(--status-bar-height) ;">
</view>
<view class="nav">
<view class="">
<u-icon name="scan" @click="scanFn" color="white" :size="30"></u-icon>
</view>
<view class="" style="margin-left: 20rpx;">
<u-icon name="coupon-fill" color="white" @click="showModal=true" :size="28"></u-icon>
</view>
<view class="" style="margin-left: 20rpx;">
<u-icon name="plus-circle" color="white" @click="navto('/pages/addLand/addLand')"
:size="28"></u-icon>
</view>
</view>
</view>
<view class="">
<view class="" style="height:var(--status-bar-height) ;">
</view>
<view class="nav">
</view>
</view>
<view class="content" v-if="true">
<!-- 土地信息 -->
<view class="">
<view class="card" v-if="Object.keys(dataobj).length>0">
<view class="" @click="navgo">
<view class="">
土地名称: {{dataobj.title}}
</view>
<!-- <view class="" style="margin: 10rpx 0;">
农作物: 洋芋
</view> -->
<view class="">
土地面积: {{dataobj.total_area}}亩
</view>
<view class="">
种植面积: {{dataobj.total_area-dataobj.residual_area}}亩
</view>
</view>
<view class="changeLand" @click="show=true">
切换土地
</view>
</view>
<view class="card" v-else>
<view class="" @click="navgo">
<view class="">
暂无信息
</view>
</view>
</view>
</view>
<!-- 苗情监测 -->
<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>
<view class="video" @click="navto('/pages/live/live')">
<!-- <u--image :src="url" width="100%" height="300rpx"></u--image> -->
<u-swiper :list="dataobj.pic" width="100%" height="300rpx"></u-swiper>
</view>
</view>
<!-- 土壤监测 -->
<view class="" v-if="dataobj&&dataobj.monitor&&dataobj.monitor.length>0">
<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>
</view>
<view class="num">
<text style="font-size: 70rpx;">{{item.num}}</text>
<text>{{item.unit}}</text>
</view>
</view>
</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 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>
</view>
<view class="num">
<text style="font-size: 70rpx;">{{item.num}}</text>
<text>{{item.unit}}</text>
</view>
</view>
</view>
</view>
</view>
<view class="coneng-detail" v-else>
<view class="">
<image src="@/static/img/zw.png" mode="aspectFit"></image>
<view class="">
暂无数据
</view>
</view>
</view>
<!-- 组件 -->
<u-loading-page :loading="showLoading"></u-loading-page>
<u-action-sheet :show="show" keyName="name" closeOnClickOverlay :actions="columns" title="请选择"
@close="show = false" @select="confirm">
</u-action-sheet>
</view>
<view class="empty" v-else>
<view class="addLand">
<view class="">
你还没有土地信息
</view>
<view class="addBtn" @click="navto('/pages/addLand/addLand')">
去添加
</view>
</view>
</view>
<!-- 组件 -->
<view class="Modal">
<u-popup :show="showModal" mode="center" @close="showModal=false" :round="10">
<view class="Modal">
<text> 产品编号:</text>
<uni-data-select v-model="equipmentId" :disabled="mode=='detail'"
style="width: 300rpx;margin-left: 30rpx;" :localdata="range"></uni-data-select>
</view>
<view class="Modal-btn">
<view class="Modal-btna" @click="showModal=false">
取消
</view>
<view class="Modal-btnb" @click="bindFn">
确定
</view>
</view>
</u-popup>
</view>
</view>
</template>
<script setup>
import {
reactive,
ref
} from 'vue';
import {
onLoad
} from "@dcloudio/uni-app"
import {
bindproduct,
lindexist,
landlist,
landproduct
} from '@/api/file.js'
const showModal = ref(false)
const range = reactive([{
value: 0,
text: "喷灌"
},
{
value: 1,
text: "滴灌"
},
{
value: 2,
text: "沟灌"
},
])
// 土壤监测数据
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: "℃",
}, {
icon: "/static/img/sj.png",
name: "土壤湿度",
num: 20,
unit: "%RH",
}, {
icon: "/static/img/sj.png",
name: "土壤导电率",
num: 20,
unit: "μS/cm",
}, {
icon: "/static/img/sj.png",
name: "土壤PH值",
num: 20,
unit: "PH",
}, {
icon: "/static/img/sj.png",
name: "土壤含氮量",
num: 20,
unit: "mg/kg",
}, {
icon: "/static/img/sj.png",
name: "土壤含磷量",
num: 20,
unit: "mg/kg",
}, {
icon: "/static/img/sj.png",
name: "土壤含钾量",
num: 20,
unit: "mg/kg",
},
])
const dataobj = reactive({})
const tdId = ref('')
// 绑定设备
const equipmentId = ref("")
const bindFn = () => {
biproduct()
showModal.value = false
}
// 扫码
const scanFn = () => {
uni.scanCode({
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
}
});
}
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: "%RH",
}, {
icon: "/static/img/sj.png",
name: "二氧化碳",
num: 20,
unit: "ppm",
}, {
icon: "/static/img/sj.png",
name: "气压",
num: 20,
unit: "KPa",
}, {
icon: "/static/img/sj.png",
name: "雨量",
num: 20,
unit: "mm",
}, {
icon: "/static/img/sj.png",
name: "光照量",
num: 20,
unit: "Lux",
},
])
onLoad(() => {
getlist()
getlist1()
getlist2()
})
//列表获取
const getlist = () => {
lindexist({
land_id: tdId.value
}).then((res) => {
if (res.code == 1) {
Object.assign(dataobj, res.data);
if (res.data && res.data.monitor && res.data.monitor.soil_monitor_data) {
soilList[0].num = res.data.monitor.soil_monitor_data.temperature
soilList[1].num = res.data.monitor.soil_monitor_data.moisture
soilList[2].num = res.data.monitor.soil_monitor_data.conductivity
soilList[3].num = res.data.monitor.soil_monitor_data.ph
soilList[4].num = res.data.monitor.soil_monitor_data.n_content
soilList[5].num = res.data.monitor.soil_monitor_data.p_content
soilList[6].num = res.data.monitor.soil_monitor_data.k_content
}
if (res.data && res.data.monitor && res.data.monitor.air_monitor_data) {
environmentList[0].num = res.data.monitor.air_monitor_data.wind_speed
environmentList[1].num = res.data.monitor.air_monitor_data.wind_direction
environmentList[2].num = res.data.monitor.air_monitor_data.temperature
environmentList[3].num = res.data.monitor.air_monitor_data.moisture
environmentList[4].num = res.data.monitor.air_monitor_data.co2_content
environmentList[5].num = res.data.monitor.air_monitor_data.pressure
environmentList[6].num = res.data.monitor.air_monitor_data.rainfall
environmentList[7].num = res.data.monitor.air_monitor_data.light_intensity
}
}
})
}
const getlist1 = () => {
landlist({
page_no: 1,
page_size: 99995,
keyword: ''
}).then((res) => {
if (res.code == 1) {
if (res.data.length > 0) {
columns.splice(0, columns.length, ...res.data.map((step, index) => {
return {
name: step.title,
id: step.id,
};
}));
}
}
})
}
const getlist2 = () => {
landproduct().then((res) => {
if (res.code == 1) {
console.log(res)
}
})
}
const biproduct = () => {
bindproduct({
land_id: '2222',
product_id: equipmentId.value
}).then((res) => {
if (res.code == 1) {
uni.$u.toast(res.msg);
// this.dataobj=res.data
}
console.log(res)
})
}
const confirm = (e) => {
// console.log(e)
tdId.value = e.id
getlist()
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 navgo = () => {
uni.navigateTo({
url: '/pages/landDetail/index?id=' + dataobj.id
})
}
const navto = (url) => {
uni.navigateTo({
url
})
}
getNowTimeFn()
</script>
<style lang="scss" scoped>
page {
background-color: $theme-bg-color;
}
.top {
background-color: #34D190;
position: fixed;
z-index: 999999;
width: 750rpx;
}
.coneng-detail {
width: 478rpx;
height: 341rpx;
background: #FFFFFF;
border-radius: 6px 6px 6px 6px;
opacity: 1;
font-size: 25rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #737373;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
margin: 70rpx auto;
image {
width: 280rpx;
height: 142rpx;
margin-bottom: 20rpx;
}
}
.Modal {
padding: 60rpx 40rpx;
display: flex;
text {
margin-top: 5rpx;
}
.Modal-btn {
display: flex;
justify-content: space-around;
padding-bottom: 20rpx;
.Modal-btna {
width: 120rpx;
height: 60rpx;
line-height: 60rpx;
font-size: 25rpx;
background-color: #e5e0d8;
text-align: center;
border-radius: 30rpx;
color: #fff;
}
.Modal-btnb {
width: 120rpx;
height: 60rpx;
line-height: 60rpx;
font-size: 25rpx;
background-color: #34D190;
text-align: center;
border-radius: 30rpx;
color: #fff;
}
}
}
.uni-select__selector {
z-index: 9999 !important;
}
.nav {
height: 70rpx;
display: flex;
justify-content: flex-end;
box-sizing: border-box;
align-items: center;
padding-right: 40rpx;
}
.card {
display: flex;
justify-content: space-between;
.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;
padding: 0 30rpx;
padding-top: 20rpx;
box-sizing: border-box;
}
.soil-monitor {
margin-top: 40rpx;
.head {
.tit {
font-size: 33.29rpx;
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;
.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;
}
}
}
}
.video {
margin-top: 20rpx;
width: 100%;
height: 300rpx;
}
.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;
}
}
}
</style>