feat: 电子药箱小程序 - 4Tab药品管理
- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
const MEMBER_KEY = 'family_member';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
avatars: ['👤', '👨', '👩', '👴', '👵', '👶', '🧒', '👦', '👧'],
|
||||
relations: ['本人', '配偶', '父亲', '母亲', '儿子', '女儿', '爷爷', '奶奶', '外公', '外婆', '其他'],
|
||||
bloodTypes: ['A', 'B', 'AB', 'O', '未知'],
|
||||
relationIdx: -1,
|
||||
today: '',
|
||||
form: {
|
||||
avatar: '👤',
|
||||
name: '',
|
||||
gender: '',
|
||||
birthday: '',
|
||||
relation: '',
|
||||
bloodType: '',
|
||||
allergies: '',
|
||||
chronicDiseases: '',
|
||||
longTermMeds: '',
|
||||
notes: '',
|
||||
},
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
const today = new Date();
|
||||
this.setData({
|
||||
today: `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`,
|
||||
});
|
||||
|
||||
const member = wx.getStorageSync(MEMBER_KEY);
|
||||
if (member && member.name) {
|
||||
this.setData({
|
||||
form: { ...this.data.form, ...member },
|
||||
relationIdx: this.data.relations.indexOf(member.relation),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
pickAvatar(e: WechatMiniprogram.TouchEvent) {
|
||||
this.setData({ 'form.avatar': e.currentTarget.dataset.avatar });
|
||||
},
|
||||
|
||||
onField(e: WechatMiniprogram.Input) {
|
||||
this.setData({ [`form.${e.currentTarget.dataset.field}`]: e.detail.value });
|
||||
},
|
||||
|
||||
onRelationChange(e: WechatMiniprogram.PickerChange) {
|
||||
const idx = Number(e.detail.value);
|
||||
this.setData({ relationIdx: idx, 'form.relation': this.data.relations[idx] });
|
||||
},
|
||||
|
||||
onBirthdayChange(e: WechatMiniprogram.PickerChange) {
|
||||
this.setData({ 'form.birthday': e.detail.value });
|
||||
},
|
||||
|
||||
pickGender(e: WechatMiniprogram.TouchEvent) {
|
||||
this.setData({ 'form.gender': e.currentTarget.dataset.gender });
|
||||
},
|
||||
|
||||
pickBlood(e: WechatMiniprogram.TouchEvent) {
|
||||
this.setData({ 'form.bloodType': e.currentTarget.dataset.bt });
|
||||
},
|
||||
|
||||
save() {
|
||||
if (!this.data.form.name.trim()) {
|
||||
wx.showToast({ title: '请输入姓名', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
wx.setStorageSync(MEMBER_KEY, this.data.form);
|
||||
wx.showToast({ title: '已保存', icon: 'success' });
|
||||
setTimeout(() => wx.navigateBack(), 800);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user