TraceabilityAPP/pages/index/massif.vue

943 lines
19 KiB
Vue

<template>
<view class="" style="position: relative;">
<view class="top">
<!-- 17828474084 -->
<view class="" style="height:var(--status-bar-height) ;">
</view>
<view class="nav-con" style="justify-content: space-between;">
<view class="" v-if="Object.keys(dataobj).length>0"
style="padding-left: 20rpx;display: flex;color: white;" @click="show=true">
<u--image :src="u('qhtd')" width="38.55rpx" @click="scanFn" height="38.55rpx"
style="margin-right: 20rpx;"></u--image>
{{dataobj.title}}
</view>
<view class="" style="display: flex;align-items: center;">
<view class="nav">
<view class="" style="margin-right: 20rpx;">
<!-- <u-icon name="scan" @click="scanFn" color="white" :size="30"></u-icon> -->
<u--image :src="u('sys')" width="38.55rpx" @click="scanFn" height="38.55rpx"></u--image>
</view>
<view class="" style="margin-left: 20rpx;">
<!-- <u-icon name="coupon-fill" color="white" @click="showModal=true" :size="28"></u-icon> -->
<u--image :src="u('sbbd')" width="38.55rpx" @click="showModal=true"
height="38.55rpx"></u--image>
</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 class="" style="margin-top: -5rpx;">
<Myindex url='/pages/index/massif' />
</view>
</view>
</view>
</view>
<view class="">
<view class="" style="height:var(--status-bar-height) ;">
</view>
<view class="nav-con" style="margin-bottom: 80rpx;">
</view>
</view>
<view class="content" v-if="true">
<!-- 土地信息 -->
<view class="">
<view class="empty-land" v-if="Object.keys(dataobj).length<=0">
<text>没有土地信息?</text>
<text @click="navto('/pages/addLand/addLand')">去新增》</text>
</view>
<view class="land-info">
<view class="land-area">
土地面积
<view class="">
{{dataobj.total_area|| "--"}}亩
</view>
</view>
<view class="plant-area">
种植面积
<view class="">
{{dataobj.total_area-dataobj.residual_area||"--"}}亩
</view>
</view>
</view>
<view v-if="(dataobj.total_area-dataobj.residual_area)==0" @click="palnt(dataobj.id)">
<view class="empty-land" style="background-image: url('static/main/index/xzzh.png');">
<text></text>
<text @click="navto('/pages/addLand/addLand')">去新增》</text>
</view>
</view>
<view class="note" v-else>
<u--image v-if="columns2[0]&&columns2[0].length>0" @click="showPicker1=true" :src="u('qtj')"
click="showPicker1=true" width="170rpx" height="40rpx"
style="position: absolute;right: 80rpx;top: 80rpx;"></u--image>
</view>
<view class="live-tit" style="color: #1A1A1A;">
<view class="tit" style="">
苗情检测视频
</view>
<view class="" style="font-size: 24rpx;color: #ACACAC;display: flex;align-items: center;">
<u-icon name="clock" style="margin-right: 5rpx;"></u-icon> 刷新时间:{{getNowTimeFn()}}
</view>
</view>
<view class="live">
<u--image :src="u('K')" width="100%"></u--image>
</view>
<view class="">
<view class="tit">
土壤检测信息
</view>
<view class="area-check">
<view class="area-li" v-for="(item,index) in soilList" key="index"
:style="{backgroundImage:`url(${bgc(item.icon)})`}">
<view class="">
{{item.name}}
</view>
<view class="" style="color:#73DFB2">
{{ item.num?item.num+item.unit:'--' }}
</view>
</view>
</view>
</view>
<view class="">
<view class="tit">
环境检测信息
</view>
<view class="area-check">
<view class="area-li" v-for="(item,index) in environmentList" key="index"
:style="{backgroundImage:`url(${bgc(item.icon)})`}">
<view class="">
{{item.name}}
</view>
<view class="" style="color:#73DFB2">
{{ item.num?item.num+item.unit:'--' }}
</view>
</view>
</view>
</view>
<!-- old -->
<!-- <view class="card" v-if="Object.keys(dataobj).length>0">
<view class="" @click="navgo">
<view class="" style="margin: 10rpx 0;">
土地名称: {{dataobj.title}}
</view>
<view class="" style="margin: 10rpx 0;">
土地面积: {{dataobj.total_area}}亩
</view>
<view class="" style="margin: 10rpx 0;">
种植面积: {{dataobj.total_area-dataobj.residual_area}}亩
</view>
</view>
<view class="changeLand" @click="show=true">
切换土地
</view>
</view>
<view class="card" v-else>
<view class="">
<view class="">
暂无信息
</view>
</view>
</view> -->
</view>
<!-- <view class="add-thing" v-if="(dataobj.total_area-dataobj.residual_area)==0" @click="palnt(dataobj.id)">
新增种植
</view>
<view class="" v-else>
<view class="add-thing" @click="showPicker1=true" v-if="columns2[0]&&columns2[0].length>0">
记农事
</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-swiper :list="dataobj.pic" width="100%" height="300rpx"></u-swiper>
</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="closeModal" :round="10">
<view class="Modal">
<text> 产品编号:</text>
<uni-data-select v-model="equipmentId" style="width: 300rpx;margin-left: 30rpx;"
:localdata="range"></uni-data-select>
</view>
<view class="Modal-btn">
<view class="Modal-btna" @click="closeModal">
取消
</view>
<view class="Modal-btnb" @click="bindFn">
确定
</view>
</view>
</u-popup>
</view>
<u-picker keyName="name" :show="showPicker1" @cancel="showPicker1=false" @confirm="confirm1"
:columns="columns2"></u-picker>
<u-picker keyName="label" :show="showPicker" @cancel="showPicker=false" @confirm="confirm2"
:columns="columns1"></u-picker>
</view>
</template>
<script setup>
import {
reactive,
ref
} from 'vue';
import {
onLoad,
onShow
} from "@dcloudio/uni-app"
import Myindex from '@/components/return/index.vue';
import {
bindproduct,
lindexist,
landlist,
plantlist,
landproduct
} from '@/api/api.js'
import store from "@/store/index.js"
const showPicker = ref(false)
const showPicker1 = ref(false)
const showModal = ref(false)
const columns1 = reactive([
[{
label: '施肥',
route: "/pages/husbandryForm/fertilize"
}, {
label: '除草',
route: "/pages/husbandryForm/weeding"
}, {
label: '灌溉',
route: "/pages/husbandryForm/irrigate"
}, {
label: '除虫',
route: "/pages/husbandryForm/Pest"
}, {
label: '收获',
route: "/pages/husbandryForm/harvest"
}]
]);
const columns2 = reactive([])
const range = reactive([])
// 土壤监测数据
const url = ref('https://ceshi-worker-task.lihaink.cn//uploads//images//20231121//202311211336582b7920656.jpg')
const soilList = reactive([{
icon: "trwd",
name: "土壤温度",
num: 0,
unit: "℃",
}, {
icon: "trsd",
name: "土壤湿度",
num: 0,
unit: "%RH",
}, {
icon: "trddl",
name: "土壤导电率",
num: 0,
unit: "μS/cm",
}, {
icon: "trph",
name: "土壤PH值",
num: 0,
unit: "PH",
}, {
icon: "trhdl",
name: "土壤含氮量",
num: 0,
unit: "mg/kg",
}, {
icon: "trhll",
name: "土壤含磷量",
num: 0,
unit: "mg/kg",
}, {
icon: "trhjl",
name: "土壤含钾量",
num: 0,
unit: "mg/kg",
},
])
onLoad(() => {
// console.log(store.state.userInfo)
if (!store.state.userInfo) {
uni.redirectTo({
url: '/pages/Login/login'
})
}
})
const dataobj = reactive({})
const tdId = ref('')
const palntId = 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.split('='));
uni.navigateTo({
url: '/pages/landDetail/results?id=' + res.result.split('=')[1]
})
}
});
}
const show = ref(false)
const showLoading = ref(false)
const columns = reactive([]);
// 环境监测数据
const environmentList = reactive([{
icon: "FS",
name: "风速",
num: 0,
unit: "%",
}, {
icon: "FX",
name: "风向",
num: 0,
unit: "%",
}, {
icon: "WD1",
name: "温度",
num: 0,
unit: "℃",
}, {
icon: "SD",
name: "湿度",
num: 0,
unit: "%RH",
}, {
icon: 'eyht',
name: "二氧化碳",
num: 0,
unit: "ppm",
}, {
icon: "QY",
name: "气压",
num: 0,
unit: "KPa",
}, {
icon: "YL",
name: "雨量",
num: 0,
unit: "mm",
}, {
icon: "GZ",
name: "光照量",
num: 0,
unit: "Lux",
},
])
onShow(() => {
getlist()
getlist1()
getlist2()
})
const bgc = (icon) => {
return `/static/main/index/${icon}.png`
}
//列表获取
const getlist = () => {
lindexist({
land_id: tdId.value
}).then((res) => {
if (res.code == 1) {
if (Object.keys(res.data).length > 0) {
getlist3(res.data.id)
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) {
range.splice(0, range.length, ...res.data.map((step, index) => {
return {
text: step.name,
value: step.product_id,
};
}));
// console.log(res)
}
})
}
const getlist3 = (id) => {
plantlist({
land_id: id
}).then((res) => {
if (res.code == 1) {
columns2.splice(0)
let arr1 = []
arr1.splice(0, arr1.length, ...res.data.map((step, index) => {
return {
name: step.kind + '-' + step.id,
id: step.id,
status: step.status
};
}));
columns2.push(arr1)
}
})
}
//关闭弹窗
const closeModal = () => {
showModal.value = false
equipmentId.value = ''
}
//绑定产品
const biproduct = () => {
if (equipmentId.value) {
bindproduct({
land_id: dataobj.id,
product_id: equipmentId.value
}).then((res) => {
if (res.code == 1) {
uni.$u.toast(res.msg);
// this.dataobj=res.data
equipmentId.value = ''
}
console.log(res)
})
} else {
uni.$u.toast('请选择产品编号');
}
}
const confirm2 = (e) => {
showPicker.value = false
uni.navigateTo({
url: e.value[0].route + '?id=' + palntId.value
})
}
const confirm1 = (e) => {
palntId.value = e.value[0].id
showPicker1.value = false
if (e.value[0].status == 2) {
uni.$u.toast('该土地已经收获,不能进行操作');
} else {
showPicker.value = true
}
}
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 palnt = (id) => {
uni.navigateTo({
url: '/pages/husbandryForm/sow?id=' + id
})
}
const navto = (url) => {
uni.navigateTo({
url
})
}
getNowTimeFn()
const u = (name) => {
return `/static/main/index/${name}.png`
}
</script>
<style lang="scss">
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;
}
}
.add-thing {
width: 266.36rpx;
height: 66.59rpx;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
border: 1px solid $theme-main-color;
margin: 20rpx auto;
line-height: 66rpx;
text-align: center;
color: $theme-main-color;
}
.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-con {
display: flex;
padding-top: 20rpx;
padding-bottom: 10rpx;
}
.nav {
display: flex;
padding-right: 20rpx;
padding-left: 10rpx;
}
.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;
// .land.land-info
.land-info {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
.land-area {
width: 340rpx;
height: 120rpx;
// background-color: red;
background-image: url('/static/main/index/tdmj.png');
background-size: 100% 100%;
text-align: center;
padding-top: 20rpx;
box-shadow: 1rpx 1rpx 10rpx 1rpx rgba(0, 0, 0, 0.1);
}
.plant-area {
width: 340rpx;
height: 120rpx;
background-image: url('/static/main/index/zzmj.png');
background-size: 100% 100%;
text-align: center;
padding-top: 20rpx;
box-shadow: 1rpx 1rpx 10rpx 1rpx rgba(0, 0, 0, 0.1);
}
}
.live-tit {
display: flex;
justify-content: space-between;
align-items: center;
}
.live {
width: 100%;
height: 447rpx;
margin-bottom: 20rpx;
// background-color: red;
}
}
.note {
height: 168rpx;
background-image: url('/static/main/index/JNS.png');
background-size: 100% 100%;
margin-bottom: 20rpx;
position: relative;
}
.area-check {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.area-li {
width: 335rpx;
height: 200rpx;
border-radius: 10rpx;
background-size: 100% 100%;
margin-bottom: 20rpx;
padding: 45rpx 30rpx;
}
}
.tit {
position: relative;
padding-left: 20rpx;
font-weight: bold;
margin-bottom: 20rpx;
}
.tit::before {
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
width: 3px;
/* 左边框的宽度 */
height: 30rpx;
background-color: #34D08D;
}
// old
.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;
}
}
}
.empty-land {
width: 690rpx;
height: 135rpx;
color: #74A0EA;
text-align: center;
background-image: url('../../static/main/index/xz.png');
background-size: 100% 100%;
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 200rpx;
padding-right: 10rpx;
}
</style>