TraceabilityAPP/pages/detail/plant.vue

405 lines
6.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="content">
</view>
</template>
<script setup>
import {
landInfoAPI,
addLandCropPicAPI,
landCropRecordListAPI,
landEnvDataCurrAPI,
setLandCropRipeAPI,
ediLandCropRecordAPI,
landCropAllRipeAPI
} from "@/api/plant.js"
import myTable from "@/components/myTable/index.vue"
import imgCard from "@/components/imgCard.vue"
import uplodeImg from "@/utils/uplodeImg.js"
import landInfo from "@/components/plant/landInfo.vue"
import {
actionsAPI
} from "@/api/animal.js"
import {
ref,
reactive
} from "vue"
import {
onLoad,
onShow
} from "@dcloudio/uni-app"
const crop_yield = ref("")
const showPop = ref(false)
const tableDate = reactive({})
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',
},
], )
const baseData = reactive({})
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)
onLoad(async (options) => {
land_id.value = options.land_id
let res = await landInfoAPI({
user_id: 307,
land_id: options.land_id
})
objFn(res.data, landDeatil)
// let res2 = await landCropRecordListAPI({
// crop_id: landDeatil.crop_id
// })
let res2 = await actionsAPI({
type: 1,
crop_id: landDeatil.crop_id
})
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)
})
})
}
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 `
}
const markFn = () => {
setLandCropRipeAPI({
crop_id: landDeatil.crop_id,
crop_yield: Number(crop_yield.value)
}).then(res => {
showPop.value = false
})
}
const objFn = (res, data) => {
for (let key in res) {
data[key] = res[key]
}
}
const allripeFn = () => {
landCropAllRipeAPI({
crop_id: crop_id.value
})
uni.navigateTo({
url: '/pages/index/index'
})
}
// actionsAPI({
// type: 1
// }).then(res => {
// for (let key in res.data) {
// actionList[key] = (res.data)[key]
// }
// })
</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;
}
}
.grow-record-tit {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
align-items: center;
font-size: 26.29rpx;
.updata-btn {
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;
}
}
.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);
}
.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;
}
}
.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;
}
}
</style>