From 7dbeeeb0c94e09638952c62f6fcf2485eda0b8a4 Mon Sep 17 00:00:00 2001 From: sdaduanbilei Date: Wed, 3 Dec 2025 09:41:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE=E6=89=80=E5=B1=9E=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 2 +- pages/community/index.js | 13 ++++++------- pages/community/info.wxml | 2 +- pages/garden/index.js | 11 ++++++++++- pages/garden/index.wxml | 10 +++++----- pages/index/index.js | 12 ++++++------ pages/login/index.js | 2 -- pages/user/index.js | 1 + 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/app.js b/app.js index 8448770..be2b106 100644 --- a/app.js +++ b/app.js @@ -12,7 +12,7 @@ App({ // 发送 res.code 到后台换取 openId, sessionKey, unionId api("/auth/miniLogin?code=" + res.code).then(res => { if (res.code === 200) { - wx.setStorageSync('saOpenId', res.data.user.openId) + wx.setStorageSync('openId', res.data.user.miniOpenId) wx.setStorageSync('sessionKey', res.data.user.sessionKey) if (res.data.user.id){ wx.setStorageSync('user', res.data.user) diff --git a/pages/community/index.js b/pages/community/index.js index 0ce05ba..b10fcda 100644 --- a/pages/community/index.js +++ b/pages/community/index.js @@ -23,13 +23,12 @@ Page({ goAdd(){ const tmp = wx.getStorageSync('user') - // todo - // if (tmp.phone.length === 0){ - // wx.navigateTo({ - // url: '../login/index', - // }) - // return - // } + if (tmp.phone.length === 0){ + wx.navigateTo({ + url: '../login/index', + }) + return + } wx.navigateTo({ url: '../community/add', }) diff --git a/pages/community/info.wxml b/pages/community/info.wxml index f3832a3..43ef45d 100644 --- a/pages/community/info.wxml +++ b/pages/community/info.wxml @@ -15,7 +15,7 @@ - + diff --git a/pages/garden/index.js b/pages/garden/index.js index 7125e77..a4fc30d 100644 --- a/pages/garden/index.js +++ b/pages/garden/index.js @@ -3,7 +3,8 @@ const { api } = require("../../utils/api") // index.js Page({ data: { - list:[] + list:[], + dash:null }, onLoad(options) { @@ -30,6 +31,14 @@ Page({ this.setData({list:res.data}) } }) + + api('/plant/taskProgress','GET').then(res => { + if (res.code == 200){ + const dash = res.data + dash.progress = parseFloat((dash.progress * 100).toFixed(2)) + this.setData({dash:dash}) + } + }) }, goAdd(){ wx.navigateTo({ diff --git a/pages/garden/index.wxml b/pages/garden/index.wxml index c243e7a..8bfea80 100644 --- a/pages/garden/index.wxml +++ b/pages/garden/index.wxml @@ -1,16 +1,16 @@ - + - 📅 今日养护(4个任务) + 📅 今日养护( {{dash.total}}个任务) - 已经完成 4 / 5 + 已经完成 {{dash.complete}} / {{dash.total}} - + @@ -31,7 +31,7 @@ {{item.name}} - + diff --git a/pages/index/index.js b/pages/index/index.js index 7f72f63..a1d76df 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -141,12 +141,12 @@ Page({ goAdd() { const tmp = wx.getStorageSync('user') - // if (tmp.phone.length === 0){ - // wx.navigateTo({ - // url: '../login/index', - // }) - // return - // } + if (tmp.phone.length === 0){ + wx.navigateTo({ + url: '../login/index', + }) + return + } wx.navigateTo({ url: '../add/index', }) diff --git a/pages/login/index.js b/pages/login/index.js index c3c87a8..36ac0b7 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -52,8 +52,6 @@ Page({ api("/auth/getPhone", 'GET', data).then(res => { wx.hideLoading() if (res.code === 200) { - wx.setStorageSync('user', res.data.user) - wx.setStorageSync('token', res.data.token) wx.navigateBack() } else { wx.showToast({ diff --git a/pages/user/index.js b/pages/user/index.js index 9fe53e9..1b50f90 100644 --- a/pages/user/index.js +++ b/pages/user/index.js @@ -60,6 +60,7 @@ Page({ if (data.code === 200) { const tmps = _this.data.user tmps.avatar = data.data.file + tmps.avatarId = data.data.file.id _this.setData({ user:tmps })