This commit is contained in:
wt 2025-10-09 17:57:04 +08:00
parent 77b974780a
commit f2d67f5d90
16 changed files with 506 additions and 42 deletions

View File

@ -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",

71
pages/about/index.js Normal file
View File

@ -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() {
}
})

3
pages/about/index.json Normal file
View File

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

16
pages/about/index.wxml Normal file
View File

@ -0,0 +1,16 @@
<!--pages/about/index.wxml-->
<view class="padding">
<view class="row padding">
<view>
<view class="flex flex-center flex-justify-start">
<image src="https://res.catter.cn/pub/2025/09/30/20250930143142508.png" style="width: 100rpx;height: 100rpx;" />
<view class="ml-16">养花小技巧-植趣</view>
</view>
<view class="flex flex-center flex-col">
<image src="https://res.catter.cn/pub/2025/10/09/20251009151641528.png" style="width: 90vw; height: 90vw;" show-menu-by-longpress/>
<view>关注公众号,接收浇水、施肥等日程提醒</view>
<view class="mt-32 font-12 grey text-center">系统会根据您添加的花卉,自动生成浇水、施肥、修剪等提醒,您需要通过长按上面的二维码识别并关注我们的公众号,确保能接收消息提醒。</view>
</view>
</view>
</view>
</view>

4
pages/about/index.wxss Normal file
View File

@ -0,0 +1,4 @@
/* pages/about/index.wxss */
page {
background-color: #F6F6F6;
}

View File

@ -35,7 +35,7 @@ Page({
}
this.fetchList(key)
}, 1000)
}, 500)
},
fetchList(key){

View File

@ -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',
})
}
})

View File

@ -23,11 +23,12 @@
</view>
<view class="padding white-bg ">
<view class="flex flex-center flex-justify-start">
<view class="flex flex-center flex-justify-start font-12">
<view>常用名:</view>
<view class="bold">{{info.aliases}}</view>
</view>
<view class="grey" style="margin-top: 10rpx;">{{info.growthHabit}}</view>
<view class="grey" style="margin-top: 10rpx;" class="font-12">{{info.growthHabit}}</view>
</view>
<view class="padding" style="padding-bottom: 240rpx;">
@ -36,7 +37,7 @@
<view>浇水</view>
<view class="flex flex-justify-start flex-justify-start mt-16">
<t-avatar shape="round" icon="color-invert" />
<view class="font-14 bold ml-16">每7天一次</view>
<view class="font-14 bold ml-16">每{{info.careSchedules[season].wateringCycle}}天一次</view>
</view>
</view>
@ -45,22 +46,23 @@
<view class="flex flex-justify-start flex-justify-start mt-16">
<t-avatar shape="round" icon="color-invert" />
<view>
<view class="bold ml-16">每1月一次</view>
<view class="bold ml-16">每{{info.careSchedules[season].liquidFertilizerCycle}}天一次</view>
<view class="ml-16 grey">液体肥料</view>
</view>
</view>
<view class="flex flex-justify-start flex-justify-start mt-32">
<t-avatar shape="round" icon="color-invert" />
<view>
<view class="bold ml-16">每1月一次</view>
<view class="bold ml-16">每{{info.careSchedules[season].slowReleaseFertilizerCycle}}天一次</view>
<view class="ml-16 grey">缓释肥</view>
</view>
</view>
<view class="mt-32">推荐肥料</view>
<view class="mt-16">
<t-tag class="margin-16" variant="light" shape="round">树木、灌木专用肥料</t-tag>
<t-tag class="margin-16" variant="light" shape="round">通用型植物肥料</t-tag>
<t-tag theme="primary" >
{{info.careSchedules[season].suitableFertilizer}}
</t-tag>
</view>
</view>
@ -68,27 +70,101 @@
<view class="row padding mt-32">
<view>修剪</view>
<view class="flex flex-justify-start flex-justify-start mt-16">
<view class="flex flex-justify-start flex-center mt-16">
<t-avatar shape="round" icon="color-invert" />
<view class="font-14 bold ml-16">每7天一次</view>
<view class="ml-16">
<view class="font-14 bold ">每{{info.careSchedules[season].pruningCycle}}天一次</view>
<view class="font-12 grey">抵御病虫害、生长茂盛</view>
</view>
</view>
</view>
<view class="row padding mt-32">
<view>旋转</view>
<view class="flex flex-justify-start flex-center mt-16">
<t-avatar shape="round" icon="color-invert" />
<view class="ml-16">
<view class="font-14 bold ">每{{info.careSchedules[season].rotationCycle}}天一次</view>
<view class="font-12 grey">株形匀称</view>
</view>
</view>
</view>
<view class="row padding mt-32">
<view>光照</view>
<view class="flex flex-justify-start flex-justify-start mt-16">
<view class="flex flex-justify-start flex-center mt-16">
<t-avatar shape="round" icon="sunny" />
<view class="font-14 bold ml-16">{{info.lightIntensity}}、{{info.lightType}}</view>
<view class="ml-16">
<view class="font-14 bold ">{{info.lightIntensity}}、{{info.lightType}}</view>
<view class="font-12 grey">最佳光照</view>
</view>
</view>
</view>
<view class="row padding mt-32">
<view>病害</view>
<view>常见害/虫害</view>
<view style="margin-top: 16rpx;">
<t-tag class="margin-16" wx:for="{{info.pestsList}}" theme="danger" style="margin-right: 10rpx;" variant="light" >{{item}}</t-tag>
<t-tag class="margin-16" wx:for="{{info.pestsList}}" theme="danger" style="margin-right: 10rpx;" variant="light">{{item}}</t-tag>
</view>
</view>
<view class="row padding mt-32">
<view>特征</view>
<view style="margin-top: 16rpx;">
<view class="flex flex-justify-start flex-center mt-16">
<t-avatar shape="round" icon="color-invert" />
<view class="font-14 bold ml-16">
<view>
{{info.lifeCycle}}
</view>
<view class="font-12 grey">
生命周期
</view>
</view>
</view>
</view>
<view class="flex flex-justify-start flex-center mt-32">
<t-avatar shape="round" icon="color-invert" />
<view class="font-14 bold ml-16">
<view>
{{info.flowerDiameter}} mm
</view>
<view class="font-12 grey">
花直径
</view>
</view>
</view>
<view class="flex flex-justify-start flex-center mt-32">
<t-avatar shape="round" icon="color-invert" />
<view class="font-14 bold ml-16">
<view>
{{info.floweringColor}}
</view>
<view class="font-12 grey">
花色
</view>
</view>
</view>
<view class="flex flex-justify-start flex-center mt-32">
<t-avatar shape="round" icon="color-invert" />
<view class="font-14 bold ml-16">
<view>
{{info.floweringPeriod}}
</view>
<view class="font-12 grey">
花期
</view>
</view>
</view>
</view>
</view>
<view class="bottom">

117
pages/index/edit.js Normal file
View File

@ -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() {
}
})

6
pages/index/edit.json Normal file
View File

@ -0,0 +1,6 @@
{
"usingComponents": {
"t-dialog": "tdesign-miniprogram/dialog/dialog",
"t-cell": "tdesign-miniprogram/cell/cell"
}
}

43
pages/index/edit.wxml Normal file
View File

@ -0,0 +1,43 @@
<!--pages/index/edit.wxml-->
<view>
<view class="padding">
<view class="row padding">
<view class="flex flex-center flex-justify-between">
<view class="flex flex-center flex-justify-start">
<image src="https://res.catter.cn/pub/2025/09/30/20250930143920286.png" class="pic"></image>
<view class="padding">
<view>
{{info.name}}
</view>
<view class="font-12 grey">
{{info.latinName}}
</view>
</view>
</view>
<view style="width: 60rpx;height: 60rpx;" class="flex flex-justify-end flex-center" bind:tap="changeDialog">
<t-icon name="edit"></t-icon>
</view>
</view>
</view>
<view class="white-bg mt-32 " style="border-radius: 16rpx;">
<view style=" padding-top: 16rpx; padding-bottom: 16rpx;">
<t-cell title="浇水" bordered="{{false}}" hover arrow note="每{{info.farms.wateringCycle}}天"/>
<t-cell title="施肥" bordered="{{false}}" hover arrow note="每{{info.farms.slowReleaseFertilizerCycle}}天"/>
<t-cell title="施肥类型" bordered="{{false}}" hover arrow note="水溶肥"/>
<t-cell title="旋转" bordered="{{false}}" hover arrow note="每{{info.farms.rotationCycle}}天"/>
<t-cell title="修剪" bordered="{{false}}" hover arrow note="每{{info.farms.pruningCycle}}天"/>
</view>
</view>
</view>
<view class="flex flex-center">
<t-button theme="danger" icon="delete" shape="round" style="width: 80%;" variant="outline" bind:tap="del">删除植物</t-button>
</view>
<t-dialog visible="{{showDialog}}" title="更改名称" confirm-btn="确定" cancel-btn="取消" bind:confirm="update" bind:cancel="changeDialog">
<t-input borderless clearable slot="content" placeholder="请输入新的名称" bind:change="onInput" />
</t-dialog>
</view>

10
pages/index/edit.wxss Normal file
View File

@ -0,0 +1,10 @@
/* pages/index/edit.wxss */
page {
background-color: #F6F6F6;
}
.pic{
width: 150rpx;
height: 150rpx;
border-radius: 16rpx;
}

View File

@ -29,6 +29,12 @@ Page({
})
},
goEdit(){
wx.navigateTo({
url: '../index/edit?id=' + this.data.id,
})
},
goBack(){
wx.navigateBack()
},

View File

@ -12,12 +12,25 @@
</view>
<!-- info -->
<view style="background-color:white;margin-top: -130rpx;z-index: 99;position: absolute; width: 100vw; border-top-right-radius: 50rpx; border-top-left-radius: 50rpx;">
<view class="flex flex-center flex-justify-start" style="padding: 52rpx 0 10rpx 32rpx">
<view class="font-16 bold ">{{info.name}}</view>
<view class="font-12 grey ml-16">{{info.genus}}</view>
<view style="background-color:white;margin-top: -160rpx;z-index: 99;position: absolute; width: 100vw; border-top-right-radius: 50rpx; border-top-left-radius: 50rpx;">
<view class="flex flex-center flex-justify-between" style="padding: 52rpx 32rpx 10rpx 32rpx">
<view class="flex flex-center flex-justify-start">
<view class="font-16 bold ">{{info.name}}</view>
<view class="font-12 grey ml-16">{{info.genus}}</view>
</view>
<view style="width: 100rpx;" class="flex flex-center flex-justify-end" bind:tap="goEdit">
<t-icon name="setting"></t-icon>
</view>
</view>
<view style="padding: 0rpx 0 10rpx 32rpx" class="flex flex-center flex-justify-start font-12">
<view class="grey">常用名:</view>
<view>{{info.aliases}}</view>
</view>
<view style="padding: 0rpx 0 10rpx 32rpx" class="flex flex-center flex-justify-start font-12">
<view class="grey">植物学名:</view>
<view>{{info.latinName}}</view>
</view>
<view style="padding: 0rpx 0 10rpx 32rpx">{{info.latinName}}</view>
</view>
<view class="padding" style="padding-bottom: 240rpx;">
@ -27,7 +40,10 @@
<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="font-14 bold ml-16">浇水</view>
<view class="ml-16">
<view class="font-14 bold">浇水</view>
<view class="font-12 grey">每{{info.farms.wateringCycle}}天一次</view>
</view>
</view>
<view>
<t-button theme="primary" shape="round" size="small">完成</t-button>
@ -36,7 +52,25 @@
<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="font-14 bold ml-16">施肥</view>
<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>
@ -45,7 +79,21 @@
</view>
<view class="row padding mt-32">
<view>养护计划信息</view>
<view>当前状态</view>
<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">健康状态</view>
</view>
</view>
<view class="flex flex-center mt-32">
<t-button theme="primary" icon="chat-bubble-error" shape="round" style="width: 100%;">AI 病害诊断</t-button>
</view>
</view>
<view class="row padding mt-32">
<view>养护提示</view>
<view class="flex flex-center flex-justify-between mt-16">
<view class="flex flex-justify-start flex-aligin-center mt-16">
<view class="font-14 bold ml-16">{{info.farms.desc}}</view>
@ -55,6 +103,27 @@
<t-tag class="margin-16" wx:for="{{info.farms.suitableFertilizer}}" theme="danger" style="margin-right: 10rpx;" variant="light">{{item}}</t-tag>
</view>
</view>
<view class="row padding mt-32">
<view>花期</view>
<view class="flex flex-center flex-justify-between mt-16">
<view class="flex flex-justify-start flex-aligin-center mt-16">
<view class="font-14 bold ml-16">{{info.floweringPeriod}}</view>
</view>
</view>
</view>
<view class="row padding mt-32">
<view>其他</view>
<view class="flex flex-center flex-justify-between mt-16">
<view class="flex flex-justify-start flex-aligin-center mt-16">
<t-tag theme="primary" class="font-14 bold ml-16">{{info.lifeCycle}}</t-tag>
<t-tag theme="primary" class="font-14 bold ml-16">{{info.lightIntensity}}</t-tag>
<t-tag theme="primary" class="font-14 bold ml-16">{{info.lightType}}</t-tag>
<t-tag theme="primary" class="font-14 bold ml-16">{{info.foliageType}}</t-tag>
</view>
</view>
</view>
</view>
</view>
</view>

View File

@ -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) {

View File

@ -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",