diff --git a/app.json b/app.json
index 816e6aa..31ff0d9 100644
--- a/app.json
+++ b/app.json
@@ -7,7 +7,8 @@
"pages/add/info",
"pages/index/info",
"pages/index/edit",
- "pages/about/index"
+ "pages/about/index",
+ "pages/today/index"
],
"window": {
"navigationBarTextStyle": "black",
@@ -15,6 +16,26 @@
"navigationBarBackgroundColor": "#ffffff"
},
"darkmode": false,
+ "tabBar": {
+ "selectedColor": "#54B87E",
+ "backgroundColor": "white",
+ "list": [
+ {
+ "iconPath": "static/img/home.png",
+ "selectedIconPath": "static/img/home1.png",
+ "pagePath": "pages/index/index",
+ "iconSize": 48,
+ "text": "首页"
+ },
+ {
+ "iconPath": "static/img/home.png",
+ "selectedIconPath": "static/img/home1.png",
+ "pagePath": "pages/today/index",
+ "iconSize": 48,
+ "text": "今日农事"
+ }
+ ]
+ },
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents",
diff --git a/components/count-picker/index.js b/components/count-picker/index.js
new file mode 100644
index 0000000..3b11d93
--- /dev/null
+++ b/components/count-picker/index.js
@@ -0,0 +1,78 @@
+// components/picker/index.js
+Component({
+
+ /**
+ * 组件的属性列表
+ */
+ properties: {
+ title: {
+ type: String,
+ require: true
+ },
+ prop: {
+ type: String,
+ require: true
+ },
+ value: {
+ type: String,
+ require: false
+ }
+ },
+
+ observers: {
+ // 监听 visible 的变化
+ 'value': function (newVal, oldVal) {
+ if (newVal) {
+ this.setData({
+ result:newVal
+ })
+ }
+ }
+ },
+ /**
+ * 组件的初始数据
+ */
+ data: {
+ visible: false,
+ result: '',
+ counts: []
+ },
+
+ /**
+ * 组件的方法列表
+ */
+ methods: {
+ init() {
+ var list = []
+ for (let index = 1; index < 31; index++) {
+ const item = {
+ label: index,
+ value: index
+ }
+ list.push(item)
+ }
+ this.setData({
+ counts: list
+ })
+ },
+ confirm(e) {
+ const value = e.detail.value[0]
+ this.setData({
+ result: value,
+ visible:false
+ })
+ this.triggerEvent('ok', {
+ value: {prop: this.data.prop,value:value}
+ });
+ },
+ onVisibleChange() {
+ const show = !this.data.visible
+ if (show) {
+ this.init()
+ }
+ this.setData({
+ visible: show
+ })
+ },
+ }
+})
\ No newline at end of file
diff --git a/components/count-picker/index.json b/components/count-picker/index.json
new file mode 100644
index 0000000..41a14c2
--- /dev/null
+++ b/components/count-picker/index.json
@@ -0,0 +1,9 @@
+{
+ "component": true,
+ "styleIsolation": "apply-shared",
+ "usingComponents": {
+ "t-popup": "tdesign-miniprogram/popup/popup",
+ "t-picker": "tdesign-miniprogram/picker/picker",
+ "t-picker-item": "tdesign-miniprogram/picker-item/picker-item"
+ }
+}
\ No newline at end of file
diff --git a/components/count-picker/index.wxml b/components/count-picker/index.wxml
new file mode 100644
index 0000000..d6c1772
--- /dev/null
+++ b/components/count-picker/index.wxml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/count-picker/index.wxss b/components/count-picker/index.wxss
new file mode 100644
index 0000000..033253e
--- /dev/null
+++ b/components/count-picker/index.wxss
@@ -0,0 +1 @@
+/* components/picker/index.wxss */
\ No newline at end of file
diff --git a/pages/index/edit.js b/pages/index/edit.js
index bc66bb3..0c4f4ca 100644
--- a/pages/index/edit.js
+++ b/pages/index/edit.js
@@ -1,4 +1,5 @@
// pages/index/edit.js
+const config = require("../../config/config")
const { api } = require("../../utils/api")
Page({
@@ -40,6 +41,64 @@ Page({
onInput(e){
const value = e.detail.value
this.setData({newName:value})
+
+ },
+ updateFarms(e){
+ const value = e.detail.value
+ console.log(value);
+ const user = wx.getStorageSync('user')
+ var data = {id: this.data.info.farms.id,plantId: this.data.info.farms.plantId,userId:user.id}
+ data[value.prop] = value.value
+ api('/plant/updateFarm','POST',data,'json').then(res => {
+ if (res.code === 200){
+ wx.showToast({
+ icon:'success',
+ title: res.msg,
+ })
+ }
+ })
+ },
+
+ upload(){
+ const _this = this
+ wx.chooseMedia({
+ count: 1,
+ mediaType: ['image'],
+ sourceType: ['album', 'camera'],
+ camera: 'back',
+ success(res) {
+ const avatarUrl = res.tempFiles[0].tempFilePath
+ wx.showLoading({
+ title: '请稍后...',
+ })
+ wx.uploadFile({
+ filePath: avatarUrl,
+ name: 'file',
+ header:{
+ 'Authorization': 'Bearer ' + wx.getStorageSync('token'),
+ },
+ url: config.baseUrl + '/oss/upload',
+ success: res => {
+ var data = JSON.parse(res.data);
+ if (data.code === 200) {
+ const params = {ossIds:[data.data.file.id],plantId: _this.data.info.farms.plantId}
+ api('/plant/uploadImg','POST',params,'json').then(res => {
+ if (res.code === 200){
+ wx.showToast({
+ icon:'success',
+ title: res.msg,
+ })
+ }else {
+ wx.showModal({
+ content: res.msg
+ })
+ }
+ })
+ }
+ }
+ })
+ }
+ })
},
update(){
@@ -48,6 +107,16 @@ Page({
data.name = this.data.newName
}
console.log(data);
+ api('/plant/updatePlant','POST',data,'json').then(res => {
+ if (res.code === 200){
+ this.fetchInfo()
+ } else {
+ wx.showModal({
+ content: res.msg
+ })
+ }
+ this.setData({showDialog:false})
+ })
},
del(){
diff --git a/pages/index/edit.json b/pages/index/edit.json
index df1ce0a..7772833 100644
--- a/pages/index/edit.json
+++ b/pages/index/edit.json
@@ -1,6 +1,7 @@
{
"usingComponents": {
"t-dialog": "tdesign-miniprogram/dialog/dialog",
- "t-cell": "tdesign-miniprogram/cell/cell"
+ "t-cell": "tdesign-miniprogram/cell/cell",
+ "picker": "/components/count-picker/index"
}
}
\ No newline at end of file
diff --git a/pages/index/edit.wxml b/pages/index/edit.wxml
index 55cd806..6348313 100644
--- a/pages/index/edit.wxml
+++ b/pages/index/edit.wxml
@@ -4,7 +4,16 @@
-
+
+
+
+
+
+
+
+
+
+
{{info.name}}
@@ -22,22 +31,22 @@
-
-
-
-
-
+
+
+
+
+
-
-
- 删除植物
-
+
+
+ 删除植物
+
-
-
-
+
+
+
\ No newline at end of file
diff --git a/pages/index/edit.wxss b/pages/index/edit.wxss
index e7f9854..a78f93b 100644
--- a/pages/index/edit.wxss
+++ b/pages/index/edit.wxss
@@ -3,8 +3,30 @@ page {
background-color: #F6F6F6;
}
-.pic{
+.container {
+ position: relative;
width: 150rpx;
height: 150rpx;
+
+ padding: 0;
+ flex-shrink: 0;
+ overflow: hidden; /* 防止内容溢出 */
+}
+
+.bg {
+ width: 100%;
+ height: 100%;
+ background-color: rebeccapurple;
border-radius: 16rpx;
+ z-index: 1;
+ display: block; /* 必须加,否则 image 不会撑满父容器 */
+}
+
+.tips {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ z-index: 3;
+ display: block; /* 必须加,否则 image 不会撑满父容器 */
+ font-size: 28rpx;
}
\ No newline at end of file
diff --git a/pages/index/info.js b/pages/index/info.js
index 678173d..a1b8e58 100644
--- a/pages/index/info.js
+++ b/pages/index/info.js
@@ -19,7 +19,8 @@ Page({
},
fetchInfo(){
- api('/plant/detail','GET',{id: this.data.id}).then(res => {
+ const data ={id: this.data.id}
+ api('/plant/detail','GET',data).then(res => {
if (res.code === 200){
const tmp = res.data
tmp.farms.suitableFertilizer = tmp.farms.suitableFertilizer.split(',')
@@ -27,6 +28,11 @@ Page({
console.log(tmp);
}
})
+ api('/plant/todayFarm',data).then(res => {
+ if (res.code === 200){
+ console.log(res);
+ }
+ })
},
goEdit(){
diff --git a/pages/today/index.js b/pages/today/index.js
new file mode 100644
index 0000000..475c248
--- /dev/null
+++ b/pages/today/index.js
@@ -0,0 +1,84 @@
+const { api } = require("../../utils/api")
+
+// pages/today/index.js
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ user:null,
+ list:[],
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad(options) {
+ this.init()
+ },
+
+ init(){
+ const tmp = wx.getStorageSync('user')
+ this.setData({user:tmp})
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow() {
+ this.fetchInfo()
+ },
+
+ fetchInfo(){
+ api('/plant/todayCare','GET',{userId: this.data.user.id}).then(res => {
+ if (res.code === 200){
+ const data = res.data
+ if (data !== null){
+ this.setData({list:data})
+ }
+ }
+ })
+ },
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload() {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh() {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom() {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage() {
+
+ }
+})
\ No newline at end of file
diff --git a/pages/today/index.json b/pages/today/index.json
new file mode 100644
index 0000000..8835af0
--- /dev/null
+++ b/pages/today/index.json
@@ -0,0 +1,3 @@
+{
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/pages/today/index.wxml b/pages/today/index.wxml
new file mode 100644
index 0000000..7522869
--- /dev/null
+++ b/pages/today/index.wxml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+ 已完成所有任务
+ 今天暂无农事需要完成
+
+
+
+
\ No newline at end of file
diff --git a/pages/today/index.wxss b/pages/today/index.wxss
new file mode 100644
index 0000000..6896fbd
--- /dev/null
+++ b/pages/today/index.wxss
@@ -0,0 +1,9 @@
+/* pages/today/index.wxss */
+.empty {
+ width: 140rpx;
+ height: 140rpx;
+ background-color:#F6F6F6 ;
+ border-radius: 140rpx;
+ background-image: url("https://res.catter.cn/pub/2025/09/30/20250930143142508.png");
+ background-size: cover;
+}
\ No newline at end of file
diff --git a/static/img/home.png b/static/img/home.png
new file mode 100644
index 0000000..a9786bd
Binary files /dev/null and b/static/img/home.png differ
diff --git a/static/img/home1.png b/static/img/home1.png
new file mode 100644
index 0000000..7669935
Binary files /dev/null and b/static/img/home1.png differ