From f2d67f5d90f837a098276f6d88bbe3c8bfa05f00 Mon Sep 17 00:00:00 2001 From: wt Date: Thu, 9 Oct 2025 17:57:04 +0800 Subject: [PATCH] fix --- app.json | 4 +- pages/about/index.js | 71 ++++++++++++++++++++++ pages/about/index.json | 3 + pages/about/index.wxml | 16 +++++ pages/about/index.wxss | 4 ++ pages/add/index.js | 2 +- pages/add/info.js | 66 +++++++++++++++----- pages/add/info.wxml | 102 +++++++++++++++++++++++++++---- pages/index/edit.js | 117 ++++++++++++++++++++++++++++++++++++ pages/index/edit.json | 6 ++ pages/index/edit.wxml | 43 +++++++++++++ pages/index/edit.wxss | 10 +++ pages/index/info.js | 6 ++ pages/index/info.wxml | 85 +++++++++++++++++++++++--- pages/login/index.js | 6 +- project.private.config.json | 7 +++ 16 files changed, 506 insertions(+), 42 deletions(-) create mode 100644 pages/about/index.js create mode 100644 pages/about/index.json create mode 100644 pages/about/index.wxml create mode 100644 pages/about/index.wxss create mode 100644 pages/index/edit.js create mode 100644 pages/index/edit.json create mode 100644 pages/index/edit.wxml create mode 100644 pages/index/edit.wxss diff --git a/app.json b/app.json index fc8c7b5..816e6aa 100644 --- a/app.json +++ b/app.json @@ -5,7 +5,9 @@ "pages/add/edit", "pages/login/index", "pages/add/info", - "pages/index/info" + "pages/index/info", + "pages/index/edit", + "pages/about/index" ], "window": { "navigationBarTextStyle": "black", diff --git a/pages/about/index.js b/pages/about/index.js new file mode 100644 index 0000000..9d97241 --- /dev/null +++ b/pages/about/index.js @@ -0,0 +1,71 @@ +// pages/about/index.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + if (options.type !=undefined){ + wx.showToast({ + title: '获取成功', + icon: 'success' + }) + } + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/about/index.json b/pages/about/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/about/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/about/index.wxml b/pages/about/index.wxml new file mode 100644 index 0000000..e418144 --- /dev/null +++ b/pages/about/index.wxml @@ -0,0 +1,16 @@ + + + + + + + 养花小技巧-植趣 + + + + 关注公众号,接收浇水、施肥等日程提醒 + 系统会根据您添加的花卉,自动生成浇水、施肥、修剪等提醒,您需要通过长按上面的二维码识别并关注我们的公众号,确保能接收消息提醒。 + + + + \ No newline at end of file diff --git a/pages/about/index.wxss b/pages/about/index.wxss new file mode 100644 index 0000000..a44a0da --- /dev/null +++ b/pages/about/index.wxss @@ -0,0 +1,4 @@ +/* pages/about/index.wxss */ +page { + background-color: #F6F6F6; +} \ No newline at end of file diff --git a/pages/add/index.js b/pages/add/index.js index 843410d..e6da50c 100644 --- a/pages/add/index.js +++ b/pages/add/index.js @@ -35,7 +35,7 @@ Page({ } this.fetchList(key) - }, 1000) + }, 500) }, fetchList(key){ diff --git a/pages/add/info.js b/pages/add/info.js index 829a62e..8d315a6 100644 --- a/pages/add/info.js +++ b/pages/add/info.js @@ -1,4 +1,6 @@ -const { api } = require("../../utils/api") +const { + api +} = require("../../utils/api") // pages/add/info.js Page({ @@ -7,11 +9,12 @@ Page({ * 页面的初始数据 */ data: { - id:'', - info:null + id: '', + info: null, + season: 0 }, - goBack(){ + goBack() { wx.navigateBack() }, @@ -19,32 +22,63 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { - this.setData({id:options.id}) + this.setData({ + id: options.id + }) + this.init() this.fetchInfo() }, - fetchInfo(){ - const data ={id:this.data.id} - api('/library/detail','GET',data,'json').then(res => { + init() { + const month = new Date().getMonth() + 1; // getMonth() 返回 0~11,所以要 +1 + var tmp = 0 + if (month >= 3 && month <= 5) { + tmp = 0; // 春 + } else if (month >= 6 && month <= 8) { + tmp = 1; // 夏 + } else if (month >= 9 && month <= 11) { + tmp = 2; // 秋 + } else { + tmp = 3; // 冬 + } + this.setData({season:tmp}) + }, + + fetchInfo() { + const data = { + id: this.data.id + } + api('/library/detail', 'GET', data, 'json').then(res => { if (res.code === 200) { const data = res.data data.pestsList = data.pestsDiseases.split(',') - this.setData({info:data}) + this.setData({ + info: data + }) } }) }, - add(){ + add() { const user = wx.getStorageSync('user') console.log(user); + // 如果用户的为授权 手机号,责提示登录 + if(user.phone === ''){ + wx.navigateTo({ + url: '../login/index', + }) + return + } wx.showLoading({ title: '请稍后', }) - const data ={libraryId: this.data.info.id,userId:user.id} - api('/plant/plantByLibrary','POST',data,'json').then(res => { - if (res.code === 200){ - wx.showToast({ - title: res.msg, - icon:'success' + const data = { + libraryId: this.data.info.id, + userId: user.id + } + api('/plant/plantByLibrary', 'POST', data, 'json').then(res => { + if (res.code === 200) { + wx.navigateTo({ + url: '../about/index?type=1', }) } }) diff --git a/pages/add/info.wxml b/pages/add/info.wxml index 37165b1..9fab3cb 100644 --- a/pages/add/info.wxml +++ b/pages/add/info.wxml @@ -23,11 +23,12 @@ - + + 常用名: {{info.aliases}} - {{info.growthHabit}} + {{info.growthHabit}} @@ -36,7 +37,7 @@ 浇水 - 每7天一次 + 每{{info.careSchedules[season].wateringCycle}}天一次 @@ -45,22 +46,23 @@ - 每1月一次 + 每{{info.careSchedules[season].liquidFertilizerCycle}}天一次 液体肥料 - 每1月一次 + 每{{info.careSchedules[season].slowReleaseFertilizerCycle}}天一次 缓释肥 推荐肥料 - 树木、灌木专用肥料 - 通用型植物肥料 + + {{info.careSchedules[season].suitableFertilizer}} + @@ -68,27 +70,101 @@ 修剪 - + - 每7天一次 + + 每{{info.careSchedules[season].pruningCycle}}天一次 + 抵御病虫害、生长茂盛 + + + + + + 旋转 + + + + 每{{info.careSchedules[season].rotationCycle}}天一次 + 株形匀称 + + 光照 - + - {{info.lightIntensity}}、{{info.lightType}} + + {{info.lightIntensity}}、{{info.lightType}} + 最佳光照 + - 病害 + 常见病害/虫害 - {{item}} + {{item}} + + + + 特征 + + + + + + {{info.lifeCycle}} + + + 生命周期 + + + + + + + + + + {{info.flowerDiameter}} mm + + + 花直径 + + + + + + + + + {{info.floweringColor}} + + + 花色 + + + + + + + + + {{info.floweringPeriod}} + + + 花期 + + + + + + diff --git a/pages/index/edit.js b/pages/index/edit.js new file mode 100644 index 0000000..bc66bb3 --- /dev/null +++ b/pages/index/edit.js @@ -0,0 +1,117 @@ +// pages/index/edit.js +const { api } = require("../../utils/api") +Page({ + + /** + * 页面的初始数据 + */ + data: { + showDialog:false, + newName:'', + id:'', + info:null + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.setData({id:options.id}) + }, + + + + fetchInfo(){ + api('/plant/detail','GET',{id: this.data.id}).then(res => { + if (res.code === 200){ + const tmp = res.data + tmp.farms.suitableFertilizer = tmp.farms.suitableFertilizer.split(',') + this.setData({info:res.data}) + console.log(tmp); + } + }) + }, + + changeDialog(){ + const show = this.data.showDialog === false ? true:false + this.setData({showDialog:show}) + }, + + onInput(e){ + const value = e.detail.value + this.setData({newName:value}) + }, + + update(){ + const data = {id: this.data.id} + if (this.data.newName != ''){ + data.name = this.data.newName + } + console.log(data); + }, + + del(){ + wx.showModal({ + content: '删除改植物后,与之相关的数据和历史记录也将被删除,此删除不能被恢复。', + complete: (res) => { + if (res.confirm) { + const data = {ids: [this.data.id]} + api('/plant/delete','POST',data,'json').then(res => { + if (res.code === 200){ + wx.navigateBack() + } + }) + } + } + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + this.fetchInfo() + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/index/edit.json b/pages/index/edit.json new file mode 100644 index 0000000..df1ce0a --- /dev/null +++ b/pages/index/edit.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "t-dialog": "tdesign-miniprogram/dialog/dialog", + "t-cell": "tdesign-miniprogram/cell/cell" + } +} \ No newline at end of file diff --git a/pages/index/edit.wxml b/pages/index/edit.wxml new file mode 100644 index 0000000..55cd806 --- /dev/null +++ b/pages/index/edit.wxml @@ -0,0 +1,43 @@ + + + + + + + + + + {{info.name}} + + + {{info.latinName}} + + + + + + + + + + + + + + + + + + + + + + 删除植物 + + + + + + + + \ No newline at end of file diff --git a/pages/index/edit.wxss b/pages/index/edit.wxss new file mode 100644 index 0000000..e7f9854 --- /dev/null +++ b/pages/index/edit.wxss @@ -0,0 +1,10 @@ +/* pages/index/edit.wxss */ +page { + background-color: #F6F6F6; +} + +.pic{ + width: 150rpx; + height: 150rpx; + border-radius: 16rpx; +} \ No newline at end of file diff --git a/pages/index/info.js b/pages/index/info.js index 6045f89..678173d 100644 --- a/pages/index/info.js +++ b/pages/index/info.js @@ -29,6 +29,12 @@ Page({ }) }, + goEdit(){ + wx.navigateTo({ + url: '../index/edit?id=' + this.data.id, + }) + }, + goBack(){ wx.navigateBack() }, diff --git a/pages/index/info.wxml b/pages/index/info.wxml index 3605d8f..415747b 100644 --- a/pages/index/info.wxml +++ b/pages/index/info.wxml @@ -12,12 +12,25 @@ - - - {{info.name}} - {{info.genus}} + + + + {{info.name}} + {{info.genus}} + + + + + + + 常用名: + {{info.aliases}} + + + + 植物学名: + {{info.latinName}} - {{info.latinName}} @@ -27,7 +40,10 @@ - 浇水 + + 浇水 + 每{{info.farms.wateringCycle}}天一次 + 完成 @@ -36,7 +52,25 @@ - 施肥 + + + 施肥 + 每{{info.farms.liquidFertilizerCycle}}天一次 + + + + 未完成 + + + + + + + + + 旋转 + 每{{info.farms.rotationCycle}}天一次 + 未完成 @@ -45,7 +79,21 @@ - 养护计划信息 + 当前状态 + + + + 当前:健康 + 健康状态 + + + + AI 病害诊断 + + + + + 养护提示 {{info.farms.desc}} @@ -55,6 +103,27 @@ {{item}} + + + 花期 + + + {{info.floweringPeriod}} + + + + + + 其他 + + + {{info.lifeCycle}} + {{info.lightIntensity}} + {{info.lightType}} + {{info.foliageType}} + + + \ No newline at end of file diff --git a/pages/login/index.js b/pages/login/index.js index 100fe64..3b20bf2 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -35,13 +35,13 @@ Page({ }, getPhoneNumber(e){ - if (e.detail.errMsg != 'getPhoneNumber:ok') { return } - const data = {code:e.detail.code, ...this.data.openData} - + wx.showLoading({ + title: '请稍后', + }) api("/auth/getPhone", 'GET', data).then(res => { wx.hideLoading() if (res.code === 200) { diff --git a/project.private.config.json b/project.private.config.json index da04a1c..db9afdb 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -23,6 +23,13 @@ "condition": { "miniprogram": { "list": [ + { + "name": "pages/about/index", + "pathName": "pages/about/index", + "query": "", + "scene": null, + "launchMode": "default" + }, { "name": "pages/index/info", "pathName": "pages/index/info",