feat: 电子药箱小程序 - 4Tab药品管理

- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡
- 药品百科: 搜索 + 分类筛选 + 20种药品静态数据
- 惠教中心: 4条药品使用指南课程
- 我的: 家庭成员信息管理
- 自定义TabBar + navigation-bar组件
- SVG药品分类插图
This commit is contained in:
陈誉午
2026-07-29 11:20:52 +08:00
commit 994b267f5c
683 changed files with 43849 additions and 0 deletions
@@ -0,0 +1,10 @@
export type locationItemType = {
id: number,
mbuId: number,
address: string,
areaId: number,
defaultStatus: boolean | number,
location: string[],
name: string,
mobile: string
}
@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"van-switch": "@vant/weapp/switch/index"
}
}
@@ -0,0 +1,93 @@
/* components/location-item/location-item.wxss */
@import "variables";
.item {
display: flex;
border-radius: $primary-border-radius;
justify-content: space-between;
align-items: center;
background: white;
margin-bottom: $primary-border-radius;
min-height: 180rpx;
padding: $primary-gap;
.info {
display: flex;
flex-direction: column;
width: 100%;
.location {
height: 60rpx;
line-height: 60rpx;
color: $gray-color;
display: flex;
justify-content: space-between;
// align-items: center;
.delete {
width: $primary-gap * 1.3;
height: $primary-gap * 1.3;
image {
width: 100%;
height: 100%;
}
}
}
.address {
// height: 70rpx;
line-height: 70rpx;
font-size: $large-font-size;
font-weight: 600;
display: flex;
justify-content: space-between;
// align-items: center;
.address-info {
max-width: 600rpx;
}
.edit {
width: $primary-gap * 1.5;
height: $primary-gap * 1.5;
line-height: 85rpx;
}
}
.footer {
display: flex;
justify-content: space-between;
.user {
height: 60rpx;
display: flex;
flex-direction: row;
line-height: 60rpx;
.phone {
margin-left: $primary-gap;
}
}
.default-address {
display: flex;
align-items: center;
gap: $primary-gap;
.default-item {
line-height: 60rpx;
color: $primary-color;
}
.switch {
margin-top: 6rpx;
}
}
}
}
}
@@ -0,0 +1,160 @@
// @ts-nocheck
import { request } from '../../../utils/request'
import { locationItemType } from './location-item'
Component({
properties: {
item: {} as locationItemType,
selectLocation: {
type: Boolean,
value: true
}
},
data: {
locationStr: ''
},
observers: {
'item.location': function (location: string[]) {
if (location && Array.isArray(location)) {
this.setData({
locationStr: location.join(' ')
})
}
},
},
methods: {
handleEdit() {
console.log("this.data.item", this.data.item)
this.triggerEvent('edit', { item: this.data.item })
},
handleDelete() {
wx.showModal({
title: '地址设置',
content: '要将此收货地址删除吗?',
success: async (res) => {
if (res.confirm) {
wx.showLoading({ title: "加载中" })
try {
await request({
options: {
url: "/app/member-address/remove",
data: {
// mbuId: Number(wx.getStorageSync("mbuId")),
id: this.data.item.id
}
}
}).then(() => {
wx.showToast({ title: "删除成功" })
if (this.data.item.defaultStatus) {
wx.removeStorageSync("addressId");
wx.removeStorageSync("defualtAddress");
}
this.triggerEvent("refresh")
})
} catch {
}
}
}
})
},
handleSelect() {
// console.log(this.data.item)
if (this.data.selectLocation) {
wx.showModal({
title: '地址设置',
content: '要选择此收货地址吗?',
success: (res) => {
if (res.confirm) {
this.triggerEvent("select", {
id: this.data.item.id,
item: this.data.item
});
}
},
// success: async (res) => {
// if (res.confirm) {
// const value: any = {
// location: this.data.item.location,
// address: this.data.item.address,
// mobile: this.data.item.mobile,
// name: this.data.item.name,
// id: this.data.item.id,
// defaultStatus: 1,
// mbuId: wx.getStorageSync('mbuId')
// }
// try {
// await request<any[]>({
// options: {
// url: "/app/member-address/editor",
// data: value
// }, loadingTitle: "保存中"
// })
// .then(() => {
// // wx.showToast({ title: "设置地址成功!", duration: 1000 })
// wx.setStorage({ key: "addressId", data: this.data.item.id })
// if (this.data.item.location) wx.setStorage({ key: "defualtAddress", data: `${this.data.item.location.join("")}${this.data.item.address}` })
// this.triggerEvent("refresh")
// }).then(() => {
// wx.navigateBack()
// })
// } catch (e) {
// console.log(e, '出现错误')
// }
// } else if (res.cancel) {
// console.log('用户点击了取消')
// }
// },
fail: (e) => {
console.log(e, '错误')
}
})
}
},
stopTap() { },//阻止点击穿透
handleSwitch(e) {
const checked = e.detail;
if (!checked) {
wx.showToast({ title: "不能取消默认地址,请切换到其他默认地址~", icon: "none" });
return;
}
wx.showModal({
title: '地址设置',
content: '要将此地址设置为默认收货地址吗?',
success: async (res) => {
if (res.confirm) {
const value = {
location: this.data.item.location,
address: this.data.item.address,
mobile: this.data.item.mobile,
name: this.data.item.name,
id: this.data.item.id,
defaultStatus: 1,
mbuId: wx.getStorageSync('mbuId')
};
await request({
options: {
url: "/app/member-address/editor",
data: value
},
loadingTitle: "保存中"
});
wx.setStorageSync("addressId", this.data.item.id);
if (this.data.item.location) {
wx.setStorageSync(
"defualtAddress",
`${this.data.item.location.join("")}${this.data.item.address}`
);
}
this.triggerEvent("refresh");
}
}
});
},
}
})
@@ -0,0 +1,31 @@
<!--components/location-item/location-item.wxml-->
<view class="item">
<view class="info" bind:tap="handleSelect">
<view class="location">
{{locationStr}}
<view class="delete" catch:tap="handleDelete">
<image src="../../../assets/img/delete.svg"></image>
</view>
</view>
<view class="address">
<view class="address-info">{{item.address}}</view>
<view class="edit" catch:tap="handleEdit">
<image style="width: 100%;height: 100%;" src="../../../assets/img/edit.svg" class="icon" />
</view>
</view>
<view class="footer">
<view class="user">
<view class="name">{{item.name}}</view>
<view class="phone">{{item.mobile}}</view>
</view>
<view class="default-address">
<view class="default-item" wx:if="{{item.defaultStatus}}">默认收货地址</view>
<view class="default-item" style="color: #AEADB2;" wx:if="{{!item.defaultStatus}}">选为默认收货地址</view>
<van-switch class="switch" checked="{{item.defaultStatus == true}}" size="30rpx" active-color="#FA6905"
bind:change="handleSwitch" catch:tap="stopTap" />
</view>
</view>
</view>
</view>