This commit is contained in:
wt 2025-10-11 14:45:02 +08:00
parent d72bc9ccd8
commit 5ee3e89e0a
14 changed files with 133 additions and 51 deletions

View File

@ -25,7 +25,7 @@
"selectedIconPath": "static/img/home1.png", "selectedIconPath": "static/img/home1.png",
"pagePath": "pages/index/index", "pagePath": "pages/index/index",
"iconSize": 48, "iconSize": 48,
"text": "首页" "text": "我的花园"
}, },
{ {
"iconPath": "static/img/home.png", "iconPath": "static/img/home.png",

View File

@ -50,7 +50,6 @@ Page({
if(res.errMsg.indexOf("uploadFile:ok") > -1){ if(res.errMsg.indexOf("uploadFile:ok") > -1){
const data = JSON.parse(res.data) const data = JSON.parse(res.data)
const id = data.data.file.id const id = data.data.file.id
console.log(id);
} }
} }
}) })

View File

@ -75,7 +75,7 @@ Page({
libraryId: this.data.info.id, libraryId: this.data.info.id,
userId: user.id userId: user.id
} }
api('/plant/plantByLibrary', 'POST', data, 'json').then(res => { api('/plant/plantByLibrary', 'GET', data).then(res => {
if (res.code === 200) { if (res.code === 200) {
wx.navigateTo({ wx.navigateTo({
url: '../about/index?type=1', url: '../about/index?type=1',

View File

@ -8,8 +8,10 @@
<!-- back --> <!-- back -->
<view style="z-index: 99;position: absolute; top: 110rpx; left: -20rpx; padding: 0 32rpx; " bind:tap="goBack"> <view style="z-index: 999;position: fixed; top: 110rpx; left: 32rpx; background-color: #34343482 ; width: 60rpx ; height: 60rpx; border-radius: 30rpx; " bind:tap="goBack">
<t-icon name="chevron-left" size="58rpx" style="color: white;"></t-icon> <view class="flex flex-center" style="width: 100%;height: 100%;">
<t-icon name="chevron-left" size="48rpx" style="color: white;"></t-icon>
</view>
</view> </view>
<!-- info --> <!-- info -->

View File

@ -27,8 +27,10 @@ Page({
if (res.code === 200){ if (res.code === 200){
const tmp = res.data const tmp = res.data
tmp.farms.suitableFertilizer = tmp.farms.suitableFertilizer.split(',') tmp.farms.suitableFertilizer = tmp.farms.suitableFertilizer.split(',')
if (tmp.ossList.length >0 ){
tmp.pic = tmp.ossList[0].url
}
this.setData({info:res.data}) this.setData({info:res.data})
console.log(tmp);
} }
}) })
}, },
@ -88,6 +90,7 @@ Page({
icon:'success', icon:'success',
title: res.msg, title: res.msg,
}) })
this.fetchInfo()
}else { }else {
wx.showModal({ wx.showModal({
content: res.msg content: res.msg

View File

@ -6,7 +6,8 @@
<view class="flex flex-center flex-justify-start"> <view class="flex flex-center flex-justify-start">
<view > <view >
<view class="container"> <view class="container">
<image src="https://res.catter.cn/pub/2025/09/30/20250930143920286.png" mode="aspectFill" class="bg"></image> <image wx:if="{{info.pic}}" src="{{info.pic}}" mode="aspectFill" class="bg"></image>
<image wx:else src="https://res.catter.cn/pub/2025/09/30/20250930143920286.png" mode="aspectFill" class="bg"></image>
<view class="tips "> <view class="tips ">
<view style="background-color: #34343442;height: 100%; width: 100%" class="flex flex-center" bind:tap="upload"> <view style="background-color: #34343442;height: 100%; width: 100%" class="flex flex-center" bind:tap="upload">
<t-icon name="camera" style="color: white;" size="48rpx"></t-icon> <t-icon name="camera" style="color: white;" size="48rpx"></t-icon>

View File

@ -6,7 +6,9 @@ Page({
list:[] list:[]
}, },
onLoad(options) { onLoad(options) {
wx.setNavigationBarTitle({
title: '我的花园',
})
}, },
onShow(){ onShow(){
this.fetchList() this.fetchList()
@ -22,7 +24,12 @@ Page({
const data = {userId: user.id,current:1,pageSize:20} const data = {userId: user.id,current:1,pageSize:20}
api('/plant/getList','POST',data,'json').then(res => { api('/plant/getList','POST',data,'json').then(res => {
if (res.code === 200){ if (res.code === 200){
const tmps = res.data.list const tmps = res.data.list.map(e => {
if (e.ossList.length >0){
e.pic = e.ossList[0].url
}
return e
})
this.setData({list:tmps}) this.setData({list:tmps})
} }
}) })

View File

@ -17,7 +17,8 @@
<view class="padding"> <view class="padding">
<view wx:for="{{list}}" class="row padding mb-32" data-id="{{item.id}}" bind:tap="goInfo"> <view wx:for="{{list}}" class="row padding mb-32" data-id="{{item.id}}" bind:tap="goInfo">
<view class="flex flex-center flex-justify-start"> <view class="flex flex-center flex-justify-start">
<image class="pic" src="https://res.catter.cn/pub/2025/09/30/20250930143920286.png"></image> <image class="pic" mode="aspectFill" wx:if="{{item.pic}}" src="{{item.pic}}"></image>
<image class="pic" mode="aspectFill" wx:else src="https://res.catter.cn/pub/2025/09/30/20250930143920286.png"></image>
<view style="margin-left:16rpx"> <view style="margin-left:16rpx">
<view class="font-16 bold">{{item.name}}</view> <view class="font-16 bold">{{item.name}}</view>
<view class="font-14 grey">{{item.latinName}}</view> <view class="font-14 grey">{{item.latinName}}</view>

View File

@ -7,7 +7,8 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
id:'' id:'',
farms:[]
}, },
/** /**
@ -24,13 +25,31 @@ Page({
if (res.code === 200){ if (res.code === 200){
const tmp = res.data const tmp = res.data
tmp.farms.suitableFertilizer = tmp.farms.suitableFertilizer.split(',') tmp.farms.suitableFertilizer = tmp.farms.suitableFertilizer.split(',')
this.setData({info:res.data}) if (tmp.ossList.length >0 ){
tmp.pic = tmp.ossList[0].url
tmp.picList = tmp.ossList.map(sub => sub.url)
}
console.log(tmp); console.log(tmp);
this.setData({info:res.data})
} }
}) })
api('/plant/todayFarm',data).then(res => { api('/plant/todayFarm','GET',data).then(res => {
if (res.code === 200){ if (res.code === 200){
console.log(res); this.setData({farms:res.data})
}
})
},
addFarmLog(e){
const item = e.currentTarget.dataset.item
const data = {id:item.id,plantId:item.plantId, title:item.title,remark:'测试',status:2}
api('/plant/addRecord','POST',data,'json').then(res => {
if (res.code === 200){
wx.showToast({
icon:'success',
title: res.msg,
})
this.fetchInfo()
} }
}) })
}, },

View File

@ -1,4 +1,7 @@
{ {
"navigationStyle": "custom", "navigationStyle": "custom",
"usingComponents": {} "usingComponents": {
"t-swiper": "tdesign-miniprogram/swiper/swiper",
"t-swiper-nav": "tdesign-miniprogram/swiper-nav/swiper-nav"
}
} }

View File

@ -2,13 +2,19 @@
<view> <view>
<!-- top --> <!-- top -->
<view class="top" style="position: relative; z-index: 2;"> <view class="top" style="position: relative; z-index: 2;">
<image src="https://res.catter.cn/pub/2025/09/30/20250930150006852.png" style="width: 100vw; height: 680rpx;" mode="aspectFill"></image> <t-swiper style="width: 100vw;" height="640rpx" wx:if="{{info.pic}}" list="{{info.picList}}" >
</t-swiper>
<image wx:else="" src="https://res.catter.cn/pub/2025/09/30/20250930150006852.png" style="width: 100vw; height: 680rpx;" mode="aspectFill"></image>
</view> </view>
<!-- back --> <!-- back -->
<view style="z-index: 99;position: absolute; top: 110rpx; left: -20rpx; padding: 0 32rpx; " bind:tap="goBack"> <view style="z-index: 999;position: fixed; top: 110rpx; left: 32rpx; background-color: #34343482 ; width: 60rpx ; height: 60rpx; border-radius: 30rpx; " bind:tap="goBack">
<t-icon name="chevron-left" size="58rpx" style="color: white;"></t-icon> <view class="flex flex-center" style="width: 100%;height: 100%;">
<t-icon name="chevron-left" size="48rpx" style="color: white;"></t-icon>
</view>
</view> </view>
<!-- info --> <!-- info -->
@ -37,43 +43,18 @@
<view> <view>
<view class="row padding mt-32"> <view class="row padding mt-32">
<view>今日任务</view> <view>今日任务</view>
<view class="flex flex-center flex-justify-between mt-16"> <view class="flex flex-center flex-justify-between mt-16" wx:for="{{farms}}">
<view class="flex flex-justify-start flex-aligin-center mt-16"> <view class="flex flex-justify-start flex-aligin-center mt-16">
<t-avatar icon="color-invert" /> <t-avatar icon="color-invert" />
<view class="ml-16"> <view class="ml-16">
<view class="font-14 bold">浇水</view> <view class="font-14 bold">{{item.title}}</view>
<view class="font-12 grey">每{{info.farms.wateringCycle}}天一次</view> <view class="font-12 grey">每{{info.farms.wateringCycle}}天一次</view>
</view> </view>
</view> </view>
<view> <view>
<t-button theme="primary" shape="round" size="small">完成</t-button> <t-button wx:if="{{item.status == 1}}" theme="danger" variant="outline" shape="round" size="small" data-item="{{item}}" bind:tap="addFarmLog">未完成</t-button>
</view> <t-button wx:if="{{item.status == 2}}" theme="primary" shape="round" size="small" data-item="{{item}}" bind:tap="addFarmLog">完成</t-button>
</view> <t-button wx:if="{{item.status == 3}}" theme="primary" shape="round" size="small" data-item="{{item}}" bind:tap="addFarmLog">逾期</t-button>
<view class="flex flex-center flex-justify-between mt-16">
<view class="flex flex-justify-start flex-aligin-center mt-16">
<t-avatar icon="color-invert" />
<view class="ml-16">
<view class="font-14 bold">施肥</view>
<view class="font-12 grey">每{{info.farms.liquidFertilizerCycle}}天一次</view>
</view>
</view>
<view>
<t-button shape="round" size="small">未完成</t-button>
</view>
</view>
<view class="flex flex-center flex-justify-between mt-16">
<view class="flex flex-justify-start flex-aligin-center mt-16">
<t-avatar icon="color-invert" />
<view class="ml-16">
<view class="font-14 bold">旋转</view>
<view class="font-12 grey">每{{info.farms.rotationCycle}}天一次</view>
</view>
</view>
<view>
<t-button shape="round" size="small">未完成</t-button>
</view> </view>
</view> </view>
</view> </view>

View File

@ -16,6 +16,9 @@ Page({
*/ */
onLoad(options) { onLoad(options) {
this.init() this.init()
wx.setNavigationBarTitle({
title: '今日农事',
})
}, },
init(){ init(){
@ -42,8 +45,28 @@ Page({
if (res.code === 200){ if (res.code === 200){
const data = res.data const data = res.data
if (data !== null){ if (data !== null){
this.setData({list:data}) const tmps = data.map(e => {
if (e.ossList.length > 0){
e.pic = e.ossList[0].url
} }
return e
})
this.setData({list:tmps})
}
}
})
},
addFarmLog(e){
const item = e.currentTarget.dataset.item
const data = {id:item.id,plantId:item.plantId, title:item.title,remark:'测试',status:2}
api('/plant/addRecord','POST',data,'json').then(res => {
if (res.code === 200){
wx.showToast({
icon:'success',
title: res.msg,
})
this.fetchInfo()
} }
}) })
}, },

View File

@ -1,13 +1,41 @@
<!--pages/today/index.wxml--> <!--pages/today/index.wxml-->
<view> <view>
<view> <view>
<view wx:if="{{list.length === 0}}" class="flex flex-center flex-col " style="margin-top: 268rpx;" > <view wx:if="{{list.length === 0}}" class="flex flex-center flex-col " style="margin-top: 268rpx;">
<view class="empty flex flex-center flex-col"> <view class="empty flex flex-center flex-col">
</view> </view>
<view class="mt-16 flex flex-center flex-col"> <view class="mt-16 flex flex-center flex-col">
<view class="font-16 bold" >已完成所有任务</view> <view class="font-16 bold">已完成所有任务</view>
<view class="font-12 grey mt-16">今天暂无农事需要完成</view> <view class="font-12 grey mt-16">今天暂无农事需要完成</view>
</view> </view>
</view> </view>
<view wx:else class="padding">
<view>
今日任务
</view>
<view class="mt-32">
<view wx:for="{{list}}">
<view class="">
<view wx:for="{{item.FarmRecord}}" wx:for-item="sub" class=" row padding mt-32">
<view>
<view class="action font-16 bold">{{sub.title}}</view>
<view class="flex flex-center flex-justify-between">
<view class="flex flex-center flex-justify-start mt-16">
<image src="{{item.pic}}" class="pic"></image>
<view class="ml-16">{{item.name}}</view>
</view>
<view>
<t-button wx:if="{{sub.status == 1}}" theme="danger" variant="outline" shape="round" size="small" data-item="{{sub}}" bind:tap="addFarmLog">未完成</t-button>
<t-button wx:if="{{sub.status == 2}}" theme="primary" shape="round" size="small" data-item="{{sub}}" bind:tap="addFarmLog">完成</t-button>
<t-button wx:if="{{sub.status == 3}}" theme="primary" shape="round" size="small" data-item="{{sub}}" bind:tap="addFarmLog">逾期</t-button>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view> </view>
</view> </view>

View File

@ -1,4 +1,8 @@
/* pages/today/index.wxss */ /* pages/today/index.wxss */
page {
background-color: #F6F6F6;
}
.empty { .empty {
width: 140rpx; width: 140rpx;
height: 140rpx; height: 140rpx;
@ -7,3 +11,14 @@
background-image: url("https://res.catter.cn/pub/2025/09/30/20250930143142508.png"); background-image: url("https://res.catter.cn/pub/2025/09/30/20250930143142508.png");
background-size: cover; background-size: cover;
} }
.pic{
width: 100rpx;
height: 100rpx;
border-radius: 16rpx;
}
.action {
}