TraceabilityAPP/pages/detail/plant.vue

405 lines
6.9 KiB
Vue
Raw Normal View History

2023-10-20 18:45:15 +08:00
<template>
<view class="content">
2023-10-21 18:02:06 +08:00
2023-10-20 18:45:15 +08:00
2023-10-31 18:40:32 +08:00
2023-11-21 18:54:33 +08:00
2023-10-20 18:45:15 +08:00
</view>
</template>
2023-10-25 19:55:18 +08:00
<script setup>
import {
landInfoAPI,
addLandCropPicAPI,
landCropRecordListAPI,
landEnvDataCurrAPI,
2023-10-28 18:28:10 +08:00
setLandCropRipeAPI,
2023-10-31 18:40:32 +08:00
ediLandCropRecordAPI,
landCropAllRipeAPI
2023-10-25 19:55:18 +08:00
} from "@/api/plant.js"
2023-10-23 17:57:19 +08:00
import myTable from "@/components/myTable/index.vue"
import imgCard from "@/components/imgCard.vue"
2023-10-25 19:55:18 +08:00
import uplodeImg from "@/utils/uplodeImg.js"
import landInfo from "@/components/plant/landInfo.vue"
2023-10-26 19:02:26 +08:00
import {
actionsAPI
} from "@/api/animal.js"
2023-10-20 18:45:15 +08:00
import {
2023-10-25 19:55:18 +08:00
ref,
reactive
} from "vue"
import {
2023-10-28 18:28:10 +08:00
onLoad,
onShow
2023-10-25 19:55:18 +08:00
} from "@dcloudio/uni-app"
const crop_yield = ref("")
const showPop = ref(false)
2023-10-27 19:26:03 +08:00
const tableDate = reactive({})
2023-10-25 19:55:18 +08:00
const landDeatil = reactive({})
const data = reactive([{
tit: "土壤温度",
icon: 'TRWD',
dw: "℃",
cont: 'soil_temp',
flag: false,
}, {
tit: "土壤湿度",
icon: 'TRSD',
dw: "%RH",
cont: 'soil_mois',
}, {
tit: "磷含量",
icon: 'FX',
cont: 'k_content',
dw: "%",
}, {
tit: "氮含量",
icon: 'FS',
dw: "mg/l",
cont: 'n_content',
}, {
tit: "钾含量",
icon: 'JYL',
dw: "%",
cont: 'p_content',
2023-10-20 18:45:15 +08:00
},
2023-10-25 19:55:18 +08:00
], )
const baseData = reactive({})
2023-10-28 18:28:10 +08:00
const crop_id = ref(0)
const getcropidFn = (e) => {
crop_id.value = e.cropid
}
onShow(async () => {
let res = await landInfoAPI({
user_id: 307,
land_id: land_id.value
})
objFn(res.data, landDeatil)
})
const land_id = ref(0)
2023-10-25 19:55:18 +08:00
onLoad(async (options) => {
2023-10-28 18:28:10 +08:00
land_id.value = options.land_id
2023-10-25 19:55:18 +08:00
let res = await landInfoAPI({
user_id: 307,
land_id: options.land_id
})
objFn(res.data, landDeatil)
2023-10-27 19:26:03 +08:00
// let res2 = await landCropRecordListAPI({
// crop_id: landDeatil.crop_id
// })
let res2 = await actionsAPI({
2023-10-30 19:09:40 +08:00
type: 1,
crop_id: landDeatil.crop_id
2023-10-25 19:55:18 +08:00
})
objFn(res2.data, tableDate)
let res3 = await landEnvDataCurrAPI({
user_id: 307,
})
objFn(res3.data, baseData)
}, )
const updateImgFn = () => {
let image = ""
uplodeImg().then(res => {
image = res.data.image
landDeatil.pic = image
addLandCropPicAPI({
crop_id: landDeatil.crop_id,
pic: image
}).then(res2 => {
console.log(res2)
2023-10-20 18:45:15 +08:00
})
2023-10-25 19:55:18 +08:00
})
}
const navgo = (url) => {
uni.navigateTo({
url
})
}
const dateFn = () => {
var today = new Date();
// 获取年、月、日
var year = today.getFullYear();
var month = today.getMonth() + 1; // 月份从0开始需要加1
var day = today.getDate();
// 构建日期字符串
var dateStr = year + '-' + month + '-' + day;
return dateStr
// 输出日期字符串
}
const backFn = () => {
uni.navigateBack()
}
const urlFn = (name) => {
return `/static/img/${name}.png`
}
const img = (w, h, m) => {
return `width:${w}rpx;height:${h};margin:0 ${m}rpx `
}
2023-10-30 19:09:40 +08:00
2023-10-25 19:55:18 +08:00
const markFn = () => {
setLandCropRipeAPI({
crop_id: landDeatil.crop_id,
crop_yield: Number(crop_yield.value)
2023-10-30 19:09:40 +08:00
}).then(res => {
showPop.value = false
2023-10-25 19:55:18 +08:00
})
}
const objFn = (res, data) => {
for (let key in res) {
data[key] = res[key]
2023-10-20 18:45:15 +08:00
}
2023-10-25 19:55:18 +08:00
2023-10-20 18:45:15 +08:00
}
2023-10-30 19:09:40 +08:00
const allripeFn = () => {
2023-10-31 18:40:32 +08:00
landCropAllRipeAPI({
crop_id: crop_id.value
})
2023-10-30 19:09:40 +08:00
uni.navigateTo({
url: '/pages/index/index'
})
}
2023-10-27 18:38:25 +08:00
// actionsAPI({
// type: 1
// }).then(res => {
// for (let key in res.data) {
// actionList[key] = (res.data)[key]
// }
// })
2023-10-20 18:45:15 +08:00
</script>
<style lang="scss" scoped>
.content {
padding: 30rpx;
// background-color: grey;
background-color: #EBF1EF;
}
.head-img {
border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
margin: 0 auto;
position: relative;
.poisition {
opacity: 0.7;
position: absolute;
width: 380.26rpx;
height: 71rpx;
background-color: #FFFFFF;
left: 43rpx;
bottom: 36rpx;
border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
display: flex;
align-items: center;
font-size: 29.79rpx;
.dw-cls {
margin: 0 5rpx;
}
}
}
.bad-info {
display: flex;
// background-color: red;
justify-content: space-between;
align-items: center;
margin: 20rpx 0;
color: #737373;
width: 693.93rpx;
font-size: 26.29rpx;
.tit-b {
color: red;
}
}
.up-plant-btn {
width: 371.5rpx;
height: 66.59rpx;
color: #00A15E;
margin: 40rpx auto;
border: 1px solid #00A15E;
font-weight: bold;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
display: flex;
align-items: center;
justify-content: center;
}
.data {
.tit {
.tit-b {
color: #B3B3B3;
font-size: 26.29rpx;
display: flex;
align-items: center;
}
}
.data-alanys {
// background-color: blue;
float: right;
color: white;
}
.data-cont {
// margin: 20rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-top: 30rpx;
box-sizing: border-box;
// padding: 70rpx;
.data-cont-li {
border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
width: 310.94rpx;
height: 212.03rpx;
background-color: white;
margin-bottom: 20rpx;
}
}
}
.center {
display: flex;
align-items: center;
}
.b-cls {
display: flex;
align-items: flex-end;
width: 250rpx;
justify-content: space-between;
color: #4CC593;
}
.card {
.tit {
display: flex;
justify-content: space-between;
padding-bottom: 20rpx;
border-bottom: 1px solid #EBF1EF;
}
.card-li {
margin-top: 20rpx;
display: flex;
justify-content: space-between;
}
}
2023-10-23 17:57:19 +08:00
.grow-record-tit {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
align-items: center;
font-size: 26.29rpx;
2023-10-20 18:45:15 +08:00
2023-10-23 17:57:19 +08:00
.updata-btn {
width: 192.76rpx;
height: 57.83rpx;
border: 1px solid #00A15E;
color: #00A15E;
2023-10-20 18:45:15 +08:00
display: flex;
2023-10-23 17:57:19 +08:00
justify-content: center;
align-items: center;
border-radius: 31.54rpx 31.54rpx 31.54rpx 31.54rpx;
2023-10-20 18:45:15 +08:00
}
}
2023-10-23 17:57:19 +08:00
2023-10-20 18:45:15 +08:00
.ripe-btn {
width: 588.79rpx;
height: 84.11rpx;
background-color: #00A15E;
color: white;
display: flex;
justify-content: center;
align-items: center;
margin: 0 auto;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
background: linear-gradient(to right, #00A15E, #4CC593);
}
2023-10-25 19:55:18 +08:00
.mark {
// padding: 30rpx;
padding: 30rpx;
.head {
display: flex;
justify-content: space-between;
align-items: center;
}
.mark-li {
display: flex;
justify-content: space-between;
margin: 40rpx;
border-bottom: 1px solid #EBF1EF;
padding-bottom: 20rpx;
}
}
2023-10-26 19:02:26 +08:00
.circumstance {
width: 693.93rpx;
margin: 0 auto;
margin-bottom: 43rpx;
.card-tit {
display: flex;
justify-content: space-between;
margin-bottom: 28rpx;
}
.updata-btn {
font-size: 26.29rpx;
width: 192.76rpx;
height: 57.83rpx;
border: 1px solid #00A15E;
color: #00A15E;
display: flex;
justify-content: center;
align-items: center;
border-radius: 31.54rpx 31.54rpx 31.54rpx 31.54rpx;
}
.check {
font-size: 29.79rpx;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.tab {
height: 500rpx;
background-color: red;
}
}
2023-10-20 18:45:15 +08:00
</style>