From a015ee7de3d3e92a59bac1da1f698000a173250d Mon Sep 17 00:00:00 2001 From: ypc <15051963820@163.com> Date: Sat, 6 Jun 2026 22:26:09 +0800 Subject: [PATCH] =?UTF-8?q?<=E4=BF=AE=E6=94=B9>=201=E3=80=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=94=A8=E6=88=B7=E9=80=89=E9=A1=B9=EF=BC=8C=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E4=B8=BA=E5=A4=9A=E7=94=A8=E6=88=B7=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 112 +++++++++++++---- app.wxss | 17 +++ pages/details/details.js | 25 +++- pages/details/details.wxml | 5 + pages/entry/entry.js | 23 +++- pages/entry/entry.wxml | 5 + pages/home/home.js | 174 +++++++++++++++++++++++++- pages/home/home.wxml | 104 ++++++++++++++-- pages/home/home.wxss | 235 ++++++++++++++++++++++++++++++++---- pages/items/items.js | 16 ++- pages/items/items.wxml | 5 + pages/trend/trend.js | 16 ++- pages/trend/trend.wxml | 5 + project.config.json | 14 ++- project.private.config.json | 11 +- 15 files changed, 689 insertions(+), 78 deletions(-) diff --git a/app.js b/app.js index 672be92..2a428a1 100644 --- a/app.js +++ b/app.js @@ -1,36 +1,95 @@ -App({ +App({ globalData: { - items: ["血红蛋白", "尿素", "肌酐", "尿酸", "血钾", "血钙", "血磷", "β2微球蛋白", "体重"], - records: [] + currentPersonId: null, + persons: [], + dataMap: {} }, onLaunch() { - const defaults = ["血红蛋白", "尿素", "肌酐", "尿酸", "血钾", "血钙", "血磷", "β2微球蛋白", "体重"] - const data = wx.getStorageSync("health_data") + // 清除旧版存储,避免残留 + wx.removeStorageSync("health_data") + var data = wx.getStorageSync("health_data_v2") if (data) { - // 合并:保留用户自定义项目,同时补上新增的默认项目 - const storedItems = data.items || [] - const merged = [...defaults] - storedItems.forEach(item => { - if (!merged.includes(item)) merged.push(item) - }) - this.globalData.items = merged - this.globalData.records = data.records || [] - } else { - this.globalData.items = [...defaults] + this.globalData.persons = data.persons || [] + this.globalData.dataMap = data.dataMap || {} + this.globalData.currentPersonId = data.currentPersonId || (this.globalData.persons[0] && this.globalData.persons[0].id) || null } - this.saveData() + // 无存储或 persons 为空时,由首页弹窗引导创建首个用户 + }, + + _defaultItems() { + return ["血红蛋白", "尿素", "肌酐", "尿酸", "血钾", "血钙", "血磷", "β2微球蛋白", "体重"] }, saveData() { - wx.setStorageSync("health_data", { - items: this.globalData.items, - records: this.globalData.records + wx.setStorageSync("health_data_v2", { + persons: this.globalData.persons, + dataMap: this.globalData.dataMap, + currentPersonId: this.globalData.currentPersonId }) }, + getCurrentData() { + var id = this.globalData.currentPersonId + if (!id || !this.globalData.dataMap[id]) return { items: [], records: [] } + return this.globalData.dataMap[id] + }, + + getCurrentPerson() { + var id = this.globalData.currentPersonId + var persons = this.globalData.persons + for (var i = 0; i < persons.length; i++) { + if (persons[i].id === id) return persons[i] + } + return null + }, + + switchPerson(id) { + if (!this.globalData.dataMap[id]) return false + this.globalData.currentPersonId = id + this.saveData() + return true + }, + + addPerson(name) { + var id = Date.now().toString(36) + Math.random().toString(36).slice(2, 6) + this.globalData.persons.push({ id: id, name: name }) + // 新用户默认有一份默认项目列表 + this.globalData.dataMap[id] = { + items: this._defaultItems(), + records: [] + } + this.saveData() + return id + }, + + removePerson(id) { + var persons = this.globalData.persons + if (persons.findIndex(function(p){return p.id===id}) < 0) return false + this.globalData.persons = persons.filter(function (p) { return p.id !== id }) + delete this.globalData.dataMap[id] + if (this.globalData.currentPersonId === id) { + this.globalData.currentPersonId = this.globalData.persons.length > 0 ? this.globalData.persons[0].id : null + } + this.saveData() + return true + }, + + renamePerson(id, newName) { + var persons = this.globalData.persons + for (var i = 0; i < persons.length; i++) { + if (persons[i].id === id) { + persons[i].name = newName + this.saveData() + return true + } + } + return false + }, + addRecord(record) { - this.globalData.records.push({ + var data = this.getCurrentData() + data.records.push({ id: Date.now().toString(36) + Math.random().toString(36).slice(2, 6), item: record.item, date: record.date, @@ -40,20 +99,23 @@ }, deleteRecord(id) { - this.globalData.records = this.globalData.records.filter(r => r.id !== id) + var data = this.getCurrentData() + data.records = data.records.filter(function (r) { return r.id !== id }) this.saveData() }, addItem(name) { - if (!this.globalData.items.includes(name)) { - this.globalData.items.push(name) + var data = this.getCurrentData() + if (data.items.indexOf(name) === -1) { + data.items.push(name) this.saveData() } }, removeItem(name) { - this.globalData.items = this.globalData.items.filter(i => i !== name) - this.globalData.records = this.globalData.records.filter(r => r.item !== name) + var data = this.getCurrentData() + data.items = data.items.filter(function (i) { return i !== name }) + data.records = data.records.filter(function (r) { return r.item !== name }) this.saveData() } }) diff --git a/app.wxss b/app.wxss index a0c0d6c..5dd8e1f 100644 --- a/app.wxss +++ b/app.wxss @@ -25,6 +25,23 @@ page { min-height: 100vh; } +/* ===== 用户标识栏(各页面顶部) ===== */ +.user-info-bar { + display: flex; + align-items: center; + margin-bottom: 20rpx; + padding: 16rpx 24rpx; + background: #fff; + border-radius: 10rpx; + box-shadow: 0 1px 3px rgba(0,0,0,0.06); +} + +.user-info-text { + font-size: 28rpx; + font-weight: 500; + color: #2c7a7b; +} + /* ===== 通用卡片 ===== */ .card { background: #fff; diff --git a/pages/details/details.js b/pages/details/details.js index a48a923..031a741 100644 --- a/pages/details/details.js +++ b/pages/details/details.js @@ -2,6 +2,8 @@ var app = getApp() Page({ data: { + persons: [], + currentPersonName: "", items: [], viewMode: "month", filterMonth: "", @@ -18,8 +20,11 @@ Page({ var today = this.formatDate(new Date(), "day") var month = today.slice(0, 7) var year = today.slice(0, 4) + var person = app.getCurrentPerson() this.setData({ - items: app.globalData.items, + persons: app.globalData.persons, + currentPersonName: person ? person.name : "", + items: app.getCurrentData().items, filterMonth: month, filterYear: year, customStart: month, @@ -29,7 +34,12 @@ Page({ }, onShow: function () { - var items = app.globalData.items + var items = app.getCurrentData().items + var person = app.getCurrentPerson() + this.setData({ + persons: app.globalData.persons, + currentPersonName: person ? person.name : "" + }) if (items.length !== this.data.items.length || items.some(function (v, i) { return v !== this.data.items[i] }, this)) { this.setData({ items: items }) @@ -69,7 +79,8 @@ Page({ }, refreshData: function () { - var records = app.globalData.records + var data = app.getCurrentData() + var records = data.records var items = this.data.items var range = this.getDateRange() var start = range.start @@ -140,7 +151,8 @@ Page({ confirmColor: "#e53e3e", success: function (res) { if (!res.confirm) return - app.globalData.records = app.globalData.records.filter(function (r) { return r.date !== dateKey }) + var data = app.getCurrentData() + data.records = data.records.filter(function (r) { return r.date !== dateKey }) app.saveData() that.refreshData() wx.showToast({ title: "已删除", icon: "success", duration: 1000 }) @@ -185,15 +197,16 @@ Page({ var items = this.data.items var savedCount = 0 var that = this + var data = app.getCurrentData() - app.globalData.records = app.globalData.records.filter(function (r) { return r.date !== editingDate }) + data.records = data.records.filter(function (r) { return r.date !== editingDate }) items.forEach(function (item) { var raw = editValues[item] if (!raw || raw.trim() === "") return var v = parseFloat(raw) if (isNaN(v) || v <= 0) return - app.globalData.records.push({ + data.records.push({ id: Date.now().toString(36) + Math.random().toString(36).slice(2, 6), item: item, date: editingDate, diff --git a/pages/details/details.wxml b/pages/details/details.wxml index 65548b7..636c5f3 100644 --- a/pages/details/details.wxml +++ b/pages/details/details.wxml @@ -1,5 +1,10 @@ + + + + + diff --git a/pages/entry/entry.js b/pages/entry/entry.js index 8556549..3fd8f8f 100644 --- a/pages/entry/entry.js +++ b/pages/entry/entry.js @@ -2,6 +2,8 @@ var app = getApp() Page({ data: { + persons: [], + currentPersonName: "", items: [], inputDate: "", values: {}, @@ -10,12 +12,23 @@ Page({ onLoad: function () { var today = this.formatDate(new Date()) - this.setData({ inputDate: today, items: app.globalData.items }) + var person = app.getCurrentPerson() + this.setData({ + persons: app.globalData.persons, + currentPersonName: person ? person.name : "", + inputDate: today, + items: app.getCurrentData().items + }) this.loadExisting(today) }, onShow: function () { - var items = app.globalData.items + var person = app.getCurrentPerson() + var items = app.getCurrentData().items + this.setData({ + persons: app.globalData.persons, + currentPersonName: person ? person.name : "" + }) if (items.length !== this.data.items.length || items.some(function (v, i) { return v !== this.data.items[i] }, this)) { this.setData({ items: items }) @@ -24,7 +37,8 @@ Page({ }, loadExisting: function (date) { - var records = app.globalData.records.filter(function (r) { return r.date === date }) + var data = app.getCurrentData() + var records = data.records.filter(function (r) { return r.date === date }) this.setData({ existingRecords: records }) }, @@ -48,6 +62,7 @@ Page({ var values = this.data.values var savedCount = 0 var that = this + var data = app.getCurrentData() items.forEach(function (item) { var raw = values[item] @@ -55,7 +70,7 @@ Page({ var v = parseFloat(raw) if (isNaN(v) || v <= 0) return - var existing = app.globalData.records.find(function (r) { return r.item === item && r.date === inputDate }) + var existing = data.records.find(function (r) { return r.item === item && r.date === inputDate }) if (existing) { existing.value = v } else { diff --git a/pages/entry/entry.wxml b/pages/entry/entry.wxml index 325438f..8d5434f 100644 --- a/pages/entry/entry.wxml +++ b/pages/entry/entry.wxml @@ -1,5 +1,10 @@ + + + 选择日期 diff --git a/pages/home/home.js b/pages/home/home.js index 1d181c7..ea5cbc5 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -1,6 +1,44 @@ var app = getApp() Page({ + data: { + persons: [], + personNames: [], + currentPersonName: "", + currentPersonIndex: 0, + showAddInput: false, + newPersonName: "", + showForceModal: false, + forceName: "", + showPersonModal: false, + editingPersonId: "", + editingPersonName: "" + }, + + onShow: function () { + this.refreshView() + }, + + refreshView: function () { + var persons = app.globalData.persons + var names = persons.map(function (p) { return p.name }) + var person = app.getCurrentPerson() + var idx = persons.findIndex(function (p) { return p && person && p.id === person.id }) + this.setData({ + persons: persons, + personNames: names, + currentPersonName: person ? person.name : "", + currentPersonIndex: idx >= 0 ? idx : 0 + }) + if (persons.length === 0) { + this.setData({ showForceModal: true }) + } else { + this.setData({ showForceModal: false }) + } + }, + + noop: function () {}, + goEntry: function () { wx.navigateTo({ url: '/pages/entry/entry' }) }, @@ -13,19 +51,151 @@ Page({ goDetails: function () { wx.navigateTo({ url: '/pages/details/details' }) }, + onClearAll: function () { var that = this wx.showModal({ title: "⚠️ 危险操作", - content: "确定要清除所有检查记录吗?\n此操作将删除所有历史数据,但保留检查项目,且不可恢复!", + content: "确定要清除「" + this.data.currentPersonName + "」的所有检查记录吗?\n此操作将删除所有历史数据,但保留检查项目,且不可恢复!", confirmText: "确认清除", confirmColor: "#e53e3e", success: function (res) { if (!res.confirm) return - app.globalData.records = [] + var data = app.getCurrentData() + data.records = [] app.saveData() wx.showToast({ title: "已清除全部记录", icon: "success", duration: 1500 }) } }) + }, + + // ===== 切换用户 ===== + onSwitchPerson: function (e) { + var idx = parseInt(e.detail.value) + var persons = this.data.persons + if (idx === this.data.currentPersonIndex) return + var person = persons[idx] + if (!person) return + app.switchPerson(person.id) + this.refreshView() + wx.showToast({ title: "已切换至" + person.name, icon: "success", duration: 1000 }) + }, + + // ===== 新增用户(首页行内) ===== + onShowAddInput: function () { + this.setData({ showAddInput: true, newPersonName: "" }) + }, + + onCancelAddPerson: function () { + this.setData({ showAddInput: false, newPersonName: "" }) + }, + + onAddNameInput: function (e) { + this.setData({ newPersonName: e.detail.value }) + }, + + onConfirmAddPerson: function () { + var name = this.data.newPersonName.trim() + if (!name) { + wx.showToast({ title: "请输入用户名", icon: "none" }) + return + } + if (name.length > 10) { + wx.showToast({ title: "用户名最多10个字符", icon: "none" }) + return + } + app.addPerson(name) + app.switchPerson(app.globalData.persons[app.globalData.persons.length - 1].id) + this.setData({ showAddInput: false, newPersonName: "" }) + this.refreshView() + wx.showToast({ title: "已添加" + name, icon: "success", duration: 1000 }) + }, + + // ===== 强制创建首个用户(无用户弹窗) ===== + onForceNameInput: function (e) { + this.setData({ forceName: e.detail.value }) + }, + + onConfirmForceCreate: function () { + var name = this.data.forceName.trim() + if (!name) { + wx.showToast({ title: "请先创建用户", icon: "none" }) + return + } + if (name.length > 10) { + wx.showToast({ title: "用户名最多10个字符", icon: "none" }) + return + } + var id = app.addPerson(name) + app.switchPerson(id) + this.setData({ showForceModal: false, forceName: "" }) + this.refreshView() + wx.showToast({ title: "欢迎," + name, icon: "success", duration: 1200 }) + }, + + onCancelForceCreate: function () { + // 取消了,但仍无用户,弹窗不退 + wx.showToast({ title: "请先创建用户", icon: "none" }) + }, + + // ===== 用户管理弹窗(重命名/删除) ===== + onTogglePersonModal: function () { + this.setData({ + showPersonModal: !this.data.showPersonModal, + editingPersonId: "", + editingPersonName: "" + }) + }, + + onStartRename: function (e) { + var id = e.currentTarget.dataset.id + var person = this.data.persons.find(function (p) { return p.id === id }) + this.setData({ + editingPersonId: id, + editingPersonName: person ? person.name : "" + }) + }, + + onEditNameInput: function (e) { + this.setData({ editingPersonName: e.detail.value }) + }, + + onConfirmRename: function () { + var name = this.data.editingPersonName.trim() + if (!name) { + wx.showToast({ title: "请输入新名称", icon: "none" }) + return + } + if (name.length > 10) { + wx.showToast({ title: "用户名最多10个字符", icon: "none" }) + return + } + app.renamePerson(this.data.editingPersonId, name) + this.setData({ editingPersonId: "", editingPersonName: "" }) + this.refreshView() + wx.showToast({ title: "已重命名", icon: "success", duration: 1000 }) + }, + + onDeletePerson: function (e) { + var id = e.currentTarget.dataset.id + var person = this.data.persons.find(function (p) { return p.id === id }) + if (!person) return + var that = this + wx.showModal({ + title: "确认删除", + content: "确定删除用户「" + person.name + "」吗?\n该用户的所有数据将被永久删除。", + confirmColor: "#e53e3e", + success: function (res) { + if (!res.confirm) return + app.removePerson(id) + that.setData({ editingPersonId: "", editingPersonName: "" }) + // 删完后如无用户,关闭管理弹窗并强制展示创建弹窗 + if (app.globalData.persons.length === 0) { + that.setData({ showPersonModal: false }) + } + that.refreshView() + wx.showToast({ title: "已删除", icon: "success", duration: 1000 }) + } + }) } }) diff --git a/pages/home/home.wxml b/pages/home/home.wxml index abe6bad..d25e108 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -1,12 +1,42 @@ + + + + + 👤 + {{currentPersonName}} + + + + + + + + + + + + + 确认 + 取消 + + 健康数据追踪 选择您需要的功能 - 📝 @@ -15,7 +45,6 @@ 记录每日健康指标 - ⚙️ @@ -24,7 +53,6 @@ 自定义追踪指标 - 📈 @@ -33,7 +61,6 @@ 查看变化趋势图 - 📋 @@ -43,11 +70,74 @@ - - + 🗑️ - 清除所有历史数据 + 清除{{currentPersonName}}的历史数据 + + + + + + + + 欢迎使用健康数据追踪 + 请先创建您的第一位用户 + + + + + + + + + + + + + 用户管理 + + + + + {{item.name}} + + + ✏️ + 🗑️ + + + + + + + + + + + + diff --git a/pages/home/home.wxss b/pages/home/home.wxss index cee3b92..6f65f57 100644 --- a/pages/home/home.wxss +++ b/pages/home/home.wxss @@ -4,9 +4,119 @@ background: linear-gradient(180deg, #e6f2f2 0%, #f5f7fa 30%); } +/* ===== 用户栏 ===== */ +.person-bar { + display: flex; + align-items: center; + justify-content: space-between; + background: #fff; + margin: 20rpx 24rpx 0; + padding: 16rpx 28rpx; + border-radius: 12rpx; + box-shadow: 0 1px 3px rgba(0,0,0,0.06); +} + +.person-selector { + display: flex; + align-items: center; + gap: 12rpx; +} + +.person-icon { + font-size: 32rpx; +} + +.person-name { + font-size: 30rpx; + font-weight: 600; + color: #2c7a7b; +} + +.person-arrow { + font-size: 20rpx; + color: #a0aec0; +} + +.person-bar-right { + display: flex; + align-items: center; + gap: 20rpx; +} + +.person-bar-btn { + width: 48rpx; + height: 48rpx; + line-height: 48rpx; + text-align: center; + font-size: 32rpx; + font-weight: 600; + color: #2c7a7b; + background: #e6f2f2; + border-radius: 50%; +} + +.person-bar-btn:active { + background: #d0e8e8; +} + +.person-bar-btn--manage { + font-size: 26rpx; + color: #718096; + background: #f7fafc; +} + +/* ===== 行内新增用户输入 ===== */ +.add-person-row { + display: flex; + align-items: center; + gap: 16rpx; + margin: 16rpx 24rpx 0; + padding: 16rpx 20rpx; + background: #fff; + border-radius: 12rpx; + box-shadow: 0 1px 3px rgba(0,0,0,0.06); +} + +.add-person-input { + flex: 1; + padding: 14rpx 16rpx; + border: 1rpx solid #2c7a7b; + border-radius: 8rpx; + font-size: 28rpx; + height: 52rpx; + box-sizing: border-box; +} + +.add-person-btn { + flex-shrink: 0; + font-size: 26rpx; + font-weight: 500; + padding: 12rpx 20rpx; + border-radius: 8rpx; +} + +.add-person-btn--confirm { + color: #fff; + background: #2c7a7b; +} + +.add-person-btn--confirm:active { + background: #1a5c5d; +} + +.add-person-btn--cancel { + color: #718096; + background: #edf2f7; +} + +.add-person-btn--cancel:active { + background: #e2e8f0; +} + +/* ===== 页面标题 ===== */ .home-header { text-align: center; - padding: 60rpx 0 40rpx; + padding: 50rpx 0 0; } .home-title { @@ -26,7 +136,7 @@ display: grid; grid-template-columns: 1fr 1fr; gap: 20rpx; - padding: 0 24rpx; + padding: 40rpx 24rpx 0; } .home-card { @@ -58,21 +168,10 @@ line-height: 1; } -.home-card-icon--entry { - background: #e6f7ff; -} - -.home-card-icon--items { - background: #f0f5ff; -} - -.home-card-icon--trend { - background: #f6ffed; -} - -.home-card-icon--details { - background: #fff7e6; -} +.home-card-icon--entry { background: #e6f7ff; } +.home-card-icon--items { background: #f0f5ff; } +.home-card-icon--trend { background: #f6ffed; } +.home-card-icon--details { background: #fff7e6; } .home-card-title { display: block; @@ -103,16 +202,106 @@ background: #fff5f5; } -.clear-btn:active { - background: #ffe0e0; -} +.clear-btn:active { background: #ffe0e0; } -.clear-icon { - font-size: 32rpx; -} +.clear-icon { font-size: 32rpx; } .clear-text { font-size: 26rpx; color: #e53e3e; font-weight: 500; } + +/* ===== 无用户强制弹窗 ===== */ +.modal-desc { + font-size: 28rpx; + color: #718096; + text-align: center; + margin-bottom: 24rpx; +} + +.force-input-row { margin-bottom: 8rpx; } + +.force-input { + width: 100%; + padding: 18rpx 20rpx; + border: 2rpx solid #2c7a7b; + border-radius: 10rpx; + font-size: 30rpx; + text-align: center; + box-sizing: border-box; + height: 60rpx; +} + +/* ===== 用户管理弹窗 ===== */ +.person-list { margin-bottom: 20rpx; } + +.person-list-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 22rpx 16rpx; + border-radius: 10rpx; + margin-bottom: 8rpx; + background: #f7fafc; + border: 1rpx solid #edf2f7; +} + +.person-list-item--active { + background: #e6f2f2; + border-color: #2c7a7b; +} + +.person-list-left { + display: flex; + align-items: center; + gap: 12rpx; +} + +.person-list-name { + font-size: 28rpx; + font-weight: 500; + color: #2d3748; +} + +.person-list-item--active .person-list-name { + color: #2c7a7b; + font-weight: 600; +} + +.person-list-right { + display: flex; + gap: 20rpx; +} + +.person-list-action { + font-size: 28rpx; + padding: 4rpx; +} + +.person-edit-row { + display: flex; + gap: 16rpx; + align-items: center; + margin-bottom: 8rpx; +} + +.person-edit-input { + flex: 1; + padding: 16rpx 20rpx; + border: 1rpx solid #e2e8f0; + border-radius: 8rpx; + background: #f7fafc; + font-size: 28rpx; + height: 56rpx; + box-sizing: border-box; +} + +.person-edit-btn { + flex-shrink: 0; + width: 130rpx; + height: 56rpx; + line-height: 56rpx; + padding: 0; + font-size: 26rpx; +} diff --git a/pages/items/items.js b/pages/items/items.js index bd4344e..d0da023 100644 --- a/pages/items/items.js +++ b/pages/items/items.js @@ -2,12 +2,19 @@ var app = getApp() Page({ data: { + persons: [], + currentPersonName: "", items: [], newItemName: "" }, onShow: function () { - this.setData({ items: app.globalData.items }) + var person = app.getCurrentPerson() + this.setData({ + persons: app.globalData.persons, + currentPersonName: person ? person.name : "", + items: app.getCurrentData().items + }) }, onNameInput: function (e) { @@ -20,13 +27,14 @@ Page({ wx.showToast({ title: "请输入项目名称", icon: "none" }) return } - if (app.globalData.items.indexOf(name) > -1) { + var data = app.getCurrentData() + if (data.items.indexOf(name) > -1) { wx.showToast({ title: "该项目已存在", icon: "none" }) return } app.addItem(name) this.setData({ - items: app.globalData.items, + items: app.getCurrentData().items, newItemName: "" }) wx.showToast({ title: "已添加", icon: "success", duration: 1000 }) @@ -42,7 +50,7 @@ Page({ success: function (res) { if (!res.confirm) return app.removeItem(item) - that.setData({ items: app.globalData.items }) + that.setData({ items: app.getCurrentData().items }) wx.showToast({ title: "已删除", icon: "success", duration: 1000 }) } }) diff --git a/pages/items/items.wxml b/pages/items/items.wxml index b193379..3a25e33 100644 --- a/pages/items/items.wxml +++ b/pages/items/items.wxml @@ -1,5 +1,10 @@ + + + 新增检查项目 diff --git a/pages/trend/trend.js b/pages/trend/trend.js index 7404c31..730c377 100644 --- a/pages/trend/trend.js +++ b/pages/trend/trend.js @@ -5,6 +5,8 @@ var COLORS = ["#e53e3e", "#3182ce", "#38a169", "#d69e2e", "#805ad5", "#dd6b20", Page({ data: { + persons: [], + currentPersonName: "", items: [], filterItems: [], viewMode: "month", @@ -20,8 +22,11 @@ Page({ var today = this.formatDate(new Date(), "day") var month = today.slice(0, 7) var year = today.slice(0, 4) - var items = app.globalData.items + var items = app.getCurrentData().items + var person = app.getCurrentPerson() this.setData({ + persons: app.globalData.persons, + currentPersonName: person ? person.name : "", items: items, filterItems: items.slice(), filterMonth: month, @@ -36,7 +41,12 @@ Page({ }, onShow: function () { - var items = app.globalData.items + var items = app.getCurrentData().items + var person = app.getCurrentPerson() + this.setData({ + persons: app.globalData.persons, + currentPersonName: person ? person.name : "" + }) if (items.length !== this.data.items.length || items.some(function (v, i) { return v !== this.data.items[i] }, this)) { this.setData({ items: items }) @@ -99,7 +109,7 @@ Page({ }, refreshChart: function () { - var records = app.globalData.records + var records = app.getCurrentData().records var filterItems = this.data.filterItems var range = this.getDateRange() var start = range.start diff --git a/pages/trend/trend.wxml b/pages/trend/trend.wxml index 63007e2..f2cfb4b 100644 --- a/pages/trend/trend.wxml +++ b/pages/trend/trend.wxml @@ -1,5 +1,10 @@ + + + diff --git a/project.config.json b/project.config.json index 41a8b4b..3d30687 100644 --- a/project.config.json +++ b/project.config.json @@ -12,7 +12,16 @@ "outputPath": "" }, "useCompilerPlugins": false, - "minifyWXML": true + "minifyWXML": true, + "compileWorklet": false, + "uploadWithSourceMap": true, + "packNpmManually": false, + "minifyWXSS": true, + "localPlugins": false, + "disableUseStrict": false, + "condition": false, + "swc": false, + "disableSWC": true }, "compileType": "miniprogram", "simulatorPluginLibVersion": {}, @@ -22,5 +31,6 @@ }, "appid": "wxefee3681fb349e54", "editorSetting": {}, - "testRoot": "minitest/" + "testRoot": "minitest/", + "libVersion": "3.15.2" } \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json index 2b46f79..f349875 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -1,6 +1,6 @@ { "libVersion": "3.15.2", - "projectname": "%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F", + "projectname": "weixinxiaochengxu", "setting": { "urlCheck": true, "coverView": true, @@ -9,6 +9,13 @@ "preloadBackgroundData": false, "autoAudits": false, "showShadowRootInWxmlPanel": true, - "compileHotReLoad": true + "compileHotReLoad": true, + "useApiHook": true, + "useStaticServer": false, + "useLanDebug": false, + "showES6CompileOption": false, + "checkInvalidKey": true, + "ignoreDevUnusedFiles": true, + "bigPackageSizeSupport": false } } \ No newline at end of file