补充数据库数据,修改分类栏内容
This commit is contained in:
461
.pages-backup/pages.consumer.2026-05-20T00-39-16-812Z.json
Normal file
461
.pages-backup/pages.consumer.2026-05-20T00-39-16-812Z.json
Normal file
@@ -0,0 +1,461 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/main/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "首页",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/boot",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/register",
|
||||
"style": {
|
||||
"navigationBarTitleText": "注册"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/forgot-password",
|
||||
"style": {
|
||||
"navigationBarTitleText": "忘记密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/terms",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议与隐私政策"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/center",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户中心"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/change-password",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/bind-phone",
|
||||
"style": {
|
||||
"navigationBarTitleText": "绑定手机"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/bind-email",
|
||||
"style": {
|
||||
"navigationBarTitleText": "绑定邮箱"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/messages",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/cart",
|
||||
"style": {
|
||||
"navigationBarTitleText": "购物车",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/category",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分类",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subPackages": [
|
||||
{
|
||||
"root": "pages/mall/consumer",
|
||||
"pages": [
|
||||
{
|
||||
"path": "settings",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "edit-profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "wallet",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的钱包"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "withdraw",
|
||||
"style": {
|
||||
"navigationBarTitleText": "余额提现"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "search",
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "product-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "channel-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "频道详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "shop-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "店铺详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "coupons",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的优惠券"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "favorites",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的收藏"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "footprint",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的足迹"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "address",
|
||||
"style": {
|
||||
"navigationBarTitleText": "地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "address-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "收货地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "address-edit",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "checkout",
|
||||
"style": {
|
||||
"navigationBarTitleText": "确认订单"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "payment",
|
||||
"style": {
|
||||
"navigationBarTitleText": "收银台"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "payment-success",
|
||||
"style": {
|
||||
"navigationBarTitleText": "支付成功",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "orders",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的订单",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "order-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订单详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "logistics",
|
||||
"style": {
|
||||
"navigationBarTitleText": "物流详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "review",
|
||||
"style": {
|
||||
"navigationBarTitleText": "评价晒单"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "refund",
|
||||
"style": {
|
||||
"navigationBarTitleText": "退款/售后"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "apply-refund",
|
||||
"style": {
|
||||
"navigationBarTitleText": "申请售后"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "refund-review",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务评价"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "chat",
|
||||
"style": {
|
||||
"navigationBarTitleText": "客服聊天",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "chat_new",
|
||||
"style": {
|
||||
"navigationBarTitleText": "客服聊天(新版)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/plan-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "软件订阅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/plan-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订阅详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/subscribe-checkout",
|
||||
"style": {
|
||||
"navigationBarTitleText": "确认订阅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/my-subscriptions",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的订阅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/followed-shops",
|
||||
"style": {
|
||||
"navigationBarTitleText": "关注店铺"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "积分管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/signin",
|
||||
"style": {
|
||||
"navigationBarTitleText": "签到"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/exchange",
|
||||
"style": {
|
||||
"navigationBarTitleText": "积分兑换"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/exchange-records",
|
||||
"style": {
|
||||
"navigationBarTitleText": "兑换记录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "red-packets/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的红包"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bank-cards/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "银行卡管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bank-cards/add",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加银行卡"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "居家上门服务",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/apply",
|
||||
"style": {
|
||||
"navigationBarTitleText": "提交服务申请",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/service-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "预约服务",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/order-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/feedback",
|
||||
"style": {
|
||||
"navigationBarTitleText": "验收反馈",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bank-cards/verify",
|
||||
"style": {
|
||||
"navigationBarTitleText": "银行卡验证"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "balance/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "余额"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "my-reviews",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的评价"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "message-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "member/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "会员中心"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "product-reviews",
|
||||
"style": {
|
||||
"navigationBarTitleText": "商品评价"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tabBar": {
|
||||
"color": "#999999",
|
||||
"selectedColor": "#ff5000",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/main/index",
|
||||
"text": "首页",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/main/messages",
|
||||
"text": "消息",
|
||||
"iconPath": "static/tabbar/message.png",
|
||||
"selectedIconPath": "static/tabbar/message.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/main/cart",
|
||||
"text": "购物车",
|
||||
"iconPath": "static/tabbar/cart.png",
|
||||
"selectedIconPath": "static/tabbar/cart.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/main/profile",
|
||||
"text": "我的",
|
||||
"iconPath": "static/tabbar/user.png",
|
||||
"selectedIconPath": "static/tabbar/user.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "mall",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
"condition": {
|
||||
"current": 0,
|
||||
"list": [
|
||||
{
|
||||
"name": "consumer端",
|
||||
"path": "pages/main/index",
|
||||
"query": "role=consumer"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
117
.pages-backup/pages.consumer.2026-05-21T00-45-52-493Z.json
Normal file
117
.pages-backup/pages.consumer.2026-05-21T00-45-52-493Z.json
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/user/register",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务人员注册",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/terms",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议与隐私政策",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务人员登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/home/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工作台",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工单列表",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/service-record/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务记录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/exception",
|
||||
"style": {
|
||||
"navigationBarTitleText": "异常上报",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/settings",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subPackages": [],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "delivery",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"backgroundColor": "#F3F7F9"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#6B7280",
|
||||
"selectedColor": "#0F766E",
|
||||
"backgroundColor": "#FFFFFF",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/home/index",
|
||||
"text": "工作台",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/orders/index",
|
||||
"text": "订单",
|
||||
"iconPath": "static/tabbar/cart.png",
|
||||
"selectedIconPath": "static/tabbar/cart.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/profile/index",
|
||||
"text": "我的",
|
||||
"iconPath": "static/tabbar/user.png",
|
||||
"selectedIconPath": "static/tabbar/user.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"condition": {
|
||||
"current": 0,
|
||||
"list": [
|
||||
{
|
||||
"name": "delivery端",
|
||||
"path": "pages/user/login",
|
||||
"query": "mode=delivery&role=delivery"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
461
.pages-backup/pages.delivery.2026-05-20T08-49-16-858Z.json
Normal file
461
.pages-backup/pages.delivery.2026-05-20T08-49-16-858Z.json
Normal file
@@ -0,0 +1,461 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/main/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "首页",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/boot",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/register",
|
||||
"style": {
|
||||
"navigationBarTitleText": "注册"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/forgot-password",
|
||||
"style": {
|
||||
"navigationBarTitleText": "忘记密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/terms",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议与隐私政策"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/center",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户中心"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/change-password",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/bind-phone",
|
||||
"style": {
|
||||
"navigationBarTitleText": "绑定手机"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/bind-email",
|
||||
"style": {
|
||||
"navigationBarTitleText": "绑定邮箱"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/messages",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/cart",
|
||||
"style": {
|
||||
"navigationBarTitleText": "购物车",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/category",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分类",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subPackages": [
|
||||
{
|
||||
"root": "pages/mall/consumer",
|
||||
"pages": [
|
||||
{
|
||||
"path": "settings",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "edit-profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "wallet",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的钱包"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "withdraw",
|
||||
"style": {
|
||||
"navigationBarTitleText": "余额提现"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "search",
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "product-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "channel-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "频道详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "shop-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "店铺详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "coupons",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的优惠券"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "favorites",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的收藏"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "footprint",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的足迹"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "address",
|
||||
"style": {
|
||||
"navigationBarTitleText": "地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "address-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "收货地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "address-edit",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "checkout",
|
||||
"style": {
|
||||
"navigationBarTitleText": "确认订单"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "payment",
|
||||
"style": {
|
||||
"navigationBarTitleText": "收银台"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "payment-success",
|
||||
"style": {
|
||||
"navigationBarTitleText": "支付成功",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "orders",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的订单",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "order-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订单详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "logistics",
|
||||
"style": {
|
||||
"navigationBarTitleText": "物流详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "review",
|
||||
"style": {
|
||||
"navigationBarTitleText": "评价晒单"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "refund",
|
||||
"style": {
|
||||
"navigationBarTitleText": "退款/售后"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "apply-refund",
|
||||
"style": {
|
||||
"navigationBarTitleText": "申请售后"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "refund-review",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务评价"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "chat",
|
||||
"style": {
|
||||
"navigationBarTitleText": "客服聊天",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "chat_new",
|
||||
"style": {
|
||||
"navigationBarTitleText": "客服聊天(新版)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/plan-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "软件订阅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/plan-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订阅详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/subscribe-checkout",
|
||||
"style": {
|
||||
"navigationBarTitleText": "确认订阅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/my-subscriptions",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的订阅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/followed-shops",
|
||||
"style": {
|
||||
"navigationBarTitleText": "关注店铺"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "积分管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/signin",
|
||||
"style": {
|
||||
"navigationBarTitleText": "签到"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/exchange",
|
||||
"style": {
|
||||
"navigationBarTitleText": "积分兑换"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/exchange-records",
|
||||
"style": {
|
||||
"navigationBarTitleText": "兑换记录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "red-packets/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的红包"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bank-cards/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "银行卡管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bank-cards/add",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加银行卡"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "居家上门服务",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/apply",
|
||||
"style": {
|
||||
"navigationBarTitleText": "提交服务申请",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/service-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "预约服务",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/order-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/feedback",
|
||||
"style": {
|
||||
"navigationBarTitleText": "验收反馈",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bank-cards/verify",
|
||||
"style": {
|
||||
"navigationBarTitleText": "银行卡验证"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "balance/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "余额"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "my-reviews",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的评价"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "message-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "member/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "会员中心"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "product-reviews",
|
||||
"style": {
|
||||
"navigationBarTitleText": "商品评价"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tabBar": {
|
||||
"color": "#999999",
|
||||
"selectedColor": "#ff5000",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/main/index",
|
||||
"text": "首页",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/main/messages",
|
||||
"text": "消息",
|
||||
"iconPath": "static/tabbar/message.png",
|
||||
"selectedIconPath": "static/tabbar/message.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/main/cart",
|
||||
"text": "购物车",
|
||||
"iconPath": "static/tabbar/cart.png",
|
||||
"selectedIconPath": "static/tabbar/cart.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/main/profile",
|
||||
"text": "我的",
|
||||
"iconPath": "static/tabbar/user.png",
|
||||
"selectedIconPath": "static/tabbar/user.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "mall",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
"condition": {
|
||||
"current": 0,
|
||||
"list": [
|
||||
{
|
||||
"name": "consumer端",
|
||||
"path": "pages/main/index",
|
||||
"query": "role=consumer"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
179
.pages-backup/pages.delivery.2026-05-20T16-33-05-129Z.json
Normal file
179
.pages-backup/pages.delivery.2026-05-20T16-33-05-129Z.json
Normal file
@@ -0,0 +1,179 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/user/register",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务人员注册",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/terms",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议与隐私政策",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务人员登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/home/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工作台",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工单列表",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/route",
|
||||
"style": {
|
||||
"navigationBarTitleText": "出发与导航",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/checkin",
|
||||
"style": {
|
||||
"navigationBarTitleText": "到达签到",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/execute",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务执行",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/evidence",
|
||||
"style": {
|
||||
"navigationBarTitleText": "证据上传",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/exception",
|
||||
"style": {
|
||||
"navigationBarTitleText": "异常上报",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/finish",
|
||||
"style": {
|
||||
"navigationBarTitleText": "完成确认",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/records/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务记录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/records/detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "记录详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/messages/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息中心",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/certificates",
|
||||
"style": {
|
||||
"navigationBarTitleText": "资质证书",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/settings",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subPackages": [],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "delivery",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"backgroundColor": "#F3F7F9"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#6B7280",
|
||||
"selectedColor": "#0F766E",
|
||||
"backgroundColor": "#FFFFFF",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/home/index",
|
||||
"text": "工作台",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/orders/index",
|
||||
"text": "工单",
|
||||
"iconPath": "static/tabbar/cart.png",
|
||||
"selectedIconPath": "static/tabbar/cart.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/messages/index",
|
||||
"text": "消息",
|
||||
"iconPath": "static/tabbar/message.png",
|
||||
"selectedIconPath": "static/tabbar/message.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/profile/index",
|
||||
"text": "我的",
|
||||
"iconPath": "static/tabbar/user.png",
|
||||
"selectedIconPath": "static/tabbar/user.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"condition": {
|
||||
"current": 0,
|
||||
"list": [
|
||||
{
|
||||
"name": "delivery端",
|
||||
"path": "pages/user/login",
|
||||
"query": "mode=delivery&role=delivery"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
117
.pages-backup/pages.delivery.2026-05-21T00-45-43-192Z.json
Normal file
117
.pages-backup/pages.delivery.2026-05-21T00-45-43-192Z.json
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/user/register",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务人员注册",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/terms",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议与隐私政策",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务人员登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/home/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工作台",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工单列表",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/service-record/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务记录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/exception",
|
||||
"style": {
|
||||
"navigationBarTitleText": "异常上报",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/settings",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subPackages": [],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "delivery",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"backgroundColor": "#F3F7F9"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#6B7280",
|
||||
"selectedColor": "#0F766E",
|
||||
"backgroundColor": "#FFFFFF",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/home/index",
|
||||
"text": "工作台",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/orders/index",
|
||||
"text": "订单",
|
||||
"iconPath": "static/tabbar/cart.png",
|
||||
"selectedIconPath": "static/tabbar/cart.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/profile/index",
|
||||
"text": "我的",
|
||||
"iconPath": "static/tabbar/user.png",
|
||||
"selectedIconPath": "static/tabbar/user.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"condition": {
|
||||
"current": 0,
|
||||
"list": [
|
||||
{
|
||||
"name": "delivery端",
|
||||
"path": "pages/user/login",
|
||||
"query": "mode=delivery&role=delivery"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<scroll-view
|
||||
class="hmall-secondary-scroll"
|
||||
direction="horizontal"
|
||||
:scroll-x="true"
|
||||
:show-scrollbar="false"
|
||||
:scroll-with-animation="true"
|
||||
>
|
||||
@@ -141,7 +142,11 @@
|
||||
</view>
|
||||
|
||||
<view v-else class="hmall-empty-wrap">
|
||||
<EmptyState text="当前分类暂无商品"></EmptyState>
|
||||
<view v-if="emptyStateDescription != ''" class="hmall-empty-state-extended">
|
||||
<EmptyState :text="emptyStateTitle"></EmptyState>
|
||||
<text class="hmall-empty-desc">{{ emptyStateDescription }}</text>
|
||||
</view>
|
||||
<EmptyState v-else :text="emptyStateTitle"></EmptyState>
|
||||
</view>
|
||||
|
||||
<view v-if="loading || showLoadMore" class="hmall-load-more-status">
|
||||
@@ -204,6 +209,14 @@ const props = defineProps({
|
||||
showLoadMore: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
emptyStateTitle: {
|
||||
type: String,
|
||||
default: '当前分类暂无商品'
|
||||
},
|
||||
emptyStateDescription: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
|
||||
@@ -848,6 +861,20 @@ function showMarketPrice(product: Product): boolean {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.hmall-empty-state-extended {
|
||||
padding-bottom: 32rpx;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.hmall-empty-desc {
|
||||
margin-top: -8rpx;
|
||||
padding: 0 40rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
color: #9a9a9a;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hmall-loading-text,
|
||||
.hmall-feed-end-text {
|
||||
font-size: 24rpx;
|
||||
|
||||
125
docs/medical-mall-product-category-mapping-guide.md
Normal file
125
docs/medical-mall-product-category-mapping-guide.md
Normal file
@@ -0,0 +1,125 @@
|
||||
# 医疗商城商品分类映射说明
|
||||
|
||||
说明:
|
||||
|
||||
- 本文用于补齐 public.medical_mall_product_categories 的真实商品分类关联。
|
||||
- 首页和分类页现在都优先依赖这张关联表;关键词 fallback 只作为临时兜底,不应长期替代真实映射。
|
||||
- 推荐配套执行文件见 [mall_sql/migrations/20260521_medical_mall_categories_v1.sql](../mall_sql/migrations/20260521_medical_mall_categories_v1.sql)。
|
||||
|
||||
## 目标
|
||||
|
||||
需要补齐三类数据:
|
||||
|
||||
- 主分类映射:每个商品至少挂 1 个最准确的二级分类,且建议设置 1 条 is_primary = true。
|
||||
- 扩展分类映射:一个商品可以额外挂多个补充分类,用于“全部”“交叉场景”与推荐流召回。
|
||||
- 存量纠偏:清理错误分类、重复主分类和已下架商品的失效映射。
|
||||
|
||||
## 一级分类与二级分类
|
||||
|
||||
当前医疗商城一级分类:
|
||||
|
||||
- med_device:医疗器械
|
||||
- otc_medicine:家庭常备药
|
||||
- rehab_care:康复护理
|
||||
- chronic_monitor:慢病监测
|
||||
- elderly_aid:适老用品
|
||||
- nutrition_health:营养保健
|
||||
- protection_disinfection:防护消毒
|
||||
- tcm_health:中医保健
|
||||
- home_care_daily:居家护理
|
||||
- all_medical:全部
|
||||
|
||||
优先补的二级分类:
|
||||
|
||||
- blood_pressure_monitor:血压计
|
||||
- blood_glucose_meter:血糖仪
|
||||
- oximeter:血氧仪
|
||||
- thermometer:体温计
|
||||
- oxygen_concentrator:制氧机
|
||||
- nebulizer:雾化器
|
||||
- wheelchair_crutch:轮椅拐杖
|
||||
- nursing_bed:护理床
|
||||
- cold_fever:感冒发烧
|
||||
- cough_throat:咳嗽咽喉
|
||||
- stomach_medicine:肠胃用药
|
||||
- skin_external:皮肤外用
|
||||
- eye_ear_nose:眼耳口鼻
|
||||
- pain_relief:止痛用药
|
||||
- trauma_sprain:跌打损伤
|
||||
- child_medicine:儿童用药
|
||||
- postop_rehab:术后康复
|
||||
- wound_dressing:伤口敷料
|
||||
- brace_support:护具支具
|
||||
- rehab_training:康复训练器
|
||||
- physiotherapy_hot:理疗热敷
|
||||
- mobility_training:行动训练
|
||||
- hypertension:高血压管理
|
||||
- diabetes:糖尿病管理
|
||||
- cardiovascular:心脑血管
|
||||
- respiratory_health:呼吸健康
|
||||
- weight_bodyfat:体重体脂
|
||||
- home_testing:家庭检测
|
||||
- anti_slip:防滑安全
|
||||
- elderly_bathroom:适老卫浴
|
||||
- eating_aid:助餐用品
|
||||
- bathing_aid:助浴用品
|
||||
- incontinence_care:失禁护理
|
||||
- daily_living_aid:生活辅助
|
||||
- vitamin:维生素
|
||||
- calcium:钙铁锌硒
|
||||
- protein:蛋白营养
|
||||
- elderly_nutrition:老人营养
|
||||
- gut_health:肠道益生菌
|
||||
- immune_support:免疫支持
|
||||
- mask:口罩
|
||||
- disinfectant:消毒液
|
||||
- alcohol_wipes:酒精湿巾
|
||||
- gloves:手套
|
||||
- first_aid:急救包
|
||||
- dressing_tools:棉签纱布
|
||||
- moxibustion:艾灸拔罐
|
||||
- herbal_drink:养生茶饮
|
||||
- tcm_patch:中医贴敷
|
||||
- medicated_diet:药膳滋补
|
||||
- massage_tools:按摩理疗
|
||||
- foot_bath:泡脚养生
|
||||
- wound_care:伤口护理
|
||||
- oral_care:口腔护理
|
||||
- skin_care:皮肤护理
|
||||
- cleaning_care:清洁护理
|
||||
- nursing_consumables:护理耗材
|
||||
- home_health_tool:家庭健康工具
|
||||
|
||||
## 建议映射原则
|
||||
|
||||
1. 一个商品先确定一个最准确的二级分类,写为主分类。
|
||||
2. 只有确实横跨多个场景时,再补额外分类,不要为了提高曝光滥挂多个类。
|
||||
3. 一级类不直接挂商品,优先挂到二级类;只有“全部”这种聚合入口由前端自动聚合,不需要单独插 all_medical。
|
||||
4. OTC、器械、处方隐藏类商品要优先核对 compliance_type,不要把应隐藏的商品映射到公开可见分类。
|
||||
5. 已下架、删除、测试商品不要补映射,避免推荐流被污染。
|
||||
|
||||
## 建议执行顺序
|
||||
|
||||
1. 先找出当前首页和分类页实际展示的商品。
|
||||
2. 给这些商品补主分类。
|
||||
3. 再补扩展分类和长尾商品。
|
||||
4. 最后执行核对 SQL,清理多余主分类和无效映射。
|
||||
|
||||
## 需要重点人工核对的商品类型
|
||||
|
||||
- 通用耗材:如纱布、棉签、消毒棉片,容易在 wound_care、dressing_tools、nursing_consumables 之间混淆。
|
||||
- 保健品:如复合维生素、蛋白粉、益生菌,容易在 vitamin、protein、gut_health、immune_support 之间重叠。
|
||||
- 康复用品:如护腰、支撑带、热敷贴,可能落在 brace_support、postop_rehab、physiotherapy_hot、tcm_patch。
|
||||
- 慢病设备:如血压计、血糖仪、血氧仪,既是器械,也服务于慢病管理,但主分类仍建议落二级商品类本身。
|
||||
|
||||
## 配套文件
|
||||
|
||||
- 映射维护模板:[sql/medical_mall_product_category_manual_mapping_template.sql](../sql/medical_mall_product_category_manual_mapping_template.sql)
|
||||
- 一体化迁移:[mall_sql/migrations/20260521_medical_mall_categories_v1.sql](../mall_sql/migrations/20260521_medical_mall_categories_v1.sql)
|
||||
- 拆分 seed:[sql/seed_medical_mall_categories.sql](../sql/seed_medical_mall_categories.sql)
|
||||
|
||||
## 当前状态
|
||||
|
||||
- 现有 seed 只补了少量关键词示例关联。
|
||||
- 首页和分类页已经切到 medical_mall 数据源。
|
||||
- 如果不补真实映射,线上数据仍会部分依赖关键词 fallback,结果不可控。
|
||||
36
docs/medical-product-image-candidates.md
Normal file
36
docs/medical-product-image-candidates.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# 医疗首页商品候选图片清单
|
||||
|
||||
说明:
|
||||
- 当前阶段先整理“商品名 -> 候选图片页”,不直接写回 SQL。
|
||||
- 优先使用 Unsplash 内部图片页作为候选来源;少数品类在 Unsplash 内匹配度较低,已标注低置信度。
|
||||
- 后续建议:你确认图片后,再上传到 Supabase Storage 或自有图床,再把最终地址回填到 SQL。
|
||||
|
||||
## 本轮确认结果
|
||||
|
||||
- 已按你的反馈确认这些商品可继续沿用当前候选:家庭退热护理贴、智能血压监测仪、高钙维D营养片、乳清蛋白营养粉、术后支撑恢复带、肩颈草本热敷贴、折叠助行辅助器、浴室防滑扶手套装。
|
||||
- 已按你的要求重找并替换:草本暖胃调理贴、静音雾化护理机、家用艾灸温灸盒。
|
||||
- 第 2、8 项已去掉付费来源,改为免费可访问图片页。
|
||||
- 无菌伤口护理包本轮未被点名调整,暂保留原候选。
|
||||
|
||||
## 候选清单
|
||||
|
||||
| 商品模板 | 候选图片页 | 匹配度 | 备注 |
|
||||
|---|---|---:|---|
|
||||
| 家庭退热护理贴 | https://unsplash.com/photos/woman-holding-cooling-gel-patches-for-fever-relief-KZ1r0RrbXdc | 高 | 语义最贴近“退热贴/降温贴” |
|
||||
| 草本暖胃调理贴 | https://unsplash.com/photos/a-knitted-hot-water-bottle-with-a-green-stopper-4XlKcKpmjwU | 中 | 免费来源。偏腹部热敷/暖胃护理场景,不是贴剂包装图,但比付费候选更适合作为当前免费替代 |
|
||||
| 智能血压监测仪 | https://unsplash.com/photos/a-person-with-a-blood-pressure-meter-on-their-arm-oi6jf34bQrU | 高 | 与家用电子血压计场景贴近 |
|
||||
| 静音雾化护理机 | https://unsplash.com/photos/beautiful-sick-boy-inhalation-therapy-by-the-mask-of-inhaler-image-of-a-cute-kid-with-respiratory-problem-or-asthma-view-of-nebulizer-with-smoke-from-oxygen-mask-wLldIFm5E4Q | 高 | 已按你指定的儿童雾化器图片方向替换为具体图片页 |
|
||||
| 高钙维D营养片 | https://unsplash.com/photos/four-bottles-of-vitamin-supplements-sitting-next-to-a-plant-dY14deLOUGk | 中高 | 更像营养补充剂瓶装商品,适合替代钙片视觉 |
|
||||
| 乳清蛋白营养粉 | https://unsplash.com/photos/a-jar-of-protein-powder-next-to-a-scoop-of-protein-powder-DvunqLOsKco | 高 | 与蛋白粉罐装商品很贴近 |
|
||||
| 术后支撑恢复带 | https://unsplash.com/photos/woman-wearing-a-white-ribbed-band-and-denim-shorts-rArjMQ0rT7Y | 中 | 偏腹部支撑带场景,能表达术后支撑语义 |
|
||||
| 无菌伤口护理包 | https://unsplash.com/photos/first-aid-kit-contents-with-bandages-and-medical-supplies-nGfxoclUgSI | 高 | 与无菌换药/护理包很贴近 |
|
||||
| 家用艾灸温灸盒 | https://commons.wikimedia.org/wiki/File:Ibuki_moxa_set.jpg | 中高 | 免费来源。Wikimedia Commons 图片页,偏艾灸产品实物/套装展示,比当前能拿到的免费场景图更接近商品本体 |
|
||||
| 肩颈草本热敷贴 | https://unsplash.com/photos/person-with-patch-on-neck-against-orange-background-HjdjzIrL6GM | 高 | 与肩颈贴敷场景较贴近 |
|
||||
| 折叠助行辅助器 | https://unsplash.com/photos/elderly-woman-on-a-walker-EbLMgFcCXV4 | 高 | 与长者助行器商品高度贴近 |
|
||||
| 浴室防滑扶手套装 | https://unsplash.com/photos/a-toilet-with-a-metal-bar-lFDGy3yzCc0 | 高 | 与浴室扶手安装场景贴近 |
|
||||
|
||||
## 当前建议
|
||||
|
||||
1. 如果这版没问题,我下一步直接把已确认候选回填成 SQL 映射表。
|
||||
2. 如果你还想继续压低风险,我可以只对第三方链接生成“待上传素材清单”,不直接写热链。
|
||||
3. 正式上线前,仍建议把这些图片上传到你们自己的存储后再回填数据库。
|
||||
64
docs/sql/10_schema/product/medical_mall_categories_v1.sql
Normal file
64
docs/sql/10_schema/product/medical_mall_categories_v1.sql
Normal file
@@ -0,0 +1,64 @@
|
||||
-- Schema: 医疗商城独立分类与商品分类关联
|
||||
-- 执行阶段: 10_schema
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.medical_mall_categories (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
parent_id TEXT NULL REFERENCES public.medical_mall_categories(id),
|
||||
level INTEGER NOT NULL CHECK (level IN (1, 2)),
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
icon TEXT,
|
||||
image_url TEXT,
|
||||
description TEXT,
|
||||
scene TEXT NOT NULL DEFAULT 'medical_mall',
|
||||
category_type TEXT NOT NULL DEFAULT 'normal',
|
||||
compliance_type TEXT NOT NULL DEFAULT 'normal',
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
deleted_at TIMESTAMPTZ NULL,
|
||||
deleted_by UUID NULL REFERENCES public.ak_users(id),
|
||||
restored_at TIMESTAMPTZ NULL,
|
||||
restored_by UUID NULL REFERENCES public.ak_users(id),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
COMMENT ON TABLE public.medical_mall_categories IS '医疗商城独立分类表';
|
||||
COMMENT ON COLUMN public.medical_mall_categories.scene IS '分类场景,如 medical_mall / home_mall';
|
||||
COMMENT ON COLUMN public.medical_mall_categories.category_type IS '分类类型:device / otc / care / rehab / elderly / nutrition / protection / tcm / all';
|
||||
COMMENT ON COLUMN public.medical_mall_categories.compliance_type IS '合规类型:normal / otc / device_class_i / device_class_ii / device_class_iii / rx_hidden';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_categories_parent
|
||||
ON public.medical_mall_categories(parent_id)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_categories_level_sort
|
||||
ON public.medical_mall_categories(level, sort_order)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_categories_scene_active
|
||||
ON public.medical_mall_categories(scene, is_active)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.medical_mall_product_categories (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
product_id UUID NOT NULL REFERENCES public.ml_products(id) ON DELETE CASCADE,
|
||||
category_id TEXT NOT NULL REFERENCES public.medical_mall_categories(id),
|
||||
is_primary BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
deleted_at TIMESTAMPTZ NULL,
|
||||
deleted_by UUID NULL REFERENCES public.ak_users(id),
|
||||
restored_at TIMESTAMPTZ NULL,
|
||||
restored_by UUID NULL REFERENCES public.ak_users(id),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
UNIQUE (product_id, category_id)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE public.medical_mall_product_categories IS '医疗商城商品与分类关联表';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_product_categories_category
|
||||
ON public.medical_mall_product_categories(category_id, sort_order)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_product_categories_product
|
||||
ON public.medical_mall_product_categories(product_id)
|
||||
WHERE deleted_at IS NULL;
|
||||
23
docs/sql/20_rls/product/medical_mall_categories_rls_v1.sql
Normal file
23
docs/sql/20_rls/product/medical_mall_categories_rls_v1.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- RLS: 医疗商城独立分类与商品分类关联
|
||||
-- 执行阶段: 20_rls
|
||||
|
||||
ALTER TABLE public.medical_mall_categories ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE public.medical_mall_product_categories ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
DROP POLICY IF EXISTS medical_mall_categories_public_select_active ON public.medical_mall_categories;
|
||||
CREATE POLICY medical_mall_categories_public_select_active
|
||||
ON public.medical_mall_categories
|
||||
FOR SELECT
|
||||
TO anon, authenticated
|
||||
USING (
|
||||
deleted_at IS NULL
|
||||
AND is_active = TRUE
|
||||
AND compliance_type <> 'rx_hidden'
|
||||
);
|
||||
|
||||
DROP POLICY IF EXISTS medical_mall_product_categories_public_select_active ON public.medical_mall_product_categories;
|
||||
CREATE POLICY medical_mall_product_categories_public_select_active
|
||||
ON public.medical_mall_product_categories
|
||||
FOR SELECT
|
||||
TO anon, authenticated
|
||||
USING (deleted_at IS NULL);
|
||||
@@ -1,12 +1,15 @@
|
||||
# SQL 文件执行顺序文档(软删除标准化改造 + Admin 模块全量)
|
||||
|
||||
## 目标
|
||||
|
||||
为本次“软删除标准化改造(Schema + RLS + RPC)”提供**可直接执行**且**顺序准确**的数据库同步步骤,同时整理**全量 Admin 模块**对应的数据库文件,确保:
|
||||
|
||||
- 先补齐表字段与索引(避免 RPC/RLS 引用字段失败);
|
||||
- 再应用 RLS(确保查询默认过滤已软删数据);
|
||||
- 最后加载/替换 RPC(确保删除行为变更与审计字段写入生效)。
|
||||
|
||||
## 前置约束
|
||||
|
||||
- 执行账号需具备:`ALTER TABLE`、`CREATE INDEX`、`ALTER POLICY/CREATE POLICY`、`CREATE OR REPLACE FUNCTION` 等权限。
|
||||
- **禁止并发执行**:建议串行执行,尤其是 RLS/RPC 部分。
|
||||
- 若生产环境已存在同名对象:本次以 `CREATE OR REPLACE FUNCTION` 与 policy 更新为主,属于“覆盖式更新”。
|
||||
@@ -14,99 +17,115 @@
|
||||
---
|
||||
|
||||
## 第一阶段:Schema / Migration(必须先执行)
|
||||
|
||||
> 目的:补齐 `deleted_at/deleted_by/restored_at/restored_by` 字段与软删除索引,作为后续 RLS/RPC 的基础依赖。
|
||||
|
||||
| 序号 | 文件路径 | 说明 |
|
||||
|:--:|:---|:---|
|
||||
| 1 | [`10_schema/99_soft_delete_migration_v1.sql`](./10_schema/99_soft_delete_migration_v1.sql) | 软删除字段迁移(核心) |
|
||||
| 序号 | 文件路径 | 说明 |
|
||||
| :--: | :----------------------------------------------------------------------------------------- | :--------------------- |
|
||||
| 1 | [`10_schema/99_soft_delete_migration_v1.sql`](./10_schema/99_soft_delete_migration_v1.sql) | 软删除字段迁移(核心) |
|
||||
|
||||
### 其他 Schema 文件(按业务域分类)
|
||||
|
||||
#### Admin 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------- | :--------- |
|
||||
| [`10_schema/admin/ml_system_configs_v1.sql`](./10_schema/admin/ml_system_configs_v1.sql) | 系统配置表 |
|
||||
|
||||
#### Auth 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`10_schema/user/ak_auth_system_v1.sql`](./10_schema/user/ak_auth_system_v1.sql) | 认证系统表(roles/permissions/admin_roles/role_permissions) |
|
||||
| [`10_schema/user/ak_users_add_phone_real_name_v1.sql`](./10_schema/user/ak_users_add_phone_real_name_v1.sql) | 用户扩展字段 |
|
||||
| [`10_schema/user/ak_users_finance_fields_v1.sql`](./10_schema/user/ak_users_finance_fields_v1.sql) | 用户财务字段 |
|
||||
| [`10_schema/user/ak_users_constraints_fix_v1.sql`](./10_schema/user/ak_users_constraints_fix_v1.sql) | 用户表约束修复 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------- |
|
||||
| [`10_schema/user/ak_auth_system_v1.sql`](./10_schema/user/ak_auth_system_v1.sql) | 认证系统表(roles/permissions/admin_roles/role_permissions) |
|
||||
| [`10_schema/user/ak_users_add_phone_real_name_v1.sql`](./10_schema/user/ak_users_add_phone_real_name_v1.sql) | 用户扩展字段 |
|
||||
| [`10_schema/user/ak_users_finance_fields_v1.sql`](./10_schema/user/ak_users_finance_fields_v1.sql) | 用户财务字段 |
|
||||
| [`10_schema/user/ak_users_constraints_fix_v1.sql`](./10_schema/user/ak_users_constraints_fix_v1.sql) | 用户表约束修复 |
|
||||
|
||||
#### CMS 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------- | :------------- |
|
||||
| [`10_schema/cms/ml_cms_tables_v1.sql`](./10_schema/cms/ml_cms_tables_v1.sql) | CMS 内容管理表 |
|
||||
|
||||
#### Decoration 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------- | :--------- |
|
||||
| [`10_schema/decoration/ak_diy_pages_v1.sql`](./10_schema/decoration/ak_diy_pages_v1.sql) | DIY 页面表 |
|
||||
|
||||
#### Delivery 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------- | :--------- |
|
||||
| [`10_schema/delivery/ak_delivery_system_v1.sql`](./10_schema/delivery/ak_delivery_system_v1.sql) | 配送系统表 |
|
||||
|
||||
#### Distribution 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`10_schema/distribution/ak_distribution_agents_v1.sql`](./10_schema/distribution/ak_distribution_agents_v1.sql) | 分销代理表 |
|
||||
| [`10_schema/distribution/ak_distribution_agent_applications_v1.sql`](./10_schema/distribution/ak_distribution_agent_applications_v1.sql) | 代理申请表 |
|
||||
| [`10_schema/distribution/ak_distribution_divisions_v1.sql`](./10_schema/distribution/ak_distribution_divisions_v1.sql) | 事业部表 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`10_schema/distribution/ak_distribution_agents_v1.sql`](./10_schema/distribution/ak_distribution_agents_v1.sql) | 分销代理表 |
|
||||
| [`10_schema/distribution/ak_distribution_agent_applications_v1.sql`](./10_schema/distribution/ak_distribution_agent_applications_v1.sql) | 代理申请表 |
|
||||
| [`10_schema/distribution/ak_distribution_divisions_v1.sql`](./10_schema/distribution/ak_distribution_divisions_v1.sql) | 事业部表 |
|
||||
| [`10_schema/distribution/ak_distribution_division_applications_v1.sql`](./10_schema/distribution/ak_distribution_division_applications_v1.sql) | 事业部申请表 |
|
||||
| [`10_schema/distribution/ak_promoter_relations_v1.sql`](./10_schema/distribution/ak_promoter_relations_v1.sql) | 推广员关系表 |
|
||||
| [`10_schema/distribution/ak_commission_logs_v1.sql`](./10_schema/distribution/ak_commission_logs_v1.sql) | 佣金日志表 |
|
||||
| [`10_schema/distribution/ak_distribution_level_v1.sql`](./10_schema/distribution/ak_distribution_level_v1.sql) | 分销等级表 |
|
||||
| [`10_schema/distribution/ak_distribution_config_v1.sql`](./10_schema/distribution/ak_distribution_config_v1.sql) | 分销配置表 |
|
||||
| [`10_schema/distribution/ak_promoter_relations_v1.sql`](./10_schema/distribution/ak_promoter_relations_v1.sql) | 推广员关系表 |
|
||||
| [`10_schema/distribution/ak_commission_logs_v1.sql`](./10_schema/distribution/ak_commission_logs_v1.sql) | 佣金日志表 |
|
||||
| [`10_schema/distribution/ak_distribution_level_v1.sql`](./10_schema/distribution/ak_distribution_level_v1.sql) | 分销等级表 |
|
||||
| [`10_schema/distribution/ak_distribution_config_v1.sql`](./10_schema/distribution/ak_distribution_config_v1.sql) | 分销配置表 |
|
||||
|
||||
#### Finance 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`10_schema/finance/ml_invoices_v1.sql`](./10_schema/finance/ml_invoices_v1.sql) | 发票表 |
|
||||
| [`10_schema/finance/ml_extract_v1.sql`](./10_schema/finance/ml_extract_v1.sql) | 提现表 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------- | :--------- |
|
||||
| [`10_schema/finance/ml_invoices_v1.sql`](./10_schema/finance/ml_invoices_v1.sql) | 发票表 |
|
||||
| [`10_schema/finance/ml_extract_v1.sql`](./10_schema/finance/ml_extract_v1.sql) | 提现表 |
|
||||
| [`10_schema/finance/ml_user_recharge_v1.sql`](./10_schema/finance/ml_user_recharge_v1.sql) | 用户充值表 |
|
||||
| [`10_schema/finance/ml_user_bill_v1.sql`](./10_schema/finance/ml_user_bill_v1.sql) | 用户账单表 |
|
||||
| [`10_schema/finance/ml_user_bill_v1.sql`](./10_schema/finance/ml_user_bill_v1.sql) | 用户账单表 |
|
||||
|
||||
#### Kefu 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------- | :--------- |
|
||||
| [`10_schema/kefu/ml_kefu_tables_v1.sql`](./10_schema/kefu/ml_kefu_tables_v1.sql) | 客服系统表 |
|
||||
|
||||
#### Marketing 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`10_schema/marketing/ak_lottery_live_v1.sql`](./10_schema/marketing/ak_lottery_live_v1.sql) | 直播抽奖 |
|
||||
| [`10_schema/marketing/ak_marketing_signin_logs_v1.sql`](./10_schema/marketing/ak_marketing_signin_logs_v1.sql) | 签到日志 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------------- | :------- |
|
||||
| [`10_schema/marketing/ak_lottery_live_v1.sql`](./10_schema/marketing/ak_lottery_live_v1.sql) | 直播抽奖 |
|
||||
| [`10_schema/marketing/ak_marketing_signin_logs_v1.sql`](./10_schema/marketing/ak_marketing_signin_logs_v1.sql) | 签到日志 |
|
||||
| [`10_schema/marketing/ak_marketing_newcomer_config_v1.sql`](./10_schema/marketing/ak_marketing_newcomer_config_v1.sql) | 新人配置 |
|
||||
| [`10_schema/marketing/ak_bargain_groupbuy_v1.sql`](./10_schema/marketing/ak_bargain_groupbuy_v1.sql) | 拼团砍价 |
|
||||
| [`10_schema/marketing/ak_live_products_v1.sql`](./10_schema/marketing/ak_live_products_v1.sql) | 直播商品 |
|
||||
| [`10_schema/marketing/ak_advanced_marketing_v1.sql`](./10_schema/marketing/ak_advanced_marketing_v1.sql) | 高级营销 |
|
||||
| [`10_schema/marketing/ak_bargain_groupbuy_v1.sql`](./10_schema/marketing/ak_bargain_groupbuy_v1.sql) | 拼团砍价 |
|
||||
| [`10_schema/marketing/ak_live_products_v1.sql`](./10_schema/marketing/ak_live_products_v1.sql) | 直播商品 |
|
||||
| [`10_schema/marketing/ak_advanced_marketing_v1.sql`](./10_schema/marketing/ak_advanced_marketing_v1.sql) | 高级营销 |
|
||||
| [`10_schema/marketing/ak_marketing_checkin_configs_v1.sql`](./10_schema/marketing/ak_marketing_checkin_configs_v1.sql) | 签到配置 |
|
||||
| [`10_schema/marketing/ak_recharge_management_v1.sql`](./10_schema/marketing/ak_recharge_management_v1.sql) | 充值管理 |
|
||||
| [`10_schema/marketing/ak_member_management_v1.sql`](./10_schema/marketing/ak_member_management_v1.sql) | 会员管理 |
|
||||
| [`10_schema/marketing/ak_signin_configs_v1.sql`](./10_schema/marketing/ak_signin_configs_v1.sql) | 签到配置 |
|
||||
| [`10_schema/marketing/ak_recharge_management_v1.sql`](./10_schema/marketing/ak_recharge_management_v1.sql) | 充值管理 |
|
||||
| [`10_schema/marketing/ak_member_management_v1.sql`](./10_schema/marketing/ak_member_management_v1.sql) | 会员管理 |
|
||||
| [`10_schema/marketing/ak_signin_configs_v1.sql`](./10_schema/marketing/ak_signin_configs_v1.sql) | 签到配置 |
|
||||
|
||||
#### Order 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------- | :------------- |
|
||||
| [`10_schema/order/ml_orders_schema_update_v1.sql`](./10_schema/order/ml_orders_schema_update_v1.sql) | 订单表结构更新 |
|
||||
|
||||
#### Product 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`10_schema/product/ml_products_ext_v1.sql`](./10_schema/product/ml_products_ext_v1.sql) | 商品扩展表 |
|
||||
| [`10_schema/product/ak_shipping_templates_v1.sql`](./10_schema/product/ak_shipping_templates_v1.sql) | 运费模板 |
|
||||
| [`10_schema/product/ak_product_member_prices_v1.sql`](./10_schema/product/ak_product_member_prices_v1.sql) | 会员价 |
|
||||
| [`10_schema/product/ak_product_protections_v1.sql`](./10_schema/product/ak_product_protections_v1.sql) | 商品保障 |
|
||||
| [`10_schema/product/ak_product_templates_v1.sql`](./10_schema/product/ak_product_templates_v1.sql) | 商品模板 |
|
||||
| [`10_schema/product/ak_product_labels_v1.sql`](./10_schema/product/ak_product_labels_v1.sql) | 商品标签 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------ |
|
||||
| [`../../mall_sql/migrations/20260521_medical_mall_categories_v1.sql`](../../mall_sql/migrations/20260521_medical_mall_categories_v1.sql) | 医疗商城独立分类一体化迁移(含 Schema + RLS + 初始化 Seed,推荐优先执行) |
|
||||
| [`10_schema/product/ml_products_ext_v1.sql`](./10_schema/product/ml_products_ext_v1.sql) | 商品扩展表 |
|
||||
| [`10_schema/product/ak_shipping_templates_v1.sql`](./10_schema/product/ak_shipping_templates_v1.sql) | 运费模板 |
|
||||
| [`10_schema/product/ak_product_member_prices_v1.sql`](./10_schema/product/ak_product_member_prices_v1.sql) | 会员价 |
|
||||
| [`10_schema/product/ak_product_protections_v1.sql`](./10_schema/product/ak_product_protections_v1.sql) | 商品保障 |
|
||||
| [`10_schema/product/ak_product_templates_v1.sql`](./10_schema/product/ak_product_templates_v1.sql) | 商品模板 |
|
||||
| [`10_schema/product/ak_product_labels_v1.sql`](./10_schema/product/ak_product_labels_v1.sql) | 商品标签 |
|
||||
|
||||
> 补充说明:若执行 [`../../mall_sql/migrations/20260521_medical_mall_categories_v1.sql`](../../mall_sql/migrations/20260521_medical_mall_categories_v1.sql),则无需再重复执行 `10_schema/product/medical_mall_categories_v1.sql`、`20_rls/product/medical_mall_categories_rls_v1.sql` 与 `sql/seed_medical_mall_categories.sql` 的拆分版内容。
|
||||
|
||||
#### User 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------- | :--------- |
|
||||
| [`10_schema/user/ak_user_labels_v1.sql`](./10_schema/user/ak_user_labels_v1.sql) | 用户标签表 |
|
||||
| [`10_schema/user/ak_user_groups_v1.sql`](./10_schema/user/ak_user_groups_v1.sql) | 用户分组表 |
|
||||
| [`10_schema/user/ak_user_levels_v1.sql`](./10_schema/user/ak_user_levels_v1.sql) | 用户等级表 |
|
||||
@@ -114,63 +133,74 @@
|
||||
---
|
||||
|
||||
## 第二阶段:RLS(在 Schema 之后执行)
|
||||
|
||||
> 目的:将各模块策略统一补齐 `deleted_at IS NULL`,确保默认查询排除已软删记录。
|
||||
|
||||
按域执行(域之间无强依赖,可按任意顺序;但**必须在 RPC 之前**执行):
|
||||
|
||||
### Auth 域(新增)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------- | :----------------------------------- |
|
||||
| [`20_rls/auth/ak_auth_rls_v1.sql`](./20_rls/auth/ak_auth_rls_v1.sql) | 权限/角色表 RLS 策略(禁止直接访问) |
|
||||
|
||||
### Admin 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`20_rls/admin/ml_system_configs_rls_v1.sql`](./20_rls/admin/ml_system_configs_rls_v1.sql) | 系统配置 RLS |
|
||||
|
||||
### CMS 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------- | :----------- |
|
||||
| [`20_rls/cms/ml_cms_rls_v1.sql`](./20_rls/cms/ml_cms_rls_v1.sql) | CMS 内容 RLS |
|
||||
|
||||
### Decoration 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------- | :------- |
|
||||
| [`20_rls/decoration/ml_decoration_rls_v1.sql`](./20_rls/decoration/ml_decoration_rls_v1.sql) | 装修 RLS |
|
||||
|
||||
### Delivery 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------- | :------- |
|
||||
| [`20_rls/delivery/ak_delivery_rls_v1.sql`](./20_rls/delivery/ak_delivery_rls_v1.sql) | 配送 RLS |
|
||||
|
||||
### Distribution 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------- | :------- |
|
||||
| [`20_rls/distribution/ml_distribution_rls_v1.sql`](./20_rls/distribution/ml_distribution_rls_v1.sql) | 分销 RLS |
|
||||
|
||||
### Finance 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`20_rls/finance/ml_extract_rls_v1.sql`](./20_rls/finance/ml_extract_rls_v1.sql) | 提现 RLS |
|
||||
| [`20_rls/finance/ml_invoices_rls_v1.sql`](./20_rls/finance/ml_invoices_rls_v1.sql) | 发票 RLS |
|
||||
| [`20_rls/finance/ml_user_bill_rls_v1.sql`](./20_rls/finance/ml_user_bill_rls_v1.sql) | 用户账单 RLS |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`20_rls/finance/ml_extract_rls_v1.sql`](./20_rls/finance/ml_extract_rls_v1.sql) | 提现 RLS |
|
||||
| [`20_rls/finance/ml_invoices_rls_v1.sql`](./20_rls/finance/ml_invoices_rls_v1.sql) | 发票 RLS |
|
||||
| [`20_rls/finance/ml_user_bill_rls_v1.sql`](./20_rls/finance/ml_user_bill_rls_v1.sql) | 用户账单 RLS |
|
||||
| [`20_rls/finance/ml_user_recharge_rls_v1.sql`](./20_rls/finance/ml_user_recharge_rls_v1.sql) | 用户充值 RLS |
|
||||
|
||||
### Kefu 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------- | :------- |
|
||||
| [`20_rls/kefu/ml_kefu_rls_v1.sql`](./20_rls/kefu/ml_kefu_rls_v1.sql) | 客服 RLS |
|
||||
|
||||
### Marketing 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`20_rls/marketing/ml_marketing_others_rls_v1.sql`](./20_rls/marketing/ml_marketing_others_rls_v1.sql) | 其他营销 RLS |
|
||||
| [`20_rls/marketing/ml_marketing_activities_rls_v1.sql`](./20_rls/marketing/ml_marketing_activities_rls_v1.sql) | 营销活动 RLS |
|
||||
| [`20_rls/marketing/ml_coupon_templates_rls_v1.sql`](./20_rls/marketing/ml_coupon_templates_rls_v1.sql) | 优惠券模板 RLS |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------------- | :------------- |
|
||||
| [`20_rls/marketing/ml_marketing_others_rls_v1.sql`](./20_rls/marketing/ml_marketing_others_rls_v1.sql) | 其他营销 RLS |
|
||||
| [`20_rls/marketing/ml_marketing_activities_rls_v1.sql`](./20_rls/marketing/ml_marketing_activities_rls_v1.sql) | 营销活动 RLS |
|
||||
| [`20_rls/marketing/ml_coupon_templates_rls_v1.sql`](./20_rls/marketing/ml_coupon_templates_rls_v1.sql) | 优惠券模板 RLS |
|
||||
|
||||
### User 域
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------- | :----------- |
|
||||
| [`20_rls/user/ak_user_labels_rls_v1.sql`](./20_rls/user/ak_user_labels_rls_v1.sql) | 用户标签 RLS |
|
||||
| [`20_rls/user/ak_user_groups_rls_v1.sql`](./20_rls/user/ak_user_groups_rls_v1.sql) | 用户分组 RLS |
|
||||
| [`20_rls/user/ak_user_levels_rls_v1.sql`](./20_rls/user/ak_user_levels_rls_v1.sql) | 用户等级 RLS |
|
||||
@@ -178,6 +208,7 @@
|
||||
---
|
||||
|
||||
## 第三阶段:RPC(最后执行)
|
||||
|
||||
> 目的:将“删除”统一切换为软删除(写入 `deleted_at/deleted_by`),并在需要的函数中补齐级联软删。
|
||||
|
||||
按域执行(域之间一般无强依赖;但建议按下列顺序,先基础权限/用户,再业务模块):
|
||||
@@ -187,15 +218,17 @@
|
||||
### 3.1 Admin 域(系统管理)
|
||||
|
||||
#### 查询类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/admin/rpc_admin_get_system_info_v1.sql`](./30_rpc/admin/rpc_admin_get_system_info_v1.sql) | 获取系统信息 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/admin/rpc_admin_get_system_info_v1.sql`](./30_rpc/admin/rpc_admin_get_system_info_v1.sql) | 获取系统信息 |
|
||||
| [`30_rpc/admin/rpc_admin_get_overall_stats_v1.sql`](./30_rpc/admin/rpc_admin_get_overall_stats_v1.sql) | 获取整体统计 |
|
||||
| [`30_rpc/admin/rpc_admin_system_config_get_v1.sql`](./30_rpc/admin/rpc_admin_system_config_get_v1.sql) | 获取系统配置 |
|
||||
|
||||
#### 保存/更新类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/admin/rpc_admin_system_config_save_v1.sql`](./30_rpc/admin/rpc_admin_system_config_save_v1.sql) | 保存系统配置 |
|
||||
|
||||
---
|
||||
@@ -203,33 +236,38 @@
|
||||
### 3.2 Auth 域(权限认证)
|
||||
|
||||
#### 权限校验辅助函数(新增)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------- | :--------------------- |
|
||||
| [`30_rpc/auth/fn_check_admin_permission_v1.sql`](./30_rpc/auth/fn_check_admin_permission_v1.sql) | 通用 RBAC 权限校验函数 |
|
||||
|
||||
#### 查询类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/auth/rpc_admin_get_permission_list_v1.sql`](./30_rpc/auth/rpc_admin_get_permission_list_v1.sql) | 获取权限列表 |
|
||||
| [`30_rpc/auth/rpc_admin_get_role_list_v1.sql`](./30_rpc/auth/rpc_admin_get_role_list_v1.sql) | 获取角色列表 |
|
||||
| [`30_rpc/auth/rpc_admin_get_admin_list_v1.sql`](./30_rpc/auth/rpc_admin_get_admin_list_v1.sql) | 获取管理员列表 |
|
||||
| [`30_rpc/auth/get_current_user_role_v1.sql`](./30_rpc/auth/get_current_user_role_v1.sql) | 获取当前用户角色 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------- | :--------------- |
|
||||
| [`30_rpc/auth/rpc_admin_get_permission_list_v1.sql`](./30_rpc/auth/rpc_admin_get_permission_list_v1.sql) | 获取权限列表 |
|
||||
| [`30_rpc/auth/rpc_admin_get_role_list_v1.sql`](./30_rpc/auth/rpc_admin_get_role_list_v1.sql) | 获取角色列表 |
|
||||
| [`30_rpc/auth/rpc_admin_get_admin_list_v1.sql`](./30_rpc/auth/rpc_admin_get_admin_list_v1.sql) | 获取管理员列表 |
|
||||
| [`30_rpc/auth/get_current_user_role_v1.sql`](./30_rpc/auth/get_current_user_role_v1.sql) | 获取当前用户角色 |
|
||||
|
||||
#### 保存/更新类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------- | :------- |
|
||||
| [`30_rpc/auth/rpc_admin_save_permission_v1.sql`](./30_rpc/auth/rpc_admin_save_permission_v1.sql) | 保存权限 |
|
||||
| [`30_rpc/auth/rpc_admin_save_role_v1.sql`](./30_rpc/auth/rpc_admin_save_role_v1.sql) | 保存角色 |
|
||||
| [`30_rpc/auth/rpc_admin_save_role_v1.sql`](./30_rpc/auth/rpc_admin_save_role_v1.sql) | 保存角色 |
|
||||
|
||||
#### 删除类(软删除)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------- | :----------------- |
|
||||
| [`30_rpc/auth/rpc_admin_delete_permission_v1.sql`](./30_rpc/auth/rpc_admin_delete_permission_v1.sql) | 删除权限(软删除) |
|
||||
| [`30_rpc/auth/rpc_admin_delete_role_v1.sql`](./30_rpc/auth/rpc_admin_delete_role_v1.sql) | 删除角色(软删除) |
|
||||
| [`30_rpc/auth/rpc_admin_delete_role_v1.sql`](./30_rpc/auth/rpc_admin_delete_role_v1.sql) | 删除角色(软删除) |
|
||||
|
||||
#### 用户处理类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------- | :------------ |
|
||||
| [`30_rpc/auth/handle_new_user_v3.sql`](./30_rpc/auth/handle_new_user_v3.sql) | 处理新用户 v3 |
|
||||
| [`30_rpc/auth/handle_new_user_v2.sql`](./30_rpc/auth/handle_new_user_v2.sql) | 处理新用户 v2 |
|
||||
|
||||
@@ -238,28 +276,32 @@
|
||||
### 3.3 CMS 域(内容管理)
|
||||
|
||||
#### 查询类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/cms/rpc_admin_article_list_v1.sql`](./30_rpc/cms/rpc_admin_article_list_v1.sql) | 获取文章列表 |
|
||||
| [`30_rpc/cms/rpc_admin_article_get_detail_v1.sql`](./30_rpc/cms/rpc_admin_article_get_detail_v1.sql) | 获取文章详情 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------- | :--------------- |
|
||||
| [`30_rpc/cms/rpc_admin_article_list_v1.sql`](./30_rpc/cms/rpc_admin_article_list_v1.sql) | 获取文章列表 |
|
||||
| [`30_rpc/cms/rpc_admin_article_get_detail_v1.sql`](./30_rpc/cms/rpc_admin_article_get_detail_v1.sql) | 获取文章详情 |
|
||||
| [`30_rpc/cms/rpc_admin_article_category_list_v1.sql`](./30_rpc/cms/rpc_admin_article_category_list_v1.sql) | 获取文章分类列表 |
|
||||
|
||||
#### 保存/更新类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/cms/rpc_admin_article_save_v1.sql`](./30_rpc/cms/rpc_admin_article_save_v1.sql) | 保存文章 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/cms/rpc_admin_article_save_v1.sql`](./30_rpc/cms/rpc_admin_article_save_v1.sql) | 保存文章 |
|
||||
| [`30_rpc/cms/rpc_admin_article_category_save_v1.sql`](./30_rpc/cms/rpc_admin_article_category_save_v1.sql) | 保存文章分类 |
|
||||
|
||||
#### 删除类(软删除)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/cms/rpc_admin_article_delete_v1.sql`](./30_rpc/cms/rpc_admin_article_delete_v1.sql) | 删除文章(软删除) |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------------- | :--------------------- |
|
||||
| [`30_rpc/cms/rpc_admin_article_delete_v1.sql`](./30_rpc/cms/rpc_admin_article_delete_v1.sql) | 删除文章(软删除) |
|
||||
| [`30_rpc/cms/rpc_admin_article_category_delete_v1.sql`](./30_rpc/cms/rpc_admin_article_category_delete_v1.sql) | 删除文章分类(软删除) |
|
||||
|
||||
#### 状态管理类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/cms/rpc_admin_article_set_status_v1.sql`](./30_rpc/cms/rpc_admin_article_set_status_v1.sql) | 设置文章状态 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------------- | :--------------- |
|
||||
| [`30_rpc/cms/rpc_admin_article_set_status_v1.sql`](./30_rpc/cms/rpc_admin_article_set_status_v1.sql) | 设置文章状态 |
|
||||
| [`30_rpc/cms/rpc_admin_article_category_set_status_v1.sql`](./30_rpc/cms/rpc_admin_article_category_set_status_v1.sql) | 设置文章分类状态 |
|
||||
|
||||
---
|
||||
@@ -267,19 +309,22 @@
|
||||
### 3.4 Decoration 域(装修管理)
|
||||
|
||||
#### 查询类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------- | :---------------- |
|
||||
| [`30_rpc/decoration/rpc_admin_get_diy_page_list_v1.sql`](./30_rpc/decoration/rpc_admin_get_diy_page_list_v1.sql) | 获取 DIY 页面列表 |
|
||||
|
||||
#### 保存/更新类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------- | :------------ |
|
||||
| [`30_rpc/decoration/rpc_admin_save_diy_page_v1.sql`](./30_rpc/decoration/rpc_admin_save_diy_page_v1.sql) | 保存 DIY 页面 |
|
||||
| [`30_rpc/decoration/rpc_admin_set_home_page_v1.sql`](./30_rpc/decoration/rpc_admin_set_home_page_v1.sql) | 设置首页 |
|
||||
| [`30_rpc/decoration/rpc_admin_set_home_page_v1.sql`](./30_rpc/decoration/rpc_admin_set_home_page_v1.sql) | 设置首页 |
|
||||
|
||||
#### 删除类(软删除)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------------------- | :---------------------- |
|
||||
| [`30_rpc/decoration/rpc_admin_delete_diy_page_v1.sql`](./30_rpc/decoration/rpc_admin_delete_diy_page_v1.sql) | 删除 DIY 页面(软删除) |
|
||||
|
||||
---
|
||||
@@ -287,21 +332,24 @@
|
||||
### 3.5 Delivery 域(配送管理)
|
||||
|
||||
#### 查询类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/delivery/rpc_admin_get_delivery_staff_list_v1.sql`](./30_rpc/delivery/rpc_admin_get_delivery_staff_list_v1.sql) | 获取配送员列表 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------------------- | :--------------- |
|
||||
| [`30_rpc/delivery/rpc_admin_get_delivery_staff_list_v1.sql`](./30_rpc/delivery/rpc_admin_get_delivery_staff_list_v1.sql) | 获取配送员列表 |
|
||||
| [`30_rpc/delivery/rpc_admin_get_delivery_station_list_v1.sql`](./30_rpc/delivery/rpc_admin_get_delivery_station_list_v1.sql) | 获取配送站点列表 |
|
||||
|
||||
#### 保存/更新类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/delivery/rpc_admin_save_delivery_staff_v1.sql`](./30_rpc/delivery/rpc_admin_save_delivery_staff_v1.sql) | 保存配送员 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/delivery/rpc_admin_save_delivery_staff_v1.sql`](./30_rpc/delivery/rpc_admin_save_delivery_staff_v1.sql) | 保存配送员 |
|
||||
| [`30_rpc/delivery/rpc_admin_save_delivery_station_v1.sql`](./30_rpc/delivery/rpc_admin_save_delivery_station_v1.sql) | 保存配送站点 |
|
||||
|
||||
#### 删除类(软删除)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/delivery/rpc_admin_delete_delivery_staff_v1.sql`](./30_rpc/delivery/rpc_admin_delete_delivery_staff_v1.sql) | 删除配送员(软删除) |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------------------------------- | :--------------------- |
|
||||
| [`30_rpc/delivery/rpc_admin_delete_delivery_staff_v1.sql`](./30_rpc/delivery/rpc_admin_delete_delivery_staff_v1.sql) | 删除配送员(软删除) |
|
||||
| [`30_rpc/delivery/rpc_admin_delete_delivery_station_v1.sql`](./30_rpc/delivery/rpc_admin_delete_delivery_station_v1.sql) | 删除配送站点(软删除) |
|
||||
|
||||
---
|
||||
@@ -309,28 +357,32 @@
|
||||
### 3.6 Distribution 域(分销管理)
|
||||
|
||||
#### 查询类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/distribution/rpc_admin_get_agent_list_v1.sql`](./30_rpc/distribution/rpc_admin_get_agent_list_v1.sql) | 获取代理列表 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------------------------- | :--------------- |
|
||||
| [`30_rpc/distribution/rpc_admin_get_agent_list_v1.sql`](./30_rpc/distribution/rpc_admin_get_agent_list_v1.sql) | 获取代理列表 |
|
||||
| [`30_rpc/distribution/rpc_admin_get_agent_apply_list_v1.sql`](./30_rpc/distribution/rpc_admin_get_agent_apply_list_v1.sql) | 获取代理申请列表 |
|
||||
| [`30_rpc/distribution/rpc_admin_get_division_list_v1.sql`](./30_rpc/distribution/rpc_admin_get_division_list_v1.sql) | 获取事业部列表 |
|
||||
| [`30_rpc/distribution/rpc_admin_get_promoter_list_v1.sql`](./30_rpc/distribution/rpc_admin_get_promoter_list_v1.sql) | 获取推广员列表 |
|
||||
| [`30_rpc/distribution/rpc_admin_get_division_list_v1.sql`](./30_rpc/distribution/rpc_admin_get_division_list_v1.sql) | 获取事业部列表 |
|
||||
| [`30_rpc/distribution/rpc_admin_get_promoter_list_v1.sql`](./30_rpc/distribution/rpc_admin_get_promoter_list_v1.sql) | 获取推广员列表 |
|
||||
|
||||
#### 保存/更新类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/distribution/rpc_admin_save_agent_v1.sql`](./30_rpc/distribution/rpc_admin_save_agent_v1.sql) | 保存代理 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------------------- | :--------- |
|
||||
| [`30_rpc/distribution/rpc_admin_save_agent_v1.sql`](./30_rpc/distribution/rpc_admin_save_agent_v1.sql) | 保存代理 |
|
||||
| [`30_rpc/distribution/rpc_admin_save_division_v1.sql`](./30_rpc/distribution/rpc_admin_save_division_v1.sql) | 保存事业部 |
|
||||
|
||||
#### 删除类(软删除)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/distribution/rpc_admin_delete_agent_v1.sql`](./30_rpc/distribution/rpc_admin_delete_agent_v1.sql) | 删除代理(软删除) |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------- | :------------------- |
|
||||
| [`30_rpc/distribution/rpc_admin_delete_agent_v1.sql`](./30_rpc/distribution/rpc_admin_delete_agent_v1.sql) | 删除代理(软删除) |
|
||||
| [`30_rpc/distribution/rpc_admin_delete_division_v1.sql`](./30_rpc/distribution/rpc_admin_delete_division_v1.sql) | 删除事业部(软删除) |
|
||||
|
||||
#### 处理/审核类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/distribution/rpc_admin_process_agent_apply_v1.sql`](./30_rpc/distribution/rpc_admin_process_agent_apply_v1.sql) | 处理代理申请 |
|
||||
|
||||
---
|
||||
@@ -338,68 +390,75 @@
|
||||
### 3.7 Finance 域(财务管理)
|
||||
|
||||
#### 查询/统计类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/finance/rpc_admin_balance_stats_v1.sql`](./30_rpc/finance/rpc_admin_balance_stats_v1.sql) | 余额统计 |
|
||||
| [`30_rpc/finance/rpc_admin_balance_distribution_v1.sql`](./30_rpc/finance/rpc_admin_balance_distribution_v1.sql) | 余额分布 |
|
||||
| [`30_rpc/finance/rpc_admin_balance_trend_v1.sql`](./30_rpc/finance/rpc_admin_balance_trend_v1.sql) | 余额趋势 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/finance/rpc_admin_balance_stats_v1.sql`](./30_rpc/finance/rpc_admin_balance_stats_v1.sql) | 余额统计 |
|
||||
| [`30_rpc/finance/rpc_admin_balance_distribution_v1.sql`](./30_rpc/finance/rpc_admin_balance_distribution_v1.sql) | 余额分布 |
|
||||
| [`30_rpc/finance/rpc_admin_balance_trend_v1.sql`](./30_rpc/finance/rpc_admin_balance_trend_v1.sql) | 余额趋势 |
|
||||
| [`30_rpc/finance/rpc_admin_finance_bill_summary_v1.sql`](./30_rpc/finance/rpc_admin_finance_bill_summary_v1.sql) | 财务账单汇总 |
|
||||
| [`30_rpc/finance/rpc_admin_finance_overview_v1.sql`](./30_rpc/finance/rpc_admin_finance_overview_v1.sql) | 财务概览 |
|
||||
| [`30_rpc/finance/rpc_admin_invoice_list_v1.sql`](./30_rpc/finance/rpc_admin_invoice_list_v1.sql) | 发票列表 |
|
||||
| [`30_rpc/finance/rpc_admin_user_bill_list_v1.sql`](./30_rpc/finance/rpc_admin_user_bill_list_v1.sql) | 用户账单列表 |
|
||||
| [`30_rpc/finance/rpc_admin_recharge_list_v1.sql`](./30_rpc/finance/rpc_admin_recharge_list_v1.sql) | 充值列表 |
|
||||
| [`30_rpc/finance/rpc_admin_extract_list_v1.sql`](./30_rpc/finance/rpc_admin_extract_list_v1.sql) | 提现列表 |
|
||||
| [`30_rpc/finance/rpc_admin_finance_overview_v1.sql`](./30_rpc/finance/rpc_admin_finance_overview_v1.sql) | 财务概览 |
|
||||
| [`30_rpc/finance/rpc_admin_invoice_list_v1.sql`](./30_rpc/finance/rpc_admin_invoice_list_v1.sql) | 发票列表 |
|
||||
| [`30_rpc/finance/rpc_admin_user_bill_list_v1.sql`](./30_rpc/finance/rpc_admin_user_bill_list_v1.sql) | 用户账单列表 |
|
||||
| [`30_rpc/finance/rpc_admin_recharge_list_v1.sql`](./30_rpc/finance/rpc_admin_recharge_list_v1.sql) | 充值列表 |
|
||||
| [`30_rpc/finance/rpc_admin_extract_list_v1.sql`](./30_rpc/finance/rpc_admin_extract_list_v1.sql) | 提现列表 |
|
||||
|
||||
#### 处理/审核类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------------- | :------- |
|
||||
| [`30_rpc/finance/rpc_admin_invoice_process_v1.sql`](./30_rpc/finance/rpc_admin_invoice_process_v1.sql) | 处理发票 |
|
||||
| [`30_rpc/finance/rpc_admin_recharge_audit_v1.sql`](./30_rpc/finance/rpc_admin_recharge_audit_v1.sql) | 审核充值 |
|
||||
| [`30_rpc/finance/rpc_admin_extract_review_v1.sql`](./30_rpc/finance/rpc_admin_extract_review_v1.sql) | 审核提现 |
|
||||
| [`30_rpc/finance/rpc_admin_recharge_audit_v1.sql`](./30_rpc/finance/rpc_admin_recharge_audit_v1.sql) | 审核充值 |
|
||||
| [`30_rpc/finance/rpc_admin_extract_review_v1.sql`](./30_rpc/finance/rpc_admin_extract_review_v1.sql) | 审核提现 |
|
||||
|
||||
---
|
||||
|
||||
### 3.8 Kefu 域(客服管理)
|
||||
|
||||
#### 查询类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_account_list_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_account_list_v1.sql) | 获取客服账号列表 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_auto_reply_list_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_auto_reply_list_v1.sql) | 获取自动回复列表 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_word_list_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_word_list_v1.sql) | 获取客服话术列表 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------- | :--------------- |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_account_list_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_account_list_v1.sql) | 获取客服账号列表 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_auto_reply_list_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_auto_reply_list_v1.sql) | 获取自动回复列表 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_word_list_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_word_list_v1.sql) | 获取客服话术列表 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_word_category_list_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_word_category_list_v1.sql) | 获取话术分类列表 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_feedback_list_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_feedback_list_v1.sql) | 获取反馈列表 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_feedback_list_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_feedback_list_v1.sql) | 获取反馈列表 |
|
||||
|
||||
#### 保存/更新类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_account_save_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_account_save_v1.sql) | 保存客服账号 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_auto_reply_save_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_auto_reply_save_v1.sql) | 保存自动回复 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_word_save_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_word_save_v1.sql) | 保存客服话术 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_account_save_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_account_save_v1.sql) | 保存客服账号 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_auto_reply_save_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_auto_reply_save_v1.sql) | 保存自动回复 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_word_save_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_word_save_v1.sql) | 保存客服话术 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_word_category_save_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_word_category_save_v1.sql) | 保存话术分类 |
|
||||
|
||||
#### 删除类(软删除)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_account_delete_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_account_delete_v1.sql) | 删除客服账号(软删除) |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_auto_reply_delete_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_auto_reply_delete_v1.sql) | 删除自动回复(软删除) |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_word_delete_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_word_delete_v1.sql) | 删除客服话术(软删除) |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------------------- | :--------------------- |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_account_delete_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_account_delete_v1.sql) | 删除客服账号(软删除) |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_auto_reply_delete_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_auto_reply_delete_v1.sql) | 删除自动回复(软删除) |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_word_delete_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_word_delete_v1.sql) | 删除客服话术(软删除) |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_word_category_delete_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_word_category_delete_v1.sql) | 删除话术分类(软删除) |
|
||||
|
||||
#### 状态/处理类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_account_set_status_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_account_set_status_v1.sql) | 设置客服账号状态 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------------- | :--------------- |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_account_set_status_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_account_set_status_v1.sql) | 设置客服账号状态 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_auto_reply_set_status_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_auto_reply_set_status_v1.sql) | 设置自动回复状态 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_feedback_process_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_feedback_process_v1.sql) | 处理客服反馈 |
|
||||
| [`30_rpc/kefu/rpc_admin_kefu_feedback_process_v1.sql`](./30_rpc/kefu/rpc_admin_kefu_feedback_process_v1.sql) | 处理客服反馈 |
|
||||
|
||||
---
|
||||
|
||||
### 3.9 Marketing 域(营销管理)
|
||||
|
||||
#### 查询/统计类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/marketing/rpc_admin_get_integral_stats_v1.sql`](./30_rpc/marketing/rpc_admin_get_integral_stats_v1.sql) | 获取积分统计 |
|
||||
|
||||
---
|
||||
@@ -407,32 +466,35 @@
|
||||
### 3.10 Order 域(订单管理)
|
||||
|
||||
#### 查询/统计类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/order/rpc_admin_order_list_v1.sql`](./30_rpc/order/rpc_admin_order_list_v1.sql) | 获取订单列表 |
|
||||
| [`30_rpc/order/rpc_admin_order_source_stats_v1.sql`](./30_rpc/order/rpc_admin_order_source_stats_v1.sql) | 订单来源统计 |
|
||||
| [`30_rpc/order/rpc_admin_order_type_stats_v1.sql`](./30_rpc/order/rpc_admin_order_type_stats_v1.sql) | 订单类型统计 |
|
||||
| [`30_rpc/order/rpc_admin_order_stats_v1.sql`](./30_rpc/order/rpc_admin_order_stats_v1.sql) | 订单统计 |
|
||||
| [`30_rpc/order/rpc_admin_order_trend_v1.sql`](./30_rpc/order/rpc_admin_order_trend_v1.sql) | 订单趋势 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/order/rpc_admin_order_list_v1.sql`](./30_rpc/order/rpc_admin_order_list_v1.sql) | 获取订单列表 |
|
||||
| [`30_rpc/order/rpc_admin_order_source_stats_v1.sql`](./30_rpc/order/rpc_admin_order_source_stats_v1.sql) | 订单来源统计 |
|
||||
| [`30_rpc/order/rpc_admin_order_type_stats_v1.sql`](./30_rpc/order/rpc_admin_order_type_stats_v1.sql) | 订单类型统计 |
|
||||
| [`30_rpc/order/rpc_admin_order_stats_v1.sql`](./30_rpc/order/rpc_admin_order_stats_v1.sql) | 订单统计 |
|
||||
| [`30_rpc/order/rpc_admin_order_trend_v1.sql`](./30_rpc/order/rpc_admin_order_trend_v1.sql) | 订单趋势 |
|
||||
| [`30_rpc/order/rpc_admin_write_off_record_list_v1.sql`](./30_rpc/order/rpc_admin_write_off_record_list_v1.sql) | 核销记录列表 |
|
||||
| [`30_rpc/order/rpc_admin_refund_order_list_v1.sql`](./30_rpc/order/rpc_admin_refund_order_list_v1.sql) | 退款订单列表 |
|
||||
| [`30_rpc/order/rpc_admin_cashier_order_list_v1.sql`](./30_rpc/order/rpc_admin_cashier_order_list_v1.sql) | 收银订单列表 |
|
||||
| [`30_rpc/order/rpc_admin_refund_order_list_v1.sql`](./30_rpc/order/rpc_admin_refund_order_list_v1.sql) | 退款订单列表 |
|
||||
| [`30_rpc/order/rpc_admin_cashier_order_list_v1.sql`](./30_rpc/order/rpc_admin_cashier_order_list_v1.sql) | 收银订单列表 |
|
||||
|
||||
---
|
||||
|
||||
### 3.11 Product 域(商品管理)
|
||||
|
||||
#### 查询/统计类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/product/rpc_admin_get_product_reviews_v1.sql`](./30_rpc/product/rpc_admin_get_product_reviews_v1.sql) | 获取商品评价 |
|
||||
| [`30_rpc/product/rpc_admin_product_count_stats_v1.sql`](./30_rpc/product/rpc_admin_product_count_stats_v1.sql) | 商品数量统计 |
|
||||
| [`30_rpc/product/rpc_admin_product_analytics_v1.sql`](./30_rpc/product/rpc_admin_product_analytics_v1.sql) | 商品分析 |
|
||||
| [`30_rpc/product/rpc_admin_product_trend_v1.sql`](./30_rpc/product/rpc_admin_product_trend_v1.sql) | 商品趋势 |
|
||||
| [`30_rpc/product/rpc_admin_product_analytics_v1.sql`](./30_rpc/product/rpc_admin_product_analytics_v1.sql) | 商品分析 |
|
||||
| [`30_rpc/product/rpc_admin_product_trend_v1.sql`](./30_rpc/product/rpc_admin_product_trend_v1.sql) | 商品趋势 |
|
||||
|
||||
#### 删除类(软删除)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------------- | :--------------------- |
|
||||
| [`30_rpc/product/rpc_admin_category_delete_v1.sql`](./30_rpc/product/rpc_admin_category_delete_v1.sql) | 删除商品分类(软删除) |
|
||||
|
||||
---
|
||||
@@ -440,45 +502,50 @@
|
||||
### 3.12 User 域(用户管理)
|
||||
|
||||
#### 查询类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------- | :--------------- |
|
||||
| [`30_rpc/user/rpc_admin_user_label_list_v1.sql`](./30_rpc/user/rpc_admin_user_label_list_v1.sql) | 获取用户标签列表 |
|
||||
| [`30_rpc/user/rpc_admin_user_group_list_v1.sql`](./30_rpc/user/rpc_admin_user_group_list_v1.sql) | 获取用户分组列表 |
|
||||
| [`30_rpc/user/rpc_admin_user_level_list_v1.sql`](./30_rpc/user/rpc_admin_user_level_list_v1.sql) | 获取用户等级列表 |
|
||||
|
||||
#### 保存/更新类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------- | :----------- |
|
||||
| [`30_rpc/user/rpc_admin_user_label_save_v1.sql`](./30_rpc/user/rpc_admin_user_label_save_v1.sql) | 保存用户标签 |
|
||||
| [`30_rpc/user/rpc_admin_user_group_save_v1.sql`](./30_rpc/user/rpc_admin_user_group_save_v1.sql) | 保存用户分组 |
|
||||
| [`30_rpc/user/rpc_admin_user_level_save_v1.sql`](./30_rpc/user/rpc_admin_user_level_save_v1.sql) | 保存用户等级 |
|
||||
|
||||
#### 删除类(软删除)
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :--------------------------------------------------------------------------------------------------- | :--------------------- |
|
||||
| [`30_rpc/user/rpc_admin_user_label_delete_v1.sql`](./30_rpc/user/rpc_admin_user_label_delete_v1.sql) | 删除用户标签(软删除) |
|
||||
| [`30_rpc/user/rpc_admin_user_group_delete_v1.sql`](./30_rpc/user/rpc_admin_user_group_delete_v1.sql) | 删除用户分组(软删除) |
|
||||
| [`30_rpc/user/rpc_admin_user_level_delete_v1.sql`](./30_rpc/user/rpc_admin_user_level_delete_v1.sql) | 删除用户等级(软删除) |
|
||||
|
||||
#### 状态/可见性管理类
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| [`30_rpc/user/rpc_admin_user_label_set_status_v1.sql`](./30_rpc/user/rpc_admin_user_label_set_status_v1.sql) | 设置用户标签状态 |
|
||||
| [`30_rpc/user/rpc_admin_user_group_set_status_v1.sql`](./30_rpc/user/rpc_admin_user_group_set_status_v1.sql) | 设置用户分组状态 |
|
||||
| [`30_rpc/user/rpc_admin_user_level_set_status_v1.sql`](./30_rpc/user/rpc_admin_user_level_set_status_v1.sql) | 设置用户等级状态 |
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
| :------------------------------------------------------------------------------------------------------------- | :----------------- |
|
||||
| [`30_rpc/user/rpc_admin_user_label_set_status_v1.sql`](./30_rpc/user/rpc_admin_user_label_set_status_v1.sql) | 设置用户标签状态 |
|
||||
| [`30_rpc/user/rpc_admin_user_group_set_status_v1.sql`](./30_rpc/user/rpc_admin_user_group_set_status_v1.sql) | 设置用户分组状态 |
|
||||
| [`30_rpc/user/rpc_admin_user_level_set_status_v1.sql`](./30_rpc/user/rpc_admin_user_level_set_status_v1.sql) | 设置用户等级状态 |
|
||||
| [`30_rpc/user/rpc_admin_user_level_set_visible_v1.sql`](./30_rpc/user/rpc_admin_user_level_set_visible_v1.sql) | 设置用户等级可见性 |
|
||||
|
||||
---
|
||||
|
||||
### 3.13 Analytics 域(数据分析)
|
||||
|
||||
| 文件路径 | 说明 |
|
||||
|:---|:---|
|
||||
| 文件路径 | 说明 |
|
||||
| :----------------------------------------------------------------------------------------------------------------------------------- | :--------------- |
|
||||
| [`30_rpc/analytics/rpc_analytics_user_gender_distribution_v1.sql`](./30_rpc/analytics/rpc_analytics_user_gender_distribution_v1.sql) | 用户性别分布分析 |
|
||||
|
||||
---
|
||||
|
||||
## 执行后验证清单
|
||||
|
||||
- 字段存在性:抽查任一涉及表,确认 `deleted_at/deleted_by` 字段存在。
|
||||
- 索引存在性:确认 `idx_<table>_soft_delete` 存在。
|
||||
- RLS 生效:软删一条数据后,使用正常查询路径确认该条记录不可见。
|
||||
|
||||
269
mall_sql/migrations/20260521_medical_mall_categories_v1.sql
Normal file
269
mall_sql/migrations/20260521_medical_mall_categories_v1.sql
Normal file
@@ -0,0 +1,269 @@
|
||||
-- Medical mall categories migration
|
||||
-- Includes: schema + RLS + initial seed
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.medical_mall_categories (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
parent_id TEXT NULL REFERENCES public.medical_mall_categories(id),
|
||||
level INTEGER NOT NULL CHECK (level IN (1, 2)),
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
icon TEXT,
|
||||
image_url TEXT,
|
||||
description TEXT,
|
||||
scene TEXT NOT NULL DEFAULT 'medical_mall',
|
||||
category_type TEXT NOT NULL DEFAULT 'normal',
|
||||
compliance_type TEXT NOT NULL DEFAULT 'normal',
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
deleted_at TIMESTAMPTZ NULL,
|
||||
deleted_by UUID NULL REFERENCES public.ak_users(id),
|
||||
restored_at TIMESTAMPTZ NULL,
|
||||
restored_by UUID NULL REFERENCES public.ak_users(id),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
COMMENT ON TABLE public.medical_mall_categories IS '医疗商城独立分类表';
|
||||
COMMENT ON COLUMN public.medical_mall_categories.scene IS '分类场景,如 medical_mall / home_mall';
|
||||
COMMENT ON COLUMN public.medical_mall_categories.category_type IS '分类类型:device / otc / care / rehab / elderly / nutrition / protection / tcm / all';
|
||||
COMMENT ON COLUMN public.medical_mall_categories.compliance_type IS '合规类型:normal / otc / device_class_i / device_class_ii / device_class_iii / rx_hidden';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_categories_parent
|
||||
ON public.medical_mall_categories(parent_id)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_categories_level_sort
|
||||
ON public.medical_mall_categories(level, sort_order)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_categories_scene_active
|
||||
ON public.medical_mall_categories(scene, is_active)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.medical_mall_product_categories (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
product_id UUID NOT NULL REFERENCES public.ml_products(id) ON DELETE CASCADE,
|
||||
category_id TEXT NOT NULL REFERENCES public.medical_mall_categories(id),
|
||||
is_primary BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
deleted_at TIMESTAMPTZ NULL,
|
||||
deleted_by UUID NULL REFERENCES public.ak_users(id),
|
||||
restored_at TIMESTAMPTZ NULL,
|
||||
restored_by UUID NULL REFERENCES public.ak_users(id),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
UNIQUE (product_id, category_id)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE public.medical_mall_product_categories IS '医疗商城商品与分类关联表';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_product_categories_category
|
||||
ON public.medical_mall_product_categories(category_id, sort_order)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_medical_mall_product_categories_product
|
||||
ON public.medical_mall_product_categories(product_id)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
ALTER TABLE public.medical_mall_categories ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE public.medical_mall_product_categories ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
DROP POLICY IF EXISTS medical_mall_categories_public_select_active ON public.medical_mall_categories;
|
||||
CREATE POLICY medical_mall_categories_public_select_active
|
||||
ON public.medical_mall_categories
|
||||
FOR SELECT
|
||||
TO anon, authenticated
|
||||
USING (
|
||||
deleted_at IS NULL
|
||||
AND is_active = TRUE
|
||||
AND compliance_type <> 'rx_hidden'
|
||||
);
|
||||
|
||||
DROP POLICY IF EXISTS medical_mall_product_categories_public_select_active ON public.medical_mall_product_categories;
|
||||
CREATE POLICY medical_mall_product_categories_public_select_active
|
||||
ON public.medical_mall_product_categories
|
||||
FOR SELECT
|
||||
TO anon, authenticated
|
||||
USING (deleted_at IS NULL);
|
||||
|
||||
INSERT INTO public.medical_mall_categories (
|
||||
id, name, parent_id, level, sort_order, icon, image_url, description, scene, category_type, compliance_type, is_active, created_at, updated_at
|
||||
)
|
||||
VALUES
|
||||
('med_device', '医疗器械', NULL, 1, 10, '🩺', NULL, '家庭监测与基础器械', 'medical_mall', 'device', 'device_class_i', TRUE, NOW(), NOW()),
|
||||
('otc_medicine', '家庭常备药', NULL, 1, 20, '💊', NULL, 'OTC 家庭常备药与应急用药', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('rehab_care', '康复护理', NULL, 1, 30, '🩹', NULL, '术后恢复、敷料护具与护理用品', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('chronic_monitor', '慢病监测', NULL, 1, 40, '📈', NULL, '高血压、糖尿病与家庭检测场景', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('elderly_aid', '适老用品', NULL, 1, 50, '🧓', NULL, '长者安全辅助与居家适老用品', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('nutrition_health', '营养保健', NULL, 1, 60, '🥛', NULL, '维生素、钙片、蛋白营养等保健品', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('protection_disinfection', '防护消毒', NULL, 1, 70, '😷', NULL, '口罩、消毒、急救与防护耗材', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('tcm_health', '中医保健', NULL, 1, 80, '🌿', NULL, '艾灸、贴敷、按摩理疗与草本养护', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('home_care_daily', '居家护理', NULL, 1, 90, '🏠', NULL, '伤口、口腔、皮肤与家庭健康工具', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('all_medical', '全部', NULL, 1, 100, '🧺', NULL, '查看全部康养医疗商品', 'medical_mall', 'all', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('blood_pressure_monitor', '血压计', 'med_device', 2, 11, '🫀', NULL, '家庭血压监测设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('blood_glucose_meter', '血糖仪', 'med_device', 2, 12, '🩸', NULL, '家庭血糖检测设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('oximeter', '血氧仪', 'med_device', 2, 13, '💗', NULL, '指夹式血氧监测设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('thermometer', '体温计', 'med_device', 2, 14, '🌡️', NULL, '额温枪与电子体温计', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('oxygen_concentrator', '制氧机', 'med_device', 2, 15, '🫁', NULL, '家庭制氧与吸氧辅助设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('nebulizer', '雾化器', 'med_device', 2, 16, '💨', NULL, '家用雾化护理设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('wheelchair_crutch', '轮椅拐杖', 'med_device', 2, 17, '🦽', NULL, '轮椅、拐杖与行动辅助器具', 'medical_mall', 'device', 'device_class_i', TRUE, NOW(), NOW()),
|
||||
('nursing_bed', '护理床', 'med_device', 2, 18, '🛏️', NULL, '护理床与居家照护床具', 'medical_mall', 'device', 'device_class_i', TRUE, NOW(), NOW()),
|
||||
|
||||
('cold_fever', '感冒发烧', 'otc_medicine', 2, 21, '🤒', NULL, '感冒、退热与家庭常备药', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('cough_throat', '咳嗽咽喉', 'otc_medicine', 2, 22, '🗣️', NULL, '咳嗽、咽喉与润喉护理', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('stomach_medicine', '肠胃用药', 'otc_medicine', 2, 23, '🥣', NULL, '肠胃调理与胃肠常备药', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('skin_external', '皮肤外用', 'otc_medicine', 2, 24, '🧴', NULL, '皮肤喷剂、软膏与外用护理', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('eye_ear_nose', '眼耳口鼻', 'otc_medicine', 2, 25, '👁️', NULL, '眼耳鼻喉口腔常备用品', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('pain_relief', '止痛用药', 'otc_medicine', 2, 26, '🩹', NULL, '止痛、舒缓与应急常备药', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('trauma_sprain', '跌打损伤', 'otc_medicine', 2, 27, '🦴', NULL, '跌打扭伤与运动损伤护理', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('child_medicine', '儿童用药', 'otc_medicine', 2, 28, '🧒', NULL, '儿童常备药与护理用品', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
|
||||
('postop_rehab', '术后康复', 'rehab_care', 2, 31, '🩺', NULL, '术后恢复与支撑护理', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('wound_dressing', '伤口敷料', 'rehab_care', 2, 32, '🩹', NULL, '敷料、纱布与换药护理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('brace_support', '护具支具', 'rehab_care', 2, 33, '🦵', NULL, '护腰、护膝与支撑固定用品', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('rehab_training', '康复训练器', 'rehab_care', 2, 34, '🏋️', NULL, '康复训练与恢复辅助设备', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('physiotherapy_hot', '理疗热敷', 'rehab_care', 2, 35, '🔥', NULL, '热敷理疗与家庭舒缓护理', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('mobility_training', '行动训练', 'rehab_care', 2, 36, '🚶', NULL, '恢复行动能力的辅助训练用品', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('hypertension', '高血压管理', 'chronic_monitor', 2, 41, '❤️', NULL, '高血压居家管理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('diabetes', '糖尿病管理', 'chronic_monitor', 2, 42, '🩸', NULL, '血糖监测与糖尿病管理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('cardiovascular', '心脑血管', 'chronic_monitor', 2, 43, '🫀', NULL, '心脑血管健康管理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('respiratory_health', '呼吸健康', 'chronic_monitor', 2, 44, '🫁', NULL, '呼吸道护理与呼吸健康', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('weight_bodyfat', '体重体脂', 'chronic_monitor', 2, 45, '⚖️', NULL, '体重与体脂监测', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('home_testing', '家庭检测', 'chronic_monitor', 2, 46, '🧪', NULL, '家庭常用健康检测用品', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('anti_slip', '防滑安全', 'elderly_aid', 2, 51, '🧱', NULL, '长者防滑与跌倒预防', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('elderly_bathroom', '适老卫浴', 'elderly_aid', 2, 52, '🚿', NULL, '浴室扶手与适老卫浴辅助', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('eating_aid', '助餐用品', 'elderly_aid', 2, 53, '🍽️', NULL, '适老助餐与餐具辅助', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('bathing_aid', '助浴用品', 'elderly_aid', 2, 54, '🛁', NULL, '助浴椅与洗护辅助用品', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('incontinence_care', '失禁护理', 'elderly_aid', 2, 55, '🧻', NULL, '长者失禁护理用品', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('daily_living_aid', '生活辅助', 'elderly_aid', 2, 56, '🪑', NULL, '日常起居与生活辅助用品', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('vitamin', '维生素', 'nutrition_health', 2, 61, '🍊', NULL, '复合维生素与维 C 等营养补充', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('calcium', '钙铁锌硒', 'nutrition_health', 2, 62, '🦴', NULL, '钙铁锌硒等基础营养', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('protein', '蛋白营养', 'nutrition_health', 2, 63, '🥛', NULL, '蛋白粉与恢复期营养', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('elderly_nutrition', '老人营养', 'nutrition_health', 2, 64, '👴', NULL, '适合长者的专用营养补充', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('gut_health', '肠道益生菌', 'nutrition_health', 2, 65, '🦠', NULL, '益生菌与肠胃营养补充', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('immune_support', '免疫支持', 'nutrition_health', 2, 66, '🛡️', NULL, '免疫支持与日常补给', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('mask', '口罩', 'protection_disinfection', 2, 71, '😷', NULL, '日常口罩与防护耗材', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('disinfectant', '消毒液', 'protection_disinfection', 2, 72, '🧴', NULL, '家庭与环境消毒用品', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('alcohol_wipes', '酒精湿巾', 'protection_disinfection', 2, 73, '🧻', NULL, '酒精湿巾与便携消毒', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('gloves', '手套', 'protection_disinfection', 2, 74, '🧤', NULL, '检查手套与护理手套', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('first_aid', '急救包', 'protection_disinfection', 2, 75, '🧰', NULL, '家庭急救包与应急护理', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('dressing_tools', '棉签纱布', 'protection_disinfection', 2, 76, '🧺', NULL, '棉签纱布与护理耗材', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('moxibustion', '艾灸拔罐', 'tcm_health', 2, 81, '🔥', NULL, '艾灸、拔罐与温灸理疗', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('herbal_drink', '养生茶饮', 'tcm_health', 2, 82, '🍵', NULL, '草本茶饮与养生冲饮', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('tcm_patch', '中医贴敷', 'tcm_health', 2, 83, '🩹', NULL, '中医贴敷与草本热敷', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('medicated_diet', '药膳滋补', 'tcm_health', 2, 84, '🥣', NULL, '药膳汤料与滋补调养', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('massage_tools', '按摩理疗', 'tcm_health', 2, 85, '💆', NULL, '按摩仪、刮痧与理疗工具', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('foot_bath', '泡脚养生', 'tcm_health', 2, 86, '🪣', NULL, '泡脚包与足浴理疗用品', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('wound_care', '伤口护理', 'home_care_daily', 2, 91, '🩹', NULL, '创面处理与换药护理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('oral_care', '口腔护理', 'home_care_daily', 2, 92, '🦷', NULL, '口腔护理与清洁用品', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('skin_care', '皮肤护理', 'home_care_daily', 2, 93, '🧴', NULL, '皮肤护理与修护用品', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('cleaning_care', '清洁护理', 'home_care_daily', 2, 94, '🫧', NULL, '清洁护理与日常消耗品', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('nursing_consumables', '护理耗材', 'home_care_daily', 2, 95, '📦', NULL, '棉签、纱布、护理垫等耗材', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('home_health_tool', '家庭健康工具', 'home_care_daily', 2, 96, '🧰', NULL, '家庭健康小工具与辅具', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW())
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
name = EXCLUDED.name,
|
||||
parent_id = EXCLUDED.parent_id,
|
||||
level = EXCLUDED.level,
|
||||
sort_order = EXCLUDED.sort_order,
|
||||
icon = EXCLUDED.icon,
|
||||
image_url = EXCLUDED.image_url,
|
||||
description = EXCLUDED.description,
|
||||
scene = EXCLUDED.scene,
|
||||
category_type = EXCLUDED.category_type,
|
||||
compliance_type = EXCLUDED.compliance_type,
|
||||
is_active = EXCLUDED.is_active,
|
||||
deleted_at = NULL,
|
||||
updated_at = NOW();
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'blood_pressure_monitor', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%血压计%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'blood_glucose_meter', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%血糖仪%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'thermometer', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%体温计%' OR p.name ILIKE '%额温枪%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'oxygen_concentrator', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%制氧机%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'nebulizer', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%雾化器%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'mask', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%口罩%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'disinfectant', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%消毒%' OR p.name ILIKE '%酒精%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'wound_care', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%创可贴%' OR p.name ILIKE '%纱布%' OR p.name ILIKE '%敷料%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'wheelchair_crutch', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%轮椅%' OR p.name ILIKE '%拐杖%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'nursing_bed', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%护理床%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'calcium', TRUE, 30, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%钙片%' OR p.name ILIKE '%钙铁锌%' OR p.name ILIKE '%补钙%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'vitamin', TRUE, 30, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%维生素%' OR p.name ILIKE '%维C%' OR p.name ILIKE '%维D%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'protein', TRUE, 30, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%蛋白%' OR p.name ILIKE '%蛋白粉%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'cold_fever', TRUE, 40, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%感冒%' OR p.name ILIKE '%退热%' OR p.name ILIKE '%发烧%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
COMMIT;
|
||||
681
mock/delivery-care.mock.uts
Normal file
681
mock/delivery-care.mock.uts
Normal file
@@ -0,0 +1,681 @@
|
||||
import type {
|
||||
DeliveryAbnormalReportType,
|
||||
DeliveryDashboardType,
|
||||
DeliveryExceptionPayloadType,
|
||||
DeliveryInfoType,
|
||||
DeliveryLocationType,
|
||||
DeliveryOnlineStatus,
|
||||
DeliveryOrderStatus,
|
||||
DeliveryOrderType,
|
||||
DeliveryRecordType,
|
||||
DeliveryServiceItemType,
|
||||
DeliveryServiceRecordType,
|
||||
DeliveryStatusLogType,
|
||||
DeliveryTimelineItemType
|
||||
} from '@/types/delivery.uts'
|
||||
|
||||
const PROFILE_KEY = 'delivery_care_profile'
|
||||
const ORDER_KEY = 'delivery_care_orders'
|
||||
|
||||
function nowText(): string {
|
||||
return new Date().toISOString().replace('T', ' ').substring(0, 19)
|
||||
}
|
||||
|
||||
function cloneProfile(profile: DeliveryInfoType): DeliveryInfoType {
|
||||
return JSON.parse(JSON.stringify(profile)) as DeliveryInfoType
|
||||
}
|
||||
|
||||
function cloneOrder(order: DeliveryOrderType): DeliveryOrderType {
|
||||
return JSON.parse(JSON.stringify(order)) as DeliveryOrderType
|
||||
}
|
||||
|
||||
function cloneOrders(orders: Array<DeliveryOrderType>): Array<DeliveryOrderType> {
|
||||
return JSON.parse(JSON.stringify(orders)) as Array<DeliveryOrderType>
|
||||
}
|
||||
|
||||
function createStatusText(status: DeliveryOrderStatus): string {
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') return '待接单'
|
||||
if (status == 'accepted') return '已接单'
|
||||
if (status == 'waiting_departure') return '待出发'
|
||||
if (status == 'departed' || status == 'on_the_way') return '已出发'
|
||||
if (status == 'arrived') return '已到达'
|
||||
if (status == 'checked_in') return '已签到'
|
||||
if (status == 'in_service' || status == 'serving') return '服务中'
|
||||
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') return '待确认'
|
||||
if (status == 'completed') return '已完成'
|
||||
if (status == 'rejected') return '已拒单'
|
||||
if (status == 'cancelled') return '已取消'
|
||||
if (status == 'abnormal' || status == 'exception_pending') return '异常上报'
|
||||
if (status == 'terminated') return '服务终止'
|
||||
return '已归档'
|
||||
}
|
||||
|
||||
function createStatusTone(status: DeliveryOrderStatus): string {
|
||||
if (status == 'pending_assignment' || status == 'pending_accept' || status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') return 'warning'
|
||||
if (status == 'completed') return 'success'
|
||||
if (status == 'rejected' || status == 'cancelled' || status == 'terminated') return 'neutral'
|
||||
if (status == 'abnormal' || status == 'exception_pending') return 'danger'
|
||||
return 'primary'
|
||||
}
|
||||
|
||||
function createStatusLog(orderId: string, fromStatus: DeliveryOrderStatus, toStatus: DeliveryOrderStatus, remark: string): DeliveryStatusLogType {
|
||||
return {
|
||||
id: orderId + '-log-' + nowText().replace(/[-: ]/g, ''),
|
||||
orderId,
|
||||
fromStatus,
|
||||
toStatus,
|
||||
operatorRole: 'service_staff',
|
||||
operatorId: 'mock-staff-001',
|
||||
remark,
|
||||
createdAt: nowText()
|
||||
} as DeliveryStatusLogType
|
||||
}
|
||||
|
||||
function createTimeline(title: string, description: string): DeliveryTimelineItemType {
|
||||
return {
|
||||
id: 'timeline-' + nowText().replace(/[-: ]/g, ''),
|
||||
title,
|
||||
time: nowText(),
|
||||
description
|
||||
} as DeliveryTimelineItemType
|
||||
}
|
||||
|
||||
function createServiceItems(orderId: string): Array<DeliveryServiceItemType> {
|
||||
return [
|
||||
{
|
||||
id: orderId + '-item-1',
|
||||
name: '生命体征监测',
|
||||
required: true,
|
||||
completed: false,
|
||||
incompleteReason: '',
|
||||
remark: '',
|
||||
updatedAt: ''
|
||||
} as DeliveryServiceItemType,
|
||||
{
|
||||
id: orderId + '-item-2',
|
||||
name: '基础照护服务',
|
||||
required: true,
|
||||
completed: false,
|
||||
incompleteReason: '',
|
||||
remark: '',
|
||||
updatedAt: ''
|
||||
} as DeliveryServiceItemType,
|
||||
{
|
||||
id: orderId + '-item-3',
|
||||
name: '家属沟通与宣教',
|
||||
required: false,
|
||||
completed: false,
|
||||
incompleteReason: '',
|
||||
remark: '',
|
||||
updatedAt: ''
|
||||
} as DeliveryServiceItemType
|
||||
]
|
||||
}
|
||||
|
||||
function createProfile(): DeliveryInfoType {
|
||||
return {
|
||||
id: 'mock-staff-001',
|
||||
userId: 'mock-delivery-user-001',
|
||||
staffNo: 'CARE-202605-001',
|
||||
name: '陈护理',
|
||||
phone: '13600001111',
|
||||
role: 'care_worker',
|
||||
status: 'active',
|
||||
organizationId: 'org-care-001',
|
||||
organizationName: '梅江区居家康护中心',
|
||||
certificates: [] as Array<any>,
|
||||
certificateStatus: 'valid',
|
||||
certificateExpireAt: '2027-12-31',
|
||||
onlineStatus: 'online',
|
||||
serviceArea: '梅江区 / 梅县区',
|
||||
skills: ['上门助浴', '康复陪护', '慢病随访', '居家照护'],
|
||||
avatarUrl: '',
|
||||
todayAccepted: 2,
|
||||
todayServing: 1,
|
||||
todayCompleted: 1,
|
||||
usesMock: true
|
||||
} as DeliveryInfoType
|
||||
}
|
||||
|
||||
function createOrder(
|
||||
orderId: string,
|
||||
serviceName: string,
|
||||
serviceType: string,
|
||||
status: DeliveryOrderStatus,
|
||||
appointmentTime: string,
|
||||
duration: number,
|
||||
price: number,
|
||||
staffIncome: number,
|
||||
elderName: string,
|
||||
elderGender: string,
|
||||
elderAge: number,
|
||||
elderPhone: string,
|
||||
contactName: string,
|
||||
contactPhone: string,
|
||||
contactRelation: string,
|
||||
address: string,
|
||||
addressDetail: string,
|
||||
distance: string,
|
||||
riskTags: Array<string>,
|
||||
healthTags: Array<string>,
|
||||
needFamilyPresent: boolean,
|
||||
needMaterials: boolean,
|
||||
remark: string
|
||||
): DeliveryOrderType {
|
||||
const statusText = createStatusText(status)
|
||||
const items = createServiceItems(orderId)
|
||||
return {
|
||||
id: orderId,
|
||||
orderNo: 'CARE-' + orderId.toUpperCase(),
|
||||
serviceType,
|
||||
serviceName,
|
||||
serviceCategory: serviceType,
|
||||
serviceItems: items,
|
||||
serviceContentOptions: ['基础护理', '生命体征监测', '安全巡视', '家属沟通'],
|
||||
elderId: 'elder-' + orderId,
|
||||
elderName,
|
||||
elderNameMasked: elderName.substring(0, 1) + '**',
|
||||
elderGender,
|
||||
elderAge,
|
||||
elderPhone,
|
||||
elderPhoneMasked: elderPhone.substring(0, 3) + '****' + elderPhone.substring(elderPhone.length - 4),
|
||||
fullElderName: elderName,
|
||||
fullPhone: elderPhone,
|
||||
contactName,
|
||||
contactPhone,
|
||||
contactRelation,
|
||||
addressSummary: address,
|
||||
address,
|
||||
addressDetail,
|
||||
fullAddress: address + ' ' + addressDetail,
|
||||
latitude: 24.2898,
|
||||
longitude: 116.1179,
|
||||
appointmentTime,
|
||||
appointmentStartTime: appointmentTime,
|
||||
appointmentEndTime: appointmentTime,
|
||||
duration,
|
||||
estimatedDuration: duration,
|
||||
price,
|
||||
staffIncome,
|
||||
distance,
|
||||
actualStartTime: '',
|
||||
actualEndTime: '',
|
||||
status,
|
||||
statusText,
|
||||
statusTone: createStatusTone(status),
|
||||
riskTags,
|
||||
healthTags,
|
||||
careLevel: '护理二级',
|
||||
needFamilyPresent,
|
||||
needMaterials,
|
||||
remark,
|
||||
merchantId: 'merchant-care-001',
|
||||
merchantName: '梅江区居家康护中心',
|
||||
deliveryStaffId: 'mock-staff-001',
|
||||
deliveryStaffName: '陈护理',
|
||||
acceptTime: '',
|
||||
rejectTime: '',
|
||||
departTime: '',
|
||||
arriveTime: '',
|
||||
checkinTime: '',
|
||||
startServiceTime: '',
|
||||
finishTime: '',
|
||||
cancelReason: '',
|
||||
exceptionType: '',
|
||||
exceptionDesc: '',
|
||||
evidenceList: [] as Array<any>,
|
||||
signatureUrl: '',
|
||||
signatureName: '',
|
||||
satisfactionStatus: '待确认',
|
||||
settlementStatus: '待结算',
|
||||
archiveStatus: '未归档',
|
||||
createdAt: nowText(),
|
||||
updatedAt: nowText(),
|
||||
notices: ['请提前 15 分钟电话联系', '如遇突发异常先上报再处置'],
|
||||
timeline: [createTimeline('订单已生成', '平台已生成上门服务订单')],
|
||||
statusLog: [createStatusLog(orderId, status, status, '初始化 mock 订单')],
|
||||
serviceSummary: '',
|
||||
progressNote: '',
|
||||
distanceKm: distance,
|
||||
allowCheckinRadiusMeters: 120,
|
||||
lastLocation: null,
|
||||
trackPoints: [] as Array<DeliveryLocationType>,
|
||||
serviceRecord: null,
|
||||
abnormalReport: null
|
||||
} as DeliveryOrderType
|
||||
}
|
||||
|
||||
function createDefaultOrders(): Array<DeliveryOrderType> {
|
||||
const orders = [
|
||||
createOrder('mock-care-001', '上门助浴', '生活照护', 'pending_assignment', '2026-05-20 09:00', 90, 199, 128, '李秀珍', '女', 79, '13800131024', '李晓兰', '13900139000', '女儿', '梅江区江南路 18 号', '2 栋 602 室', '2.4km', ['高龄', '行动不便'], ['高血压'], true, true, '请准备防滑垫和浴后保暖衣物'),
|
||||
createOrder('mock-care-002', '康复陪护', '康复护理', 'pending_assignment', '2026-05-20 10:30', 120, 260, 160, '张志坤', '男', 83, '13700132233', '张春梅', '13600136666', '女儿', '梅县区新城锦绣花园 5 栋', '1403 室', '5.8km', ['需家属在场'], ['术后恢复'], true, true, '需携带弹力带与康复手册'),
|
||||
createOrder('mock-care-003', '陪诊服务', '陪诊陪护', 'accepted', '2026-05-20 13:00', 180, 320, 220, '黄玉英', '女', 76, '13500135566', '黄晓娟', '13500130088', '女儿', '梅江区学海路康养公寓 A 座', '907 室', '1.1km', ['高龄'], ['糖尿病'], false, false, '就诊前需先核对病历资料'),
|
||||
createOrder('mock-care-004', '慢病随访', '健康管理', 'departed', '2026-05-20 14:30', 60, 168, 108, '陈国辉', '男', 81, '13900133301', '陈丽芳', '13800136660', '妻子', '梅县区扶老社区 11 栋', '203 室', '3.6km', ['行动不便'], ['高血压', '冠心病'], false, true, '重点测量血压并复核药盒'),
|
||||
createOrder('mock-care-005', '居家照护', '长期照护', 'in_service', '2026-05-20 15:00', 120, 288, 190, '王月兰', '女', 87, '13400137744', '王秀玲', '13600139922', '女儿', '梅江区东汇城旁康颐楼 3 单元', '1204 室', '4.2km', ['失能', '需家属在场'], ['血糖异常'], true, true, '服务中注意翻身护理与进食观察'),
|
||||
createOrder('mock-care-006', '上门护理', '护理服务', 'completed', '2026-05-19 16:00', 90, 230, 150, '刘建华', '男', 72, '13300136655', '刘敏', '13300998877', '儿子', '梅江区和顺苑 9 栋', '401 室', '6.0km', ['术后恢复'], ['低蛋白'], false, false, '完成换药与术后宣教')
|
||||
]
|
||||
orders[2].acceptTime = '2026-05-20 11:40:00'
|
||||
orders[2].timeline.unshift(createTimeline('已接单', '服务人员已确认接单'))
|
||||
orders[2].statusLog.unshift(createStatusLog(orders[2].id, 'pending_assignment', 'accepted', '手动接单'))
|
||||
orders[3].acceptTime = '2026-05-20 12:00:00'
|
||||
orders[3].departTime = '2026-05-20 13:58:00'
|
||||
orders[3].timeline.unshift(createTimeline('已出发', '服务人员已从机构出发'))
|
||||
orders[3].statusLog.unshift(createStatusLog(orders[3].id, 'accepted', 'departed', '已出发'))
|
||||
orders[4].acceptTime = '2026-05-20 13:00:00'
|
||||
orders[4].departTime = '2026-05-20 14:00:00'
|
||||
orders[4].arriveTime = '2026-05-20 14:40:00'
|
||||
orders[4].checkinTime = '2026-05-20 14:45:00'
|
||||
orders[4].startServiceTime = '2026-05-20 14:50:00'
|
||||
orders[4].actualStartTime = '2026-05-20 14:50:00'
|
||||
orders[4].serviceItems[0].completed = true
|
||||
orders[4].serviceItems[0].remark = '血压 132/82,心率 76 次/分'
|
||||
orders[4].serviceItems[0].updatedAt = '2026-05-20 15:10:00'
|
||||
orders[4].timeline.unshift(createTimeline('开始服务', '已进入服务执行阶段'))
|
||||
orders[4].statusLog.unshift(createStatusLog(orders[4].id, 'checked_in', 'in_service', '开始服务'))
|
||||
orders[5].acceptTime = '2026-05-19 14:30:00'
|
||||
orders[5].departTime = '2026-05-19 15:10:00'
|
||||
orders[5].arriveTime = '2026-05-19 15:48:00'
|
||||
orders[5].checkinTime = '2026-05-19 15:52:00'
|
||||
orders[5].startServiceTime = '2026-05-19 15:55:00'
|
||||
orders[5].finishTime = '2026-05-19 17:18:00'
|
||||
orders[5].actualStartTime = '2026-05-19 15:55:00'
|
||||
orders[5].actualEndTime = '2026-05-19 17:18:00'
|
||||
orders[5].serviceSummary = '已完成换药、伤口巡视和家属宣教。'
|
||||
orders[5].serviceRecord = {
|
||||
id: 'record-' + orders[5].id,
|
||||
orderId: orders[5].id,
|
||||
startTime: '2026-05-19 15:55:00',
|
||||
endTime: '2026-05-19 17:18:00',
|
||||
actualDurationMinutes: 83,
|
||||
serviceItems: orders[5].serviceItems,
|
||||
serviceContent: ['换药护理', '伤口观察', '家属宣教'],
|
||||
processNote: '服务过程平稳,老人配合良好。',
|
||||
elderStatus: '精神状态稳定,伤口恢复良好。',
|
||||
healthMetrics: {
|
||||
bloodPressure: '126/80',
|
||||
heartRate: '74',
|
||||
bloodSugar: '',
|
||||
bloodOxygen: '98'
|
||||
},
|
||||
materialsUsed: '无菌敷料 2 片,棉签 4 支',
|
||||
abnormalNote: '',
|
||||
photos: ['mock-photo-1'],
|
||||
staffRemark: '建议继续保持每日换药。',
|
||||
familyConfirmation: {
|
||||
method: 'sms_code',
|
||||
code: '652318',
|
||||
signatureName: '刘敏',
|
||||
signatureUrl: '',
|
||||
confirmedAt: '2026-05-19 17:20:00'
|
||||
},
|
||||
createdAt: '2026-05-19 17:18:00',
|
||||
updatedAt: '2026-05-19 17:18:00'
|
||||
} as DeliveryServiceRecordType
|
||||
return orders
|
||||
}
|
||||
|
||||
function readProfileStore(): DeliveryInfoType {
|
||||
const cached = uni.getStorageSync(PROFILE_KEY) as DeliveryInfoType | null
|
||||
if (cached != null && cached.id != null && cached.id != '') {
|
||||
return cloneProfile(cached)
|
||||
}
|
||||
const created = createProfile()
|
||||
uni.setStorageSync(PROFILE_KEY, cloneProfile(created))
|
||||
return created
|
||||
}
|
||||
|
||||
function writeProfileStore(profile: DeliveryInfoType): DeliveryInfoType {
|
||||
uni.setStorageSync(PROFILE_KEY, cloneProfile(profile))
|
||||
return profile
|
||||
}
|
||||
|
||||
function readOrderStore(): Array<DeliveryOrderType> {
|
||||
const cached = uni.getStorageSync(ORDER_KEY) as Array<DeliveryOrderType> | null
|
||||
if (cached != null && cached.length > 0) {
|
||||
return cloneOrders(cached)
|
||||
}
|
||||
const created = createDefaultOrders()
|
||||
uni.setStorageSync(ORDER_KEY, cloneOrders(created))
|
||||
return created
|
||||
}
|
||||
|
||||
function writeOrderStore(orders: Array<DeliveryOrderType>): Array<DeliveryOrderType> {
|
||||
uni.setStorageSync(ORDER_KEY, cloneOrders(orders))
|
||||
return orders
|
||||
}
|
||||
|
||||
function sortOrdersByAppointment(orders: Array<DeliveryOrderType>): Array<DeliveryOrderType> {
|
||||
return orders.sort((left, right) => left.appointmentTime.localeCompare(right.appointmentTime))
|
||||
}
|
||||
|
||||
function isPendingStatus(status: DeliveryOrderStatus): boolean {
|
||||
return status == 'pending_assignment' || status == 'pending_accept'
|
||||
}
|
||||
|
||||
function isHistoryStatus(status: DeliveryOrderStatus): boolean {
|
||||
return status == 'completed' || status == 'rejected' || status == 'cancelled' || status == 'abnormal' || status == 'terminated' || status == 'archived'
|
||||
}
|
||||
|
||||
function isTodayStatus(status: DeliveryOrderStatus): boolean {
|
||||
return !isPendingStatus(status) && !isHistoryStatus(status)
|
||||
}
|
||||
|
||||
function refreshOrderMeta(order: DeliveryOrderType): void {
|
||||
order.statusText = createStatusText(order.status)
|
||||
order.statusTone = createStatusTone(order.status)
|
||||
order.updatedAt = nowText()
|
||||
order.distanceKm = order.distance
|
||||
order.fullAddress = order.address + ' ' + order.addressDetail
|
||||
order.fullElderName = order.elderName
|
||||
order.fullPhone = order.elderPhone
|
||||
order.elderNameMasked = order.elderName.substring(0, 1) + '**'
|
||||
order.elderPhoneMasked = order.elderPhone.substring(0, 3) + '****' + order.elderPhone.substring(order.elderPhone.length - 4)
|
||||
order.timeline.unshift(createTimeline(order.statusText, '订单状态已更新为' + order.statusText))
|
||||
}
|
||||
|
||||
function findOrderIndex(orders: Array<DeliveryOrderType>, orderId: string): number {
|
||||
for (let i = 0; i < orders.length; i++) {
|
||||
if (orders[i].id == orderId) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
export function getDeliveryCareProfile(): DeliveryInfoType {
|
||||
return readProfileStore()
|
||||
}
|
||||
|
||||
export function updateDeliveryCareOnlineStatus(status: DeliveryOnlineStatus): DeliveryInfoType {
|
||||
const profile = readProfileStore()
|
||||
profile.onlineStatus = status
|
||||
return cloneProfile(writeProfileStore(profile))
|
||||
}
|
||||
|
||||
export function getDeliveryCareDashboard(): DeliveryDashboardType {
|
||||
const profile = readProfileStore()
|
||||
const orders = sortOrdersByAppointment(readOrderStore())
|
||||
let pendingCount = 0
|
||||
let todayCount = 0
|
||||
let pendingDepartCount = 0
|
||||
let servingCount = 0
|
||||
let completedCount = 0
|
||||
let exceptionCount = 0
|
||||
let expectedIncome = 0
|
||||
let nextOrder: DeliveryOrderType | null = null
|
||||
const recentOrders: Array<DeliveryOrderType> = []
|
||||
for (let i = 0; i < orders.length; i++) {
|
||||
const item = orders[i]
|
||||
if (isPendingStatus(item.status)) {
|
||||
pendingCount += 1
|
||||
}
|
||||
if (isTodayStatus(item.status) || item.status == 'completed') {
|
||||
todayCount += 1
|
||||
}
|
||||
if (item.status == 'accepted' || item.status == 'waiting_departure') {
|
||||
pendingDepartCount += 1
|
||||
}
|
||||
if (item.status == 'in_service' || item.status == 'serving') {
|
||||
servingCount += 1
|
||||
}
|
||||
if (item.status == 'completed') {
|
||||
completedCount += 1
|
||||
}
|
||||
if (item.status == 'abnormal' || item.status == 'exception_pending') {
|
||||
exceptionCount += 1
|
||||
}
|
||||
if (!isHistoryStatus(item.status) && item.status != 'rejected' && item.status != 'cancelled') {
|
||||
expectedIncome += item.staffIncome
|
||||
}
|
||||
if (nextOrder == null && !isHistoryStatus(item.status)) {
|
||||
nextOrder = cloneOrder(item)
|
||||
}
|
||||
if (recentOrders.length < 4) {
|
||||
recentOrders.push(cloneOrder(item))
|
||||
}
|
||||
}
|
||||
profile.todayAccepted = pendingDepartCount
|
||||
profile.todayServing = servingCount
|
||||
profile.todayCompleted = completedCount
|
||||
writeProfileStore(profile)
|
||||
return {
|
||||
pendingAssignmentCount: pendingCount,
|
||||
pendingAcceptCount: pendingCount,
|
||||
todayOrderCount: todayCount,
|
||||
pendingDepartCount,
|
||||
servingCount,
|
||||
completedCount,
|
||||
exceptionCount,
|
||||
expectedIncome,
|
||||
onlineStatus: profile.onlineStatus,
|
||||
nextOrder,
|
||||
recentOrders
|
||||
} as DeliveryDashboardType
|
||||
}
|
||||
|
||||
export function getPendingCareOrders(): Array<DeliveryOrderType> {
|
||||
const orders = sortOrdersByAppointment(readOrderStore())
|
||||
const result: Array<DeliveryOrderType> = []
|
||||
for (let i = 0; i < orders.length; i++) {
|
||||
if (isPendingStatus(orders[i].status)) {
|
||||
result.push(cloneOrder(orders[i]))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export function getTodayCareOrders(): Array<DeliveryOrderType> {
|
||||
const orders = sortOrdersByAppointment(readOrderStore())
|
||||
const result: Array<DeliveryOrderType> = []
|
||||
for (let i = 0; i < orders.length; i++) {
|
||||
if (isTodayStatus(orders[i].status)) {
|
||||
result.push(cloneOrder(orders[i]))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export function getHistoryCareOrders(): Array<DeliveryOrderType> {
|
||||
const orders = sortOrdersByAppointment(readOrderStore())
|
||||
const result: Array<DeliveryOrderType> = []
|
||||
for (let i = 0; i < orders.length; i++) {
|
||||
if (isHistoryStatus(orders[i].status)) {
|
||||
result.push(cloneOrder(orders[i]))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export function getCareOrderDetail(orderId: string): DeliveryOrderType | null {
|
||||
const orders = readOrderStore()
|
||||
const index = findOrderIndex(orders, orderId)
|
||||
if (index < 0) {
|
||||
return null
|
||||
}
|
||||
return cloneOrder(orders[index])
|
||||
}
|
||||
|
||||
export function updateCareOrderStatus(orderId: string, nextStatus: DeliveryOrderStatus, remark: string): DeliveryOrderType | null {
|
||||
const orders = readOrderStore()
|
||||
const index = findOrderIndex(orders, orderId)
|
||||
if (index < 0) {
|
||||
return null
|
||||
}
|
||||
const target = orders[index]
|
||||
const fromStatus = target.status
|
||||
target.status = nextStatus
|
||||
if (nextStatus == 'accepted') {
|
||||
target.acceptTime = nowText()
|
||||
}
|
||||
if (nextStatus == 'rejected') {
|
||||
target.rejectTime = nowText()
|
||||
}
|
||||
if (nextStatus == 'departed') {
|
||||
target.departTime = nowText()
|
||||
}
|
||||
if (nextStatus == 'arrived') {
|
||||
target.arriveTime = nowText()
|
||||
}
|
||||
if (nextStatus == 'checked_in') {
|
||||
target.checkinTime = nowText()
|
||||
}
|
||||
if (nextStatus == 'in_service') {
|
||||
target.startServiceTime = nowText()
|
||||
target.actualStartTime = target.startServiceTime != null ? target.startServiceTime : nowText()
|
||||
}
|
||||
if (nextStatus == 'completed') {
|
||||
target.finishTime = nowText()
|
||||
target.actualEndTime = target.finishTime
|
||||
}
|
||||
target.statusLog.unshift(createStatusLog(orderId, fromStatus, nextStatus, remark))
|
||||
refreshOrderMeta(target)
|
||||
writeOrderStore(orders)
|
||||
return cloneOrder(target)
|
||||
}
|
||||
|
||||
export function acceptCareOrder(orderId: string): DeliveryOrderType | null {
|
||||
return updateCareOrderStatus(orderId, 'accepted', '接单成功')
|
||||
}
|
||||
|
||||
export function rejectCareOrder(orderId: string, reason: string): DeliveryOrderType | null {
|
||||
const order = updateCareOrderStatus(orderId, 'rejected', reason)
|
||||
if (order != null) {
|
||||
const orders = readOrderStore()
|
||||
const index = findOrderIndex(orders, orderId)
|
||||
if (index >= 0) {
|
||||
orders[index].cancelReason = reason
|
||||
writeOrderStore(orders)
|
||||
return cloneOrder(orders[index])
|
||||
}
|
||||
}
|
||||
return order
|
||||
}
|
||||
|
||||
export function markCareOrderDeparted(orderId: string): DeliveryOrderType | null {
|
||||
return updateCareOrderStatus(orderId, 'departed', '服务人员已出发')
|
||||
}
|
||||
|
||||
export function markCareOrderArrived(orderId: string): DeliveryOrderType | null {
|
||||
return updateCareOrderStatus(orderId, 'arrived', '服务人员已到达')
|
||||
}
|
||||
|
||||
export function checkInCareOrder(orderId: string, location: DeliveryLocationType | null, note: string): DeliveryOrderType | null {
|
||||
const order = updateCareOrderStatus(orderId, 'checked_in', note != '' ? note : '到达签到')
|
||||
if (order == null) {
|
||||
return null
|
||||
}
|
||||
const orders = readOrderStore()
|
||||
const index = findOrderIndex(orders, orderId)
|
||||
if (index >= 0) {
|
||||
orders[index].lastLocation = location
|
||||
writeOrderStore(orders)
|
||||
return cloneOrder(orders[index])
|
||||
}
|
||||
return order
|
||||
}
|
||||
|
||||
export function startCareService(orderId: string): DeliveryOrderType | null {
|
||||
return updateCareOrderStatus(orderId, 'in_service', '开始服务')
|
||||
}
|
||||
|
||||
export function submitCareServiceRecord(orderId: string, record: DeliveryServiceRecordType): DeliveryOrderType | null {
|
||||
const orders = readOrderStore()
|
||||
const index = findOrderIndex(orders, orderId)
|
||||
if (index < 0) {
|
||||
return null
|
||||
}
|
||||
orders[index].serviceRecord = cloneOrder({
|
||||
...orders[index],
|
||||
serviceRecord: record
|
||||
} as DeliveryOrderType).serviceRecord
|
||||
orders[index].serviceSummary = record.processNote
|
||||
orders[index].progressNote = record.staffRemark
|
||||
orders[index].serviceItems = record.serviceItems
|
||||
orders[index].status = 'pending_confirm'
|
||||
orders[index].statusLog.unshift(createStatusLog(orderId, 'in_service', 'pending_confirm', '已提交服务记录'))
|
||||
refreshOrderMeta(orders[index])
|
||||
writeOrderStore(orders)
|
||||
return cloneOrder(orders[index])
|
||||
}
|
||||
|
||||
export function completeCareOrder(orderId: string): DeliveryOrderType | null {
|
||||
const orders = readOrderStore()
|
||||
const index = findOrderIndex(orders, orderId)
|
||||
if (index < 0) {
|
||||
return null
|
||||
}
|
||||
if (orders[index].serviceRecord == null) {
|
||||
return null
|
||||
}
|
||||
orders[index].statusLog.unshift(createStatusLog(orderId, orders[index].status, 'completed', '完成服务'))
|
||||
orders[index].status = 'completed'
|
||||
orders[index].finishTime = nowText()
|
||||
orders[index].actualEndTime = orders[index].finishTime
|
||||
refreshOrderMeta(orders[index])
|
||||
writeOrderStore(orders)
|
||||
return cloneOrder(orders[index])
|
||||
}
|
||||
|
||||
export function submitCareAbnormalReport(orderId: string, payload: DeliveryExceptionPayloadType): DeliveryOrderType | null {
|
||||
const orders = readOrderStore()
|
||||
const index = findOrderIndex(orders, orderId)
|
||||
if (index < 0) {
|
||||
return null
|
||||
}
|
||||
orders[index].abnormalReport = {
|
||||
id: 'abnormal-' + orderId,
|
||||
orderId,
|
||||
type: payload.exceptionType,
|
||||
description: payload.description,
|
||||
occurredAt: payload.occurredAt != null ? payload.occurredAt : nowText(),
|
||||
locationText: payload.locationText != null ? payload.locationText : '当前位置 mock',
|
||||
images: payload.images,
|
||||
needPlatformIntervention: payload.needPlatformIntervention === true,
|
||||
requestCancelOrder: payload.requestCancelOrder === true,
|
||||
requestReschedule: payload.requestReschedule === true,
|
||||
createdAt: nowText()
|
||||
} as DeliveryAbnormalReportType
|
||||
orders[index].exceptionType = payload.exceptionType
|
||||
orders[index].exceptionDesc = payload.description
|
||||
orders[index].statusLog.unshift(createStatusLog(orderId, orders[index].status, 'abnormal', '提交异常上报'))
|
||||
orders[index].status = 'abnormal'
|
||||
refreshOrderMeta(orders[index])
|
||||
writeOrderStore(orders)
|
||||
return cloneOrder(orders[index])
|
||||
}
|
||||
|
||||
export function getCareRecords(): Array<DeliveryRecordType> {
|
||||
const orders = readOrderStore()
|
||||
const result: Array<DeliveryRecordType> = []
|
||||
for (let i = 0; i < orders.length; i++) {
|
||||
const item = orders[i]
|
||||
if (item.serviceRecord != null || item.status == 'completed') {
|
||||
result.push({
|
||||
id: 'record-list-' + item.id,
|
||||
orderId: item.id,
|
||||
orderNo: item.orderNo,
|
||||
serviceName: item.serviceName,
|
||||
elderName: item.elderName,
|
||||
elderNameMasked: item.elderNameMasked,
|
||||
status: item.status,
|
||||
statusText: item.statusText,
|
||||
appointmentStartTime: item.appointmentStartTime,
|
||||
appointmentTime: item.appointmentTime,
|
||||
actualStartTime: item.actualStartTime,
|
||||
actualEndTime: item.actualEndTime,
|
||||
staffIncome: item.staffIncome,
|
||||
settlementStatus: item.settlementStatus,
|
||||
acceptanceStatus: item.satisfactionStatus,
|
||||
exceptionDesc: item.exceptionDesc,
|
||||
ratingText: item.satisfactionStatus,
|
||||
hasServiceRecord: item.serviceRecord != null
|
||||
} as DeliveryRecordType)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export function resetCareOrderStore(): void {
|
||||
uni.removeStorageSync(ORDER_KEY)
|
||||
uni.removeStorageSync(PROFILE_KEY)
|
||||
}
|
||||
@@ -38,35 +38,14 @@
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工单详情",
|
||||
"navigationBarTitleText": "订单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/route",
|
||||
"path": "pages/mall/delivery/service-record/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "出发与导航",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/checkin",
|
||||
"style": {
|
||||
"navigationBarTitleText": "到达签到",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/execute",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务执行",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/evidence",
|
||||
"style": {
|
||||
"navigationBarTitleText": "证据上传",
|
||||
"navigationBarTitleText": "服务记录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
@@ -77,34 +56,6 @@
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/orders/finish",
|
||||
"style": {
|
||||
"navigationBarTitleText": "完成确认",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/records/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务记录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/records/detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "记录详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/messages/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息中心",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/index",
|
||||
"style": {
|
||||
@@ -112,13 +63,6 @@
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/certificates",
|
||||
"style": {
|
||||
"navigationBarTitleText": "资质证书",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mall/delivery/profile/settings",
|
||||
"style": {
|
||||
@@ -148,16 +92,10 @@
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/orders/index",
|
||||
"text": "工单",
|
||||
"text": "订单",
|
||||
"iconPath": "static/tabbar/cart.png",
|
||||
"selectedIconPath": "static/tabbar/cart.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/messages/index",
|
||||
"text": "消息",
|
||||
"iconPath": "static/tabbar/message.png",
|
||||
"selectedIconPath": "static/tabbar/message.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mall/delivery/profile/index",
|
||||
"text": "我的",
|
||||
|
||||
@@ -201,6 +201,15 @@ const currentCategoryDesc = ref('')
|
||||
// 页面参数
|
||||
const pageParams = ref<any>({})
|
||||
|
||||
function normalizeSelectedMedicalCategoryId(categoryId: string): string {
|
||||
if (categoryId == 'device') return 'med_device'
|
||||
if (categoryId == 'external') return 'home_care_daily'
|
||||
if (categoryId == 'cold') return 'otc_medicine'
|
||||
if (categoryId == 'medicine') return 'otc_medicine'
|
||||
if (categoryId == 'care') return 'home_care_daily'
|
||||
return categoryId
|
||||
}
|
||||
|
||||
function getProductCover(product: Product): string {
|
||||
if (product.main_image_url != null && product.main_image_url !== '') return product.main_image_url
|
||||
if (product.images != null && product.images.length > 0 && product.images[0] !== '') return product.images[0]
|
||||
@@ -272,7 +281,7 @@ async function loadProducts(): Promise<void> {
|
||||
loading.value = true
|
||||
try {
|
||||
console.log('开始加载商品,分类ID:', activePrimary.value, '页码:', currentPage.value)
|
||||
const response = await supabaseService.getProductsByCategory(activePrimary.value, currentPage.value)
|
||||
const response = await supabaseService.getMedicalMallProductsByCategory(activePrimary.value, currentPage.value, 20)
|
||||
console.log('商品加载结果:', {
|
||||
dataCount: response.data.length,
|
||||
total: response.total,
|
||||
@@ -324,7 +333,7 @@ async function loadProducts(): Promise<void> {
|
||||
async function loadSubCategories(parentId: string): Promise<void> {
|
||||
console.log('加载二级分类,父级ID:', parentId)
|
||||
try {
|
||||
const subCats = await supabaseService.getSubCategories(parentId)
|
||||
const subCats = await supabaseService.getMedicalMallSubCategories(parentId)
|
||||
console.log('获取到二级分类数量:', subCats.length)
|
||||
|
||||
const categories: LocalCategory[] = []
|
||||
@@ -379,9 +388,10 @@ async function selectSubCategory(subCategoryId: string): Promise<void> {
|
||||
// originalCategoryId: 可能是一级分类ID,也可能是二级分类ID
|
||||
async function selectPrimaryCategory(originalCategoryId: string): Promise<void> {
|
||||
console.log('=== selectPrimaryCategory函数开始执行 ===')
|
||||
console.log('传入的categoryId:', originalCategoryId)
|
||||
const normalizedCategoryId = normalizeSelectedMedicalCategoryId(originalCategoryId)
|
||||
console.log('传入的categoryId:', originalCategoryId, '归一化后:', normalizedCategoryId)
|
||||
|
||||
if (originalCategoryId == '') {
|
||||
if (normalizedCategoryId == '') {
|
||||
console.error('categoryId为空,尝试使用第一个分类')
|
||||
if (primaryCategories.value.length > 0) {
|
||||
originalCategoryId = primaryCategories.value[0].id
|
||||
@@ -397,8 +407,9 @@ async function selectPrimaryCategory(originalCategoryId: string): Promise<void>
|
||||
console.log('当前一级分类列表长度:', primaryCategories.value.length)
|
||||
let foundInPrimary: LocalCategory | null = null
|
||||
for (let i = 0; i < primaryCategories.value.length; i++) {
|
||||
if (primaryCategories.value[i].id == originalCategoryId) {
|
||||
if (primaryCategories.value[i].id == normalizedCategoryId) {
|
||||
foundInPrimary = primaryCategories.value[i]
|
||||
targetParentId = normalizedCategoryId
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -410,7 +421,7 @@ async function selectPrimaryCategory(originalCategoryId: string): Promise<void>
|
||||
|
||||
// 从服务器获取分类信息以确定父级
|
||||
try {
|
||||
const categoryInfo = await supabaseService.getCategoryById(originalCategoryId)
|
||||
const categoryInfo = await supabaseService.getMedicalMallCategoryById(normalizedCategoryId)
|
||||
if (categoryInfo != null && categoryInfo.parent_id != null && categoryInfo.parent_id != '') {
|
||||
console.log('找到父级分类ID:', categoryInfo.parent_id)
|
||||
|
||||
@@ -427,7 +438,7 @@ async function selectPrimaryCategory(originalCategoryId: string): Promise<void>
|
||||
if (parentInPrimary != null) {
|
||||
console.log('父级分类在列表中找到:', parentInPrimary.name)
|
||||
targetParentId = categoryInfo.parent_id!
|
||||
targetSubId = originalCategoryId // 记住要选中的二级分类
|
||||
targetSubId = normalizedCategoryId // 记住要选中的二级分类
|
||||
} else {
|
||||
console.log('父级分类不在列表中,使用第一个分类')
|
||||
// 打印当前列表中的所有分类ID
|
||||
@@ -530,21 +541,13 @@ async function selectPrimaryCategory(originalCategoryId: string): Promise<void>
|
||||
|
||||
async function loadCategories(): Promise<void> {
|
||||
try {
|
||||
// 只获取一级分类(parent_id 为 null 的分类)
|
||||
const categoriesData = await supabaseService.getParentCategories()
|
||||
const categoriesData = await supabaseService.getMedicalMallParentCategories()
|
||||
console.log('加载一级分类数据成功,数量:', categoriesData.length)
|
||||
|
||||
// 映射数据并添加默认颜色,防止选中时背景透明导致文字看不清
|
||||
// 过滤掉医药健康相关分类
|
||||
const categories: LocalCategory[] = []
|
||||
for (let i = 0; i < categoriesData.length; i++) {
|
||||
const cat = categoriesData[i]
|
||||
const name = cat.name
|
||||
console.log('一级分类:', cat.id, name)
|
||||
if (name.includes('医药') || name.includes('健康')) {
|
||||
console.log('过滤掉分类:', name)
|
||||
continue
|
||||
}
|
||||
console.log('一级分类:', cat.id, cat.name)
|
||||
categories.push({
|
||||
id: cat.id,
|
||||
name: cat.name,
|
||||
@@ -572,16 +575,16 @@ async function loadCategories(): Promise<void> {
|
||||
// 检查是否有预设的分类ID
|
||||
if (activePrimary.value != '') {
|
||||
console.log('有预设的分类ID:', activePrimary.value)
|
||||
const target = categories.find((c: LocalCategory): boolean => c.id == activePrimary.value)
|
||||
const normalizedCategoryId = normalizeSelectedMedicalCategoryId(activePrimary.value)
|
||||
const target = categories.find((c: LocalCategory): boolean => c.id == normalizedCategoryId)
|
||||
if (target != null) {
|
||||
console.log('找到目标分类,执行选中:', target.name)
|
||||
selectPrimaryCategory(activePrimary.value)
|
||||
selectPrimaryCategory(normalizedCategoryId)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 默认选中第一个分类或"厨具"分类
|
||||
const defaultCategory = categories.find((c: LocalCategory): boolean => c.name.includes('厨具')) ?? categories[0]
|
||||
const defaultCategory = categories.find((c: LocalCategory): boolean => c.id == 'all_medical') ?? categories[0]
|
||||
if (defaultCategory != null) {
|
||||
console.log('设置默认分类:', defaultCategory.name)
|
||||
selectPrimaryCategory(defaultCategory.id)
|
||||
@@ -622,7 +625,7 @@ onShow(() => {
|
||||
console.log('onShow检查Storage:', savedCategoryId)
|
||||
|
||||
if (savedCategoryId != null && savedCategoryId != '') {
|
||||
const targetId = savedCategoryId as string
|
||||
const targetId = normalizeSelectedMedicalCategoryId(savedCategoryId as string)
|
||||
console.log('onShow发现存储的分类ID:', targetId)
|
||||
|
||||
// 清除存储,避免下次进入默认选中
|
||||
@@ -679,7 +682,7 @@ onLoad((options: any) => {
|
||||
const optObj = (options instanceof UTSJSONObject) ? (options as UTSJSONObject) : (JSON.parse(JSON.stringify(options ?? {})) as UTSJSONObject)
|
||||
const optCategoryId = optObj.getString('categoryId') ?? ''
|
||||
if (optCategoryId !== '') {
|
||||
categoryId = optCategoryId
|
||||
categoryId = normalizeSelectedMedicalCategoryId(optCategoryId)
|
||||
categoryName = optObj.getString('name') ?? ''
|
||||
console.log('✅ onLoad中找到分类参数:', categoryId, categoryName)
|
||||
}
|
||||
@@ -694,7 +697,7 @@ onLoad((options: any) => {
|
||||
const pageOptObj = (rawPageOptions instanceof UTSJSONObject) ? (rawPageOptions as UTSJSONObject) : (JSON.parse(JSON.stringify(rawPageOptions)) as UTSJSONObject)
|
||||
const pageCategoryId = pageOptObj.getString('categoryId') ?? ''
|
||||
if (pageCategoryId !== '') {
|
||||
categoryId = pageCategoryId
|
||||
categoryId = normalizeSelectedMedicalCategoryId(pageCategoryId)
|
||||
categoryName = pageOptObj.getString('name') ?? ''
|
||||
console.log('✅ 从getCurrentPages()找到分类参数:', categoryId, categoryName)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<scroll-view
|
||||
class="category-scroll"
|
||||
direction="horizontal"
|
||||
:scroll-x="true"
|
||||
:show-scrollbar="false"
|
||||
:scroll-with-animation="true"
|
||||
:scroll-into-view="categoryScrollIntoView"
|
||||
@@ -66,6 +67,8 @@
|
||||
:loading="loading"
|
||||
:has-more="hasMore"
|
||||
:show-load-more="showLoadMore"
|
||||
:empty-state-title="homeEmptyStateTitle"
|
||||
:empty-state-description="homeEmptyStateDescription"
|
||||
@secondary-category-click="handleSecondaryCategoryClick"
|
||||
@select-channel="navigateToChannel"
|
||||
@select-simple-channel="navigateToSimpleChannel"
|
||||
@@ -285,7 +288,7 @@ const headerSearchPlaceholder = computed((): string => {
|
||||
if (activeTopModule.value == 'service') {
|
||||
return '居家护理 / 康复照护 / 血压计 / 助餐服务'
|
||||
}
|
||||
return currentPlaceholderKeyword.value != '' ? currentPlaceholderKeyword.value : '感冒药 / 康复护理 / 居家护理 / 血压计'
|
||||
return currentPlaceholderKeyword.value != '' ? currentPlaceholderKeyword.value : '血压计 / 血糖仪 / 制氧机 / 维生素'
|
||||
})
|
||||
|
||||
type HomeCareCategoryType = {
|
||||
@@ -641,11 +644,16 @@ const showSubCategories = ref(false)
|
||||
|
||||
// 首页占位词轮播相关
|
||||
const placeholderKeywords = ref([
|
||||
'neo2无人机',
|
||||
'华为mate50',
|
||||
'血压计',
|
||||
'血糖仪',
|
||||
'体温计',
|
||||
'制氧机',
|
||||
'口罩',
|
||||
'创可贴',
|
||||
'维生素',
|
||||
'钙片',
|
||||
'感冒药',
|
||||
'维生素C',
|
||||
'康复护具',
|
||||
'护理床',
|
||||
|
||||
])
|
||||
const currentPlaceholderIndex = ref(0)
|
||||
@@ -655,6 +663,20 @@ const placeholderAnimating = ref(false)
|
||||
let placeholderTimer: number = 0
|
||||
let placeholderAnimationTimer: number = 0
|
||||
|
||||
const homeEmptyStateTitle = computed((): string => {
|
||||
if (currentFeedCategoryId.value == 'recommend') {
|
||||
return '康养医疗商品正在完善中'
|
||||
}
|
||||
return '当前分类暂无商品'
|
||||
})
|
||||
|
||||
const homeEmptyStateDescription = computed((): string => {
|
||||
if (currentFeedCategoryId.value == 'recommend') {
|
||||
return '可先查看居家服务或稍后再试'
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
const syncNextPlaceholderKeyword = () => {
|
||||
const total = placeholderKeywords.value.length
|
||||
if (total <= 1) {
|
||||
@@ -1114,7 +1136,7 @@ const handleSecondaryCategoryClick = async (category: Category): Promise<void> =
|
||||
hasMore.value = true
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await supabaseService.getProductsByCategory(category.id, 1, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallProductsByCategory(category.id, 1, defaultLoadLimit)
|
||||
failedProductImageIds.value = []
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
@@ -1165,9 +1187,9 @@ const healthNews = [
|
||||
]
|
||||
|
||||
// 获取一级分类数据
|
||||
const loadCategories = async (): Promise<void> => {
|
||||
const loadMedicalMallCategories = async (): Promise<void> => {
|
||||
try {
|
||||
const categoriesData = await supabaseService.getParentCategories()
|
||||
const categoriesData = await supabaseService.getMedicalMallParentCategories()
|
||||
parentCategories.value = categoriesData
|
||||
// 兼容其他使用 categories 的地方
|
||||
categories.value = categoriesData
|
||||
@@ -1190,7 +1212,7 @@ const loadCategories = async (): Promise<void> => {
|
||||
async function loadSubCategories(parentId: string): Promise<void> {
|
||||
try {
|
||||
console.log('[loadSubCategories] 开始加载二级分类, parentId:', parentId)
|
||||
const subData = await supabaseService.getSubCategories(parentId)
|
||||
const subData = await supabaseService.getMedicalMallSubCategories(parentId)
|
||||
console.log('[loadSubCategories] 获取到二级分类数量:', subData.length)
|
||||
console.log('[loadSubCategories] 二级分类数据:', JSON.stringify(subData))
|
||||
subCategories.value = subData
|
||||
@@ -1315,6 +1337,15 @@ function getCategoryLabelById(categoryId: string): string {
|
||||
return '精选'
|
||||
}
|
||||
|
||||
function normalizeSelectedMedicalCategoryId(categoryId: string): string {
|
||||
if (categoryId == 'device') return 'med_device'
|
||||
if (categoryId == 'external') return 'home_care_daily'
|
||||
if (categoryId == 'cold') return 'otc_medicine'
|
||||
if (categoryId == 'medicine') return 'otc_medicine'
|
||||
if (categoryId == 'care') return 'home_care_daily'
|
||||
return categoryId
|
||||
}
|
||||
|
||||
async function consumeSelectedCategoryFromStorage(): Promise<boolean> {
|
||||
if (activeTopModule.value != 'home' || categoryList.value.length == 0) {
|
||||
return false
|
||||
@@ -1328,14 +1359,15 @@ async function consumeSelectedCategoryFromStorage(): Promise<boolean> {
|
||||
return false
|
||||
}
|
||||
uni.removeStorageSync('selectedCategory')
|
||||
const matchedItem = categoryList.value.find((item: CategoryItem): boolean => item.id == nextCategoryId)
|
||||
const normalizedCategoryId = normalizeSelectedMedicalCategoryId(nextCategoryId)
|
||||
const matchedItem = categoryList.value.find((item: CategoryItem): boolean => item.id == normalizedCategoryId)
|
||||
if (matchedItem != null) {
|
||||
await refreshHomeCategory(matchedItem)
|
||||
return true
|
||||
}
|
||||
await refreshHomeCategory({
|
||||
id: nextCategoryId,
|
||||
name: getCategoryLabelById(nextCategoryId)
|
||||
id: normalizedCategoryId,
|
||||
name: getCategoryLabelById(normalizedCategoryId)
|
||||
})
|
||||
return true
|
||||
}
|
||||
@@ -1364,17 +1396,17 @@ const fetchSortedProductsPage = async (page: number, limit: number): Promise<Pag
|
||||
console.log('加载热销商品,当前排序方式:', activeSort.value, 'page:', page, 'limit:', limit)
|
||||
switch (activeSort.value) {
|
||||
case 'sales':
|
||||
console.log('调用 getProductsBySales')
|
||||
return await supabaseService.getProductsBySales(page, limit)
|
||||
console.log('调用 getMedicalMallSmartRecommendations(sales-fallback)')
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
case 'price':
|
||||
console.log('调用 getProductsByPrice, 升序:', priceAscending.value)
|
||||
return await supabaseService.getProductsByPrice(page, limit, priceAscending.value)
|
||||
console.log('调用 getMedicalMallSmartRecommendations(price-fallback), 升序:', priceAscending.value)
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
case 'new':
|
||||
console.log('调用 getProductsByNewest')
|
||||
return await supabaseService.getProductsByNewest(page, limit)
|
||||
console.log('调用 getMedicalMallSmartRecommendations(new-fallback)')
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
case 'recommend':
|
||||
console.log('调用 getSmartRecommendations')
|
||||
return await supabaseService.getSmartRecommendations(page, limit)
|
||||
console.log('调用 getMedicalMallSmartRecommendations')
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
case 'discount': {
|
||||
console.log('调用 getDiscountProducts')
|
||||
const products = await supabaseService.getDiscountProducts(limit)
|
||||
@@ -1387,8 +1419,8 @@ const fetchSortedProductsPage = async (page: number, limit: number): Promise<Pag
|
||||
}
|
||||
}
|
||||
default:
|
||||
console.log('调用默认 getProductsBySales')
|
||||
return await supabaseService.getProductsBySales(page, limit)
|
||||
console.log('调用默认 getMedicalMallSmartRecommendations')
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1427,7 +1459,7 @@ async function syncCategoryLayout(categoryId: string): Promise<void> {
|
||||
}
|
||||
|
||||
try {
|
||||
const subData = await supabaseService.getSubCategories(categoryId)
|
||||
const subData = await supabaseService.getMedicalMallSubCategories(categoryId)
|
||||
subCategories.value = subData
|
||||
} catch (error) {
|
||||
console.error('加载子分类数据失败:', error)
|
||||
@@ -1444,33 +1476,7 @@ async function loadCategoryGoods(categoryId: string): Promise<void> {
|
||||
await syncCategoryLayout(categoryId)
|
||||
if (categoryId === 'recommend') {
|
||||
try {
|
||||
let result: PaginatedResponse<Product>
|
||||
switch (activeSort.value) {
|
||||
case 'sales':
|
||||
result = await supabaseService.getProductsBySales(1, defaultLoadLimit)
|
||||
break
|
||||
case 'price':
|
||||
result = await supabaseService.getProductsByPrice(1, defaultLoadLimit, priceAscending.value)
|
||||
break
|
||||
case 'new':
|
||||
result = await supabaseService.getProductsByNewest(1, defaultLoadLimit)
|
||||
break
|
||||
case 'discount': {
|
||||
const products = await supabaseService.getDiscountProducts(defaultLoadLimit)
|
||||
result = {
|
||||
data: products,
|
||||
total: products.length,
|
||||
page: 1,
|
||||
limit: defaultLoadLimit,
|
||||
hasmore: false
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'recommend':
|
||||
default:
|
||||
result = await supabaseService.getSmartRecommendations(1, defaultLoadLimit)
|
||||
break
|
||||
}
|
||||
const result = await supabaseService.getMedicalMallSmartRecommendations(1, defaultLoadLimit)
|
||||
failedProductImageIds.value = []
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
@@ -1483,7 +1489,7 @@ async function loadCategoryGoods(categoryId: string): Promise<void> {
|
||||
} else {
|
||||
try {
|
||||
loading.value = true
|
||||
const result = await supabaseService.getProductsByCategory(categoryId, 1, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallProductsByCategory(categoryId, 1, defaultLoadLimit)
|
||||
failedProductImageIds.value = []
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
@@ -1514,7 +1520,7 @@ async function refreshHomeCategory(item: CategoryItem): Promise<void> {
|
||||
secondaryCategoryDisplay.value = buildSecondaryCategoryDisplay(item.id)
|
||||
applyChannelDisplay(item.id)
|
||||
try {
|
||||
const result = await supabaseService.getSmartRecommendations(1, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallSmartRecommendations(1, defaultLoadLimit)
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
} catch (error) {
|
||||
@@ -1528,7 +1534,7 @@ async function refreshHomeCategory(item: CategoryItem): Promise<void> {
|
||||
}
|
||||
|
||||
try {
|
||||
const subData = await supabaseService.getSubCategories(item.id)
|
||||
const subData = await supabaseService.getMedicalMallSubCategories(item.id)
|
||||
subCategories.value = subData
|
||||
} catch (error) {
|
||||
console.error('加载子分类数据失败:', error)
|
||||
@@ -1537,7 +1543,7 @@ async function refreshHomeCategory(item: CategoryItem): Promise<void> {
|
||||
secondaryCategoryDisplay.value = buildSecondaryCategoryDisplay(item.id)
|
||||
applyChannelDisplay(item.id)
|
||||
try {
|
||||
const result = await supabaseService.getProductsByCategory(item.id, 1, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallProductsByCategory(item.id, 1, defaultLoadLimit)
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
} catch (error) {
|
||||
@@ -1559,7 +1565,8 @@ function selectCategoryFromPanel(item: CategoryItem): void {
|
||||
}
|
||||
|
||||
const loadRecommendedProducts = async (limit: number): Promise<void> => {
|
||||
recommendedProducts.value = await supabaseService.getRecommendedProducts(limit)
|
||||
const result = await supabaseService.getMedicalMallSmartRecommendations(1, limit)
|
||||
recommendedProducts.value = result.data
|
||||
}
|
||||
|
||||
// 加载热搜词
|
||||
@@ -1592,7 +1599,7 @@ const initData = async () => {
|
||||
} catch (error) {
|
||||
console.error('加载用户资料失败:', error)
|
||||
}
|
||||
await loadCategories()
|
||||
await loadMedicalMallCategories()
|
||||
await loadBrands()
|
||||
await loadHotKeywords()
|
||||
await loadServiceHomeData()
|
||||
@@ -1613,7 +1620,7 @@ const familyItems = [
|
||||
desc: '伤口护理',
|
||||
icon: '🩹',
|
||||
color: '#FF5722',
|
||||
categoryId: 'external'
|
||||
categoryId: 'wound_care'
|
||||
},
|
||||
{
|
||||
id: 'family2',
|
||||
@@ -1621,7 +1628,7 @@ const familyItems = [
|
||||
desc: '健康监测',
|
||||
icon: '🌡️',
|
||||
color: '#2196F3',
|
||||
categoryId: 'device'
|
||||
categoryId: 'thermometer'
|
||||
},
|
||||
{
|
||||
id: 'family3',
|
||||
@@ -1629,7 +1636,7 @@ const familyItems = [
|
||||
desc: '环境消毒',
|
||||
icon: '🧪',
|
||||
color: '#ff5000',
|
||||
categoryId: 'external'
|
||||
categoryId: 'disinfectant'
|
||||
},
|
||||
{
|
||||
id: 'family4',
|
||||
@@ -1637,7 +1644,7 @@ const familyItems = [
|
||||
desc: '日常防护',
|
||||
icon: '😷',
|
||||
color: '#607D8B',
|
||||
categoryId: 'device'
|
||||
categoryId: 'mask'
|
||||
},
|
||||
{
|
||||
id: 'family5',
|
||||
@@ -1645,7 +1652,7 @@ const familyItems = [
|
||||
desc: '物理降温',
|
||||
icon: '🧊',
|
||||
color: '#00BCD4',
|
||||
categoryId: 'cold'
|
||||
categoryId: 'cold_fever'
|
||||
},
|
||||
{
|
||||
id: 'family6',
|
||||
@@ -1653,7 +1660,7 @@ const familyItems = [
|
||||
desc: '伤口处理',
|
||||
icon: '🩹',
|
||||
color: '#FF9800',
|
||||
categoryId: 'external'
|
||||
categoryId: 'dressing_tools'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1931,7 +1938,7 @@ const loadMore = async () => {
|
||||
currentPage.value = nextPage
|
||||
}
|
||||
} else {
|
||||
const result = await supabaseService.getProductsByCategory(currentFeedCategoryId.value, nextPage, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallProductsByCategory(currentFeedCategoryId.value, nextPage, defaultLoadLimit)
|
||||
if (result.data.length == 0) {
|
||||
hasMore.value = false
|
||||
} else {
|
||||
|
||||
@@ -1,363 +1,433 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="工作台" fallback-url="/pages/user/login?mode=delivery" :hide-header="true">
|
||||
<view class="delivery-home-page">
|
||||
<view class="delivery-home-hero">
|
||||
<view class="delivery-home-hero-top">
|
||||
<view class="delivery-home-hero-main">
|
||||
<text class="delivery-home-hero-title">服务工作台</text>
|
||||
<text class="delivery-home-hero-subtitle">聚焦今日任务、异常处理和服务进度,帮助你快速进入当前工作状态。</text>
|
||||
<view class="delivery-home-user-tags">
|
||||
<text class="delivery-home-user-tag delivery-home-user-tag-light">{{ onlineStatusText }}</text>
|
||||
<text class="delivery-home-user-tag delivery-home-user-tag-soft">今日完成 {{ dashboard.completedCount }} 单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="delivery-home-hero-actions">
|
||||
<view class="delivery-home-hero-action" @click="loadData()">
|
||||
<text class="delivery-home-hero-action-text">刷新</text>
|
||||
</view>
|
||||
<view class="delivery-home-hero-action" @click="goMessages()">
|
||||
<text class="delivery-home-hero-action-text">消息</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-hero-info-row">
|
||||
<view class="delivery-home-hero-info-item">
|
||||
<text class="delivery-home-hero-info-value">{{ dashboard.pendingAcceptCount }}</text>
|
||||
<text class="delivery-home-hero-info-label">待接单</text>
|
||||
</view>
|
||||
<view class="delivery-home-hero-info-item">
|
||||
<text class="delivery-home-hero-info-value">{{ dashboard.servingCount }}</text>
|
||||
<text class="delivery-home-hero-info-label">服务中</text>
|
||||
</view>
|
||||
<view class="delivery-home-hero-info-item">
|
||||
<text class="delivery-home-hero-info-value">{{ dashboard.exceptionCount }}</text>
|
||||
<text class="delivery-home-hero-info-label">异常待跟进</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-card delivery-home-overview-card">
|
||||
<view class="delivery-home-card-header">
|
||||
<view class="page">
|
||||
<view class="hero">
|
||||
<view class="hero-top">
|
||||
<view>
|
||||
<text class="delivery-home-card-title">今日概览</text>
|
||||
<text class="delivery-home-card-subtitle">聚焦待接单、服务执行和异常处理</text>
|
||||
<text class="hero-title">服务人员工作台</text>
|
||||
<text class="hero-subtitle">聚焦今日接单、上门履约和异常处理</text>
|
||||
</view>
|
||||
<text class="delivery-status-pill" :class="getStatusPillClass()">{{ onlineStatusText }}</text>
|
||||
<view class="hero-refresh" @click="loadData"><text class="hero-refresh-text">刷新</text></view>
|
||||
</view>
|
||||
<view class="delivery-overview-row">
|
||||
<view class="delivery-overview-item">
|
||||
<text class="delivery-overview-num delivery-overview-num-warning">{{ dashboard.pendingAcceptCount }}</text>
|
||||
<text class="delivery-overview-label">待接单</text>
|
||||
</view>
|
||||
<view class="delivery-overview-item">
|
||||
<text class="delivery-overview-num delivery-overview-num-active">{{ dashboard.pendingDepartCount }}</text>
|
||||
<text class="delivery-overview-label">待出发</text>
|
||||
</view>
|
||||
<view class="delivery-overview-item">
|
||||
<text class="delivery-overview-num delivery-overview-num-teal">{{ dashboard.servingCount }}</text>
|
||||
<text class="delivery-overview-label">服务中</text>
|
||||
</view>
|
||||
<view class="delivery-overview-item">
|
||||
<text class="delivery-overview-num delivery-overview-num-success">{{ dashboard.completedCount }}</text>
|
||||
<text class="delivery-overview-label">已完成</text>
|
||||
<view class="profile-card">
|
||||
<view class="avatar"><text class="avatar-text">护</text></view>
|
||||
<view class="profile-main">
|
||||
<text class="profile-name">{{ profileName }}</text>
|
||||
<text class="profile-role">{{ profileRole }}</text>
|
||||
<text class="profile-org">{{ organizationName }}</text>
|
||||
</view>
|
||||
<view class="status-pill"><text class="status-pill-text">{{ onlineText }}</text></view>
|
||||
</view>
|
||||
<view class="delivery-home-inline-alert" @click="goOrders('exception')">
|
||||
<view class="delivery-status-left">
|
||||
<text class="delivery-status-title">异常任务</text>
|
||||
<text class="delivery-status-desc">待优先跟进 {{ dashboard.exceptionCount }} 个异常事项</text>
|
||||
</view>
|
||||
|
||||
<view class="card stats-card">
|
||||
<view class="section-head">
|
||||
<text class="section-title">今日数据</text>
|
||||
<text class="section-desc">面向上门服务场景的实时工作概览</text>
|
||||
</view>
|
||||
<view class="stats-grid">
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ dashboard.pendingAssignmentCount }}</text>
|
||||
<text class="stat-label">待接单</text>
|
||||
</view>
|
||||
<view class="delivery-status-right">
|
||||
<text class="delivery-exception-num">{{ dashboard.exceptionCount }}</text>
|
||||
<text class="delivery-inline-link">立即查看</text>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ dashboard.todayOrderCount }}</text>
|
||||
<text class="stat-label">今日待服务</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ dashboard.servingCount }}</text>
|
||||
<text class="stat-label">服务中</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value money">{{ incomeText }}</text>
|
||||
<text class="stat-label">预计收入</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="dashboard.exceptionCount > 0" class="delivery-home-card delivery-home-alert-card" @click="goOrders('exception')">
|
||||
<view class="delivery-alert-main">
|
||||
<text class="delivery-alert-title">当前有 {{ dashboard.exceptionCount }} 个异常任务待处理</text>
|
||||
<text class="delivery-alert-desc">建议先进入异常工单列表,确认原因、联系对象并更新处理进度。</text>
|
||||
<view class="card quick-card">
|
||||
<view class="section-head">
|
||||
<text class="section-title">快捷入口</text>
|
||||
<text class="section-desc">适配上门场景的大按钮操作</text>
|
||||
</view>
|
||||
<view class="delivery-alert-action">
|
||||
<text class="delivery-alert-action-text">查看异常</text>
|
||||
<view class="quick-grid">
|
||||
<view class="quick-item" @click="openOrders('pending')"><text class="quick-title">待接单</text><text class="quick-desc">优先确认新派单</text></view>
|
||||
<view class="quick-item" @click="openOrders('today')"><text class="quick-title">今日订单</text><text class="quick-desc">查看全部待服务订单</text></view>
|
||||
<view class="quick-item" @click="openServingOrder"><text class="quick-title">服务中</text><text class="quick-desc">继续填写记录</text></view>
|
||||
<view class="quick-item" @click="openOrders('history')"><text class="quick-title">历史订单</text><text class="quick-desc">查看已完成和异常</text></view>
|
||||
<view class="quick-item" @click="openAbnormal"><text class="quick-title">异常上报</text><text class="quick-desc">快速上报现场风险</text></view>
|
||||
<view class="quick-item" @click="openProfile"><text class="quick-title">我的资料</text><text class="quick-desc">查看个人信息与设置</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-card delivery-home-current-card">
|
||||
<view class="delivery-home-card-header">
|
||||
<view>
|
||||
<text class="delivery-home-card-title">当前任务</text>
|
||||
<text class="delivery-home-card-subtitle">首页先看这一单,明确今天的下一步动作</text>
|
||||
</view>
|
||||
<view class="card next-card">
|
||||
<view class="section-head">
|
||||
<text class="section-title">下一单服务提醒</text>
|
||||
<text class="section-desc">优先处理当前最需要行动的一单</text>
|
||||
</view>
|
||||
<view v-if="dashboard.recentOrders.length == 0" class="empty-box"><text class="empty-text">暂无待执行服务</text></view>
|
||||
<view v-else class="current-task-card" :class="getStatusSurfaceClass(dashboard.recentOrders[0].status)" @click="goDetail(dashboard.recentOrders[0].id)">
|
||||
<view class="current-task-top">
|
||||
<view class="current-task-main">
|
||||
<text class="current-task-title">{{ dashboard.recentOrders[0].serviceName }}</text>
|
||||
<text class="current-task-subtitle">{{ dashboard.recentOrders[0].elderNameMasked }} · {{ dashboard.recentOrders[0].appointmentStartTime }}</text>
|
||||
</view>
|
||||
<ServiceStatusTag :text="dashboard.recentOrders[0].statusText" :tone="dashboard.recentOrders[0].statusTone"></ServiceStatusTag>
|
||||
<view v-if="dashboard.nextOrder == null" class="empty-box"><text class="empty-text">暂无待处理订单</text></view>
|
||||
<view v-else class="next-body">
|
||||
<view class="next-row">
|
||||
<text class="next-title">{{ dashboard.nextOrder!.serviceName }}</text>
|
||||
<text class="next-status">{{ nextStatusText }}</text>
|
||||
</view>
|
||||
<view class="current-task-info-card">
|
||||
<view class="current-task-field">
|
||||
<text class="current-task-field-label">服务地址</text>
|
||||
<text class="current-task-field-value">{{ dashboard.recentOrders[0].addressSummary }}</text>
|
||||
</view>
|
||||
<view class="current-task-field current-task-field-last">
|
||||
<text class="current-task-field-label">风险标签</text>
|
||||
<text class="current-task-field-value">{{ formatRiskTags(dashboard.recentOrders[0].riskTags) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="current-task-footer">
|
||||
<view class="current-task-step">
|
||||
<text class="current-task-step-label">下一步</text>
|
||||
<text class="current-task-step-text">{{ getPrimaryActionText(dashboard.recentOrders[0].status) }}</text>
|
||||
</view>
|
||||
<view class="current-task-btn" :class="getPrimaryActionClass(dashboard.recentOrders[0].status)" @click.stop="handlePrimaryAction(dashboard.recentOrders[0])">
|
||||
<text class="current-task-btn-text">{{ getPrimaryActionText(dashboard.recentOrders[0].status) }}</text>
|
||||
</view>
|
||||
<text class="next-meta">预约时间:{{ dashboard.nextOrder!.appointmentTime }}</text>
|
||||
<text class="next-meta">服务地址:{{ dashboard.nextOrder!.address }}</text>
|
||||
<text class="next-meta">下一步:{{ nextStepText }}</text>
|
||||
<view class="next-actions">
|
||||
<view class="outline-btn" @click="goDetail(dashboard.nextOrder!.id)"><text class="outline-btn-text">查看详情</text></view>
|
||||
<view class="primary-btn" @click="handleOrderAction(dashboard.nextOrder!.id)"><text class="primary-btn-text">{{ nextActionText }}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-card delivery-home-tools-card">
|
||||
<view class="delivery-home-card-header">
|
||||
<view>
|
||||
<text class="delivery-home-card-title">常用功能</text>
|
||||
<text class="delivery-home-card-subtitle">保留当前可用入口,缩短日常处理路径</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="shortcut-grid">
|
||||
<view class="shortcut-item" @click="goOrders('pending_accept')">
|
||||
<view class="shortcut-icon shortcut-icon-warning"><text class="shortcut-icon-text">接</text></view>
|
||||
<text class="shortcut-title">待接单</text>
|
||||
<text class="shortcut-desc">优先查看新派单</text>
|
||||
</view>
|
||||
<view class="shortcut-item" @click="goOrders('all')">
|
||||
<view class="shortcut-icon shortcut-icon-primary"><text class="shortcut-icon-text">单</text></view>
|
||||
<text class="shortcut-title">今日任务</text>
|
||||
<text class="shortcut-desc">进入全部工单列表</text>
|
||||
</view>
|
||||
<view class="shortcut-item" @click="goMessages()">
|
||||
<view class="shortcut-icon shortcut-icon-teal"><text class="shortcut-icon-text">讯</text></view>
|
||||
<text class="shortcut-title">消息提醒</text>
|
||||
<text class="shortcut-desc">查看沟通与通知</text>
|
||||
</view>
|
||||
<view class="shortcut-item" @click="goRecords()">
|
||||
<view class="shortcut-icon shortcut-icon-success"><text class="shortcut-icon-text">档</text></view>
|
||||
<text class="shortcut-title">服务记录</text>
|
||||
<text class="shortcut-desc">回顾已完成服务</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-card delivery-home-list-card">
|
||||
<view class="delivery-home-card-header">
|
||||
<view>
|
||||
<text class="delivery-home-card-title">服务工单</text>
|
||||
<text class="delivery-home-card-subtitle">保留最近工单,突出状态、地址和下一步动作</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="dashboard.recentOrders.length == 0" class="empty-box"><text class="empty-text">暂无任务</text></view>
|
||||
<view v-for="item in dashboard.recentOrders" :key="item.id" class="order-card" :class="getStatusSurfaceClass(item.status)" @click="goDetail(item.id)">
|
||||
<view class="card-top">
|
||||
<view class="order-main">
|
||||
<text class="order-title">{{ item.serviceName }} · {{ item.elderNameMasked }}</text>
|
||||
<text class="order-meta">预约时间:{{ item.appointmentStartTime }}</text>
|
||||
</view>
|
||||
<ServiceStatusTag :text="item.statusText" :tone="item.statusTone"></ServiceStatusTag>
|
||||
</view>
|
||||
<view class="order-info-box">
|
||||
<text class="order-meta">服务地址:{{ item.addressSummary }}</text>
|
||||
<text class="order-meta">风险标签:{{ formatRiskTags(item.riskTags) }}</text>
|
||||
</view>
|
||||
<view class="order-footer">
|
||||
<text class="order-next-text">下一步:{{ getPrimaryActionText(item.status) }}</text>
|
||||
<view class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click.stop="handlePrimaryAction(item)">
|
||||
<text class="order-action-btn-text">立即处理</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-safe"></view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import ServiceStatusTag from '@/components/homeService/ServiceStatusTag.uvue'
|
||||
import type { DeliveryDashboardType, DeliveryInfoType, DeliveryOrderType } from '@/types/delivery.uts'
|
||||
import { getDeliveryDashboard, getDeliveryProfile } from '@/services/deliveryService.uts'
|
||||
import { getDeliveryInfo, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import type { DeliveryDashboardType, DeliveryInfoType } from '@/types/delivery.uts'
|
||||
import { acceptServiceOrder, getDeliveryDashboardStats, getDeliveryProfile, markDeparted } from '@/services/deliveryService.uts'
|
||||
import { getNextStepText, getPrimaryActionText } from '@/utils/deliveryCareUi.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
|
||||
const dashboard = ref<DeliveryDashboardType>({
|
||||
const dashboard = ref({
|
||||
pendingAssignmentCount: 0,
|
||||
pendingAcceptCount: 0,
|
||||
todayOrderCount: 0,
|
||||
pendingDepartCount: 0,
|
||||
servingCount: 0,
|
||||
completedCount: 0,
|
||||
exceptionCount: 0,
|
||||
onlineStatus: 'resting',
|
||||
expectedIncome: 0,
|
||||
onlineStatus: 'online',
|
||||
nextOrder: null,
|
||||
recentOrders: [] as Array<any>
|
||||
} as DeliveryDashboardType)
|
||||
const onlineStatusText = ref('休息中')
|
||||
const deliveryInfo = ref<DeliveryInfoType | null>(null)
|
||||
const profile = ref<DeliveryInfoType | null>(null)
|
||||
|
||||
function syncStatusText(status: string) {
|
||||
if (status == 'online') {
|
||||
onlineStatusText.value = '在线接单'
|
||||
return
|
||||
}
|
||||
if (status == 'busy') {
|
||||
onlineStatusText.value = '忙碌中'
|
||||
return
|
||||
}
|
||||
onlineStatusText.value = '休息中'
|
||||
}
|
||||
|
||||
function getStatusPillClass(): string {
|
||||
if (onlineStatusText.value == '在线接单') {
|
||||
return 'delivery-status-online'
|
||||
}
|
||||
if (onlineStatusText.value == '忙碌中') {
|
||||
return 'delivery-status-busy'
|
||||
}
|
||||
return 'delivery-status-resting'
|
||||
}
|
||||
|
||||
function getPrimaryActionText(status: string): string {
|
||||
if (status == 'pending_accept') {
|
||||
return '立即接单'
|
||||
}
|
||||
if (status == 'accepted') {
|
||||
return '准备出发'
|
||||
}
|
||||
if (status == 'on_the_way' || status == 'arrived') {
|
||||
return '去签到'
|
||||
}
|
||||
if (status == 'checked_in' || status == 'serving' || status == 'pending_submit' || status == 'pending_acceptance') {
|
||||
return '继续服务'
|
||||
}
|
||||
if (status == 'exception_pending') {
|
||||
return '处理异常'
|
||||
}
|
||||
if (status == 'completed' || status == 'settled' || status == 'archived') {
|
||||
return '查看结果'
|
||||
}
|
||||
return '查看详情'
|
||||
}
|
||||
|
||||
function getPrimaryActionClass(status: string): string {
|
||||
if (status == 'pending_accept') {
|
||||
return 'action-warning'
|
||||
}
|
||||
if (status == 'accepted' || status == 'on_the_way' || status == 'arrived') {
|
||||
return 'action-primary'
|
||||
}
|
||||
if (status == 'checked_in' || status == 'serving' || status == 'pending_submit' || status == 'pending_acceptance') {
|
||||
return 'action-teal'
|
||||
}
|
||||
if (status == 'exception_pending') {
|
||||
return 'action-danger'
|
||||
}
|
||||
if (status == 'completed' || status == 'settled' || status == 'archived') {
|
||||
return 'action-success'
|
||||
}
|
||||
return 'action-default'
|
||||
}
|
||||
|
||||
function getStatusSurfaceClass(status: string): string {
|
||||
if (status == 'pending_accept') {
|
||||
return 'status-surface-warning'
|
||||
}
|
||||
if (status == 'accepted' || status == 'on_the_way' || status == 'arrived') {
|
||||
return 'status-surface-primary'
|
||||
}
|
||||
if (status == 'checked_in' || status == 'serving' || status == 'pending_submit' || status == 'pending_acceptance') {
|
||||
return 'status-surface-teal'
|
||||
}
|
||||
if (status == 'exception_pending') {
|
||||
return 'status-surface-danger'
|
||||
}
|
||||
if (status == 'completed' || status == 'settled' || status == 'archived') {
|
||||
return 'status-surface-success'
|
||||
}
|
||||
return 'status-surface-default'
|
||||
}
|
||||
|
||||
function formatRiskTags(tags: Array<string>): string {
|
||||
if (tags.length == 0) {
|
||||
return '常规服务'
|
||||
}
|
||||
return tags.join(' / ')
|
||||
}
|
||||
|
||||
function goRoute(id: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + id })
|
||||
}
|
||||
|
||||
function goCheckin(id: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/checkin?id=' + id })
|
||||
}
|
||||
|
||||
function goExecute(id: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/execute?id=' + id })
|
||||
}
|
||||
|
||||
function goException(id: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/exception?id=' + id })
|
||||
}
|
||||
|
||||
function handlePrimaryAction(order: DeliveryOrderType) {
|
||||
if (order.status == 'pending_accept') {
|
||||
goDetail(order.id)
|
||||
return
|
||||
}
|
||||
if (order.status == 'accepted') {
|
||||
goRoute(order.id)
|
||||
return
|
||||
}
|
||||
if (order.status == 'on_the_way' || order.status == 'arrived') {
|
||||
goCheckin(order.id)
|
||||
return
|
||||
}
|
||||
if (order.status == 'checked_in' || order.status == 'serving' || order.status == 'pending_submit' || order.status == 'pending_acceptance') {
|
||||
goExecute(order.id)
|
||||
return
|
||||
}
|
||||
if (order.status == 'exception_pending') {
|
||||
goException(order.id)
|
||||
return
|
||||
}
|
||||
goDetail(order.id)
|
||||
}
|
||||
const profileName = computed((): string => profile.value != null ? profile.value.name : '服务人员')
|
||||
const profileRole = computed((): string => profile.value != null ? '护工 / 上门服务人员' : '服务人员')
|
||||
const organizationName = computed((): string => profile.value != null ? profile.value.organizationName : '机构待绑定')
|
||||
const onlineText = computed((): string => {
|
||||
if (profile.value == null) return '离线'
|
||||
if (profile.value.onlineStatus == 'online') return '在线'
|
||||
if (profile.value.onlineStatus == 'busy') return '忙碌'
|
||||
return '离线'
|
||||
})
|
||||
const incomeText = computed((): string => '¥' + String(dashboard.value.expectedIncome))
|
||||
const nextActionText = computed((): string => dashboard.value.nextOrder == null ? '查看详情' : getPrimaryActionText(dashboard.value.nextOrder!.status))
|
||||
const nextStepText = computed((): string => dashboard.value.nextOrder == null ? '暂无' : getNextStepText(dashboard.value.nextOrder!.status))
|
||||
const nextStatusText = computed((): string => dashboard.value.nextOrder == null ? '' : dashboard.value.nextOrder!.statusText)
|
||||
|
||||
async function loadData() {
|
||||
const startedAt = Date.now()
|
||||
console.log('[deliveryHome] loadData start')
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
console.log('[deliveryHome] auth done', {
|
||||
ok: authResult.ok,
|
||||
message: authResult.message,
|
||||
elapsed: Date.now() - startedAt
|
||||
})
|
||||
if (!authResult.ok) {
|
||||
return
|
||||
}
|
||||
dashboard.value = await getDeliveryDashboard()
|
||||
console.log('[deliveryHome] dashboard loaded, elapsed=' + (Date.now() - startedAt))
|
||||
deliveryInfo.value = await getDeliveryProfile()
|
||||
console.log('[deliveryHome] profile loaded, elapsed=' + (Date.now() - startedAt))
|
||||
const info = deliveryInfo.value != null ? deliveryInfo.value : getDeliveryInfo()
|
||||
if (info != null) {
|
||||
syncStatusText(info.onlineStatus)
|
||||
profile.value = await getDeliveryProfile()
|
||||
dashboard.value = await getDeliveryDashboardStats()
|
||||
}
|
||||
|
||||
function openOrders(tab: string) {
|
||||
uni.setStorageSync('delivery_order_tab', tab)
|
||||
uni.switchTab({ url: '/pages/mall/delivery/orders/index' })
|
||||
}
|
||||
|
||||
function openProfile() {
|
||||
uni.switchTab({ url: '/pages/mall/delivery/profile/index' })
|
||||
}
|
||||
|
||||
function openServingOrder() {
|
||||
if (dashboard.value.nextOrder == null) {
|
||||
openOrders('today')
|
||||
return
|
||||
}
|
||||
goDetail(dashboard.value.nextOrder!.id)
|
||||
}
|
||||
|
||||
function openAbnormal() {
|
||||
if (dashboard.value.nextOrder != null) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/exception?id=' + dashboard.value.nextOrder!.id })
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: '请先进入订单详情页再上报异常', icon: 'none' })
|
||||
}
|
||||
|
||||
function goDetail(orderId: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId })
|
||||
}
|
||||
|
||||
async function handleOrderAction(orderId: string) {
|
||||
const order = dashboard.value.nextOrder
|
||||
if (order == null) {
|
||||
return
|
||||
}
|
||||
if (order.status == 'pending_assignment' || order.status == 'pending_accept') {
|
||||
await acceptServiceOrder(orderId)
|
||||
uni.showToast({ title: '已接单', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (order.status == 'accepted' || order.status == 'waiting_departure') {
|
||||
await markDeparted(orderId)
|
||||
uni.showToast({ title: '已标记出发', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
goDetail(orderId)
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
min-height: 100%;
|
||||
margin-left: -24rpx;
|
||||
margin-right: -24rpx;
|
||||
margin-top: -24rpx;
|
||||
padding: 0 24rpx 36rpx;
|
||||
background-color: #f3f8fb;
|
||||
}
|
||||
|
||||
.hero {
|
||||
padding: 64rpx 28rpx 32rpx;
|
||||
border-bottom-left-radius: 36rpx;
|
||||
border-bottom-right-radius: 36rpx;
|
||||
background: linear-gradient(180deg, #1f7db4 0%, #22a380 100%);
|
||||
}
|
||||
|
||||
.hero-top,
|
||||
.profile-card,
|
||||
.section-head,
|
||||
.stats-grid,
|
||||
.quick-grid,
|
||||
.next-row,
|
||||
.next-actions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.hero-top,
|
||||
.section-head,
|
||||
.next-row,
|
||||
.next-actions {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hero-subtitle,
|
||||
.profile-role,
|
||||
.profile-org,
|
||||
.section-desc,
|
||||
.stat-label,
|
||||
.quick-desc,
|
||||
.next-meta,
|
||||
.empty-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.hero-subtitle,
|
||||
.profile-role,
|
||||
.profile-org {
|
||||
margin-top: 10rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.hero-refresh {
|
||||
padding: 14rpx 22rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.hero-refresh-text,
|
||||
.status-pill-text,
|
||||
.primary-btn-text,
|
||||
.quick-title,
|
||||
.section-title,
|
||||
.profile-name,
|
||||
.next-title,
|
||||
.stat-value {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.hero-refresh-text,
|
||||
.status-pill-text {
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.profile-card,
|
||||
.card,
|
||||
.quick-item,
|
||||
.next-body {
|
||||
background-color: #ffffff;
|
||||
border-radius: 28rpx;
|
||||
}
|
||||
|
||||
.profile-card {
|
||||
align-items: center;
|
||||
margin-top: 28rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
background-color: #d8eff8;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.avatar-text {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: #166e96;
|
||||
}
|
||||
|
||||
.profile-main {
|
||||
flex: 1;
|
||||
padding-left: 20rpx;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.profile-name {
|
||||
font-size: 32rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
padding: 12rpx 18rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #22a380;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-top: 22rpx;
|
||||
padding: 26rpx;
|
||||
box-shadow: 0 10rpx 28rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.section-head {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.section-desc,
|
||||
.stat-label,
|
||||
.quick-desc,
|
||||
.next-meta,
|
||||
.empty-text,
|
||||
.outline-btn-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.stats-grid,
|
||||
.quick-grid {
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.stat-item,
|
||||
.quick-item {
|
||||
width: 48%;
|
||||
margin-top: 14rpx;
|
||||
padding: 22rpx;
|
||||
background-color: #f7fbfd;
|
||||
border-radius: 22rpx;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 38rpx;
|
||||
color: #166e96;
|
||||
}
|
||||
|
||||
.money {
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.quick-title {
|
||||
font-size: 28rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.quick-desc,
|
||||
.next-meta {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.next-body {
|
||||
margin-top: 18rpx;
|
||||
padding: 24rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.next-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
flex: 1;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.next-status {
|
||||
font-size: 24rpx;
|
||||
color: #1f7db4;
|
||||
}
|
||||
|
||||
.next-actions {
|
||||
margin-top: 20rpx;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
width: 48%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.outline-btn {
|
||||
background-color: #eef6fa;
|
||||
}
|
||||
|
||||
.outline-btn-text {
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background-color: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
</style>
|
||||
console.log('[deliveryHome] loadData complete, elapsed=' + (Date.now() - startedAt))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,82 +1,214 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="工单详情" fallback-url="/pages/mall/delivery/orders/index">
|
||||
<ServicePanel title="基础信息" subtitle="接单前脱敏,接单后展示完整信息。">
|
||||
<view v-if="order != null">
|
||||
<text class="row-text">工单号:{{ order.orderNo }}</text>
|
||||
<text class="row-text">服务项目:{{ order.serviceName }}</text>
|
||||
<text class="row-text">服务对象:{{ order.status == 'pending_accept' ? order.elderNameMasked : order.fullElderName }}</text>
|
||||
<text class="row-text">联系电话:{{ order.status == 'pending_accept' ? order.elderPhoneMasked : order.fullPhone }}</text>
|
||||
<text class="row-text">服务地址:{{ order.status == 'pending_accept' ? order.addressSummary : order.fullAddress }}</text>
|
||||
<text class="row-text">预约时间:{{ order.appointmentStartTime }} - {{ order.appointmentEndTime }}</text>
|
||||
<text class="row-text">联系人:{{ order.contactName }} / {{ order.contactPhone }}</text>
|
||||
<text class="row-text">注意事项:{{ order.notices.join(';') }}</text>
|
||||
<ServicePageScaffold title="订单详情" fallback-url="/pages/mall/delivery/orders/index">
|
||||
<view v-if="order != null" class="page">
|
||||
<view class="status-card">
|
||||
<view class="status-head">
|
||||
<view>
|
||||
<text class="status-title">当前状态</text>
|
||||
<text class="status-subtitle">{{ order.statusText }}</text>
|
||||
</view>
|
||||
<text class="status-tag">{{ nextStepText }}</text>
|
||||
</view>
|
||||
<view class="timeline-box">
|
||||
<view v-for="item in order.timeline" :key="item.id" class="timeline-item">
|
||||
<text class="timeline-title">{{ item.title }}</text>
|
||||
<text class="timeline-meta">{{ item.time }}</text>
|
||||
<text class="timeline-desc">{{ item.description }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePanel>
|
||||
|
||||
<ServicePanel title="服务项目" subtitle="未完成项需在执行页填写原因。">
|
||||
<view v-if="order != null" v-for="item in order.serviceItems" :key="item.id" class="item-row">
|
||||
<text class="row-text">{{ item.name }}</text>
|
||||
<view class="card">
|
||||
<text class="section-title">服务信息</text>
|
||||
<text class="row-text">服务名称:{{ order.serviceName }}</text>
|
||||
<text class="row-text">服务类型:{{ order.serviceType }}</text>
|
||||
<text class="row-text">预约时间:{{ order.appointmentTime }}</text>
|
||||
<text class="row-text">预计时长:{{ order.duration }} 分钟</text>
|
||||
<text class="row-text">服务价格:¥{{ order.price }}</text>
|
||||
<text class="row-text">预计收入:¥{{ order.staffIncome }}</text>
|
||||
</view>
|
||||
</ServicePanel>
|
||||
|
||||
<ServicePanel title="状态时间轴" subtitle="所有关键动作都需要留痕。">
|
||||
<ServiceTimeline :items="timelineItems"></ServiceTimeline>
|
||||
</ServicePanel>
|
||||
<view class="card">
|
||||
<text class="section-title">服务对象</text>
|
||||
<text class="row-text">姓名:{{ order.elderName }}</text>
|
||||
<text class="row-text">性别:{{ order.elderGender }}</text>
|
||||
<text class="row-text">年龄:{{ order.elderAge }}</text>
|
||||
<text class="row-text">电话:{{ order.elderPhone }}</text>
|
||||
<text class="row-text">健康标签:{{ joinTags(order.healthTags) }}</text>
|
||||
</view>
|
||||
|
||||
<view class="bottom-space"></view>
|
||||
<view v-if="order != null" class="fixed-bar">
|
||||
<view class="bar-btn secondary-btn" @click="goException"><text class="bar-text secondary-text">异常上报</text></view>
|
||||
<view v-if="order.status == 'pending_accept'" class="bar-btn primary-btn" @click="acceptOrder"><text class="bar-text">接单</text></view>
|
||||
<view v-else-if="order.status == 'accepted' || order.status == 'on_the_way' || order.status == 'arrived'" class="bar-btn primary-btn" @click="goRoute"><text class="bar-text">出发/签到</text></view>
|
||||
<view v-else class="bar-btn primary-btn" @click="goExecute"><text class="bar-text">进入执行</text></view>
|
||||
<view class="card">
|
||||
<text class="section-title">联系人信息</text>
|
||||
<text class="row-text">联系人:{{ order.contactName }}</text>
|
||||
<text class="row-text">联系电话:{{ order.contactPhone }}</text>
|
||||
<text class="row-text">关系:{{ order.contactRelation }}</text>
|
||||
<view class="inline-actions">
|
||||
<view class="outline-btn" @click="makePhoneCall(order.contactPhone)"><text class="outline-btn-text">拨打联系人</text></view>
|
||||
<view class="outline-btn" @click="makePhoneCall(order.elderPhone)"><text class="outline-btn-text">拨打服务对象</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">地址信息</text>
|
||||
<text class="row-text">完整地址:{{ order.address }}</text>
|
||||
<text class="row-text">门牌号:{{ order.addressDetail }}</text>
|
||||
<text class="row-text">距离:{{ order.distance }}</text>
|
||||
<view class="inline-actions">
|
||||
<view class="outline-btn" @click="mockNavigate"><text class="outline-btn-text">导航按钮</text></view>
|
||||
<view class="outline-btn" @click="makePhoneCall(order.contactPhone)"><text class="outline-btn-text">拨打电话</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">用户备注</text>
|
||||
<text class="row-text">特殊需求:{{ order.remark }}</text>
|
||||
<text class="row-text">需家属在场:{{ order.needFamilyPresent ? '是' : '否' }}</text>
|
||||
<text class="row-text">需携带耗材:{{ order.needMaterials ? '是' : '否' }}</text>
|
||||
<text class="row-text">风险标签:{{ joinTags(order.riskTags) }}</text>
|
||||
</view>
|
||||
|
||||
<view v-if="order.abnormalReport != null" class="card">
|
||||
<text class="section-title">异常记录</text>
|
||||
<text class="row-text">异常类型:{{ order.abnormalReport!.type }}</text>
|
||||
<text class="row-text">异常说明:{{ order.abnormalReport!.description }}</text>
|
||||
<text class="row-text">发生时间:{{ order.abnormalReport!.occurredAt }}</text>
|
||||
</view>
|
||||
|
||||
<view class="action-card">
|
||||
<view class="action-row">
|
||||
<view class="outline-btn" @click="goException"><text class="outline-btn-text">异常上报</text></view>
|
||||
<view v-if="showRejectButton" class="warn-btn" @click="rejectOrder"><text class="warn-btn-text">拒单</text></view>
|
||||
<view class="primary-btn" @click="handlePrimary"><text class="primary-btn-text">{{ primaryText }}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import ServicePanel from '@/components/homeService/ServicePanel.uvue'
|
||||
import ServiceTimeline from '@/components/homeService/ServiceTimeline.uvue'
|
||||
import { acceptDeliveryOrder, getDeliveryOrderDetail } from '@/services/deliveryService.uts'
|
||||
import type { DeliveryOrderType } from '@/types/delivery.uts'
|
||||
import {
|
||||
acceptServiceOrder,
|
||||
checkInServiceOrder,
|
||||
completeServiceOrder,
|
||||
getServiceOrderDetail,
|
||||
markArrived,
|
||||
markDeparted,
|
||||
rejectServiceOrder,
|
||||
startServiceOrder
|
||||
} from '@/services/deliveryService.uts'
|
||||
import { getNextStepText, getPrimaryActionText, needsServiceRecord } from '@/utils/deliveryCareUi.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
|
||||
|
||||
const orderId = ref('')
|
||||
const order = ref<DeliveryOrderType | null>(null)
|
||||
const timelineItems = ref([] as Array<any>)
|
||||
|
||||
const primaryText = computed((): string => order.value == null ? '查看详情' : getPrimaryActionText(order.value!.status))
|
||||
const nextStepText = computed((): string => order.value == null ? '' : getNextStepText(order.value!.status))
|
||||
const showRejectButton = computed((): boolean => order.value != null && (order.value!.status == 'pending_assignment' || order.value!.status == 'pending_accept'))
|
||||
|
||||
async function loadData() {
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!authResult.ok || orderId.value == '') {
|
||||
return
|
||||
}
|
||||
order.value = await getDeliveryOrderDetail(orderId.value)
|
||||
if (order.value != null) {
|
||||
timelineItems.value = order.value.timeline
|
||||
}
|
||||
order.value = await getServiceOrderDetail(orderId.value)
|
||||
}
|
||||
|
||||
async function acceptOrder() {
|
||||
await acceptDeliveryOrder(orderId.value)
|
||||
uni.showToast({ title: '接单成功', icon: 'success' })
|
||||
loadData()
|
||||
function joinTags(tags: Array<string>): string {
|
||||
if (tags.length == 0) return '无'
|
||||
return tags.join(' / ')
|
||||
}
|
||||
|
||||
function goRoute() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId.value })
|
||||
function makePhoneCall(phone: string) {
|
||||
uni.makePhoneCall({ phoneNumber: phone })
|
||||
}
|
||||
|
||||
function goExecute() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/execute?id=' + orderId.value })
|
||||
function mockNavigate() {
|
||||
uni.showToast({ title: '导航为 mock 占位', icon: 'none' })
|
||||
}
|
||||
|
||||
function goException() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/exception?id=' + orderId.value })
|
||||
}
|
||||
|
||||
function goRecord() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/service-record/index?id=' + orderId.value })
|
||||
}
|
||||
|
||||
async function rejectOrder() {
|
||||
uni.showActionSheet({
|
||||
itemList: ['时间冲突', '距离过远', '技能不匹配', '其他原因'],
|
||||
success: async (result) => {
|
||||
const reasons = ['时间冲突', '距离过远', '技能不匹配', '其他原因']
|
||||
await rejectServiceOrder(orderId.value, reasons[result.tapIndex])
|
||||
uni.showToast({ title: '已拒单', icon: 'success' })
|
||||
loadData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function handlePrimary() {
|
||||
if (order.value == null) {
|
||||
return
|
||||
}
|
||||
const status = order.value.status
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') {
|
||||
await acceptServiceOrder(orderId.value)
|
||||
uni.showToast({ title: '已接单', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'accepted' || status == 'waiting_departure') {
|
||||
await markDeparted(orderId.value)
|
||||
uni.showToast({ title: '已出发', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'departed' || status == 'on_the_way') {
|
||||
await markArrived(orderId.value)
|
||||
uni.showToast({ title: '已到达', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'arrived') {
|
||||
await checkInServiceOrder(orderId.value, '详情页签到', null)
|
||||
uni.showToast({ title: '签到成功', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'checked_in') {
|
||||
await startServiceOrder(orderId.value)
|
||||
uni.showToast({ title: '开始服务', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'in_service' || status == 'serving' || status == 'completed') {
|
||||
goRecord()
|
||||
return
|
||||
}
|
||||
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') {
|
||||
if (needsServiceRecord(order.value)) {
|
||||
uni.showToast({ title: '请先填写服务记录', icon: 'none' })
|
||||
goRecord()
|
||||
return
|
||||
}
|
||||
await completeServiceOrder(orderId.value)
|
||||
uni.showToast({ title: '服务已完成', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'abnormal' || status == 'exception_pending') {
|
||||
goException()
|
||||
return
|
||||
}
|
||||
goRecord()
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
if (options != null) {
|
||||
orderId.value = getDeliveryRouteParam(options as UTSJSONObject, 'id')
|
||||
@@ -86,59 +218,123 @@ onLoad((options) => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.row-text {
|
||||
display: block;
|
||||
margin-bottom: 14rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 38rpx;
|
||||
.page {
|
||||
padding-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.status-card,
|
||||
.card,
|
||||
.action-card {
|
||||
margin-bottom: 18rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 24rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.status-head,
|
||||
.inline-actions,
|
||||
.action-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-title,
|
||||
.section-title,
|
||||
.timeline-title,
|
||||
.primary-btn-text {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.status-title,
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.item-row {
|
||||
padding: 16rpx 0;
|
||||
border-bottom: 1rpx solid #e6edf1;
|
||||
.status-subtitle,
|
||||
.status-tag,
|
||||
.row-text,
|
||||
.timeline-meta,
|
||||
.timeline-desc,
|
||||
.outline-btn-text,
|
||||
.warn-btn-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 140rpx;
|
||||
.status-subtitle,
|
||||
.timeline-meta,
|
||||
.timeline-desc,
|
||||
.outline-btn-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.fixed-bar {
|
||||
position: fixed;
|
||||
left: 24rpx;
|
||||
right: 24rpx;
|
||||
bottom: 24rpx;
|
||||
padding: 16rpx;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
background: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
box-shadow: 0 12rpx 24rpx rgba(15, 118, 110, 0.08);
|
||||
.status-tag {
|
||||
padding: 10rpx 18rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #e6f3fa;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.bar-btn {
|
||||
width: 48%;
|
||||
padding: 20rpx 0;
|
||||
.timeline-box {
|
||||
margin-top: 18rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.timeline-item {
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.timeline-title {
|
||||
font-size: 26rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.row-text {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.inline-actions,
|
||||
.action-row {
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.warn-btn,
|
||||
.primary-btn {
|
||||
width: 31%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background: #0f766e;
|
||||
.outline-btn {
|
||||
background-color: #eef6fa;
|
||||
}
|
||||
|
||||
.secondary-btn {
|
||||
background: #eaf2f0;
|
||||
.warn-btn {
|
||||
background-color: #fff3e6;
|
||||
}
|
||||
|
||||
.bar-text {
|
||||
font-size: 28rpx;
|
||||
.warn-btn-text {
|
||||
color: #c77413;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background-color: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.secondary-text {
|
||||
color: #0f766e;
|
||||
}
|
||||
</style>
|
||||
@@ -1,84 +1,104 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="异常上报" fallback-url="/pages/mall/delivery/orders/detail">
|
||||
<ServicePanel title="异常类型" subtitle="高风险异常需立即提醒联系家属、调度或 120。">
|
||||
<view class="type-grid">
|
||||
<view v-for="item in exceptionTypes" :key="item.value" class="type-item" :class="currentType == item.value ? 'type-active' : ''" @click="currentType = item.value">
|
||||
<text class="type-text">{{ item.label }}</text>
|
||||
<view class="page">
|
||||
<view class="card">
|
||||
<text class="section-title">异常类型</text>
|
||||
<view class="type-grid">
|
||||
<view v-for="item in exceptionTypes" :key="item.value" class="type-item" :class="currentType == item.value ? 'type-active' : ''" @click="currentType = item.value">
|
||||
<text class="type-text">{{ item.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePanel>
|
||||
<ServicePanel title="异常说明" subtitle="说明必填,支持上传图片凭证。">
|
||||
<textarea class="textarea" v-model="description" placeholder="请填写异常发生情况、现场处置动作和需要协同的事项"></textarea>
|
||||
<button class="secondary-btn" @click="chooseImage">上传异常图片</button>
|
||||
<text class="info-text">已选择图片:{{ images.length }} 张</text>
|
||||
<text v-if="isHighRisk" class="risk-text">高风险异常:请同步联系家属/调度/120,并保留处置留痕。</text>
|
||||
</ServicePanel>
|
||||
<button class="primary-btn" :disabled="submitting" @click="submitForm">{{ submitting ? '提交中...' : '提交异常' }}</button>
|
||||
<view class="card">
|
||||
<text class="section-title">异常说明</text>
|
||||
<textarea class="textarea" v-model="description" placeholder="请填写异常说明"></textarea>
|
||||
<input class="field" v-model="occurredAt" placeholder="发生时间,例如 2026-05-20 15:36" />
|
||||
<input class="field" v-model="locationText" placeholder="当前位置 mock" />
|
||||
<view class="switch-row"><text class="switch-label">需要平台介入</text><switch :checked="needPlatformIntervention" color="#1f7db4" @change="changePlatformIntervention" /></view>
|
||||
<view class="switch-row"><text class="switch-label">申请取消订单</text><switch :checked="requestCancelOrder" color="#1f7db4" @change="changeCancelOrder" /></view>
|
||||
<view class="switch-row"><text class="switch-label">申请改期</text><switch :checked="requestReschedule" color="#1f7db4" @change="changeReschedule" /></view>
|
||||
<view class="mock-upload" @click="addMockImage"><text class="mock-upload-text">图片上传占位</text></view>
|
||||
<text class="info-text">已添加图片占位:{{ imageCount }} 张</text>
|
||||
</view>
|
||||
<view class="action-row">
|
||||
<view class="outline-btn" @click="goBack"><text class="outline-btn-text">返回详情</text></view>
|
||||
<view class="primary-btn" @click="submitForm"><text class="primary-btn-text">提交异常</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import ServicePanel from '@/components/homeService/ServicePanel.uvue'
|
||||
import { submitException } from '@/services/deliveryService.uts'
|
||||
import { submitAbnormalReport } from '@/services/deliveryService.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
|
||||
|
||||
const orderId = ref('')
|
||||
const currentType = ref('cannot_contact_elder')
|
||||
const currentType = ref('cannot_contact_user')
|
||||
const description = ref('')
|
||||
const images = ref([] as Array<string>)
|
||||
const submitting = ref(false)
|
||||
const occurredAt = ref(new Date().toISOString().replace('T', ' ').substring(0, 19))
|
||||
const locationText = ref('当前位置 mock')
|
||||
const needPlatformIntervention = ref(false)
|
||||
const requestCancelOrder = ref(false)
|
||||
const requestReschedule = ref(false)
|
||||
const imageCount = ref(0)
|
||||
const exceptionTypes = [
|
||||
{ label: '无法联系老人', value: 'cannot_contact_elder' },
|
||||
{ label: '无法入户', value: 'cannot_enter_home' },
|
||||
{ label: '联系不上用户', value: 'cannot_contact_user' },
|
||||
{ label: '用户不在家', value: 'user_not_home' },
|
||||
{ label: '地址错误', value: 'wrong_address' },
|
||||
{ label: '老人拒绝服务', value: 'elder_refuse_service' },
|
||||
{ label: '家属要求改期', value: 'family_requests_reschedule' },
|
||||
{ label: '现场存在安全风险', value: 'safety_risk' },
|
||||
{ label: '老人身体异常', value: 'elder_health_abnormal' },
|
||||
{ label: '家属不配合', value: 'family_uncooperative' },
|
||||
{ label: '服务对象身体异常', value: 'elder_health_abnormal' },
|
||||
{ label: '环境不适合服务', value: 'safety_risk' },
|
||||
{ label: '超出服务范围', value: 'outside_service_scope' },
|
||||
{ label: '服务人员无法继续服务', value: 'staff_cannot_continue' },
|
||||
{ label: '突发疾病', value: 'emergency_illness' },
|
||||
{ label: '服务项目无法完成', value: 'item_unavailable' },
|
||||
{ label: '投诉纠纷', value: 'complaint_dispute' },
|
||||
{ label: '其他', value: 'other' }
|
||||
]
|
||||
const isHighRisk = computed(() => currentType.value == 'safety_risk' || currentType.value == 'elder_health_abnormal' || currentType.value == 'emergency_illness')
|
||||
|
||||
function wrapChooseImage(): Promise<Array<string>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.chooseImage({
|
||||
count: 3,
|
||||
sourceType: ['camera', 'album'],
|
||||
success: (res) => { resolve(res.tempFilePaths) },
|
||||
fail: () => { reject(new Error('选择图片失败')) }
|
||||
})
|
||||
})
|
||||
function changePlatformIntervention(event: any) {
|
||||
needPlatformIntervention.value = event.detail.value === true
|
||||
}
|
||||
|
||||
async function chooseImage() {
|
||||
try {
|
||||
images.value = await wrapChooseImage()
|
||||
} catch (error) {
|
||||
uni.showToast({ title: '图片选择失败', icon: 'none' })
|
||||
}
|
||||
function changeCancelOrder(event: any) {
|
||||
requestCancelOrder.value = event.detail.value === true
|
||||
}
|
||||
|
||||
function changeReschedule(event: any) {
|
||||
requestReschedule.value = event.detail.value === true
|
||||
}
|
||||
|
||||
function addMockImage() {
|
||||
imageCount.value = imageCount.value + 1
|
||||
uni.showToast({ title: '已添加图片占位', icon: 'success' })
|
||||
}
|
||||
|
||||
async function submitForm() {
|
||||
if (submitting.value) return
|
||||
if (description.value.trim() == '') {
|
||||
uni.showToast({ title: '异常说明不能为空', icon: 'none' })
|
||||
uni.showToast({ title: '请填写异常说明', icon: 'none' })
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
try {
|
||||
await submitException(orderId.value, { exceptionType: currentType.value as any, description: description.value.trim(), images: images.value })
|
||||
uni.showToast({ title: '异常已上报', icon: 'success' })
|
||||
uni.setStorageSync('delivery_orders_tab', 'exception')
|
||||
uni.switchTab({ url: '/pages/mall/delivery/orders/index' })
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
await submitAbnormalReport(orderId.value, {
|
||||
exceptionType: currentType.value as any,
|
||||
description: description.value,
|
||||
images: imageCount.value > 0 ? ['mock-abnormal-image-' + String(imageCount.value)] : [] as Array<string>,
|
||||
occurredAt: occurredAt.value,
|
||||
locationText: locationText.value,
|
||||
needPlatformIntervention: needPlatformIntervention.value,
|
||||
requestCancelOrder: requestCancelOrder.value,
|
||||
requestReschedule: requestReschedule.value
|
||||
})
|
||||
uni.showToast({ title: '异常已提交', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
|
||||
}, 300)
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
|
||||
}
|
||||
|
||||
onLoad(async (options) => {
|
||||
@@ -93,6 +113,51 @@ onLoad(async (options) => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
padding-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-bottom: 18rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 24rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.section-title,
|
||||
.primary-btn-text,
|
||||
.type-text {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.field,
|
||||
.textarea {
|
||||
margin-top: 16rpx;
|
||||
padding: 0 20rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f4f8fb;
|
||||
font-size: 26rpx;
|
||||
color: #16324f;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.field {
|
||||
height: 84rpx;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
min-height: 180rpx;
|
||||
padding-top: 20rpx;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.type-grid {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
@@ -102,13 +167,13 @@ onLoad(async (options) => {
|
||||
.type-item {
|
||||
width: 48%;
|
||||
padding: 18rpx 16rpx;
|
||||
margin-bottom: 16rpx;
|
||||
margin-top: 16rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #eef2f6;
|
||||
}
|
||||
|
||||
.type-active {
|
||||
background: #0f766e;
|
||||
background: #1f7db4;
|
||||
}
|
||||
|
||||
.type-text {
|
||||
@@ -121,47 +186,54 @@ onLoad(async (options) => {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
min-height: 220rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #f2f7f6;
|
||||
font-size: 28rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.secondary-btn,
|
||||
.primary-btn {
|
||||
margin-top: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.secondary-btn {
|
||||
background: #eaf2f0;
|
||||
color: #0f766e;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background: #0f766e;
|
||||
color: #ffffff;
|
||||
.switch-row,
|
||||
.action-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.switch-label,
|
||||
.info-text,
|
||||
.risk-text {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
.outline-btn-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.risk-text {
|
||||
color: #b45309;
|
||||
font-weight: 700;
|
||||
.mock-upload,
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
margin-top: 18rpx;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.mock-upload,
|
||||
.outline-btn {
|
||||
background: #eaf2f0;
|
||||
}
|
||||
|
||||
.mock-upload-text,
|
||||
.outline-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
@@ -1,164 +1,371 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="工单列表" fallback-url="/pages/mall/delivery/home/index" :hide-header="true">
|
||||
<view class="delivery-orders-page">
|
||||
<view class="delivery-orders-hero">
|
||||
<view class="delivery-orders-hero-top">
|
||||
<view class="delivery-orders-hero-main">
|
||||
<text class="delivery-orders-hero-title">服务工单</text>
|
||||
<text class="delivery-orders-hero-subtitle">{{ getCurrentTabLabel() }} · {{ getCurrentTabSubtitle() }}</text>
|
||||
</view>
|
||||
<view class="delivery-orders-hero-badge">
|
||||
<text class="delivery-orders-hero-badge-text">{{ orders.length }} 单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="delivery-orders-hero-tip-box">
|
||||
<text class="delivery-orders-hero-tip">接单前仅显示脱敏信息,接单后查看详情可见完整信息。</text>
|
||||
<ServicePageScaffold title="订单" fallback-url="/pages/mall/delivery/home/index" :hide-header="true">
|
||||
<view class="page">
|
||||
<view class="hero">
|
||||
<text class="hero-title">服务订单</text>
|
||||
<text class="hero-subtitle">待接单、今日订单、历史订单统一查看</text>
|
||||
</view>
|
||||
<view class="tab-row">
|
||||
<view v-for="item in tabs" :key="item.value" class="tab-item" :class="currentTab == item.value ? 'tab-item-active' : ''" @click="switchTab(item.value)">
|
||||
<text class="tab-text" :class="currentTab == item.value ? 'tab-text-active' : ''">{{ item.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-orders-card delivery-orders-filter-card">
|
||||
<view class="delivery-orders-card-header">
|
||||
<view>
|
||||
<text class="delivery-orders-card-title">状态筛选</text>
|
||||
<text class="delivery-orders-card-subtitle">横向切换工单状态,列表会同步刷新对应内容</text>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view
|
||||
class="status-scroll"
|
||||
direction="horizontal"
|
||||
:show-scrollbar="false"
|
||||
:scroll-into-view="activeTabViewId"
|
||||
scroll-with-animation="true"
|
||||
>
|
||||
<view class="status-tabs-row">
|
||||
<view
|
||||
v-for="item in tabs"
|
||||
:key="item.value"
|
||||
:id="'status-tab-' + item.value"
|
||||
class="status-tab-item"
|
||||
:class="currentTab == item.value ? 'status-tab-active' : ''"
|
||||
@click="switchTab(item.value)"
|
||||
>
|
||||
<text class="status-tab-text" :class="currentTab == item.value ? 'status-tab-text-active' : ''">{{ item.label }}</text>
|
||||
<view class="list-card">
|
||||
<view v-if="orders.length == 0" class="empty-box"><text class="empty-text">{{ emptyText }}</text></view>
|
||||
<view v-for="item in orders" :key="item.id" class="order-card">
|
||||
<view class="order-top" @click="goDetail(item.id)">
|
||||
<view class="order-main">
|
||||
<text class="order-title">{{ item.serviceName }}</text>
|
||||
<text class="order-subtitle">{{ item.elderName }} · {{ item.appointmentTime }}</text>
|
||||
</view>
|
||||
<text class="order-status">{{ item.statusText }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-orders-card delivery-orders-list-card">
|
||||
<view class="delivery-orders-card-header">
|
||||
<view>
|
||||
<text class="delivery-orders-card-title">工单列表</text>
|
||||
<text class="delivery-orders-card-subtitle">突出状态、地址、风险与下一步处理动作</text>
|
||||
<view class="meta-box" @click="goDetail(item.id)">
|
||||
<text class="meta-text">地址:{{ item.address }} {{ item.addressDetail }}</text>
|
||||
<text class="meta-text">时长:{{ item.duration }} 分钟 · 预计收入:¥{{ item.staffIncome }}</text>
|
||||
<text class="meta-text">风险:{{ formatTags(item.riskTags) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="orders.length == 0" class="empty-box"><text class="empty-text">{{ getEmptyText() }}</text></view>
|
||||
<view v-for="item in orders" :key="item.id" class="order-card" :class="getStatusSurfaceClass(item.status)">
|
||||
<view class="card-top">
|
||||
<view class="order-main" @click="goDetail(item.id)">
|
||||
<text class="order-title">{{ item.serviceType }} · {{ item.serviceName }}</text>
|
||||
<text class="order-meta">服务对象:{{ item.elderNameMasked }}</text>
|
||||
</view>
|
||||
<ServiceStatusTag :text="item.statusText" :tone="item.statusTone"></ServiceStatusTag>
|
||||
</view>
|
||||
<view class="order-info-box" @click="goDetail(item.id)">
|
||||
<text class="order-meta">预约时间:{{ item.appointmentStartTime }}</text>
|
||||
<text class="order-meta">服务地址:{{ item.addressSummary }}</text>
|
||||
<text class="order-meta">距离:{{ item.distanceKm }} · 风险:{{ formatRiskTags(item.riskTags) }}</text>
|
||||
</view>
|
||||
<view class="order-footer">
|
||||
<text class="order-next-text">下一步:{{ getPrimaryActionText(item.status) }}</text>
|
||||
<view class="order-action-btn order-action-btn-secondary" @click="goDetail(item.id)">
|
||||
<text class="order-action-btn-text order-action-btn-text-secondary">查看详情</text>
|
||||
</view>
|
||||
<view v-if="item.status == 'pending_accept'" class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click="acceptOrder(item.id)"><text class="order-action-btn-text">接单</text></view>
|
||||
<view v-else-if="item.status == 'accepted'" class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click="goRoute(item.id)"><text class="order-action-btn-text">去出发</text></view>
|
||||
<view v-else-if="item.status == 'on_the_way' || item.status == 'arrived'" class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click="goCheckin(item.id)"><text class="order-action-btn-text">去签到</text></view>
|
||||
<view v-else-if="item.status == 'checked_in' || item.status == 'serving' || item.status == 'pending_submit' || item.status == 'pending_acceptance'" class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click="goExecute(item.id)"><text class="order-action-btn-text">继续服务</text></view>
|
||||
<view class="action-row">
|
||||
<view class="outline-btn" @click="goDetail(item.id)"><text class="outline-btn-text">查看详情</text></view>
|
||||
<view v-if="showReject(item.status)" class="warn-btn" @click="rejectOrder(item.id)"><text class="warn-btn-text">拒单</text></view>
|
||||
<view class="primary-btn" @click="handleAction(item.id, item.status)"><text class="primary-btn-text">{{ getActionText(item.status) }}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-orders-safe"></view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import ServiceStatusTag from '@/components/homeService/ServiceStatusTag.uvue'
|
||||
import { acceptDeliveryOrder, getDeliveryOrders } from '@/services/deliveryService.uts'
|
||||
import type { DeliveryOrderType } from '@/types/delivery.uts'
|
||||
import type { DeliveryOrderStatus, DeliveryOrderType } from '@/types/delivery.uts'
|
||||
import {
|
||||
acceptServiceOrder,
|
||||
checkInServiceOrder,
|
||||
completeServiceOrder,
|
||||
getHistoryServiceOrders,
|
||||
getPendingServiceOrders,
|
||||
getTodayServiceOrders,
|
||||
markArrived,
|
||||
markDeparted,
|
||||
rejectServiceOrder,
|
||||
startServiceOrder
|
||||
} from '@/services/deliveryService.uts'
|
||||
import { getDeliveryOrderTabs, getPrimaryActionText } from '@/utils/deliveryCareUi.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
|
||||
|
||||
const tabs = [
|
||||
{ label: '全部', value: 'all' },
|
||||
{ label: '待接单', value: 'pending_accept' },
|
||||
{ label: '待出发', value: 'accepted' },
|
||||
{ label: '服务中', value: 'serving' },
|
||||
{ label: '待提交', value: 'pending_submit' },
|
||||
{ label: '已完成', value: 'completed' },
|
||||
{ label: '异常', value: 'exception' }
|
||||
]
|
||||
const tabs = getDeliveryOrderTabs()
|
||||
const currentTab = ref('pending')
|
||||
const orders = ref([] as Array<DeliveryOrderType>)
|
||||
|
||||
const currentTab = ref('all')
|
||||
const activeTabViewId = ref('status-tab-all')
|
||||
const orders = ref<Array<DeliveryOrderType>>([])
|
||||
const emptyText = computed((): string => {
|
||||
if (currentTab.value == 'pending') return '暂无待接单订单'
|
||||
if (currentTab.value == 'today') return '暂无今日订单'
|
||||
return '暂无历史订单'
|
||||
})
|
||||
|
||||
function getCurrentTabLabel(): string {
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
if (tabs[i].value == currentTab.value) {
|
||||
return tabs[i].label
|
||||
async function loadData() {
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!authResult.ok) {
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'pending') {
|
||||
orders.value = await getPendingServiceOrders()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'history') {
|
||||
orders.value = await getHistoryServiceOrders()
|
||||
return
|
||||
}
|
||||
orders.value = await getTodayServiceOrders()
|
||||
}
|
||||
|
||||
function consumeStoredTab(): void {
|
||||
const storedTab = uni.getStorageSync('delivery_order_tab') as string | null
|
||||
if (storedTab != null && storedTab != '') {
|
||||
currentTab.value = storedTab
|
||||
uni.removeStorageSync('delivery_order_tab')
|
||||
}
|
||||
}
|
||||
|
||||
function switchTab(tab: string) {
|
||||
currentTab.value = tab
|
||||
loadData()
|
||||
}
|
||||
|
||||
function formatTags(tags: Array<string>): string {
|
||||
if (tags.length == 0) return '常规'
|
||||
return tags.join(' / ')
|
||||
}
|
||||
|
||||
function showReject(status: DeliveryOrderStatus): boolean {
|
||||
return status == 'pending_assignment' || status == 'pending_accept'
|
||||
}
|
||||
|
||||
function getActionText(status: DeliveryOrderStatus): string {
|
||||
return getPrimaryActionText(status)
|
||||
}
|
||||
|
||||
function goDetail(orderId: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId })
|
||||
}
|
||||
|
||||
function goRecord(orderId: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/service-record/index?id=' + orderId })
|
||||
}
|
||||
|
||||
function rejectOrder(orderId: string) {
|
||||
uni.showActionSheet({
|
||||
itemList: ['时间冲突', '距离过远', '技能不匹配', '其他原因'],
|
||||
success: async (result) => {
|
||||
const reasons = ['时间冲突', '距离过远', '技能不匹配', '其他原因']
|
||||
const reason = reasons[result.tapIndex]
|
||||
await rejectServiceOrder(orderId, reason)
|
||||
uni.showToast({ title: '已拒单', icon: 'success' })
|
||||
loadData()
|
||||
}
|
||||
})
|
||||
}
|
||||
return '全部'
|
||||
}
|
||||
|
||||
function getCurrentTabSubtitle(): string {
|
||||
if (currentTab.value == 'pending_accept') {
|
||||
return '优先响应新派单,避免错过服务时效'
|
||||
async function handleAction(orderId: string, status: DeliveryOrderStatus) {
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') {
|
||||
await acceptServiceOrder(orderId)
|
||||
uni.showToast({ title: '接单成功', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'accepted') {
|
||||
return '确认出发路线,尽快进入上门流程'
|
||||
if (status == 'accepted' || status == 'waiting_departure') {
|
||||
await markDeparted(orderId)
|
||||
uni.showToast({ title: '已标记出发', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'serving') {
|
||||
return '关注执行进度、签到与服务记录'
|
||||
if (status == 'departed' || status == 'on_the_way') {
|
||||
await markArrived(orderId)
|
||||
uni.showToast({ title: '已标记到达', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'pending_submit') {
|
||||
return '尽快补齐记录,完成本次服务提交'
|
||||
if (status == 'arrived') {
|
||||
await checkInServiceOrder(orderId, '已到达并签到', null)
|
||||
uni.showToast({ title: '签到成功', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'completed') {
|
||||
return '回顾已完成服务,跟进结算与评价反馈'
|
||||
if (status == 'checked_in') {
|
||||
await startServiceOrder(orderId)
|
||||
uni.showToast({ title: '已开始服务', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'exception') {
|
||||
return '优先处理异常事项,保障服务连续性'
|
||||
if (status == 'in_service' || status == 'serving' || status == 'completed') {
|
||||
goRecord(orderId)
|
||||
return
|
||||
}
|
||||
return '集中查看全部服务工单与处理进展'
|
||||
}
|
||||
|
||||
function isValidTab(tab: string): boolean {
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
if (tabs[i].value == tab) {
|
||||
return true
|
||||
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') {
|
||||
const result = await completeServiceOrder(orderId)
|
||||
if (result == null) {
|
||||
uni.showToast({ title: '请先填写服务记录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: '服务已完成', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
return false
|
||||
goDetail(orderId)
|
||||
}
|
||||
|
||||
onLoad(() => {
|
||||
consumeStoredTab()
|
||||
loadData()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
consumeStoredTab()
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
min-height: 100%;
|
||||
margin-left: -24rpx;
|
||||
margin-right: -24rpx;
|
||||
margin-top: -24rpx;
|
||||
padding: 0 24rpx 36rpx;
|
||||
background-color: #f3f8fb;
|
||||
}
|
||||
|
||||
function syncActiveTabViewId(): void {
|
||||
activeTabViewId.value = 'status-tab-' + currentTab.value
|
||||
.hero {
|
||||
padding: 68rpx 28rpx 26rpx;
|
||||
border-bottom-left-radius: 32rpx;
|
||||
border-bottom-right-radius: 32rpx;
|
||||
background: linear-gradient(180deg, #1f7db4 0%, #1aa67f 100%);
|
||||
}
|
||||
|
||||
function applyTab(tab: string): void {
|
||||
if (tab == '' || !isValidTab(tab)) {
|
||||
currentTab.value = 'all'
|
||||
} else {
|
||||
currentTab.value = tab
|
||||
}
|
||||
syncActiveTabViewId()
|
||||
.hero-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hero-subtitle,
|
||||
.meta-text,
|
||||
.empty-text,
|
||||
.outline-btn-text,
|
||||
.tab-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
margin-top: 10rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.tab-row,
|
||||
.order-top,
|
||||
.action-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.tab-row {
|
||||
justify-content: space-between;
|
||||
margin-top: 20rpx;
|
||||
padding: 10rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 28rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
width: 32%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.tab-item-active {
|
||||
background-color: #e6f3fa;
|
||||
}
|
||||
|
||||
.tab-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.tab-text-active {
|
||||
font-weight: 700;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.list-card {
|
||||
margin-top: 22rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 28rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 28rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.order-card {
|
||||
padding: 24rpx;
|
||||
margin-bottom: 18rpx;
|
||||
border-radius: 22rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.order-top,
|
||||
.action-row {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.order-main {
|
||||
flex: 1;
|
||||
padding-right: 18rpx;
|
||||
}
|
||||
|
||||
.order-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.order-subtitle,
|
||||
.order-status,
|
||||
.meta-text,
|
||||
.empty-text,
|
||||
.outline-btn-text,
|
||||
.warn-btn-text,
|
||||
.primary-btn-text {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.order-subtitle,
|
||||
.meta-text,
|
||||
.empty-text,
|
||||
.outline-btn-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.order-status {
|
||||
font-size: 24rpx;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.meta-box {
|
||||
margin-top: 14rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #eef7fb;
|
||||
}
|
||||
|
||||
.action-row {
|
||||
margin-top: 18rpx;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.warn-btn,
|
||||
.primary-btn {
|
||||
width: 31%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.outline-btn {
|
||||
background-color: #eef6fa;
|
||||
}
|
||||
|
||||
.warn-btn {
|
||||
background-color: #fff3e6;
|
||||
}
|
||||
|
||||
.warn-btn-text {
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
color: #c77413;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background-color: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
function consumeStoredTab(): void {
|
||||
|
||||
@@ -1,313 +1,72 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="我的" fallback-url="/pages/mall/delivery/home/index" :hide-header="true">
|
||||
<view class="delivery-profile-page">
|
||||
<view class="delivery-profile-hero">
|
||||
<view class="delivery-hero-top">
|
||||
<view class="delivery-avatar">
|
||||
<text class="delivery-avatar-text">{{ getAvatarText() }}</text>
|
||||
</view>
|
||||
<view class="delivery-user-main">
|
||||
<text class="delivery-user-name">{{ deliveryInfo != null ? deliveryInfo.name : '服务人员' }}</text>
|
||||
<view class="delivery-user-tags">
|
||||
<text class="delivery-user-tag">{{ deliveryInfo != null ? deliveryInfo.role : '居家服务人员' }}</text>
|
||||
<text class="delivery-user-tag delivery-user-tag-light">{{ getOnlineStatusText() }}</text>
|
||||
</view>
|
||||
<text class="delivery-user-org">{{ displayOrganizationName() }}</text>
|
||||
</view>
|
||||
<view class="delivery-setting-btn" @click="goSettings">
|
||||
<text class="delivery-setting-text">设置</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-hero-info-row">
|
||||
<view class="delivery-hero-info-item">
|
||||
<text class="delivery-hero-info-value">{{ displayStaffNo() }}</text>
|
||||
<text class="delivery-hero-info-label">人员编号</text>
|
||||
</view>
|
||||
<view class="delivery-hero-info-item">
|
||||
<text class="delivery-hero-info-value">{{ getCertificateStatusText() }}</text>
|
||||
<text class="delivery-hero-info-label">资质状态</text>
|
||||
</view>
|
||||
<view class="delivery-hero-info-item">
|
||||
<text class="delivery-hero-info-value">{{ displayServiceArea() }}</text>
|
||||
<text class="delivery-hero-info-label">服务区域</text>
|
||||
<view class="page">
|
||||
<view class="hero">
|
||||
<view class="hero-row">
|
||||
<view class="avatar"><text class="avatar-text">护</text></view>
|
||||
<view class="hero-main">
|
||||
<text class="hero-name">{{ nameText }}</text>
|
||||
<text class="hero-role">服务人员 / 护工 / 上门服务人员</text>
|
||||
<text class="hero-org">{{ organizationText }}</text>
|
||||
</view>
|
||||
<view class="hero-setting" @click="goSettings"><text class="hero-setting-text">设置</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-level-card">
|
||||
<view class="delivery-card-header">
|
||||
<view>
|
||||
<text class="delivery-card-title">服务等级</text>
|
||||
<text class="delivery-card-subtitle">接单、完成服务和用户好评会提升等级</text>
|
||||
</view>
|
||||
<text class="delivery-level-badge">{{ growthStats.levelName }}</text>
|
||||
</view>
|
||||
<view class="card stats-card">
|
||||
<view class="stat-item"><text class="stat-value">{{ acceptedText }}</text><text class="stat-label">今日接单</text></view>
|
||||
<view class="stat-item"><text class="stat-value">{{ servingText }}</text><text class="stat-label">服务中</text></view>
|
||||
<view class="stat-item"><text class="stat-value">{{ completedText }}</text><text class="stat-label">今日完成</text></view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-level-main">
|
||||
<text class="delivery-growth-value">{{ growthStats.growthValue }}</text>
|
||||
<text class="delivery-growth-total"> / {{ growthStats.nextLevelValue }} 成长值</text>
|
||||
</view>
|
||||
<view class="card">
|
||||
<text class="section-title">账号信息</text>
|
||||
<text class="row-text">人员编号:{{ staffNoText }}</text>
|
||||
<text class="row-text">联系电话:{{ phoneText }}</text>
|
||||
<text class="row-text">服务区域:{{ serviceAreaText }}</text>
|
||||
<text class="row-text">资质状态:{{ certificateText }}</text>
|
||||
<text class="row-text">资质到期:{{ certificateExpireText }}</text>
|
||||
</view>
|
||||
|
||||
<view class="delivery-progress-track">
|
||||
<view class="delivery-progress-fill" :style="{ width: getLevelProgressWidth() }"></view>
|
||||
</view>
|
||||
|
||||
<text class="delivery-level-tip">{{ growthStats.nextTips }}</text>
|
||||
|
||||
<view class="delivery-level-tags">
|
||||
<text class="delivery-level-tag">接单稳定</text>
|
||||
<text class="delivery-level-tag">好评优秀</text>
|
||||
<text class="delivery-level-tag">准时服务</text>
|
||||
<view class="card">
|
||||
<text class="section-title">工作状态</text>
|
||||
<view class="status-row">
|
||||
<view class="status-btn" :class="onlineStatusText == 'online' ? 'status-btn-active' : ''" @click="changeStatus('online')"><text class="status-btn-text">在线</text></view>
|
||||
<view class="status-btn" :class="onlineStatusText == 'resting' ? 'status-btn-active' : ''" @click="changeStatus('resting')"><text class="status-btn-text">离线</text></view>
|
||||
<view class="status-btn" :class="onlineStatusText == 'busy' ? 'status-btn-active' : ''" @click="changeStatus('busy')"><text class="status-btn-text">忙碌</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-stats-card">
|
||||
<view class="delivery-stat-item">
|
||||
<text class="delivery-stat-value">{{ deliveryInfo != null ? deliveryInfo.todayAccepted : 0 }}</text>
|
||||
<text class="delivery-stat-label">今日接单</text>
|
||||
</view>
|
||||
<view class="delivery-stat-item">
|
||||
<text class="delivery-stat-value">{{ deliveryInfo != null ? deliveryInfo.todayServing : 0 }}</text>
|
||||
<text class="delivery-stat-label">服务中</text>
|
||||
</view>
|
||||
<view class="delivery-stat-item">
|
||||
<text class="delivery-stat-value">{{ deliveryInfo != null ? deliveryInfo.todayCompleted : 0 }}</text>
|
||||
<text class="delivery-stat-label">今日完成</text>
|
||||
</view>
|
||||
<view class="delivery-stat-item">
|
||||
<text class="delivery-stat-value">{{ growthStats.goodRate }}%</text>
|
||||
<text class="delivery-stat-label">好评率</text>
|
||||
</view>
|
||||
<view class="card action-card">
|
||||
<view class="tool-item" @click="goOrders('today')"><text class="tool-title">今日订单</text><text class="tool-desc">查看待服务订单</text></view>
|
||||
<view class="tool-item" @click="goOrders('history')"><text class="tool-title">历史订单</text><text class="tool-desc">查看已完成和异常</text></view>
|
||||
<view class="tool-item" @click="goSettings"><text class="tool-title">设置</text><text class="tool-desc">退出登录和提醒设置</text></view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-status-card">
|
||||
<view class="delivery-card-header">
|
||||
<view>
|
||||
<text class="delivery-card-title">当前状态</text>
|
||||
<text class="delivery-card-subtitle">切换后会影响平台派单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="delivery-status-row">
|
||||
<view class="delivery-status-btn" :class="deliveryInfo != null && deliveryInfo.onlineStatus == 'online' ? 'delivery-status-active' : ''" @click="changeStatus('online')">
|
||||
<text class="delivery-status-text">在线</text>
|
||||
</view>
|
||||
<view class="delivery-status-btn" :class="deliveryInfo != null && deliveryInfo.onlineStatus == 'resting' ? 'delivery-status-active' : ''" @click="changeStatus('resting')">
|
||||
<text class="delivery-status-text">休息</text>
|
||||
</view>
|
||||
<view class="delivery-status-btn" :class="deliveryInfo != null && deliveryInfo.onlineStatus == 'busy' ? 'delivery-status-active' : ''" @click="changeStatus('busy')">
|
||||
<text class="delivery-status-text">忙碌</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-tools-card">
|
||||
<view class="delivery-card-header">
|
||||
<text class="delivery-card-title">常用功能</text>
|
||||
</view>
|
||||
<view class="delivery-tools-grid">
|
||||
<view class="delivery-tool-item" @click="goOrders">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">单</text></view>
|
||||
<text class="delivery-tool-name">工单列表</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="goMessages">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">息</text></view>
|
||||
<text class="delivery-tool-name">消息中心</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="goCertificates">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">证</text></view>
|
||||
<text class="delivery-tool-name">资质证书</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="goRecords">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">记</text></view>
|
||||
<text class="delivery-tool-name">服务记录</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="showTodo('异常上报')">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">异</text></view>
|
||||
<text class="delivery-tool-name">异常上报</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="showTodo('服务规范')">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">规</text></view>
|
||||
<text class="delivery-tool-name">服务规范</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="goSettings">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">设</text></view>
|
||||
<text class="delivery-tool-name">设置</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="showTodo('联系平台')">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">客</text></view>
|
||||
<text class="delivery-tool-name">联系平台</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-account-card">
|
||||
<view class="delivery-card-header">
|
||||
<view>
|
||||
<text class="delivery-card-title">账号与资质</text>
|
||||
<text class="delivery-card-subtitle">展示机构、区域、证书与账号安全信息</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="delivery-account-row">
|
||||
<text class="delivery-account-label">所属机构</text>
|
||||
<text class="delivery-account-value">{{ displayOrganizationName() }}</text>
|
||||
</view>
|
||||
<view class="delivery-account-row">
|
||||
<text class="delivery-account-label">服务区域</text>
|
||||
<text class="delivery-account-value">{{ displayServiceArea() }}</text>
|
||||
</view>
|
||||
<view class="delivery-account-row">
|
||||
<text class="delivery-account-label">资质状态</text>
|
||||
<text class="delivery-account-value">{{ getCertificateStatusText() }}</text>
|
||||
</view>
|
||||
<view class="delivery-account-row delivery-account-row-last">
|
||||
<text class="delivery-account-label">资质到期</text>
|
||||
<text class="delivery-account-value">{{ displayCertificateExpireAt() != '' ? displayCertificateExpireAt() : '暂无' }}</text>
|
||||
</view>
|
||||
<view class="delivery-logout-btn" @click="logout">
|
||||
<text class="delivery-logout-text">退出登录</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-profile-safe"></view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import type { DeliveryInfoType } from '@/types/delivery.uts'
|
||||
import { getDeliveryProfile, updateDeliveryOnlineStatus } from '@/services/deliveryService.uts'
|
||||
import { logoutDelivery, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
|
||||
type DeliveryGrowthStatsType = {
|
||||
levelName: string
|
||||
growthValue: number
|
||||
nextLevelValue: number
|
||||
completedTotal: number
|
||||
goodRate: number
|
||||
goodReviewCount: number
|
||||
onTimeRate: number
|
||||
nextTips: string
|
||||
}
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
|
||||
const deliveryInfo = ref<DeliveryInfoType | null>(null)
|
||||
|
||||
// TODO: 后续接入真实 delivery 服务等级统计接口
|
||||
const growthStats = ref({
|
||||
levelName: '银牌服务师',
|
||||
growthValue: 486,
|
||||
nextLevelValue: 800,
|
||||
completedTotal: 126,
|
||||
goodRate: 98,
|
||||
goodReviewCount: 112,
|
||||
onTimeRate: 96,
|
||||
nextTips: '再完成 12 单并获得 5 个好评可升级'
|
||||
} as DeliveryGrowthStatsType)
|
||||
|
||||
function displayOrganizationName(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '暂未绑定服务机构'
|
||||
}
|
||||
const organizationName = deliveryInfo.value.organizationName.trim()
|
||||
if (organizationName != '') {
|
||||
return organizationName
|
||||
}
|
||||
return '暂未绑定服务机构'
|
||||
}
|
||||
|
||||
function displayStaffNo(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '待分配'
|
||||
}
|
||||
const staffNo = deliveryInfo.value.staffNo.trim()
|
||||
if (staffNo != '') {
|
||||
return staffNo
|
||||
}
|
||||
return '待分配'
|
||||
}
|
||||
|
||||
function displayServiceArea(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '待完善'
|
||||
}
|
||||
const serviceArea = deliveryInfo.value.serviceArea.trim()
|
||||
if (serviceArea != '') {
|
||||
return serviceArea
|
||||
}
|
||||
return '待完善'
|
||||
}
|
||||
|
||||
function displayCertificateExpireAt(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return ''
|
||||
}
|
||||
return deliveryInfo.value.certificateExpireAt.trim()
|
||||
}
|
||||
|
||||
function getOnlineStatusText(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '未登录'
|
||||
}
|
||||
const status = deliveryInfo.value.onlineStatus
|
||||
if (status == 'online') {
|
||||
return '在线接单'
|
||||
}
|
||||
if (status == 'resting') {
|
||||
return '休息中'
|
||||
}
|
||||
if (status == 'busy') {
|
||||
return '忙碌中'
|
||||
}
|
||||
return '未知状态'
|
||||
}
|
||||
|
||||
function getCertificateStatusText(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '待认证'
|
||||
}
|
||||
const status = deliveryInfo.value.certificateStatus.trim()
|
||||
if (status == 'valid') {
|
||||
return '已认证'
|
||||
}
|
||||
if (status == 'expired') {
|
||||
return '已过期'
|
||||
}
|
||||
if (status == 'pending') {
|
||||
return '审核中'
|
||||
}
|
||||
if (status != '') {
|
||||
return status
|
||||
}
|
||||
return '待认证'
|
||||
}
|
||||
|
||||
function getAvatarText(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '护'
|
||||
}
|
||||
const name = deliveryInfo.value.name.trim()
|
||||
if (name == '') {
|
||||
return '护'
|
||||
}
|
||||
return name.substring(0, 1)
|
||||
}
|
||||
|
||||
function getLevelProgressWidth(): string {
|
||||
if (growthStats.value.nextLevelValue <= 0) {
|
||||
return '0%'
|
||||
}
|
||||
const percent = growthStats.value.growthValue * 100 / growthStats.value.nextLevelValue
|
||||
if (percent >= 100) {
|
||||
return '100%'
|
||||
}
|
||||
if (percent <= 0) {
|
||||
return '0%'
|
||||
}
|
||||
return percent.toString() + '%'
|
||||
}
|
||||
const nameText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.name : '服务人员')
|
||||
const organizationText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.organizationName : '机构待绑定')
|
||||
const acceptedText = computed((): string => deliveryInfo.value != null ? String(deliveryInfo.value.todayAccepted) : '0')
|
||||
const servingText = computed((): string => deliveryInfo.value != null ? String(deliveryInfo.value.todayServing) : '0')
|
||||
const completedText = computed((): string => deliveryInfo.value != null ? String(deliveryInfo.value.todayCompleted) : '0')
|
||||
const staffNoText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.staffNo : '待分配')
|
||||
const phoneText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.phone : '待完善')
|
||||
const serviceAreaText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.serviceArea : '待完善')
|
||||
const certificateText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.certificateStatus : '待认证')
|
||||
const certificateExpireText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.certificateExpireAt : '暂无')
|
||||
const onlineStatusText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.onlineStatus : 'resting')
|
||||
|
||||
async function loadData() {
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
@@ -318,419 +77,193 @@ async function loadData() {
|
||||
}
|
||||
|
||||
async function changeStatus(status: string) {
|
||||
const nextInfo = await updateDeliveryOnlineStatus(status)
|
||||
if (nextInfo != null) {
|
||||
deliveryInfo.value = nextInfo
|
||||
uni.showToast({ title: '状态已更新', icon: 'success' })
|
||||
if (deliveryInfo.value == null) {
|
||||
return
|
||||
}
|
||||
deliveryInfo.value = await updateDeliveryOnlineStatus(status)
|
||||
uni.showToast({ title: '状态已更新', icon: 'success' })
|
||||
}
|
||||
|
||||
function goCertificates() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/profile/certificates' })
|
||||
function goOrders(tab: string) {
|
||||
uni.setStorageSync('delivery_order_tab', tab)
|
||||
uni.switchTab({ url: '/pages/mall/delivery/orders/index' })
|
||||
}
|
||||
|
||||
function goSettings() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/profile/settings' })
|
||||
}
|
||||
|
||||
function goOrders() {
|
||||
uni.switchTab({ url: '/pages/mall/delivery/orders/index' })
|
||||
}
|
||||
|
||||
function goMessages() {
|
||||
uni.switchTab({ url: '/pages/mall/delivery/messages/index' })
|
||||
}
|
||||
|
||||
function goRecords() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/records/index' })
|
||||
}
|
||||
|
||||
function showTodo(title: string) {
|
||||
uni.showToast({
|
||||
title: title + '建设中',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await logoutDelivery()
|
||||
uni.reLaunch({ url: '/pages/user/login?mode=delivery' })
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.delivery-profile-page {
|
||||
.page {
|
||||
min-height: 100%;
|
||||
margin-left: -24rpx;
|
||||
margin-right: -24rpx;
|
||||
margin-top: -24rpx;
|
||||
padding-bottom: 32rpx;
|
||||
background-color: #f4f8fb;
|
||||
padding: 0 24rpx 36rpx;
|
||||
background-color: #f3f8fb;
|
||||
}
|
||||
|
||||
.delivery-profile-hero {
|
||||
padding: 72rpx 28rpx 34rpx;
|
||||
border-bottom-left-radius: 36rpx;
|
||||
border-bottom-right-radius: 36rpx;
|
||||
background-color: #0f766e;
|
||||
}
|
||||
|
||||
.delivery-hero-top {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delivery-avatar {
|
||||
width: 112rpx;
|
||||
height: 112rpx;
|
||||
margin-right: 22rpx;
|
||||
border-radius: 56rpx;
|
||||
background-color: rgba(255, 255, 255, 0.92);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.delivery-avatar-text {
|
||||
font-size: 42rpx;
|
||||
font-weight: 700;
|
||||
color: #0f766e;
|
||||
}
|
||||
|
||||
.delivery-user-main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.delivery-user-name {
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.delivery-user-tags {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-top: 12rpx;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.delivery-user-tag {
|
||||
margin-right: 10rpx;
|
||||
margin-bottom: 8rpx;
|
||||
padding: 6rpx 14rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
color: #0f766e;
|
||||
background-color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.delivery-user-tag-light {
|
||||
color: #ffffff;
|
||||
background-color: rgba(255, 255, 255, 0.22);
|
||||
}
|
||||
|
||||
.delivery-user-org {
|
||||
margin-top: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.delivery-setting-btn {
|
||||
padding: 10rpx 18rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: rgba(255, 255, 255, 0.18);
|
||||
}
|
||||
|
||||
.delivery-setting-text {
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.delivery-hero-info-row {
|
||||
margin-top: 32rpx;
|
||||
padding: 22rpx 18rpx;
|
||||
border-radius: 26rpx;
|
||||
background-color: rgba(255, 255, 255, 0.18);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.delivery-hero-info-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delivery-hero-info-value {
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
max-width: 180rpx;
|
||||
text-align: center;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.delivery-hero-info-label {
|
||||
margin-top: 8rpx;
|
||||
font-size: 22rpx;
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
}
|
||||
|
||||
.delivery-level-card,
|
||||
.delivery-stats-card,
|
||||
.delivery-status-card,
|
||||
.delivery-tools-card,
|
||||
.delivery-account-card {
|
||||
margin-left: 24rpx;
|
||||
margin-right: 24rpx;
|
||||
margin-top: 22rpx;
|
||||
padding: 26rpx;
|
||||
.hero,
|
||||
.card {
|
||||
border-radius: 28rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 28rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.delivery-level-card {
|
||||
margin-top: -18rpx;
|
||||
position: relative;
|
||||
.hero {
|
||||
padding: 64rpx 28rpx 28rpx;
|
||||
border-bottom-left-radius: 36rpx;
|
||||
border-bottom-right-radius: 36rpx;
|
||||
background: linear-gradient(180deg, #1f7db4 0%, #22a380 100%);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.delivery-card-header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.delivery-card-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.delivery-card-subtitle {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-level-badge {
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
color: #92400e;
|
||||
background-color: #fef3c7;
|
||||
}
|
||||
|
||||
.delivery-level-main {
|
||||
margin-top: 24rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.delivery-growth-value {
|
||||
font-size: 46rpx;
|
||||
font-weight: 700;
|
||||
color: #0f766e;
|
||||
}
|
||||
|
||||
.delivery-growth-total {
|
||||
margin-left: 6rpx;
|
||||
margin-bottom: 6rpx;
|
||||
font-size: 24rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-progress-track {
|
||||
margin-top: 18rpx;
|
||||
height: 16rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #e2e8f0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.delivery-progress-fill {
|
||||
height: 16rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #0f766e;
|
||||
}
|
||||
|
||||
.delivery-level-tip {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
font-size: 23rpx;
|
||||
line-height: 34rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-level-tags {
|
||||
margin-top: 18rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.delivery-level-tag {
|
||||
margin-right: 12rpx;
|
||||
margin-bottom: 10rpx;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
color: #0f766e;
|
||||
background-color: #ecfdf5;
|
||||
}
|
||||
|
||||
.delivery-stats-card {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
padding-top: 28rpx;
|
||||
padding-bottom: 28rpx;
|
||||
}
|
||||
|
||||
.delivery-stat-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delivery-stat-value {
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.delivery-stat-label {
|
||||
margin-top: 8rpx;
|
||||
font-size: 22rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-status-row {
|
||||
margin-top: 22rpx;
|
||||
.hero-row,
|
||||
.stats-card,
|
||||
.status-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.delivery-status-btn {
|
||||
width: 31%;
|
||||
height: 68rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #f1f5f9;
|
||||
display: flex;
|
||||
.hero-row {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border-radius: 48rpx;
|
||||
background-color: rgba(255, 255, 255, 0.22);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.delivery-status-active {
|
||||
background-color: #0f766e;
|
||||
box-shadow: 0 8rpx 18rpx rgba(15, 118, 110, 0.18);
|
||||
}
|
||||
|
||||
.delivery-status-text {
|
||||
font-size: 26rpx;
|
||||
.avatar-text {
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-status-active .delivery-status-text {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.delivery-tools-grid {
|
||||
margin-top: 22rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
.hero-main {
|
||||
flex: 1;
|
||||
padding-left: 20rpx;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.delivery-tool-item {
|
||||
width: 25%;
|
||||
margin-bottom: 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delivery-tool-icon {
|
||||
width: 72rpx;
|
||||
height: 72rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ecfdf5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.delivery-tool-icon-text {
|
||||
font-size: 28rpx;
|
||||
.hero-name {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: #0f766e;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.delivery-tool-name {
|
||||
margin-top: 10rpx;
|
||||
font-size: 23rpx;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
.delivery-account-row {
|
||||
min-height: 72rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
border-bottom-width: 1rpx;
|
||||
border-bottom-color: #eef2f7;
|
||||
}
|
||||
|
||||
.delivery-account-row-last {
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
|
||||
.delivery-account-label {
|
||||
font-size: 26rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-account-value {
|
||||
max-width: 420rpx;
|
||||
text-align: right;
|
||||
font-size: 26rpx;
|
||||
.hero-role,
|
||||
.hero-org,
|
||||
.stat-label,
|
||||
.row-text,
|
||||
.tool-desc,
|
||||
.hero-setting-text,
|
||||
.status-btn-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.hero-role,
|
||||
.hero-org {
|
||||
margin-top: 10rpx;
|
||||
color: rgba(255, 255, 255, 0.88);
|
||||
}
|
||||
|
||||
.hero-setting {
|
||||
padding: 14rpx 22rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.hero-setting-text {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-top: 22rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.stats-card {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
width: 31%;
|
||||
padding: 22rpx 14rpx;
|
||||
border-radius: 20rpx;
|
||||
background-color: #f7fbfd;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.stat-value,
|
||||
.section-title,
|
||||
.tool-title {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 34rpx;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.stat-label,
|
||||
.tool-desc,
|
||||
.row-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.section-title,
|
||||
.tool-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.delivery-logout-btn {
|
||||
margin-top: 24rpx;
|
||||
height: 76rpx;
|
||||
border-radius: 20rpx;
|
||||
background-color: #fff1f2;
|
||||
display: flex;
|
||||
.row-text {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.status-btn {
|
||||
width: 31%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
background-color: #eef6fa;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.delivery-logout-text {
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
color: #e11d48;
|
||||
.status-btn-active {
|
||||
background-color: #d8eef9;
|
||||
}
|
||||
|
||||
.delivery-profile-safe {
|
||||
height: 40rpx;
|
||||
.status-btn-text {
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.tool-item {
|
||||
margin-top: 14rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.tool-title {
|
||||
font-size: 28rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.tool-desc {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -8,20 +8,22 @@
|
||||
<text v-if="deliveryInfo != null" class="info-text">资质状态:{{ deliveryInfo.certificateStatus }}</text>
|
||||
</ServicePanel>
|
||||
|
||||
<ServicePanel title="提醒与权限" subtitle="预留定位权限、语音播报和消息提醒控制。">
|
||||
<ServicePanel title="提醒与权限" subtitle="保留消息提醒和定位权限提示占位。">
|
||||
<view class="setting-row">
|
||||
<text class="setting-text">消息提醒</text>
|
||||
<switch :checked="messageEnabled" color="#0f766e" @change="toggleMessage" />
|
||||
</view>
|
||||
<view class="setting-row">
|
||||
<text class="setting-text">语音播报</text>
|
||||
<switch :checked="voiceEnabled" color="#0f766e" @change="toggleVoice" />
|
||||
<switch :checked="messageEnabled" color="#1f7db4" @change="toggleMessage" />
|
||||
</view>
|
||||
<view class="setting-row">
|
||||
<text class="setting-text">定位权限提示</text>
|
||||
<text class="setting-hint">请确保 Android 和小程序侧授权开启</text>
|
||||
<text class="setting-hint">定位轨迹仅做字段预留,当前为 mock</text>
|
||||
</view>
|
||||
<view class="setting-row setting-row-last">
|
||||
<text class="setting-text">图片上传</text>
|
||||
<text class="setting-hint">当前仅占位,不做真实上传</text>
|
||||
</view>
|
||||
</ServicePanel>
|
||||
|
||||
<view class="logout-btn" @click="confirmLogout"><text class="logout-text">退出登录</text></view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
@@ -32,10 +34,9 @@ import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uv
|
||||
import ServicePanel from '@/components/homeService/ServicePanel.uvue'
|
||||
import type { DeliveryInfoType } from '@/types/delivery.uts'
|
||||
import { getDeliveryProfile } from '@/services/deliveryService.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { logoutDelivery, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
|
||||
const messageEnabled = ref(true)
|
||||
const voiceEnabled = ref(false)
|
||||
const deliveryInfo = ref<DeliveryInfoType | null>(null)
|
||||
|
||||
function displayOrganizationName(): string {
|
||||
@@ -62,9 +63,7 @@ function displayStaffNo(): string {
|
||||
|
||||
function restoreSettings() {
|
||||
const msg = uni.getStorageSync('delivery_setting_message') as boolean | null
|
||||
const voice = uni.getStorageSync('delivery_setting_voice') as boolean | null
|
||||
messageEnabled.value = msg == null ? true : msg
|
||||
voiceEnabled.value = voice == null ? false : voice
|
||||
}
|
||||
|
||||
function toggleMessage(event: any) {
|
||||
@@ -72,9 +71,17 @@ function toggleMessage(event: any) {
|
||||
uni.setStorageSync('delivery_setting_message', messageEnabled.value)
|
||||
}
|
||||
|
||||
function toggleVoice(event: any) {
|
||||
voiceEnabled.value = event.detail.value === true
|
||||
uni.setStorageSync('delivery_setting_voice', voiceEnabled.value)
|
||||
function confirmLogout() {
|
||||
uni.showModal({
|
||||
title: '退出登录',
|
||||
content: '退出后将清除服务人员信息并返回登录页。',
|
||||
success: async (result) => {
|
||||
if (result.confirm) {
|
||||
await logoutDelivery()
|
||||
uni.reLaunch({ url: '/pages/user/login?mode=delivery' })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
@@ -100,6 +107,10 @@ onShow(() => {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.setting-row-last {
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
@@ -120,4 +131,19 @@ onShow(() => {
|
||||
text-align: right;
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
margin-top: 24rpx;
|
||||
padding: 20rpx 0;
|
||||
border-radius: 18rpx;
|
||||
background-color: #fff1f2;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.logout-text {
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
color: #dc2626;
|
||||
}
|
||||
</style>
|
||||
328
pages/mall/delivery/service-record/index.uvue
Normal file
328
pages/mall/delivery/service-record/index.uvue
Normal file
@@ -0,0 +1,328 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="服务记录" fallback-url="/pages/mall/delivery/orders/detail">
|
||||
<view class="page">
|
||||
<view class="card">
|
||||
<text class="section-title">服务时间</text>
|
||||
<input class="field" v-model="startTime" placeholder="服务开始时间,例如 2026-05-20 15:00" />
|
||||
<input class="field" v-model="endTime" placeholder="服务结束时间,例如 2026-05-20 16:30" />
|
||||
<input class="field" v-model="actualDurationText" placeholder="实际服务时长(分钟)" type="number" />
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">服务内容</text>
|
||||
<view v-for="item in serviceItems" :key="item.id" class="item-row">
|
||||
<view class="item-top">
|
||||
<text class="item-name">{{ item.name }}</text>
|
||||
<switch :checked="item.completed" color="#1f7db4" @change="toggleItem(item.id, $event)" />
|
||||
</view>
|
||||
<input class="field" v-model="item.remark" placeholder="服务过程说明" />
|
||||
<input v-if="item.completed == false" class="field" v-model="item.incompleteReason" placeholder="未完成原因" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">健康与过程记录</text>
|
||||
<textarea class="textarea" v-model="processNote" placeholder="服务过程说明"></textarea>
|
||||
<input class="field" v-model="elderStatus" placeholder="服务对象状态" />
|
||||
<input class="field" v-model="bloodPressure" placeholder="血压" />
|
||||
<input class="field" v-model="heartRate" placeholder="心率" />
|
||||
<input class="field" v-model="bloodSugar" placeholder="血糖" />
|
||||
<input class="field" v-model="bloodOxygen" placeholder="血氧" />
|
||||
<input class="field" v-model="materialsUsed" placeholder="耗材使用记录" />
|
||||
<input class="field" v-model="abnormalNote" placeholder="异常情况说明" />
|
||||
<input class="field" v-model="staffRemark" placeholder="服务人员备注" />
|
||||
<view class="placeholder-row">
|
||||
<view class="placeholder-btn" @click="mockPhoto"><text class="placeholder-btn-text">服务照片占位</text></view>
|
||||
<text class="placeholder-text">{{ photosText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">家属确认方式</text>
|
||||
<view class="confirm-row">
|
||||
<view class="confirm-item" :class="confirmMethod == 'sms_code' ? 'confirm-item-active' : ''" @click="confirmMethod = 'sms_code'"><text class="confirm-text">验证码确认</text></view>
|
||||
<view class="confirm-item" :class="confirmMethod == 'signature' ? 'confirm-item-active' : ''" @click="confirmMethod = 'signature'"><text class="confirm-text">签字确认</text></view>
|
||||
</view>
|
||||
<input v-if="confirmMethod == 'sms_code'" class="field" v-model="confirmCode" placeholder="验证码 mock" />
|
||||
<input v-else class="field" v-model="signatureName" placeholder="签字人姓名 mock" />
|
||||
</view>
|
||||
|
||||
<view class="action-row">
|
||||
<view class="outline-btn" @click="goBack"><text class="outline-btn-text">返回详情</text></view>
|
||||
<view class="primary-btn" @click="submitRecord"><text class="primary-btn-text">提交服务记录</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import type { DeliveryOrderType, DeliveryServiceItemType, DeliveryServiceRecordType } from '@/types/delivery.uts'
|
||||
import { getServiceOrderDetail, submitServiceRecord } from '@/services/deliveryService.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
|
||||
|
||||
const orderId = ref('')
|
||||
const order = ref<DeliveryOrderType | null>(null)
|
||||
const serviceItems = ref([] as Array<DeliveryServiceItemType>)
|
||||
const startTime = ref('')
|
||||
const endTime = ref('')
|
||||
const actualDurationText = ref('90')
|
||||
const processNote = ref('')
|
||||
const elderStatus = ref('')
|
||||
const bloodPressure = ref('')
|
||||
const heartRate = ref('')
|
||||
const bloodSugar = ref('')
|
||||
const bloodOxygen = ref('')
|
||||
const materialsUsed = ref('')
|
||||
const abnormalNote = ref('')
|
||||
const staffRemark = ref('')
|
||||
const confirmMethod = ref('sms_code')
|
||||
const confirmCode = ref('')
|
||||
const signatureName = ref('')
|
||||
const photoCount = ref(0)
|
||||
|
||||
const photosText = computed((): string => '已添加占位照片 ' + String(photoCount.value) + ' 张')
|
||||
|
||||
function toggleItem(itemId: string, event: any) {
|
||||
for (let i = 0; i < serviceItems.value.length; i++) {
|
||||
if (serviceItems.value[i].id == itemId) {
|
||||
serviceItems.value[i].completed = event.detail.value === true
|
||||
serviceItems.value[i].updatedAt = new Date().toISOString().replace('T', ' ').substring(0, 19)
|
||||
if (serviceItems.value[i].completed) {
|
||||
serviceItems.value[i].incompleteReason = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mockPhoto() {
|
||||
photoCount.value = photoCount.value + 1
|
||||
uni.showToast({ title: '已添加照片占位', icon: 'success' })
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!authResult.ok || orderId.value == '') {
|
||||
return
|
||||
}
|
||||
order.value = await getServiceOrderDetail(orderId.value)
|
||||
if (order.value != null) {
|
||||
serviceItems.value = order.value.serviceItems
|
||||
startTime.value = order.value.startServiceTime != null && order.value.startServiceTime != '' ? order.value.startServiceTime : order.value.appointmentTime
|
||||
endTime.value = order.value.finishTime
|
||||
processNote.value = order.value.serviceSummary
|
||||
staffRemark.value = order.value.progressNote
|
||||
if (order.value.serviceRecord != null) {
|
||||
elderStatus.value = order.value.serviceRecord!.elderStatus
|
||||
bloodPressure.value = order.value.serviceRecord!.healthMetrics.bloodPressure
|
||||
heartRate.value = order.value.serviceRecord!.healthMetrics.heartRate
|
||||
bloodSugar.value = order.value.serviceRecord!.healthMetrics.bloodSugar
|
||||
bloodOxygen.value = order.value.serviceRecord!.healthMetrics.bloodOxygen
|
||||
materialsUsed.value = order.value.serviceRecord!.materialsUsed
|
||||
abnormalNote.value = order.value.serviceRecord!.abnormalNote
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateRecord(): boolean {
|
||||
if (startTime.value == '' || endTime.value == '') {
|
||||
uni.showToast({ title: '请填写开始和结束时间', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
for (let i = 0; i < serviceItems.value.length; i++) {
|
||||
if (serviceItems.value[i].completed == false && serviceItems.value[i].incompleteReason == '') {
|
||||
uni.showToast({ title: '未完成项目需要说明原因', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function submitRecordAction() {
|
||||
if (!validateRecord()) {
|
||||
return
|
||||
}
|
||||
const record = {
|
||||
id: 'record-' + orderId.value,
|
||||
orderId: orderId.value,
|
||||
startTime: startTime.value,
|
||||
endTime: endTime.value,
|
||||
actualDurationMinutes: parseInt(actualDurationText.value),
|
||||
serviceItems: serviceItems.value,
|
||||
serviceContent: serviceItems.value.filter((item) => item.completed).map((item) => item.name),
|
||||
processNote: processNote.value,
|
||||
elderStatus: elderStatus.value,
|
||||
healthMetrics: {
|
||||
bloodPressure: bloodPressure.value,
|
||||
heartRate: heartRate.value,
|
||||
bloodSugar: bloodSugar.value,
|
||||
bloodOxygen: bloodOxygen.value
|
||||
},
|
||||
materialsUsed: materialsUsed.value,
|
||||
abnormalNote: abnormalNote.value,
|
||||
photos: photoCount.value > 0 ? ['mock-photo-' + String(photoCount.value)] : [] as Array<string>,
|
||||
staffRemark: staffRemark.value,
|
||||
familyConfirmation: {
|
||||
method: confirmMethod.value == 'sms_code' ? 'sms_code' : 'signature',
|
||||
code: confirmCode.value,
|
||||
signatureName: signatureName.value,
|
||||
signatureUrl: '',
|
||||
confirmedAt: new Date().toISOString().replace('T', ' ').substring(0, 19)
|
||||
},
|
||||
createdAt: new Date().toISOString().replace('T', ' ').substring(0, 19),
|
||||
updatedAt: new Date().toISOString().replace('T', ' ').substring(0, 19)
|
||||
} as DeliveryServiceRecordType
|
||||
await submitServiceRecord(orderId.value, record)
|
||||
uni.showToast({ title: '服务记录已提交', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
|
||||
}, 300)
|
||||
}
|
||||
|
||||
function submitRecord() {
|
||||
submitRecordAction()
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
if (options != null) {
|
||||
orderId.value = getDeliveryRouteParam(options as UTSJSONObject, 'id')
|
||||
}
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
padding-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-bottom: 18rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 24rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.section-title,
|
||||
.item-name,
|
||||
.primary-btn-text,
|
||||
.confirm-text {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.field,
|
||||
.textarea {
|
||||
margin-top: 16rpx;
|
||||
padding: 0 20rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f4f8fb;
|
||||
font-size: 26rpx;
|
||||
color: #16324f;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.field {
|
||||
height: 84rpx;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
min-height: 180rpx;
|
||||
padding-top: 20rpx;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.item-row {
|
||||
margin-top: 16rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.item-top,
|
||||
.placeholder-row,
|
||||
.confirm-row,
|
||||
.action-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-size: 28rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.placeholder-row,
|
||||
.action-row {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.placeholder-btn,
|
||||
.confirm-item,
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.placeholder-btn,
|
||||
.confirm-item,
|
||||
.outline-btn {
|
||||
background-color: #eef6fa;
|
||||
}
|
||||
|
||||
.placeholder-btn {
|
||||
width: 42%;
|
||||
}
|
||||
|
||||
.placeholder-btn-text,
|
||||
.placeholder-text,
|
||||
.outline-btn-text {
|
||||
font-size: 24rpx;
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.confirm-item {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.confirm-item-active {
|
||||
background-color: #d8eef9;
|
||||
}
|
||||
|
||||
.confirm-text {
|
||||
font-size: 26rpx;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background-color: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
@@ -1,60 +1,53 @@
|
||||
import { getDeliveryProfileByUserId, loginDelivery as loginDeliveryApi } from '@/api/delivery.uts'
|
||||
import {
|
||||
acceptDeliveryOrderById,
|
||||
arriveOrderById,
|
||||
checkinOrderById,
|
||||
finishServiceById,
|
||||
getDeliveryDashboardByStaffId,
|
||||
getDeliveryMessagesList,
|
||||
getDeliveryOrderDetailById,
|
||||
getDeliveryOrdersByStaffId,
|
||||
getDeliveryProfileByUserId,
|
||||
getDeliveryRecordsByStaffId,
|
||||
loginDelivery as loginDeliveryApi,
|
||||
rejectDeliveryOrderById,
|
||||
retryEvidenceById,
|
||||
saveServiceProgressById,
|
||||
startDepartById,
|
||||
startServiceById,
|
||||
submitExceptionById,
|
||||
updateDeliveryOnlineStatusByStaffId,
|
||||
uploadEvidenceById
|
||||
} from '@/api/delivery.uts'
|
||||
import { getDeliveryInfo, getUserInfo, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
acceptCareOrder,
|
||||
checkInCareOrder,
|
||||
completeCareOrder,
|
||||
getCareOrderDetail,
|
||||
getCareRecords,
|
||||
getDeliveryCareDashboard,
|
||||
getDeliveryCareProfile,
|
||||
getHistoryCareOrders,
|
||||
getPendingCareOrders,
|
||||
getTodayCareOrders,
|
||||
markCareOrderArrived,
|
||||
markCareOrderDeparted,
|
||||
rejectCareOrder,
|
||||
startCareService,
|
||||
submitCareAbnormalReport,
|
||||
submitCareServiceRecord,
|
||||
updateCareOrderStatus,
|
||||
updateDeliveryCareOnlineStatus
|
||||
} from '@/mock/delivery-care.mock.uts'
|
||||
import { getUserInfo, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import type {
|
||||
DeliveryAbnormalReportType,
|
||||
DeliveryCheckinPayloadType,
|
||||
DeliveryDashboardType,
|
||||
DeliveryExceptionPayloadType,
|
||||
DeliveryFinishPayloadType,
|
||||
DeliveryInfoType,
|
||||
DeliveryLocationType,
|
||||
DeliveryLoginPayloadType,
|
||||
DeliveryLoginResultType,
|
||||
DeliveryMessageType,
|
||||
DeliveryOrderQueryType,
|
||||
DeliveryOrderStatus,
|
||||
DeliveryOrderType,
|
||||
DeliveryProgressPayloadType,
|
||||
DeliveryRecordType,
|
||||
DeliveryEvidenceRecordType
|
||||
DeliveryServiceRecordType
|
||||
} from '@/types/delivery.uts'
|
||||
|
||||
function getCurrentStaffId(): string {
|
||||
const info = getDeliveryInfo()
|
||||
if (info != null) {
|
||||
return info.id
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export async function loginDelivery(payload: DeliveryLoginPayloadType): Promise<DeliveryLoginResultType> {
|
||||
return await loginDeliveryApi(payload)
|
||||
}
|
||||
|
||||
export async function getDeliveryProfile(): Promise<DeliveryInfoType | null> {
|
||||
const userInfo = getUserInfo()
|
||||
if (userInfo == null || userInfo.id == null || userInfo.id == '') {
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: false, toastOnFail: false })
|
||||
if (!authResult.ok) {
|
||||
return null
|
||||
}
|
||||
return await getDeliveryProfileByUserId(userInfo.id)
|
||||
return getDeliveryCareProfile()
|
||||
}
|
||||
|
||||
export async function getDeliveryByUserId(userId: string): Promise<DeliveryInfoType | null> {
|
||||
@@ -75,69 +68,192 @@ export async function checkDeliveryAuth(): Promise<boolean> {
|
||||
}
|
||||
|
||||
export async function getDeliveryDashboard(): Promise<DeliveryDashboardType> {
|
||||
return await getDeliveryDashboardByStaffId(getCurrentStaffId())
|
||||
return getDeliveryCareDashboard()
|
||||
}
|
||||
|
||||
export async function getDeliveryOrders(params: DeliveryOrderQueryType): Promise<Array<DeliveryOrderType>> {
|
||||
return await getDeliveryOrdersByStaffId(getCurrentStaffId(), params)
|
||||
if (params.tab == 'pending' || params.tab == 'pending_assignment' || params.tab == 'pending_accept') {
|
||||
return getPendingCareOrders()
|
||||
}
|
||||
if (params.tab == 'history' || params.tab == 'completed' || params.tab == 'archive') {
|
||||
return getHistoryCareOrders()
|
||||
}
|
||||
return getTodayCareOrders()
|
||||
}
|
||||
|
||||
export async function getDeliveryOrderDetail(id: string): Promise<DeliveryOrderType | null> {
|
||||
return await getDeliveryOrderDetailById(id)
|
||||
return getCareOrderDetail(id)
|
||||
}
|
||||
|
||||
export async function acceptDeliveryOrder(id: string): Promise<DeliveryOrderType | null> {
|
||||
return await acceptDeliveryOrderById(id)
|
||||
return acceptCareOrder(id)
|
||||
}
|
||||
|
||||
export async function rejectDeliveryOrder(id: string, reason: string): Promise<DeliveryOrderType | null> {
|
||||
return await rejectDeliveryOrderById(id, reason)
|
||||
return rejectCareOrder(id, reason)
|
||||
}
|
||||
|
||||
export async function startDepart(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
|
||||
return await startDepartById(id, location)
|
||||
const order = markCareOrderDeparted(id)
|
||||
if (order != null) {
|
||||
order.lastLocation = location
|
||||
}
|
||||
return order
|
||||
}
|
||||
|
||||
export async function arriveOrder(id: string, location: DeliveryLocationType): Promise<DeliveryOrderType | null> {
|
||||
return await arriveOrderById(id, location)
|
||||
const order = markCareOrderArrived(id)
|
||||
if (order != null) {
|
||||
order.lastLocation = location
|
||||
}
|
||||
return order
|
||||
}
|
||||
|
||||
export async function checkinOrder(id: string, payload: DeliveryCheckinPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await checkinOrderById(id, payload)
|
||||
return checkInCareOrder(id, payload.location, payload.note)
|
||||
}
|
||||
|
||||
export async function startService(id: string): Promise<DeliveryOrderType | null> {
|
||||
return await startServiceById(id)
|
||||
return startCareService(id)
|
||||
}
|
||||
|
||||
export async function saveServiceProgress(id: string, payload: DeliveryProgressPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await saveServiceProgressById(id, payload)
|
||||
const current = getCareOrderDetail(id)
|
||||
if (current == null) {
|
||||
return null
|
||||
}
|
||||
current.serviceItems = payload.items
|
||||
current.progressNote = payload.progressNote
|
||||
current.serviceSummary = payload.serviceSummary
|
||||
return current
|
||||
}
|
||||
|
||||
export async function uploadEvidence(id: string, phase: string, files: Array<string>): Promise<Array<DeliveryEvidenceRecordType>> {
|
||||
return await uploadEvidenceById(id, phase, files)
|
||||
export async function uploadEvidence(id: string, phase: string, files: Array<string>): Promise<Array<any>> {
|
||||
return files.map((item, index) => ({
|
||||
id: id + '-evidence-' + String(index + 1),
|
||||
orderId: id,
|
||||
phase,
|
||||
fileType: 'image',
|
||||
name: 'mock-image-' + String(index + 1),
|
||||
url: '',
|
||||
localPath: item,
|
||||
status: 'success',
|
||||
progress: 100,
|
||||
retryable: false,
|
||||
createdAt: new Date().toISOString().replace('T', ' ').substring(0, 19)
|
||||
})) as Array<any>
|
||||
}
|
||||
|
||||
export async function retryUploadEvidence(id: string, evidenceId: string): Promise<DeliveryEvidenceRecordType | null> {
|
||||
return await retryEvidenceById(id, evidenceId)
|
||||
export async function retryUploadEvidence(id: string, evidenceId: string): Promise<any | null> {
|
||||
return {
|
||||
id: evidenceId,
|
||||
orderId: id,
|
||||
phase: 'service',
|
||||
fileType: 'image',
|
||||
name: 'mock-retry',
|
||||
url: '',
|
||||
localPath: '',
|
||||
status: 'success',
|
||||
progress: 100,
|
||||
retryable: false,
|
||||
createdAt: new Date().toISOString().replace('T', ' ').substring(0, 19)
|
||||
} as any
|
||||
}
|
||||
|
||||
export async function submitException(id: string, payload: DeliveryExceptionPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await submitExceptionById(id, payload)
|
||||
return submitCareAbnormalReport(id, payload)
|
||||
}
|
||||
|
||||
export async function finishService(id: string, payload: DeliveryFinishPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return await finishServiceById(id, payload)
|
||||
export async function finishService(id: string): Promise<DeliveryOrderType | null> {
|
||||
return completeCareOrder(id)
|
||||
}
|
||||
|
||||
export async function getDeliveryRecords(): Promise<Array<DeliveryRecordType>> {
|
||||
return await getDeliveryRecordsByStaffId(getCurrentStaffId())
|
||||
return getCareRecords()
|
||||
}
|
||||
|
||||
export async function getDeliveryMessages(): Promise<Array<DeliveryMessageType>> {
|
||||
return await getDeliveryMessagesList()
|
||||
return [
|
||||
{
|
||||
id: 'delivery-msg-01',
|
||||
title: '今日待服务提醒',
|
||||
content: '请优先处理上午 9:00 的上门助浴订单。',
|
||||
type: 'workbench',
|
||||
createdAt: new Date().toISOString().replace('T', ' ').substring(0, 19),
|
||||
read: false,
|
||||
orderId: 'mock-care-001'
|
||||
} as DeliveryMessageType
|
||||
]
|
||||
}
|
||||
|
||||
export async function updateDeliveryOnlineStatus(status: string): Promise<DeliveryInfoType | null> {
|
||||
return await updateDeliveryOnlineStatusByStaffId(getCurrentStaffId(), status)
|
||||
if (status == 'online' || status == 'resting' || status == 'busy') {
|
||||
return updateDeliveryCareOnlineStatus(status)
|
||||
}
|
||||
return getDeliveryCareProfile()
|
||||
}
|
||||
|
||||
export async function getDeliveryDashboardStats(): Promise<DeliveryDashboardType> {
|
||||
return getDeliveryCareDashboard()
|
||||
}
|
||||
|
||||
export async function getPendingServiceOrders(): Promise<Array<DeliveryOrderType>> {
|
||||
return getPendingCareOrders()
|
||||
}
|
||||
|
||||
export async function getTodayServiceOrders(): Promise<Array<DeliveryOrderType>> {
|
||||
return getTodayCareOrders()
|
||||
}
|
||||
|
||||
export async function getHistoryServiceOrders(): Promise<Array<DeliveryOrderType>> {
|
||||
return getHistoryCareOrders()
|
||||
}
|
||||
|
||||
export async function getServiceOrderDetail(orderId: string): Promise<DeliveryOrderType | null> {
|
||||
return getCareOrderDetail(orderId)
|
||||
}
|
||||
|
||||
export async function acceptServiceOrder(orderId: string): Promise<DeliveryOrderType | null> {
|
||||
return acceptCareOrder(orderId)
|
||||
}
|
||||
|
||||
export async function rejectServiceOrder(orderId: string, reason: string): Promise<DeliveryOrderType | null> {
|
||||
return rejectCareOrder(orderId, reason)
|
||||
}
|
||||
|
||||
export async function markDeparted(orderId: string): Promise<DeliveryOrderType | null> {
|
||||
return markCareOrderDeparted(orderId)
|
||||
}
|
||||
|
||||
export async function markArrived(orderId: string): Promise<DeliveryOrderType | null> {
|
||||
return markCareOrderArrived(orderId)
|
||||
}
|
||||
|
||||
export async function checkInServiceOrder(orderId: string, note: string, location: DeliveryLocationType | null = null): Promise<DeliveryOrderType | null> {
|
||||
return checkInCareOrder(orderId, location, note)
|
||||
}
|
||||
|
||||
export async function startServiceOrder(orderId: string): Promise<DeliveryOrderType | null> {
|
||||
return startCareService(orderId)
|
||||
}
|
||||
|
||||
export async function submitServiceRecord(orderId: string, record: DeliveryServiceRecordType): Promise<DeliveryOrderType | null> {
|
||||
return submitCareServiceRecord(orderId, record)
|
||||
}
|
||||
|
||||
export async function completeServiceOrder(orderId: string): Promise<DeliveryOrderType | null> {
|
||||
return completeCareOrder(orderId)
|
||||
}
|
||||
|
||||
export async function submitAbnormalReport(orderId: string, report: DeliveryExceptionPayloadType): Promise<DeliveryOrderType | null> {
|
||||
return submitCareAbnormalReport(orderId, report)
|
||||
}
|
||||
|
||||
export async function updateOrderStatus(orderId: string, nextStatus: DeliveryOrderStatus, extraRemark: string = ''): Promise<DeliveryOrderType | null> {
|
||||
return updateCareOrderStatus(orderId, nextStatus, extraRemark)
|
||||
}
|
||||
|
||||
export async function getAbnormalReport(orderId: string): Promise<DeliveryAbnormalReportType | null> {
|
||||
const order = getCareOrderDetail(orderId)
|
||||
return order != null ? order.abnormalReport : null
|
||||
}
|
||||
130
sql/medical_mall_product_category_first_batch.sql
Normal file
130
sql/medical_mall_product_category_first_batch.sql
Normal file
@@ -0,0 +1,130 @@
|
||||
-- 医疗商城首批商品分类映射
|
||||
-- 用途:为 seed_medical_homepage_data.sql 中的首批医疗商品写入正式分类关联
|
||||
-- 前提:已执行 20260521_medical_mall_categories_v1.sql
|
||||
|
||||
BEGIN;
|
||||
|
||||
-- 1. 主分类映射
|
||||
INSERT INTO public.medical_mall_product_categories (
|
||||
product_id,
|
||||
category_id,
|
||||
is_primary,
|
||||
sort_order,
|
||||
created_at
|
||||
)
|
||||
SELECT p.id, mapping.category_id, TRUE, mapping.sort_order, NOW()
|
||||
FROM public.ml_products p
|
||||
JOIN (
|
||||
VALUES
|
||||
('家庭退热护理贴', 'cold_fever', 10),
|
||||
('草本暖胃调理贴', 'tcm_patch', 20),
|
||||
('智能血压监测仪', 'blood_pressure_monitor', 30),
|
||||
('静音雾化护理机', 'nebulizer', 40),
|
||||
('高钙维D营养片', 'calcium', 50),
|
||||
('乳清蛋白营养粉', 'protein', 60),
|
||||
('术后支撑恢复带', 'postop_rehab', 70),
|
||||
('无菌伤口护理包', 'wound_dressing', 80),
|
||||
('家用艾灸温灸盒', 'moxibustion', 90),
|
||||
('肩颈草本热敷贴', 'tcm_patch', 100),
|
||||
('折叠助行辅助器', 'wheelchair_crutch', 110),
|
||||
('浴室防滑扶手套装', 'elderly_bathroom', 120)
|
||||
) AS mapping(product_name, category_id, sort_order)
|
||||
ON p.name = mapping.product_name
|
||||
WHERE p.status = '1'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET
|
||||
is_primary = EXCLUDED.is_primary,
|
||||
sort_order = EXCLUDED.sort_order,
|
||||
deleted_at = NULL;
|
||||
|
||||
-- 2. 扩展分类映射
|
||||
INSERT INTO public.medical_mall_product_categories (
|
||||
product_id,
|
||||
category_id,
|
||||
is_primary,
|
||||
sort_order,
|
||||
created_at
|
||||
)
|
||||
SELECT p.id, mapping.category_id, FALSE, mapping.sort_order, NOW()
|
||||
FROM public.ml_products p
|
||||
JOIN (
|
||||
VALUES
|
||||
('家庭退热护理贴', 'child_medicine', 210),
|
||||
('草本暖胃调理贴', 'physiotherapy_hot', 220),
|
||||
('智能血压监测仪', 'hypertension', 230),
|
||||
('静音雾化护理机', 'respiratory_health', 240),
|
||||
('高钙维D营养片', 'vitamin', 250),
|
||||
('乳清蛋白营养粉', 'immune_support', 260),
|
||||
('术后支撑恢复带', 'brace_support', 270),
|
||||
('无菌伤口护理包', 'wound_care', 280),
|
||||
('家用艾灸温灸盒', 'physiotherapy_hot', 290),
|
||||
('肩颈草本热敷贴', 'physiotherapy_hot', 300),
|
||||
('折叠助行辅助器', 'daily_living_aid', 310),
|
||||
('浴室防滑扶手套装', 'anti_slip', 320)
|
||||
) AS mapping(product_name, category_id, sort_order)
|
||||
ON p.name = mapping.product_name
|
||||
WHERE p.status = '1'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET
|
||||
is_primary = EXCLUDED.is_primary,
|
||||
sort_order = EXCLUDED.sort_order,
|
||||
deleted_at = NULL;
|
||||
|
||||
-- 3. 清理这些商品可能存在的重复主分类
|
||||
WITH duplicate_primary AS (
|
||||
SELECT
|
||||
mmc.id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY mmc.product_id
|
||||
ORDER BY mmc.sort_order ASC, mmc.created_at ASC, mmc.id ASC
|
||||
) AS row_num
|
||||
FROM public.medical_mall_product_categories mmc
|
||||
JOIN public.ml_products p ON p.id = mmc.product_id
|
||||
WHERE mmc.deleted_at IS NULL
|
||||
AND mmc.is_primary = TRUE
|
||||
AND p.name IN (
|
||||
'家庭退热护理贴',
|
||||
'草本暖胃调理贴',
|
||||
'智能血压监测仪',
|
||||
'静音雾化护理机',
|
||||
'高钙维D营养片',
|
||||
'乳清蛋白营养粉',
|
||||
'术后支撑恢复带',
|
||||
'无菌伤口护理包',
|
||||
'家用艾灸温灸盒',
|
||||
'肩颈草本热敷贴',
|
||||
'折叠助行辅助器',
|
||||
'浴室防滑扶手套装'
|
||||
)
|
||||
)
|
||||
UPDATE public.medical_mall_product_categories mmc
|
||||
SET deleted_at = NOW()
|
||||
FROM duplicate_primary dp
|
||||
WHERE mmc.id = dp.id
|
||||
AND dp.row_num > 1;
|
||||
|
||||
-- 4. 校验结果
|
||||
SELECT
|
||||
p.product_code,
|
||||
p.name,
|
||||
STRING_AGG(mmc.category_id || CASE WHEN mmc.is_primary THEN ' [P]' ELSE '' END, ', ' ORDER BY mmc.is_primary DESC, mmc.sort_order ASC) AS mapped_categories
|
||||
FROM public.ml_products p
|
||||
LEFT JOIN public.medical_mall_product_categories mmc
|
||||
ON mmc.product_id = p.id
|
||||
AND mmc.deleted_at IS NULL
|
||||
WHERE p.name IN (
|
||||
'家庭退热护理贴',
|
||||
'草本暖胃调理贴',
|
||||
'智能血压监测仪',
|
||||
'静音雾化护理机',
|
||||
'高钙维D营养片',
|
||||
'乳清蛋白营养粉',
|
||||
'术后支撑恢复带',
|
||||
'无菌伤口护理包',
|
||||
'家用艾灸温灸盒',
|
||||
'肩颈草本热敷贴',
|
||||
'折叠助行辅助器',
|
||||
'浴室防滑扶手套装'
|
||||
)
|
||||
GROUP BY p.product_code, p.name
|
||||
ORDER BY p.product_code ASC;
|
||||
|
||||
COMMIT;
|
||||
197
sql/medical_mall_product_category_manual_mapping_template.sql
Normal file
197
sql/medical_mall_product_category_manual_mapping_template.sql
Normal file
@@ -0,0 +1,197 @@
|
||||
-- 医疗商城商品分类手工映射模板
|
||||
-- 用途:批量补齐 public.medical_mall_product_categories 的真实数据
|
||||
-- 前提:已执行 20260521_medical_mall_categories_v1.sql 或拆分版 schema + RLS + seed
|
||||
|
||||
BEGIN;
|
||||
|
||||
-- 1. 查看当前未映射商品
|
||||
SELECT
|
||||
p.id,
|
||||
p.name,
|
||||
p.product_code,
|
||||
p.subtitle,
|
||||
p.category_id,
|
||||
p.status,
|
||||
p.created_at
|
||||
FROM public.ml_products p
|
||||
LEFT JOIN public.medical_mall_product_categories mmc
|
||||
ON mmc.product_id = p.id
|
||||
AND mmc.deleted_at IS NULL
|
||||
WHERE p.status = '1'
|
||||
AND mmc.product_id IS NULL
|
||||
ORDER BY p.created_at DESC;
|
||||
|
||||
-- 1.1 按商品名/编码查 UUID
|
||||
-- 用途:先定位商品 UUID,再回填到下面的手工映射段。
|
||||
SELECT
|
||||
p.id,
|
||||
p.product_code,
|
||||
p.name,
|
||||
p.subtitle,
|
||||
p.sale_count,
|
||||
p.created_at
|
||||
FROM public.ml_products p
|
||||
WHERE p.status = '1'
|
||||
AND FALSE
|
||||
-- 示例:AND (p.name ILIKE '%血压计%' OR p.product_code = 'BP001')
|
||||
ORDER BY p.sale_count DESC, p.created_at DESC;
|
||||
|
||||
-- 2. 插入主分类映射
|
||||
-- 建议:每个商品只保留 1 条 is_primary = true
|
||||
-- 默认使用 WHERE FALSE 保持模板可执行;填入真实数据后,删除 WHERE FALSE 即可。
|
||||
INSERT INTO public.medical_mall_product_categories (
|
||||
product_id,
|
||||
category_id,
|
||||
is_primary,
|
||||
sort_order,
|
||||
created_at
|
||||
)
|
||||
SELECT *
|
||||
FROM (
|
||||
VALUES
|
||||
('00000000-0000-0000-0000-000000000000'::uuid, 'blood_pressure_monitor', TRUE, 10, NOW())
|
||||
-- 示例:, ('商品UUID'::uuid, 'nebulizer', TRUE, 10, NOW())
|
||||
-- 示例:, ('商品UUID'::uuid, 'wound_care', TRUE, 20, NOW())
|
||||
) AS seed_rows(product_id, category_id, is_primary, sort_order, created_at)
|
||||
WHERE FALSE
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET
|
||||
is_primary = EXCLUDED.is_primary,
|
||||
sort_order = EXCLUDED.sort_order,
|
||||
deleted_at = NULL;
|
||||
|
||||
-- 2.1 直接按商品名/编码插入主分类映射
|
||||
-- 用途:不手填 UUID,直接从 ml_products 查出商品后写入映射。
|
||||
INSERT INTO public.medical_mall_product_categories (
|
||||
product_id,
|
||||
category_id,
|
||||
is_primary,
|
||||
sort_order,
|
||||
created_at
|
||||
)
|
||||
SELECT
|
||||
p.id,
|
||||
'blood_pressure_monitor',
|
||||
TRUE,
|
||||
10,
|
||||
NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.status = '1'
|
||||
AND FALSE
|
||||
-- 示例:AND (p.name ILIKE '%血压计%' OR p.product_code = 'BP001')
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET
|
||||
is_primary = EXCLUDED.is_primary,
|
||||
sort_order = EXCLUDED.sort_order,
|
||||
deleted_at = NULL;
|
||||
|
||||
-- 3. 插入扩展分类映射
|
||||
-- 默认使用 WHERE FALSE 保持模板可执行;填入真实数据后,删除 WHERE FALSE 即可。
|
||||
INSERT INTO public.medical_mall_product_categories (
|
||||
product_id,
|
||||
category_id,
|
||||
is_primary,
|
||||
sort_order,
|
||||
created_at
|
||||
)
|
||||
SELECT *
|
||||
FROM (
|
||||
VALUES
|
||||
('00000000-0000-0000-0000-000000000000'::uuid, 'hypertension', FALSE, 30, NOW())
|
||||
-- 示例:, ('商品UUID'::uuid, 'elderly_bathroom', FALSE, 30, NOW())
|
||||
) AS extra_rows(product_id, category_id, is_primary, sort_order, created_at)
|
||||
WHERE FALSE
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET
|
||||
is_primary = EXCLUDED.is_primary,
|
||||
sort_order = EXCLUDED.sort_order,
|
||||
deleted_at = NULL;
|
||||
|
||||
-- 3.1 直接按商品名/编码插入扩展分类映射
|
||||
INSERT INTO public.medical_mall_product_categories (
|
||||
product_id,
|
||||
category_id,
|
||||
is_primary,
|
||||
sort_order,
|
||||
created_at
|
||||
)
|
||||
SELECT
|
||||
p.id,
|
||||
'hypertension',
|
||||
FALSE,
|
||||
30,
|
||||
NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.status = '1'
|
||||
AND FALSE
|
||||
-- 示例:AND (p.name ILIKE '%电子血压计%' OR p.product_code = 'BP001')
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET
|
||||
is_primary = EXCLUDED.is_primary,
|
||||
sort_order = EXCLUDED.sort_order,
|
||||
deleted_at = NULL;
|
||||
|
||||
-- 4. 软删除错误映射
|
||||
UPDATE public.medical_mall_product_categories
|
||||
SET deleted_at = NOW()
|
||||
WHERE deleted_at IS NULL
|
||||
AND (
|
||||
-- 示例:product_id = '商品UUID' AND category_id = '错误分类ID'
|
||||
FALSE
|
||||
);
|
||||
|
||||
-- 5. 检查是否存在多个主分类
|
||||
SELECT
|
||||
product_id,
|
||||
COUNT(*) AS primary_count
|
||||
FROM public.medical_mall_product_categories
|
||||
WHERE deleted_at IS NULL
|
||||
AND is_primary = TRUE
|
||||
GROUP BY product_id
|
||||
HAVING COUNT(*) > 1;
|
||||
|
||||
-- 6. 查看分类覆盖情况
|
||||
SELECT
|
||||
c.id AS category_id,
|
||||
c.name AS category_name,
|
||||
COUNT(mmc.product_id) AS mapped_products
|
||||
FROM public.medical_mall_categories c
|
||||
LEFT JOIN public.medical_mall_product_categories mmc
|
||||
ON mmc.category_id = c.id
|
||||
AND mmc.deleted_at IS NULL
|
||||
WHERE c.deleted_at IS NULL
|
||||
GROUP BY c.id, c.name, c.sort_order
|
||||
ORDER BY c.sort_order ASC, c.id ASC;
|
||||
|
||||
-- 7. 查看仍依赖 fallback 风险较高的商品
|
||||
SELECT
|
||||
p.id,
|
||||
p.name,
|
||||
p.subtitle,
|
||||
p.sale_count,
|
||||
p.created_at
|
||||
FROM public.ml_products p
|
||||
LEFT JOIN public.medical_mall_product_categories mmc
|
||||
ON mmc.product_id = p.id
|
||||
AND mmc.deleted_at IS NULL
|
||||
WHERE p.status = '1'
|
||||
AND mmc.product_id IS NULL
|
||||
AND (
|
||||
p.name ILIKE '%血压%' OR
|
||||
p.name ILIKE '%血糖%' OR
|
||||
p.name ILIKE '%血氧%' OR
|
||||
p.name ILIKE '%体温%' OR
|
||||
p.name ILIKE '%雾化%' OR
|
||||
p.name ILIKE '%制氧%' OR
|
||||
p.name ILIKE '%轮椅%' OR
|
||||
p.name ILIKE '%拐杖%' OR
|
||||
p.name ILIKE '%护理床%' OR
|
||||
p.name ILIKE '%感冒%' OR
|
||||
p.name ILIKE '%退热%' OR
|
||||
p.name ILIKE '%创可贴%' OR
|
||||
p.name ILIKE '%纱布%' OR
|
||||
p.name ILIKE '%钙片%' OR
|
||||
p.name ILIKE '%维生素%' OR
|
||||
p.name ILIKE '%蛋白%' OR
|
||||
p.name ILIKE '%艾灸%' OR
|
||||
p.name ILIKE '%热敷%'
|
||||
)
|
||||
ORDER BY p.sale_count DESC, p.created_at DESC;
|
||||
|
||||
COMMIT;
|
||||
576
sql/seed_medical_homepage_data.sql
Normal file
576
sql/seed_medical_homepage_data.sql
Normal file
@@ -0,0 +1,576 @@
|
||||
-- 医疗项目首页种子数据
|
||||
-- 目标:补齐首页分类栏 + 首页商品流所需的基础数据
|
||||
-- 适用:public.ml_categories / public.ml_brands / public.ml_products / public.ml_shops / public.ak_users
|
||||
-- 说明:
|
||||
-- 1. 首页分类栏读取 ml_categories
|
||||
-- 2. 首页商品流主要读取 ml_products_detail_view(底层为 ml_products 联表)
|
||||
-- 3. 本脚本可重复执行,使用固定 UUID + ON CONFLICT 保持幂等
|
||||
-- 4. 服务首页当前仍是本地 mock,本脚本只覆盖“商城首页”数据
|
||||
|
||||
BEGIN;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
v_has_role BOOLEAN := FALSE;
|
||||
v_has_email BOOLEAN := FALSE;
|
||||
v_has_username BOOLEAN := FALSE;
|
||||
v_has_phone BOOLEAN := FALSE;
|
||||
v_has_avatar_url BOOLEAN := FALSE;
|
||||
v_has_status BOOLEAN := FALSE;
|
||||
v_has_registration_source BOOLEAN := FALSE;
|
||||
v_has_nickname BOOLEAN := FALSE;
|
||||
v_has_real_name BOOLEAN := FALSE;
|
||||
v_has_created_at BOOLEAN := FALSE;
|
||||
v_has_updated_at BOOLEAN := FALSE;
|
||||
v_cols TEXT;
|
||||
v_vals TEXT;
|
||||
v_index INTEGER;
|
||||
v_merchant_ids UUID[] := ARRAY[
|
||||
'5f0e7c4d-7c8a-4f6f-9a16-100000000001'::uuid,
|
||||
'5f0e7c4d-7c8a-4f6f-9a16-100000000002'::uuid,
|
||||
'5f0e7c4d-7c8a-4f6f-9a16-100000000003'::uuid,
|
||||
'5f0e7c4d-7c8a-4f6f-9a16-100000000004'::uuid,
|
||||
'5f0e7c4d-7c8a-4f6f-9a16-100000000005'::uuid,
|
||||
'5f0e7c4d-7c8a-4f6f-9a16-100000000006'::uuid
|
||||
];
|
||||
v_usernames TEXT[] := ARRAY['医疗首页商家01', '医疗首页商家02', '医疗首页商家03', '医疗首页商家04', '医疗首页商家05', '医疗首页商家06'];
|
||||
v_nicknames TEXT[] := ARRAY['康养精选商家', '慢病管理商家', '营养保健商家', '康复护理商家', '本草调理商家', '银龄照护商家'];
|
||||
v_real_names TEXT[] := ARRAY['康养医疗馆', '慢病健康馆', '营养优选馆', '康复护理馆', '本草调理馆', '银龄照护馆'];
|
||||
v_emails TEXT[] := ARRAY['seed.medical.home01@local.test', 'seed.medical.home02@local.test', 'seed.medical.home03@local.test', 'seed.medical.home04@local.test', 'seed.medical.home05@local.test', 'seed.medical.home06@local.test'];
|
||||
v_phones TEXT[] := ARRAY['13900000001', '13900000002', '13900000003', '13900000004', '13900000005', '13900000006'];
|
||||
BEGIN
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'role'
|
||||
) INTO v_has_role;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'email'
|
||||
) INTO v_has_email;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'username'
|
||||
) INTO v_has_username;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'phone'
|
||||
) INTO v_has_phone;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'avatar_url'
|
||||
) INTO v_has_avatar_url;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'status'
|
||||
) INTO v_has_status;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'registration_source'
|
||||
) INTO v_has_registration_source;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'nickname'
|
||||
) INTO v_has_nickname;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'real_name'
|
||||
) INTO v_has_real_name;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'created_at'
|
||||
) INTO v_has_created_at;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'ak_users' AND column_name = 'updated_at'
|
||||
) INTO v_has_updated_at;
|
||||
|
||||
FOR v_index IN 1..array_length(v_merchant_ids, 1) LOOP
|
||||
v_cols := 'id';
|
||||
v_vals := quote_literal(v_merchant_ids[v_index]::text) || '::uuid';
|
||||
|
||||
IF v_has_email THEN
|
||||
v_cols := v_cols || ', email';
|
||||
v_vals := v_vals || ', ' || quote_literal(v_emails[v_index]);
|
||||
END IF;
|
||||
|
||||
IF v_has_username THEN
|
||||
v_cols := v_cols || ', username';
|
||||
v_vals := v_vals || ', ' || quote_literal(v_usernames[v_index]);
|
||||
END IF;
|
||||
|
||||
IF v_has_nickname THEN
|
||||
v_cols := v_cols || ', nickname';
|
||||
v_vals := v_vals || ', ' || quote_literal(v_nicknames[v_index]);
|
||||
END IF;
|
||||
|
||||
IF v_has_real_name THEN
|
||||
v_cols := v_cols || ', real_name';
|
||||
v_vals := v_vals || ', ' || quote_literal(v_real_names[v_index]);
|
||||
END IF;
|
||||
|
||||
IF v_has_role THEN
|
||||
v_cols := v_cols || ', role';
|
||||
v_vals := v_vals || ', ''merchant''';
|
||||
END IF;
|
||||
|
||||
IF v_has_phone THEN
|
||||
v_cols := v_cols || ', phone';
|
||||
v_vals := v_vals || ', ' || quote_literal(v_phones[v_index]);
|
||||
END IF;
|
||||
|
||||
IF v_has_avatar_url THEN
|
||||
v_cols := v_cols || ', avatar_url';
|
||||
v_vals := v_vals || ', ' || quote_literal('https://picsum.photos/seed/medical-merchant-avatar-' || v_index::text || '/240/240');
|
||||
END IF;
|
||||
|
||||
IF v_has_status THEN
|
||||
v_cols := v_cols || ', status';
|
||||
v_vals := v_vals || ', ''active''';
|
||||
END IF;
|
||||
|
||||
IF v_has_registration_source THEN
|
||||
v_cols := v_cols || ', registration_source';
|
||||
v_vals := v_vals || ', ''seed''';
|
||||
END IF;
|
||||
|
||||
IF v_has_created_at THEN
|
||||
v_cols := v_cols || ', created_at';
|
||||
v_vals := v_vals || ', NOW()';
|
||||
END IF;
|
||||
|
||||
IF v_has_updated_at THEN
|
||||
v_cols := v_cols || ', updated_at';
|
||||
v_vals := v_vals || ', NOW()';
|
||||
END IF;
|
||||
|
||||
EXECUTE 'INSERT INTO public.ak_users (' || v_cols || ') VALUES (' || v_vals || ') ON CONFLICT (id) DO NOTHING';
|
||||
END LOOP;
|
||||
END $$;
|
||||
|
||||
INSERT INTO public.ml_shops (
|
||||
merchant_id,
|
||||
shop_name,
|
||||
shop_logo,
|
||||
description,
|
||||
contact_name,
|
||||
contact_phone,
|
||||
status,
|
||||
product_count,
|
||||
rating_avg,
|
||||
rating_count,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
VALUES
|
||||
('5f0e7c4d-7c8a-4f6f-9a16-100000000001', '康养医疗精选馆', 'https://picsum.photos/seed/medical-shop-logo-01/320/320', '主打家庭常备药与家用监测器械。', '康养精选商家', '13900000001', 1, 10, 4.8, 268, NOW(), NOW()),
|
||||
('5f0e7c4d-7c8a-4f6f-9a16-100000000002', '安心慢病管理馆', 'https://picsum.photos/seed/medical-shop-logo-02/320/320', '覆盖慢病监测、呼吸护理与居家健康管理。', '慢病管理商家', '13900000002', 1, 10, 4.7, 196, NOW(), NOW()),
|
||||
('5f0e7c4d-7c8a-4f6f-9a16-100000000003', '益寿营养保健馆', 'https://picsum.photos/seed/medical-shop-logo-03/320/320', '面向骨骼营养、免疫支持与恢复期补充。', '营养保健商家', '13900000003', 1, 10, 4.8, 212, NOW(), NOW()),
|
||||
('5f0e7c4d-7c8a-4f6f-9a16-100000000004', '术后康复护理馆', 'https://picsum.photos/seed/medical-shop-logo-04/320/320', '提供术后恢复、伤口护理和家庭康复用品。', '康复护理商家', '13900000004', 1, 10, 4.9, 184, NOW(), NOW()),
|
||||
('5f0e7c4d-7c8a-4f6f-9a16-100000000005', '本草理疗调养馆', 'https://picsum.photos/seed/medical-shop-logo-05/320/320', '主打艾灸理疗、草本贴敷和中式调理商品。', '本草调理商家', '13900000005', 1, 10, 4.7, 173, NOW(), NOW()),
|
||||
('5f0e7c4d-7c8a-4f6f-9a16-100000000006', '银龄居家照护馆', 'https://picsum.photos/seed/medical-shop-logo-06/320/320', '覆盖长者行动辅助和居家安全防护商品。', '银龄照护商家', '13900000006', 1, 10, 4.8, 205, NOW(), NOW())
|
||||
ON CONFLICT (merchant_id) DO UPDATE SET
|
||||
shop_name = EXCLUDED.shop_name,
|
||||
shop_logo = EXCLUDED.shop_logo,
|
||||
description = EXCLUDED.description,
|
||||
contact_name = EXCLUDED.contact_name,
|
||||
contact_phone = EXCLUDED.contact_phone,
|
||||
status = EXCLUDED.status,
|
||||
product_count = EXCLUDED.product_count,
|
||||
rating_avg = EXCLUDED.rating_avg,
|
||||
rating_count = EXCLUDED.rating_count,
|
||||
updated_at = NOW();
|
||||
|
||||
INSERT INTO public.ml_brands (id, name, logo_url, description, website, is_active, created_at, updated_at)
|
||||
VALUES
|
||||
('6f0e7c4d-7c8a-4f6f-9a16-200000000001', '康宁健康', 'https://picsum.photos/seed/brand-kangning/240/240', '家庭医疗器械与健康监测品牌', 'https://example.com/brands/kangning', TRUE, NOW(), NOW()),
|
||||
('6f0e7c4d-7c8a-4f6f-9a16-200000000002', '益寿本草', 'https://picsum.photos/seed/brand-yishou/240/240', '中医调理与养护品牌', 'https://example.com/brands/yishou', TRUE, NOW(), NOW()),
|
||||
('6f0e7c4d-7c8a-4f6f-9a16-200000000003', '安护优选', 'https://picsum.photos/seed/brand-anhu/240/240', '康复护理与长者照护品牌', 'https://example.com/brands/anhu', TRUE, NOW(), NOW()),
|
||||
('6f0e7c4d-7c8a-4f6f-9a16-200000000004', '呼吸康泰', 'https://picsum.photos/seed/brand-huxi/240/240', '呼吸护理与慢病监测设备品牌', 'https://example.com/brands/huxi', TRUE, NOW(), NOW()),
|
||||
('6f0e7c4d-7c8a-4f6f-9a16-200000000005', '乐龄守护', 'https://picsum.photos/seed/brand-laoling/240/240', '银龄照护与辅助出行品牌', 'https://example.com/brands/laoling', TRUE, NOW(), NOW()),
|
||||
('6f0e7c4d-7c8a-4f6f-9a16-200000000006', '家庭医伴', 'https://picsum.photos/seed/brand-yiban/240/240', '家庭常备药与日用健康用品品牌', 'https://example.com/brands/yiban', TRUE, NOW(), NOW())
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
name = EXCLUDED.name,
|
||||
logo_url = EXCLUDED.logo_url,
|
||||
description = EXCLUDED.description,
|
||||
website = EXCLUDED.website,
|
||||
is_active = EXCLUDED.is_active,
|
||||
updated_at = NOW();
|
||||
|
||||
INSERT INTO public.ml_categories (
|
||||
id, parent_id, name, slug, description, icon_url, banner_url, sort_order, level, path, is_active, seo_title, seo_description, created_at, updated_at
|
||||
)
|
||||
VALUES
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000001', NULL, '常用药品', 'medical-common-medicine', '面向家庭常备、感冒发热、肠胃不适等常见场景的药品分类', 'https://picsum.photos/seed/cat-common-med/200/200', 'https://picsum.photos/seed/cat-common-med-banner/1200/400', 10, 1, ARRAY['常用药品'], TRUE, '常用药品分类', '家庭常备药、感冒发热、肠胃常用药', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000002', NULL, '医疗器械', 'medical-devices', '覆盖血压计、血糖仪、雾化器等家庭监测设备', 'https://picsum.photos/seed/cat-devices/200/200', 'https://picsum.photos/seed/cat-devices-banner/1200/400', 20, 1, ARRAY['医疗器械'], TRUE, '医疗器械分类', '血压计、血糖仪、雾化器等家庭器械', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000003', NULL, '营养保健', 'nutrition-care', '适合免疫增强、骨关节与长者营养补充的保健类商品', 'https://picsum.photos/seed/cat-nutrition/200/200', 'https://picsum.photos/seed/cat-nutrition-banner/1200/400', 30, 1, ARRAY['营养保健'], TRUE, '营养保健分类', '蛋白粉、钙片、维生素等营养保健品', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000004', NULL, '康复护理', 'rehab-care', '适合术后恢复、慢病管理和家庭护理的康复用品', 'https://picsum.photos/seed/cat-rehab/200/200', 'https://picsum.photos/seed/cat-rehab-banner/1200/400', 40, 1, ARRAY['康复护理'], TRUE, '康复护理分类', '术后恢复、压疮护理、日常护理用品', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000005', NULL, '中医调理', 'tcm-care', '包含理疗贴、艾灸养护和中式调理产品', 'https://picsum.photos/seed/cat-tcm/200/200', 'https://picsum.photos/seed/cat-tcm-banner/1200/400', 50, 1, ARRAY['中医调理'], TRUE, '中医调理分类', '艾灸、穴位贴、草本调理产品', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000006', NULL, '老年照护', 'elder-care', '适合长者居家照护、安全防护和辅助生活的商品', 'https://picsum.photos/seed/cat-elder/200/200', 'https://picsum.photos/seed/cat-elder-banner/1200/400', 60, 1, ARRAY['老年照护'], TRUE, '老年照护分类', '轮椅、助行器、防跌用品等长者照护商品', NOW(), NOW()),
|
||||
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000101', '7f0e7c4d-7c8a-4f6f-9a16-300000000001', '感冒发热', 'cold-fever', '退热、止痛、感冒常备药', 'https://picsum.photos/seed/sub-cold-fever/200/200', NULL, 11, 2, ARRAY['常用药品','感冒发热'], TRUE, '感冒发热用药', '适用于家庭常备的感冒发热场景', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000102', '7f0e7c4d-7c8a-4f6f-9a16-300000000001', '肠胃调理', 'digestive-care', '适合肠胃不适和日常调理', 'https://picsum.photos/seed/sub-digestive/200/200', NULL, 12, 2, ARRAY['常用药品','肠胃调理'], TRUE, '肠胃调理用药', '肠胃调理及胃肠不适场景用药', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000201', '7f0e7c4d-7c8a-4f6f-9a16-300000000002', '血压监测', 'blood-pressure-monitoring', '家庭血压监测设备', 'https://picsum.photos/seed/sub-bp/200/200', NULL, 21, 2, ARRAY['医疗器械','血压监测'], TRUE, '血压监测设备', '适用于家庭与长者的血压监测设备', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000202', '7f0e7c4d-7c8a-4f6f-9a16-300000000002', '呼吸理疗', 'respiratory-care', '雾化与呼吸辅助设备', 'https://picsum.photos/seed/sub-respiratory/200/200', NULL, 22, 2, ARRAY['医疗器械','呼吸理疗'], TRUE, '呼吸理疗设备', '雾化器、制氧及呼吸辅助商品', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000301', '7f0e7c4d-7c8a-4f6f-9a16-300000000003', '骨骼营养', 'bone-nutrition', '钙、维生素 D 等骨骼关节营养商品', 'https://picsum.photos/seed/sub-bone/200/200', NULL, 31, 2, ARRAY['营养保健','骨骼营养'], TRUE, '骨骼营养补充', '适合中老年与骨骼健康场景', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000302', '7f0e7c4d-7c8a-4f6f-9a16-300000000003', '免疫支持', 'immune-support', '蛋白、维生素与免疫支持产品', 'https://picsum.photos/seed/sub-immune/200/200', NULL, 32, 2, ARRAY['营养保健','免疫支持'], TRUE, '免疫支持营养', '适合日常营养补充与免疫支持', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000401', '7f0e7c4d-7c8a-4f6f-9a16-300000000004', '术后恢复', 'post-surgery-recovery', '适用于术后恢复阶段的护理产品', 'https://picsum.photos/seed/sub-postop/200/200', NULL, 41, 2, ARRAY['康复护理','术后恢复'], TRUE, '术后恢复护理', '术后康复、恢复期护理场景', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000402', '7f0e7c4d-7c8a-4f6f-9a16-300000000004', '伤口护理', 'wound-care', '敷料、护理包和伤口辅助用品', 'https://picsum.photos/seed/sub-wound/200/200', NULL, 42, 2, ARRAY['康复护理','伤口护理'], TRUE, '伤口护理用品', '家庭和术后伤口护理场景用品', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000501', '7f0e7c4d-7c8a-4f6f-9a16-300000000005', '艾灸理疗', 'moxa-therapy', '艾灸盒、艾条和温灸护理商品', 'https://picsum.photos/seed/sub-moxa/200/200', NULL, 51, 2, ARRAY['中医调理','艾灸理疗'], TRUE, '艾灸理疗用品', '家庭艾灸、温灸理疗商品', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000502', '7f0e7c4d-7c8a-4f6f-9a16-300000000005', '草本贴敷', 'herbal-patch', '草本热敷、穴位贴与理疗贴', 'https://picsum.photos/seed/sub-herbal-patch/200/200', NULL, 52, 2, ARRAY['中医调理','草本贴敷'], TRUE, '草本贴敷用品', '肩颈腰腿舒缓与理疗贴类商品', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000601', '7f0e7c4d-7c8a-4f6f-9a16-300000000006', '行动辅助', 'mobility-aid', '轮椅、助行器和起身辅助用品', 'https://picsum.photos/seed/sub-mobility/200/200', NULL, 61, 2, ARRAY['老年照护','行动辅助'], TRUE, '行动辅助用品', '长者安全出行与行动辅助商品', NOW(), NOW()),
|
||||
('7f0e7c4d-7c8a-4f6f-9a16-300000000602', '7f0e7c4d-7c8a-4f6f-9a16-300000000006', '居家防护', 'home-safety', '防滑、防跌和床旁安全辅助用品', 'https://picsum.photos/seed/sub-home-safety/200/200', NULL, 62, 2, ARRAY['老年照护','居家防护'], TRUE, '居家防护用品', '适合长者家庭安全防护场景', NOW(), NOW())
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
parent_id = EXCLUDED.parent_id,
|
||||
name = EXCLUDED.name,
|
||||
slug = EXCLUDED.slug,
|
||||
description = EXCLUDED.description,
|
||||
icon_url = EXCLUDED.icon_url,
|
||||
banner_url = EXCLUDED.banner_url,
|
||||
sort_order = EXCLUDED.sort_order,
|
||||
level = EXCLUDED.level,
|
||||
path = EXCLUDED.path,
|
||||
is_active = EXCLUDED.is_active,
|
||||
seo_title = EXCLUDED.seo_title,
|
||||
seo_description = EXCLUDED.seo_description,
|
||||
updated_at = NOW();
|
||||
|
||||
WITH seed_templates AS (
|
||||
SELECT *
|
||||
FROM (
|
||||
VALUES
|
||||
(1, '5f0e7c4d-7c8a-4f6f-9a16-100000000001'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000006'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000101'::uuid, '家庭退热护理贴', '家庭常备退热护理,适合儿童与成人', '常用药品', 29.90, 4.50, 0.12, ARRAY['退热护理','家庭常备','首页推荐']::text[], '8片/盒', '直接贴敷于额头或太阳穴附近', '皮肤破损处慎用', '24个月', '阴凉干燥处保存', '粤械注准20261', '夜间应急降温与陪护', '儿童发热、成人低烧与家庭药箱场景', '家庭药箱、值班陪护、夜间临时应对', '贴敷型物理护理,不占用口服用药节奏'),
|
||||
(2, '5f0e7c4d-7c8a-4f6f-9a16-100000000001'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000006'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000102'::uuid, '草本暖胃调理贴', '腹部热敷舒缓,适合肠胃日常调理', '常用药品', 42.00, 5.00, 0.10, ARRAY['肠胃调理','草本贴敷','居家护理']::text[], '6贴/盒', '贴于腹部不适区域,每次4至6小时', '避免高温环境使用', '24个月', '阴凉处保存', '粤械注准20262', '餐后腹部热敷与换季调理', '久坐人群、饮食不规律人群与女性日常护理', '办公室抽屉、宿舍常备、出差随身护理', '贴敷型胃腹护理,更适合连续日常使用'),
|
||||
(3, '5f0e7c4d-7c8a-4f6f-9a16-100000000002'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000001'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000201'::uuid, '智能血压监测仪', '语音播报与大屏显示,适合居家监测', '医疗器械', 199.00, 18.00, 0.85, ARRAY['血压监测','家用器械','老人适用']::text[], '1台/盒', '绑好袖带后按开始键测量', '测量前请静坐5分钟', '长期', '干燥处保存', '粤械注准20263', '居家晨晚双时段血压记录', '长者家庭、慢病管理用户与社区随访场景', '卧室床头、客厅药柜、社区义诊随身箱', '适合作为家庭监测主设备,强调读数稳定和易读性'),
|
||||
(4, '5f0e7c4d-7c8a-4f6f-9a16-100000000002'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000004'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000202'::uuid, '静音雾化护理机', '家庭呼吸理疗,适合儿童与长者', '医疗器械', 239.00, 22.00, 1.20, ARRAY['呼吸护理','静音雾化','家庭理疗']::text[], '1台/盒', '加注溶液后按说明启动', '使用后及时清洁雾化杯', '长期', '干燥处保存', '粤械注准20264', '换季敏感期与夜间呼吸护理', '儿童鼻咽不适、长者呼吸护理与家庭理疗用户', '床旁护理区、儿童房、家庭护理角', '雾化颗粒更细,适合家庭安静环境连续使用'),
|
||||
(5, '5f0e7c4d-7c8a-4f6f-9a16-100000000003'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000002'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000301'::uuid, '高钙维D营养片', '骨骼营养补充,适合中老年日常使用', '营养保健', 79.00, 7.00, 0.28, ARRAY['骨骼营养','维D补充','长者营养']::text[], '60片/瓶', '每日1至2片,咀嚼后吞服', '勿超过推荐量服用', '24个月', '阴凉干燥处保存', '食健备G20265', '骨骼基础营养与长期补给', '中老年、久坐办公族与骨密度关注人群', '早餐后补充、家庭常备营养角、长周期回购', '更适合做月度补给型商品,强调长期规律使用'),
|
||||
(6, '5f0e7c4d-7c8a-4f6f-9a16-100000000003'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000006'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000302'::uuid, '乳清蛋白营养粉', '恢复期与长者补充营养更省心', '营养保健', 168.00, 15.00, 0.90, ARRAY['免疫支持','高蛋白','恢复期']::text[], '900g/罐', '温水冲调,每次20至30g', '开封后尽快食用', '18个月', '密封避光保存', '食健备G20266', '术后恢复与日常增补蛋白', '恢复期、体质偏弱、食量不足与长者营养支持人群', '早餐代餐、术后陪护、营养加餐和睡前补给', '更适合搭配恢复期护理场景,强调蛋白摄入效率'),
|
||||
(7, '5f0e7c4d-7c8a-4f6f-9a16-100000000004'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000003'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000401'::uuid, '术后支撑恢复带', '弹性支撑设计,辅助日常活动恢复', '康复护理', 128.00, 12.00, 0.42, ARRAY['术后恢复','支撑护具','康复护理']::text[], '1件/盒', '按说明固定于腰腹或术后恢复部位', '过紧佩戴会影响舒适度', '长期', '干燥通风处保存', '粤械注准20267', '术后起身支撑与短程活动辅助', '腹部术后、产后恢复与腰腹支撑需求人群', '住院陪护包、居家恢复期、复查往返途中', '更适合作为恢复阶段核心护理单品,强调支撑稳定'),
|
||||
(8, '5f0e7c4d-7c8a-4f6f-9a16-100000000004'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000003'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000402'::uuid, '无菌伤口护理包', '含敷料与清洁耗材,家庭护理更方便', '康复护理', 58.00, 6.00, 0.22, ARRAY['伤口护理','无菌敷料','家庭护理']::text[], '1包/套', '按说明进行伤口清洁与覆盖', '严重伤口请及时就医', '24个月', '阴凉干燥处保存', '粤械注准20268', '换药清洁与创面日常防护', '轻度创面护理、术后换药与家庭备用耗材需求人群', '居家药箱、门诊复诊、旅行应急护理包', '耗材组合更完整,适合作为高频消耗型护理商品'),
|
||||
(9, '5f0e7c4d-7c8a-4f6f-9a16-100000000005'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000002'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000501'::uuid, '家用艾灸温灸盒', '居家温灸理疗,适合肩颈腰腿舒缓', '中医调理', 88.00, 8.00, 0.35, ARRAY['艾灸理疗','居家调理','肩颈舒缓']::text[], '1套/盒', '放入艾柱后按说明固定使用', '避免直接接触烫伤', '长期', '干燥处保存', '粤械注准20269', '肩颈腰腿温灸放松与日常养护', '久坐办公族、居家理疗人群与中式养护偏好用户', '晚间放松、周末理疗、家庭保健角', '理疗氛围感更强,适合作为中式调养类主推单品'),
|
||||
(10, '5f0e7c4d-7c8a-4f6f-9a16-100000000005'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000002'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000502'::uuid, '肩颈草本热敷贴', '办公居家适用,帮助肩颈腰背舒缓', '中医调理', 49.90, 5.50, 0.16, ARRAY['草本贴敷','肩颈护理','居家理疗']::text[], '10贴/盒', '直接贴于肩颈腰背部位', '睡眠时不建议长时间贴敷', '24个月', '密封避光保存', '粤械注准20270', '久坐肩颈热敷与午后舒缓', '办公久坐、伏案学习与轻度劳损舒缓人群', '办公桌抽屉、车载收纳、差旅随行护理包', '贴敷便捷,适合作为通勤和办公场景高频复购商品'),
|
||||
(11, '5f0e7c4d-7c8a-4f6f-9a16-100000000006'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000005'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000601'::uuid, '折叠助行辅助器', '轻便稳固,适合长者居家外出', '老年照护', 268.00, 16.00, 2.80, ARRAY['行动辅助','长者照护','安全出行']::text[], '1台/件', '展开后调节合适高度使用', '地面湿滑时请减速慢行', '长期', '干燥环境保存', '粤械注准20271', '长者短距离行走与外出辅助', '腿脚无力长者、术后康复期与家庭陪护人群', '客厅日常使用、社区散步、医院复诊外出', '更适合作为银龄照护大件主推,强调折叠与稳固兼顾'),
|
||||
(12, '5f0e7c4d-7c8a-4f6f-9a16-100000000006'::uuid, '6f0e7c4d-7c8a-4f6f-9a16-200000000005'::uuid, '7f0e7c4d-7c8a-4f6f-9a16-300000000602'::uuid, '浴室防滑扶手套装', '长者洗浴与走道区域安全防护', '老年照护', 139.00, 11.00, 1.15, ARRAY['居家防护','防跌安全','长者必备']::text[], '2件/套', '安装于浴室或走道墙面', '安装前确认墙面承重', '长期', '常温保存', '粤械注准20272', '洗浴区起身借力与走道安全防护', '居家长者、术后行动不稳人群与家庭照护用户', '卫生间、卧室过道、床边起身点位', '更适合作为居家改造类商品,强调安装场景和防跌价值')
|
||||
) AS t(template_index, merchant_id, brand_id, category_id, product_prefix, subtitle_base, scene_name, base_price, price_step, base_weight, tags, specification, usage, precautions, expiry_date, storage_conditions, approval_prefix, care_focus, audience_focus, usage_scene, merch_focus)
|
||||
),
|
||||
image_map AS (
|
||||
SELECT *
|
||||
FROM (
|
||||
VALUES
|
||||
(1, 'https://upload.wikimedia.org/wikipedia/commons/2/20/Applying_transdermal_patch.jpg'),
|
||||
(2, 'https://images.unsplash.com/photo-1773747608435-0fa80d11a32f?q=80&w=627&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'),
|
||||
(3, 'https://images.unsplash.com/photo-1631815584191-0ed1723f0ead?q=80&w=678&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'),
|
||||
(4, 'https://images.unsplash.com/photo-1645273474824-1facac10c30c?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'),
|
||||
(5, 'https://images.unsplash.com/photo-1729700985369-c04bb4557431?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'),
|
||||
(6, 'https://images.unsplash.com/photo-1704650311190-7eeb9c4f6e11?q=80&w=1170&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'),
|
||||
(7, 'https://images.unsplash.com/photo-1768839725129-98df1d51e4b7?q=80&w=1170&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'),
|
||||
(8, 'https://images.unsplash.com/photo-1765996796562-ce301df337a0?q=80&w=1170&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'),
|
||||
(9, 'https://upload.wikimedia.org/wikipedia/commons/f/f2/Ibuki_moxa_set.jpg'),
|
||||
(10, 'https://upload.wikimedia.org/wikipedia/commons/1/18/Kinesio_taping_on_neck.jpg'),
|
||||
(11, 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Medical_Walker.JPG'),
|
||||
(12, 'https://images.unsplash.com/photo-1656646523834-dd1cc57d33c9?q=80&w=1170&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D')
|
||||
) AS t(template_index, image_url)
|
||||
),
|
||||
seed_products AS (
|
||||
SELECT
|
||||
('8f0e7c4d-7c8a-4f6f-9a16-' || LPAD((((template_index - 1) * 5) + seq)::text, 12, '0'))::uuid AS id,
|
||||
merchant_id,
|
||||
category_id,
|
||||
brand_id,
|
||||
format('MEDHOME-20260520-%s', LPAD((((template_index - 1) * 5) + seq)::text, 3, '0')) AS product_code,
|
||||
product_prefix || CASE seq
|
||||
WHEN 1 THEN ' 标准款'
|
||||
WHEN 2 THEN ' 家庭常备装'
|
||||
WHEN 3 THEN ' 舒适加强款'
|
||||
WHEN 4 THEN ' 便携随行装'
|
||||
ELSE ' 臻选礼盒装'
|
||||
END AS name,
|
||||
subtitle_base || CASE seq
|
||||
WHEN 1 THEN ',适合作为日常基础护理选择'
|
||||
WHEN 2 THEN ',更适合居家储备与多人使用'
|
||||
WHEN 3 THEN ',覆盖更集中的护理与调理需求'
|
||||
WHEN 4 THEN ',适合通勤、陪护或外出携带'
|
||||
ELSE ',兼顾体验感与送礼陈列场景'
|
||||
END AS subtitle,
|
||||
scene_name || CASE seq
|
||||
WHEN 1 THEN '场景常规推荐款,适合门店首页稳定陈列与日常转化。'
|
||||
WHEN 2 THEN '场景家庭囤货款,强调使用周期更长、备货更省心。'
|
||||
WHEN 3 THEN '场景强化护理款,适合症状较集中或恢复阶段的重点选择。'
|
||||
WHEN 4 THEN '场景轻便出行款,方便通勤、探视、陪护和短期外带。'
|
||||
ELSE '场景升级体验款,适合首页活动位、礼赠位或高客单展示。'
|
||||
END || ' 核心关注:' || care_focus || '。适用人群:' || audience_focus || '。' AS description,
|
||||
image_map.image_url AS main_image_url,
|
||||
jsonb_build_array(image_map.image_url) AS image_urls,
|
||||
'[]'::jsonb AS video_urls,
|
||||
ROUND((base_price + (
|
||||
CASE seq
|
||||
WHEN 1 THEN 0
|
||||
WHEN 2 THEN price_step * 2.2
|
||||
WHEN 3 THEN price_step * 4.8
|
||||
WHEN 4 THEN price_step * 1.1
|
||||
ELSE price_step * 7.4
|
||||
END
|
||||
))::numeric, 2)::numeric(10,2) AS base_price,
|
||||
ROUND((base_price + (
|
||||
CASE seq
|
||||
WHEN 1 THEN price_step * 2.8
|
||||
WHEN 2 THEN price_step * 5.2
|
||||
WHEN 3 THEN price_step * 8.0
|
||||
WHEN 4 THEN price_step * 3.9
|
||||
ELSE price_step * 11.4
|
||||
END
|
||||
))::numeric, 2)::numeric(10,2) AS market_price,
|
||||
ROUND((base_price + (
|
||||
CASE seq
|
||||
WHEN 1 THEN 0
|
||||
WHEN 2 THEN price_step * 2.2
|
||||
WHEN 3 THEN price_step * 4.8
|
||||
WHEN 4 THEN price_step * 1.1
|
||||
ELSE price_step * 7.4
|
||||
END
|
||||
)) * 0.58, 2)::numeric(10,2) AS cost_price,
|
||||
CASE seq
|
||||
WHEN 1 THEN 160 + (template_index * 18)
|
||||
WHEN 2 THEN 240 + (template_index * 24)
|
||||
WHEN 3 THEN 130 + (template_index * 16)
|
||||
WHEN 4 THEN 210 + (template_index * 20)
|
||||
ELSE 96 + (template_index * 12)
|
||||
END AS total_stock,
|
||||
CASE seq
|
||||
WHEN 1 THEN 148 + (template_index * 16)
|
||||
WHEN 2 THEN 222 + (template_index * 20)
|
||||
WHEN 3 THEN 118 + (template_index * 14)
|
||||
WHEN 4 THEN 192 + (template_index * 18)
|
||||
ELSE 84 + (template_index * 10)
|
||||
END AS available_stock,
|
||||
1 AS min_order_qty,
|
||||
CASE seq
|
||||
WHEN 1 THEN 3
|
||||
WHEN 2 THEN 6
|
||||
WHEN 3 THEN 2
|
||||
WHEN 4 THEN 2
|
||||
ELSE 1
|
||||
END AS max_order_qty,
|
||||
(base_weight + (
|
||||
CASE seq
|
||||
WHEN 1 THEN 0.00
|
||||
WHEN 2 THEN 0.18
|
||||
WHEN 3 THEN 0.32
|
||||
WHEN 4 THEN -0.05
|
||||
ELSE 0.46
|
||||
END
|
||||
))::numeric(10,2) AS weight,
|
||||
jsonb_build_object(
|
||||
'length', 16 + template_index + CASE seq WHEN 2 THEN 4 WHEN 3 THEN 2 WHEN 4 THEN -1 ELSE 5 END,
|
||||
'width', 10 + CASE seq WHEN 2 THEN 3 WHEN 3 THEN 2 WHEN 4 THEN 0 ELSE 4 END,
|
||||
'height', 4 + CASE seq WHEN 2 THEN 2 WHEN 3 THEN 1 WHEN 4 THEN 0 ELSE 3 END + (template_index / 3)
|
||||
) AS dimensions,
|
||||
1 AS status,
|
||||
CASE WHEN seq IN (1, 2) THEN TRUE ELSE FALSE END AS is_featured,
|
||||
CASE WHEN seq IN (2, 4, 5) THEN TRUE ELSE FALSE END AS is_new,
|
||||
CASE WHEN seq IN (1, 3) THEN TRUE ELSE FALSE END AS is_hot,
|
||||
1200 + (template_index * 280) + (seq * 160) AS view_count,
|
||||
260 + (template_index * 80) + (seq * 45) AS sale_count,
|
||||
48 + (template_index * 18) + (seq * 9) AS favorite_count,
|
||||
LEAST(4.9, 4.5 + (template_index * 0.02) + (seq * 0.05))::numeric(3,1) AS rating_avg,
|
||||
60 + (template_index * 14) + (seq * 8) AS rating_count,
|
||||
tags || ARRAY[
|
||||
CASE seq
|
||||
WHEN 1 THEN '标准护理'
|
||||
WHEN 2 THEN '家庭常备'
|
||||
WHEN 3 THEN '加强调理'
|
||||
WHEN 4 THEN '便携随行'
|
||||
ELSE '臻选礼盒'
|
||||
END,
|
||||
CASE
|
||||
WHEN scene_name = '常用药品' THEN '家庭药箱'
|
||||
WHEN scene_name = '医疗器械' THEN '居家监测'
|
||||
WHEN scene_name = '营养保健' THEN '营养补给'
|
||||
WHEN scene_name = '康复护理' THEN '恢复护理'
|
||||
WHEN scene_name = '中医调理' THEN '理疗养护'
|
||||
ELSE '银龄照护'
|
||||
END,
|
||||
'医疗首页'
|
||||
] AS full_tags,
|
||||
jsonb_build_object(
|
||||
'specification', specification || CASE seq
|
||||
WHEN 1 THEN ',标准单元配置,适合首次购买与基础日常使用'
|
||||
WHEN 2 THEN ',家庭周期装,单次备货覆盖时间更长'
|
||||
WHEN 3 THEN ',加强护理配置,核心用量或强度做了上调'
|
||||
WHEN 4 THEN ',便携小规格配置,适合外出或复诊随身携带'
|
||||
ELSE ',礼盒陈列配置,更适合作为高客单或送礼选择'
|
||||
END,
|
||||
'usage', usage || CASE seq
|
||||
WHEN 1 THEN ',适合日常基础使用频率。'
|
||||
WHEN 2 THEN ',建议放置于家庭常用药箱、护理柜或床旁储物区。'
|
||||
WHEN 3 THEN ',适合恢复期、症状较集中阶段或连续护理周期使用。'
|
||||
WHEN 4 THEN ',适合外出、复诊、短期陪护或车载随手包场景携带。'
|
||||
ELSE ',适合首页活动展示、礼赠组合或高意向用户选购。'
|
||||
END,
|
||||
'side_effects', CASE seq
|
||||
WHEN 3 THEN '个别人群可能出现短时不适,建议先小量体验'
|
||||
WHEN 5 THEN '首次使用建议阅读说明或咨询专业人员'
|
||||
ELSE '一般耐受良好'
|
||||
END,
|
||||
'precautions', precautions || CASE seq
|
||||
WHEN 2 THEN ',启封后建议尽快按周期用完。'
|
||||
WHEN 4 THEN ',随身携带时注意防潮防压。'
|
||||
WHEN 5 THEN ',升级配置请结合实际需求选择。'
|
||||
ELSE '。'
|
||||
END,
|
||||
'expiry_date', expiry_date,
|
||||
'storage_conditions', storage_conditions,
|
||||
'approval_number', approval_prefix || LPAD((((template_index - 1) * 5) + seq)::text, 4, '0'),
|
||||
'target_population', CASE seq
|
||||
WHEN 1 THEN audience_focus || ',偏基础护理与首次购买'
|
||||
WHEN 2 THEN audience_focus || ',偏家庭常备与多人共享'
|
||||
WHEN 3 THEN audience_focus || ',偏重点护理与连续使用'
|
||||
WHEN 4 THEN audience_focus || ',偏短期外带与移动场景'
|
||||
ELSE audience_focus || ',偏礼赠、升级体验与高意向消费'
|
||||
END,
|
||||
'selling_points', jsonb_build_array(
|
||||
CASE seq
|
||||
WHEN 1 THEN '入门门槛低,适合首页常规爆款位与首次下单'
|
||||
WHEN 2 THEN '容量与周期更长,适合家庭储备和周期补货'
|
||||
WHEN 3 THEN '重点场景更聚焦,适合恢复期或强化护理转化'
|
||||
WHEN 4 THEN '规格更轻便,适合外带、复诊包和临时使用'
|
||||
ELSE '陈列感更强,适合活动位、礼赠位与高客单展示'
|
||||
END,
|
||||
'支持医疗首页分类流与推荐流展示',
|
||||
scene_name || '场景匹配度高',
|
||||
merch_focus,
|
||||
CASE seq
|
||||
WHEN 1 THEN '价格带适合作为基础转化款'
|
||||
WHEN 2 THEN '价格带适合作为家庭囤货款'
|
||||
WHEN 3 THEN '价格带适合作为强化护理款'
|
||||
WHEN 4 THEN '价格带适合作为便携补充款'
|
||||
ELSE '价格带适合作为高价值展示款'
|
||||
END
|
||||
),
|
||||
'price_band', CASE seq
|
||||
WHEN 1 THEN '基础入门'
|
||||
WHEN 2 THEN '家庭常备'
|
||||
WHEN 3 THEN '加强护理'
|
||||
WHEN 4 THEN '便携补充'
|
||||
ELSE '礼盒升级'
|
||||
END,
|
||||
'stock_strategy', CASE seq
|
||||
WHEN 1 THEN '稳定补货'
|
||||
WHEN 2 THEN '高库存常备'
|
||||
WHEN 3 THEN '中库存重点护理'
|
||||
WHEN 4 THEN '中高库存便携周转'
|
||||
ELSE '低库存陈列展示'
|
||||
END,
|
||||
'care_focus', care_focus,
|
||||
'usage_scene', usage_scene,
|
||||
'merch_focus', merch_focus
|
||||
) AS attributes,
|
||||
LOWER(REPLACE(product_prefix, ' ', '-')) AS slug_base
|
||||
FROM seed_templates
|
||||
INNER JOIN image_map ON image_map.template_index = seed_templates.template_index
|
||||
CROSS JOIN generate_series(1, 5) AS seq
|
||||
)
|
||||
INSERT INTO public.ml_products (
|
||||
id, merchant_id, category_id, brand_id, product_code, name, subtitle, description,
|
||||
main_image_url, image_urls, video_urls,
|
||||
base_price, market_price, cost_price,
|
||||
total_stock, available_stock, min_order_qty, max_order_qty,
|
||||
weight, dimensions,
|
||||
status, is_featured, is_new, is_hot,
|
||||
view_count, sale_count, favorite_count, rating_avg, rating_count,
|
||||
seo_title, seo_description, seo_keywords, slug, tags, attributes,
|
||||
created_at, updated_at, published_at
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
merchant_id,
|
||||
category_id,
|
||||
brand_id,
|
||||
product_code,
|
||||
name,
|
||||
subtitle,
|
||||
description,
|
||||
main_image_url,
|
||||
image_urls,
|
||||
video_urls,
|
||||
base_price,
|
||||
market_price,
|
||||
cost_price,
|
||||
total_stock,
|
||||
available_stock,
|
||||
min_order_qty,
|
||||
max_order_qty,
|
||||
weight,
|
||||
dimensions,
|
||||
status,
|
||||
is_featured,
|
||||
is_new,
|
||||
is_hot,
|
||||
view_count,
|
||||
sale_count,
|
||||
favorite_count,
|
||||
rating_avg,
|
||||
rating_count,
|
||||
name AS seo_title,
|
||||
description AS seo_description,
|
||||
full_tags,
|
||||
slug_base || '-' || RIGHT(product_code, 3),
|
||||
full_tags,
|
||||
attributes,
|
||||
NOW(),
|
||||
NOW(),
|
||||
NOW()
|
||||
FROM seed_products
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
merchant_id = EXCLUDED.merchant_id,
|
||||
category_id = EXCLUDED.category_id,
|
||||
brand_id = EXCLUDED.brand_id,
|
||||
product_code = EXCLUDED.product_code,
|
||||
name = EXCLUDED.name,
|
||||
subtitle = EXCLUDED.subtitle,
|
||||
description = EXCLUDED.description,
|
||||
main_image_url = EXCLUDED.main_image_url,
|
||||
image_urls = EXCLUDED.image_urls,
|
||||
video_urls = EXCLUDED.video_urls,
|
||||
base_price = EXCLUDED.base_price,
|
||||
market_price = EXCLUDED.market_price,
|
||||
cost_price = EXCLUDED.cost_price,
|
||||
total_stock = EXCLUDED.total_stock,
|
||||
available_stock = EXCLUDED.available_stock,
|
||||
min_order_qty = EXCLUDED.min_order_qty,
|
||||
max_order_qty = EXCLUDED.max_order_qty,
|
||||
weight = EXCLUDED.weight,
|
||||
dimensions = EXCLUDED.dimensions,
|
||||
status = EXCLUDED.status,
|
||||
is_featured = EXCLUDED.is_featured,
|
||||
is_new = EXCLUDED.is_new,
|
||||
is_hot = EXCLUDED.is_hot,
|
||||
view_count = EXCLUDED.view_count,
|
||||
sale_count = EXCLUDED.sale_count,
|
||||
favorite_count = EXCLUDED.favorite_count,
|
||||
rating_avg = EXCLUDED.rating_avg,
|
||||
rating_count = EXCLUDED.rating_count,
|
||||
seo_title = EXCLUDED.seo_title,
|
||||
seo_description = EXCLUDED.seo_description,
|
||||
seo_keywords = EXCLUDED.seo_keywords,
|
||||
slug = EXCLUDED.slug,
|
||||
tags = EXCLUDED.tags,
|
||||
attributes = EXCLUDED.attributes,
|
||||
updated_at = NOW(),
|
||||
published_at = EXCLUDED.published_at;
|
||||
|
||||
COMMIT;
|
||||
|
||||
-- 执行完成后可运行以下校验语句:
|
||||
-- SELECT id, name, level, parent_id FROM public.ml_categories WHERE slug LIKE 'medical-%' OR slug IN ('cold-fever','digestive-care','blood-pressure-monitoring','respiratory-care','bone-nutrition','immune-support','post-surgery-recovery','wound-care','moxa-therapy','herbal-patch','mobility-aid','home-safety') ORDER BY sort_order;
|
||||
-- SELECT product_code, name, base_price, sale_count, is_featured, is_new, is_hot FROM public.ml_products WHERE product_code LIKE 'MEDHOME-%' ORDER BY product_code;
|
||||
-- SELECT category_name, brand_name, shop_name, merchant_name, name FROM public.ml_products_detail_view WHERE product_code LIKE 'MEDHOME-%' ORDER BY product_code;
|
||||
186
sql/seed_medical_mall_categories.sql
Normal file
186
sql/seed_medical_mall_categories.sql
Normal file
@@ -0,0 +1,186 @@
|
||||
-- Seed: 医疗商城首页分类与示例商品关联
|
||||
-- 依赖: public.medical_mall_categories / public.medical_mall_product_categories / public.ml_products
|
||||
|
||||
BEGIN;
|
||||
|
||||
INSERT INTO public.medical_mall_categories (
|
||||
id, name, parent_id, level, sort_order, icon, image_url, description, scene, category_type, compliance_type, is_active, created_at, updated_at
|
||||
)
|
||||
VALUES
|
||||
('med_device', '医疗器械', NULL, 1, 10, '🩺', NULL, '家庭监测与基础器械', 'medical_mall', 'device', 'device_class_i', TRUE, NOW(), NOW()),
|
||||
('otc_medicine', '家庭常备药', NULL, 1, 20, '💊', NULL, 'OTC 家庭常备药与应急用药', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('rehab_care', '康复护理', NULL, 1, 30, '🩹', NULL, '术后恢复、敷料护具与护理用品', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('chronic_monitor', '慢病监测', NULL, 1, 40, '📈', NULL, '高血压、糖尿病与家庭检测场景', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('elderly_aid', '适老用品', NULL, 1, 50, '🧓', NULL, '长者安全辅助与居家适老用品', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('nutrition_health', '营养保健', NULL, 1, 60, '🥛', NULL, '维生素、钙片、蛋白营养等保健品', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('protection_disinfection', '防护消毒', NULL, 1, 70, '😷', NULL, '口罩、消毒、急救与防护耗材', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('tcm_health', '中医保健', NULL, 1, 80, '🌿', NULL, '艾灸、贴敷、按摩理疗与草本养护', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('home_care_daily', '居家护理', NULL, 1, 90, '🏠', NULL, '伤口、口腔、皮肤与家庭健康工具', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('all_medical', '全部', NULL, 1, 100, '🧺', NULL, '查看全部康养医疗商品', 'medical_mall', 'all', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('blood_pressure_monitor', '血压计', 'med_device', 2, 11, '🫀', NULL, '家庭血压监测设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('blood_glucose_meter', '血糖仪', 'med_device', 2, 12, '🩸', NULL, '家庭血糖检测设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('oximeter', '血氧仪', 'med_device', 2, 13, '💗', NULL, '指夹式血氧监测设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('thermometer', '体温计', 'med_device', 2, 14, '🌡️', NULL, '额温枪与电子体温计', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('oxygen_concentrator', '制氧机', 'med_device', 2, 15, '🫁', NULL, '家庭制氧与吸氧辅助设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('nebulizer', '雾化器', 'med_device', 2, 16, '💨', NULL, '家用雾化护理设备', 'medical_mall', 'device', 'device_class_ii', TRUE, NOW(), NOW()),
|
||||
('wheelchair_crutch', '轮椅拐杖', 'med_device', 2, 17, '🦽', NULL, '轮椅、拐杖与行动辅助器具', 'medical_mall', 'device', 'device_class_i', TRUE, NOW(), NOW()),
|
||||
('nursing_bed', '护理床', 'med_device', 2, 18, '🛏️', NULL, '护理床与居家照护床具', 'medical_mall', 'device', 'device_class_i', TRUE, NOW(), NOW()),
|
||||
|
||||
('cold_fever', '感冒发烧', 'otc_medicine', 2, 21, '🤒', NULL, '感冒、退热与家庭常备药', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('cough_throat', '咳嗽咽喉', 'otc_medicine', 2, 22, '🗣️', NULL, '咳嗽、咽喉与润喉护理', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('stomach_medicine', '肠胃用药', 'otc_medicine', 2, 23, '🥣', NULL, '肠胃调理与胃肠常备药', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('skin_external', '皮肤外用', 'otc_medicine', 2, 24, '🧴', NULL, '皮肤喷剂、软膏与外用护理', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('eye_ear_nose', '眼耳口鼻', 'otc_medicine', 2, 25, '👁️', NULL, '眼耳鼻喉口腔常备用品', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('pain_relief', '止痛用药', 'otc_medicine', 2, 26, '🩹', NULL, '止痛、舒缓与应急常备药', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('trauma_sprain', '跌打损伤', 'otc_medicine', 2, 27, '🦴', NULL, '跌打扭伤与运动损伤护理', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
('child_medicine', '儿童用药', 'otc_medicine', 2, 28, '🧒', NULL, '儿童常备药与护理用品', 'medical_mall', 'otc', 'otc', TRUE, NOW(), NOW()),
|
||||
|
||||
('postop_rehab', '术后康复', 'rehab_care', 2, 31, '🩺', NULL, '术后恢复与支撑护理', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('wound_dressing', '伤口敷料', 'rehab_care', 2, 32, '🩹', NULL, '敷料、纱布与换药护理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('brace_support', '护具支具', 'rehab_care', 2, 33, '🦵', NULL, '护腰、护膝与支撑固定用品', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('rehab_training', '康复训练器', 'rehab_care', 2, 34, '🏋️', NULL, '康复训练与恢复辅助设备', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('physiotherapy_hot', '理疗热敷', 'rehab_care', 2, 35, '🔥', NULL, '热敷理疗与家庭舒缓护理', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
('mobility_training', '行动训练', 'rehab_care', 2, 36, '🚶', NULL, '恢复行动能力的辅助训练用品', 'medical_mall', 'rehab', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('hypertension', '高血压管理', 'chronic_monitor', 2, 41, '❤️', NULL, '高血压居家管理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('diabetes', '糖尿病管理', 'chronic_monitor', 2, 42, '🩸', NULL, '血糖监测与糖尿病管理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('cardiovascular', '心脑血管', 'chronic_monitor', 2, 43, '🫀', NULL, '心脑血管健康管理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('respiratory_health', '呼吸健康', 'chronic_monitor', 2, 44, '🫁', NULL, '呼吸道护理与呼吸健康', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('weight_bodyfat', '体重体脂', 'chronic_monitor', 2, 45, '⚖️', NULL, '体重与体脂监测', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('home_testing', '家庭检测', 'chronic_monitor', 2, 46, '🧪', NULL, '家庭常用健康检测用品', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('anti_slip', '防滑安全', 'elderly_aid', 2, 51, '🧱', NULL, '长者防滑与跌倒预防', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('elderly_bathroom', '适老卫浴', 'elderly_aid', 2, 52, '🚿', NULL, '浴室扶手与适老卫浴辅助', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('eating_aid', '助餐用品', 'elderly_aid', 2, 53, '🍽️', NULL, '适老助餐与餐具辅助', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('bathing_aid', '助浴用品', 'elderly_aid', 2, 54, '🛁', NULL, '助浴椅与洗护辅助用品', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('incontinence_care', '失禁护理', 'elderly_aid', 2, 55, '🧻', NULL, '长者失禁护理用品', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
('daily_living_aid', '生活辅助', 'elderly_aid', 2, 56, '🪑', NULL, '日常起居与生活辅助用品', 'medical_mall', 'elderly', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('vitamin', '维生素', 'nutrition_health', 2, 61, '🍊', NULL, '复合维生素与维 C 等营养补充', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('calcium', '钙铁锌硒', 'nutrition_health', 2, 62, '🦴', NULL, '钙铁锌硒等基础营养', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('protein', '蛋白营养', 'nutrition_health', 2, 63, '🥛', NULL, '蛋白粉与恢复期营养', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('elderly_nutrition', '老人营养', 'nutrition_health', 2, 64, '👴', NULL, '适合长者的专用营养补充', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('gut_health', '肠道益生菌', 'nutrition_health', 2, 65, '🦠', NULL, '益生菌与肠胃营养补充', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
('immune_support', '免疫支持', 'nutrition_health', 2, 66, '🛡️', NULL, '免疫支持与日常补给', 'medical_mall', 'nutrition', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('mask', '口罩', 'protection_disinfection', 2, 71, '😷', NULL, '日常口罩与防护耗材', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('disinfectant', '消毒液', 'protection_disinfection', 2, 72, '🧴', NULL, '家庭与环境消毒用品', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('alcohol_wipes', '酒精湿巾', 'protection_disinfection', 2, 73, '🧻', NULL, '酒精湿巾与便携消毒', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('gloves', '手套', 'protection_disinfection', 2, 74, '🧤', NULL, '检查手套与护理手套', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('first_aid', '急救包', 'protection_disinfection', 2, 75, '🧰', NULL, '家庭急救包与应急护理', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
('dressing_tools', '棉签纱布', 'protection_disinfection', 2, 76, '🧺', NULL, '棉签纱布与护理耗材', 'medical_mall', 'protection', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('moxibustion', '艾灸拔罐', 'tcm_health', 2, 81, '🔥', NULL, '艾灸、拔罐与温灸理疗', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('herbal_drink', '养生茶饮', 'tcm_health', 2, 82, '🍵', NULL, '草本茶饮与养生冲饮', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('tcm_patch', '中医贴敷', 'tcm_health', 2, 83, '🩹', NULL, '中医贴敷与草本热敷', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('medicated_diet', '药膳滋补', 'tcm_health', 2, 84, '🥣', NULL, '药膳汤料与滋补调养', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('massage_tools', '按摩理疗', 'tcm_health', 2, 85, '💆', NULL, '按摩仪、刮痧与理疗工具', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
('foot_bath', '泡脚养生', 'tcm_health', 2, 86, '🪣', NULL, '泡脚包与足浴理疗用品', 'medical_mall', 'tcm', 'normal', TRUE, NOW(), NOW()),
|
||||
|
||||
('wound_care', '伤口护理', 'home_care_daily', 2, 91, '🩹', NULL, '创面处理与换药护理', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('oral_care', '口腔护理', 'home_care_daily', 2, 92, '🦷', NULL, '口腔护理与清洁用品', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('skin_care', '皮肤护理', 'home_care_daily', 2, 93, '🧴', NULL, '皮肤护理与修护用品', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('cleaning_care', '清洁护理', 'home_care_daily', 2, 94, '🫧', NULL, '清洁护理与日常消耗品', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('nursing_consumables', '护理耗材', 'home_care_daily', 2, 95, '📦', NULL, '棉签、纱布、护理垫等耗材', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW()),
|
||||
('home_health_tool', '家庭健康工具', 'home_care_daily', 2, 96, '🧰', NULL, '家庭健康小工具与辅具', 'medical_mall', 'care', 'normal', TRUE, NOW(), NOW())
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
name = EXCLUDED.name,
|
||||
parent_id = EXCLUDED.parent_id,
|
||||
level = EXCLUDED.level,
|
||||
sort_order = EXCLUDED.sort_order,
|
||||
icon = EXCLUDED.icon,
|
||||
image_url = EXCLUDED.image_url,
|
||||
description = EXCLUDED.description,
|
||||
scene = EXCLUDED.scene,
|
||||
category_type = EXCLUDED.category_type,
|
||||
compliance_type = EXCLUDED.compliance_type,
|
||||
is_active = EXCLUDED.is_active,
|
||||
deleted_at = NULL,
|
||||
updated_at = NOW();
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'blood_pressure_monitor', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%血压计%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'blood_glucose_meter', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%血糖仪%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'thermometer', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%体温计%' OR p.name ILIKE '%额温枪%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'oxygen_concentrator', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%制氧机%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'nebulizer', TRUE, 10, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%雾化器%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'mask', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%口罩%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'disinfectant', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%消毒%' OR p.name ILIKE '%酒精%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'wound_care', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%创可贴%' OR p.name ILIKE '%纱布%' OR p.name ILIKE '%敷料%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'wheelchair_crutch', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%轮椅%' OR p.name ILIKE '%拐杖%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'nursing_bed', TRUE, 20, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%护理床%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'calcium', TRUE, 30, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%钙片%' OR p.name ILIKE '%钙铁锌%' OR p.name ILIKE '%补钙%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'vitamin', TRUE, 30, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%维生素%' OR p.name ILIKE '%维C%' OR p.name ILIKE '%维D%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'protein', TRUE, 30, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%蛋白%' OR p.name ILIKE '%蛋白粉%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
INSERT INTO public.medical_mall_product_categories (product_id, category_id, is_primary, sort_order, created_at)
|
||||
SELECT p.id, 'cold_fever', TRUE, 40, NOW()
|
||||
FROM public.ml_products p
|
||||
WHERE p.name ILIKE '%感冒%' OR p.name ILIKE '%退热%' OR p.name ILIKE '%发烧%'
|
||||
ON CONFLICT (product_id, category_id) DO UPDATE SET is_primary = EXCLUDED.is_primary, sort_order = EXCLUDED.sort_order, deleted_at = NULL;
|
||||
|
||||
COMMIT;
|
||||
@@ -7,21 +7,35 @@ export type DeliveryAccountStatus = 'active' | 'disabled' | 'locked' | 'suspende
|
||||
export type DeliveryCertificateStatus = 'valid' | 'expired' | 'pending'
|
||||
|
||||
export type DeliveryOrderStatus =
|
||||
'pending_assignment' |
|
||||
'pending_accept' |
|
||||
'accepted' |
|
||||
'waiting_departure' |
|
||||
'departed' |
|
||||
'on_the_way' |
|
||||
'arrived' |
|
||||
'checked_in' |
|
||||
'in_service' |
|
||||
'serving' |
|
||||
'pending_confirm' |
|
||||
'pending_submit' |
|
||||
'pending_acceptance' |
|
||||
'completed' |
|
||||
'rejected' |
|
||||
'abnormal' |
|
||||
'terminated' |
|
||||
'exception_pending' |
|
||||
'cancelled' |
|
||||
'settled' |
|
||||
'archived'
|
||||
|
||||
export type DeliveryExceptionType =
|
||||
'cannot_contact_user' |
|
||||
'user_not_home' |
|
||||
'family_uncooperative' |
|
||||
'outside_service_scope' |
|
||||
'staff_cannot_continue' |
|
||||
'complaint_dispute' |
|
||||
'cannot_contact_elder' |
|
||||
'cannot_enter_home' |
|
||||
'wrong_address' |
|
||||
@@ -47,6 +61,17 @@ export type DeliveryTimelineItemType = {
|
||||
description: string
|
||||
}
|
||||
|
||||
export type DeliveryStatusLogType = {
|
||||
id: string
|
||||
orderId: string
|
||||
fromStatus: DeliveryOrderStatus
|
||||
toStatus: DeliveryOrderStatus
|
||||
operatorRole: string
|
||||
operatorId: string
|
||||
remark: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export type DeliveryServiceItemType = {
|
||||
id: string
|
||||
name: string
|
||||
@@ -71,39 +96,108 @@ export type DeliveryEvidenceRecordType = {
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export type DeliveryHealthMetricsType = {
|
||||
bloodPressure: string
|
||||
heartRate: string
|
||||
bloodSugar: string
|
||||
bloodOxygen: string
|
||||
}
|
||||
|
||||
export type DeliveryConfirmationType = {
|
||||
method: 'sms_code' | 'signature' | 'none'
|
||||
code: string
|
||||
signatureName: string
|
||||
signatureUrl: string
|
||||
confirmedAt: string
|
||||
}
|
||||
|
||||
export type DeliveryServiceRecordType = {
|
||||
id: string
|
||||
orderId: string
|
||||
startTime: string
|
||||
endTime: string
|
||||
actualDurationMinutes: number
|
||||
serviceItems: Array<DeliveryServiceItemType>
|
||||
serviceContent: Array<string>
|
||||
processNote: string
|
||||
elderStatus: string
|
||||
healthMetrics: DeliveryHealthMetricsType
|
||||
materialsUsed: string
|
||||
abnormalNote: string
|
||||
photos: Array<string>
|
||||
staffRemark: string
|
||||
familyConfirmation: DeliveryConfirmationType
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export type DeliveryAbnormalReportType = {
|
||||
id: string
|
||||
orderId: string
|
||||
type: DeliveryExceptionType
|
||||
description: string
|
||||
occurredAt: string
|
||||
locationText: string
|
||||
images: Array<string>
|
||||
needPlatformIntervention: boolean
|
||||
requestCancelOrder: boolean
|
||||
requestReschedule: boolean
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export type DeliveryOrderType = {
|
||||
id: string
|
||||
orderNo: string
|
||||
serviceType: string
|
||||
serviceName: string
|
||||
serviceCategory: string
|
||||
serviceItems: Array<DeliveryServiceItemType>
|
||||
serviceContentOptions?: Array<string>
|
||||
elderId: string
|
||||
elderName: string
|
||||
elderNameMasked: string
|
||||
elderGender: string
|
||||
elderAge: number
|
||||
elderPhone: string
|
||||
elderPhoneMasked: string
|
||||
fullElderName: string
|
||||
fullPhone: string
|
||||
contactRelation: string
|
||||
addressSummary: string
|
||||
address: string
|
||||
addressDetail: string
|
||||
fullAddress: string
|
||||
latitude: number
|
||||
longitude: number
|
||||
appointmentTime: string
|
||||
appointmentStartTime: string
|
||||
appointmentEndTime: string
|
||||
duration: number
|
||||
estimatedDuration: number
|
||||
price: number
|
||||
staffIncome: number
|
||||
distance: string
|
||||
actualStartTime: string
|
||||
actualEndTime: string
|
||||
status: DeliveryOrderStatus
|
||||
statusText: string
|
||||
statusTone: string
|
||||
riskTags: Array<string>
|
||||
healthTags: Array<string>
|
||||
careLevel: string
|
||||
needFamilyPresent: boolean
|
||||
needMaterials: boolean
|
||||
remark: string
|
||||
merchantId: string
|
||||
merchantName: string
|
||||
deliveryStaffId: string
|
||||
deliveryStaffName: string
|
||||
acceptTime: string
|
||||
rejectTime?: string
|
||||
departTime: string
|
||||
arriveTime: string
|
||||
checkinTime: string
|
||||
startServiceTime?: string
|
||||
finishTime: string
|
||||
cancelReason: string
|
||||
exceptionType: string
|
||||
@@ -120,12 +214,15 @@ export type DeliveryOrderType = {
|
||||
contactPhone: string
|
||||
notices: Array<string>
|
||||
timeline: Array<DeliveryTimelineItemType>
|
||||
statusLog: Array<DeliveryStatusLogType>
|
||||
serviceSummary: string
|
||||
progressNote: string
|
||||
distanceKm: string
|
||||
allowCheckinRadiusMeters: number
|
||||
lastLocation: DeliveryLocationType | null
|
||||
trackPoints: Array<DeliveryLocationType>
|
||||
serviceRecord: DeliveryServiceRecordType | null
|
||||
abnormalReport: DeliveryAbnormalReportType | null
|
||||
}
|
||||
|
||||
export type DeliveryCertificateType = {
|
||||
@@ -161,12 +258,16 @@ export type DeliveryInfoType = {
|
||||
}
|
||||
|
||||
export type DeliveryDashboardType = {
|
||||
pendingAssignmentCount: number
|
||||
pendingAcceptCount: number
|
||||
todayOrderCount: number
|
||||
pendingDepartCount: number
|
||||
servingCount: number
|
||||
completedCount: number
|
||||
exceptionCount: number
|
||||
expectedIncome: number
|
||||
onlineStatus: DeliveryOnlineStatus
|
||||
nextOrder: DeliveryOrderType | null
|
||||
recentOrders: Array<DeliveryOrderType>
|
||||
}
|
||||
|
||||
@@ -185,16 +286,20 @@ export type DeliveryRecordType = {
|
||||
orderId: string
|
||||
orderNo: string
|
||||
serviceName: string
|
||||
elderName: string
|
||||
elderNameMasked: string
|
||||
status: string
|
||||
statusText: string
|
||||
appointmentStartTime: string
|
||||
appointmentTime: string
|
||||
actualStartTime: string
|
||||
actualEndTime: string
|
||||
staffIncome: number
|
||||
settlementStatus: string
|
||||
acceptanceStatus: string
|
||||
exceptionDesc: string
|
||||
ratingText: string
|
||||
hasServiceRecord: boolean
|
||||
}
|
||||
|
||||
export type DeliveryLoginPayloadType = {
|
||||
@@ -237,4 +342,9 @@ export type DeliveryExceptionPayloadType = {
|
||||
exceptionType: DeliveryExceptionType
|
||||
description: string
|
||||
images: Array<string>
|
||||
occurredAt?: string
|
||||
locationText?: string
|
||||
needPlatformIntervention?: boolean
|
||||
requestCancelOrder?: boolean
|
||||
requestReschedule?: boolean
|
||||
}
|
||||
@@ -25,8 +25,7 @@ const DELIVERY_HOME_PATH = '/pages/mall/delivery/home/index'
|
||||
const DELIVERY_USER_KEY = 'delivery_user_info'
|
||||
const DELIVERY_INFO_KEY = 'delivery_info'
|
||||
const DELIVERY_TOKEN_KEY = 'delivery_token'
|
||||
const DELIVERY_ROLE = 'delivery'
|
||||
const DELIVERY_ROLE_ALIAS = 'Deliverer'
|
||||
const DELIVERY_ROLE_LIST = ['delivery', 'Deliverer', 'deliverer', 'service_staff', 'care_worker'] as Array<string>
|
||||
|
||||
let redirectingToDeliveryLogin = false
|
||||
|
||||
@@ -169,7 +168,12 @@ export function isDelivererRole(userInfo: UserProfile | null): boolean {
|
||||
return false
|
||||
}
|
||||
const role = userInfo.role != null ? userInfo.role : ''
|
||||
return role == DELIVERY_ROLE || role == DELIVERY_ROLE_ALIAS
|
||||
for (let i = 0; i < DELIVERY_ROLE_LIST.length; i++) {
|
||||
if (role == DELIVERY_ROLE_LIST[i]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export async function checkDeliveryAccount(userInfo: UserProfile): Promise<DeliveryInfoType | null> {
|
||||
|
||||
73
utils/deliveryCareUi.uts
Normal file
73
utils/deliveryCareUi.uts
Normal file
@@ -0,0 +1,73 @@
|
||||
import type { DeliveryOrderStatus, DeliveryOrderType } from '@/types/delivery.uts'
|
||||
|
||||
export type DeliveryTabOptionType = {
|
||||
label: string
|
||||
value: string
|
||||
}
|
||||
|
||||
export function getDeliveryOrderTabs(): Array<DeliveryTabOptionType> {
|
||||
return [
|
||||
{ label: '待接单', value: 'pending' } as DeliveryTabOptionType,
|
||||
{ label: '今日订单', value: 'today' } as DeliveryTabOptionType,
|
||||
{ label: '历史订单', value: 'history' } as DeliveryTabOptionType
|
||||
]
|
||||
}
|
||||
|
||||
export function isHistoryStatus(status: DeliveryOrderStatus): boolean {
|
||||
return status == 'completed' || status == 'rejected' || status == 'cancelled' || status == 'abnormal' || status == 'terminated' || status == 'archived'
|
||||
}
|
||||
|
||||
export function getDeliveryStatusLabel(status: DeliveryOrderStatus): string {
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') return '待接单'
|
||||
if (status == 'accepted') return '已接单'
|
||||
if (status == 'waiting_departure') return '待出发'
|
||||
if (status == 'departed' || status == 'on_the_way') return '已出发'
|
||||
if (status == 'arrived') return '已到达'
|
||||
if (status == 'checked_in') return '已签到'
|
||||
if (status == 'in_service' || status == 'serving') return '服务中'
|
||||
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') return '待确认'
|
||||
if (status == 'completed') return '已完成'
|
||||
if (status == 'rejected') return '已拒单'
|
||||
if (status == 'cancelled') return '已取消'
|
||||
if (status == 'abnormal' || status == 'exception_pending') return '异常上报'
|
||||
if (status == 'terminated') return '服务终止'
|
||||
return '已归档'
|
||||
}
|
||||
|
||||
export function getPrimaryActionText(status: DeliveryOrderStatus): string {
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') return '接单'
|
||||
if (status == 'accepted' || status == 'waiting_departure') return '我已出发'
|
||||
if (status == 'departed' || status == 'on_the_way') return '我已到达'
|
||||
if (status == 'arrived') return '签到'
|
||||
if (status == 'checked_in') return '开始服务'
|
||||
if (status == 'in_service' || status == 'serving') return '填写记录'
|
||||
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') return '完成服务'
|
||||
if (status == 'completed') return '查看记录'
|
||||
if (status == 'abnormal' || status == 'exception_pending') return '查看异常'
|
||||
return '查看详情'
|
||||
}
|
||||
|
||||
export function getNextStepText(status: DeliveryOrderStatus): string {
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') return '确认是否接单'
|
||||
if (status == 'accepted' || status == 'waiting_departure') return '前往服务对象地址'
|
||||
if (status == 'departed' || status == 'on_the_way') return '到达服务地点'
|
||||
if (status == 'arrived') return '完成签到确认'
|
||||
if (status == 'checked_in') return '开始本次上门服务'
|
||||
if (status == 'in_service' || status == 'serving') return '补充服务记录'
|
||||
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') return '确认并完成订单'
|
||||
if (status == 'completed') return '查看历史记录'
|
||||
if (status == 'abnormal' || status == 'exception_pending') return '跟进异常处置'
|
||||
return '查看订单详情'
|
||||
}
|
||||
|
||||
export function getStatusClass(status: DeliveryOrderStatus): string {
|
||||
if (status == 'pending_assignment' || status == 'pending_accept' || status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') return 'warning'
|
||||
if (status == 'completed') return 'success'
|
||||
if (status == 'abnormal' || status == 'exception_pending') return 'danger'
|
||||
if (status == 'rejected' || status == 'cancelled' || status == 'terminated') return 'muted'
|
||||
return 'primary'
|
||||
}
|
||||
|
||||
export function needsServiceRecord(order: DeliveryOrderType): boolean {
|
||||
return order.serviceRecord == null
|
||||
}
|
||||
@@ -175,6 +175,8 @@ function parseProductFromRaw(item: any): Product {
|
||||
const result: Product = {
|
||||
id: safeGetString(itemObj, 'id'),
|
||||
name: safeGetString(itemObj, 'name'),
|
||||
short_title: safeGetString(itemObj, 'short_title'),
|
||||
subtitle: safeGetString(itemObj, 'subtitle'),
|
||||
description: safeGetString(itemObj, 'description'),
|
||||
base_price: safeGetNumber(itemObj, 'base_price'),
|
||||
price: safeGetNumber(itemObj, 'base_price'),
|
||||
@@ -193,6 +195,12 @@ function parseProductFromRaw(item: any): Product {
|
||||
is_featured: safeGetBoolean(itemObj, 'is_featured'),
|
||||
is_new: safeGetBoolean(itemObj, 'is_new'),
|
||||
is_hot: safeGetBoolean(itemObj, 'is_hot'),
|
||||
card_tags: safeGetStringArray(itemObj, 'card_tags'),
|
||||
service_tags: safeGetStringArray(itemObj, 'service_tags'),
|
||||
selling_points: safeGetStringArray(itemObj, 'selling_points'),
|
||||
display_sales_text: safeGetString(itemObj, 'display_sales_text'),
|
||||
compliance_type: safeGetString(itemObj, 'compliance_type'),
|
||||
device_class: safeGetString(itemObj, 'device_class'),
|
||||
specification: safeGetString(itemObj, 'specification'),
|
||||
usage: safeGetString(itemObj, 'usage'),
|
||||
side_effects: safeGetString(itemObj, 'side_effects'),
|
||||
@@ -256,6 +264,12 @@ export type Category = {
|
||||
parent_id?: string
|
||||
level?: number
|
||||
slug?: string
|
||||
sort_order?: number
|
||||
image_url?: string
|
||||
scene?: string
|
||||
category_type?: string
|
||||
compliance_type?: string
|
||||
is_active?: boolean
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
@@ -290,6 +304,13 @@ export type Product = {
|
||||
shop_id?: string
|
||||
tags?: string
|
||||
attributes?: string
|
||||
short_title?: string
|
||||
card_tags?: string[]
|
||||
service_tags?: string[]
|
||||
selling_points?: string[]
|
||||
display_sales_text?: string
|
||||
compliance_type?: string
|
||||
device_class?: string
|
||||
specification?: string
|
||||
usage?: string
|
||||
side_effects?: string
|
||||
@@ -491,6 +512,192 @@ function emptyProductPage(page: number, limit: number): PaginatedResponse<Produc
|
||||
}
|
||||
}
|
||||
|
||||
function buildAnyStringList(values: string[]): any[] {
|
||||
const result: any[] = []
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
if (values[i] != '') {
|
||||
result.push(values[i])
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function parseMedicalMallCategory(item: UTSJSONObject): Category {
|
||||
const icon = safeGetString(item, 'icon')
|
||||
const imageUrl = safeGetString(item, 'image_url')
|
||||
const color = safeGetString(item, 'color')
|
||||
return {
|
||||
id: safeGetString(item, 'id'),
|
||||
name: safeGetString(item, 'name'),
|
||||
icon: icon != '' ? icon : imageUrl,
|
||||
description: safeGetString(item, 'description'),
|
||||
color: color != '' ? color : '#16a085',
|
||||
parent_id: safeGetString(item, 'parent_id'),
|
||||
level: safeGetNumber(item, 'level'),
|
||||
slug: safeGetString(item, 'category_type'),
|
||||
sort_order: safeGetNumber(item, 'sort_order'),
|
||||
image_url: imageUrl,
|
||||
scene: safeGetString(item, 'scene'),
|
||||
category_type: safeGetString(item, 'category_type'),
|
||||
compliance_type: safeGetString(item, 'compliance_type'),
|
||||
is_active: safeGetBoolean(item, 'is_active'),
|
||||
created_at: safeGetString(item, 'created_at')
|
||||
} as Category
|
||||
}
|
||||
|
||||
function getMedicalMallCategoryKeywords(categoryId: string): string[] {
|
||||
if (categoryId == 'med_device') return ['医疗器械', '血压计', '血糖仪', '血氧仪', '体温计', '制氧机', '雾化器', '轮椅', '拐杖', '护理床']
|
||||
if (categoryId == 'blood_pressure_monitor') return ['血压计', '血压监测', '电子血压计']
|
||||
if (categoryId == 'blood_glucose_meter') return ['血糖仪', '血糖测试', '采血笔']
|
||||
if (categoryId == 'oximeter') return ['血氧仪', '血氧']
|
||||
if (categoryId == 'thermometer') return ['体温计', '额温枪', '测温']
|
||||
if (categoryId == 'oxygen_concentrator') return ['制氧机', '吸氧']
|
||||
if (categoryId == 'nebulizer') return ['雾化器', '雾化']
|
||||
if (categoryId == 'wheelchair_crutch') return ['轮椅', '拐杖', '助行器']
|
||||
if (categoryId == 'nursing_bed') return ['护理床', '病床']
|
||||
|
||||
if (categoryId == 'otc_medicine') return ['感冒药', '退烧药', '止咳', '咽喉', '肠胃', '皮肤', '止痛', '跌打', '儿童用药', '家庭常备药']
|
||||
if (categoryId == 'cold_fever') return ['感冒药', '退烧', '发烧', '退热贴', '感冒']
|
||||
if (categoryId == 'cough_throat') return ['咳嗽', '咽喉', '润喉']
|
||||
if (categoryId == 'stomach_medicine') return ['肠胃', '胃药', '益生菌']
|
||||
if (categoryId == 'skin_external') return ['皮肤', '外用', '软膏', '喷剂']
|
||||
if (categoryId == 'eye_ear_nose') return ['眼药', '滴眼', '鼻炎', '口腔', '耳']
|
||||
if (categoryId == 'pain_relief') return ['止痛', '镇痛']
|
||||
if (categoryId == 'trauma_sprain') return ['跌打', '扭伤', '损伤', '喷雾']
|
||||
if (categoryId == 'child_medicine') return ['儿童', '小儿']
|
||||
|
||||
if (categoryId == 'rehab_care') return ['康复', '护理', '敷料', '护具', '支具', '理疗', '热敷', '训练']
|
||||
if (categoryId == 'postop_rehab') return ['术后', '恢复带', '康复']
|
||||
if (categoryId == 'wound_dressing' || categoryId == 'wound_care') return ['伤口', '敷料', '纱布', '创可贴', '护理包']
|
||||
if (categoryId == 'brace_support') return ['护具', '支具', '护腰', '护膝', '支撑带']
|
||||
if (categoryId == 'rehab_training') return ['康复训练', '训练器']
|
||||
if (categoryId == 'physiotherapy_hot') return ['理疗', '热敷', '暖贴', '热敷贴']
|
||||
if (categoryId == 'mobility_training') return ['行动训练', '步行训练']
|
||||
|
||||
if (categoryId == 'chronic_monitor') return ['慢病', '血压', '血糖', '心脑血管', '呼吸', '体脂', '家庭检测']
|
||||
if (categoryId == 'hypertension') return ['高血压', '血压']
|
||||
if (categoryId == 'diabetes') return ['糖尿病', '血糖']
|
||||
if (categoryId == 'cardiovascular') return ['心脑血管', '心率', '心电']
|
||||
if (categoryId == 'respiratory_health') return ['呼吸', '雾化', '氧', '制氧']
|
||||
if (categoryId == 'weight_bodyfat') return ['体重', '体脂']
|
||||
if (categoryId == 'home_testing') return ['检测', '试纸']
|
||||
|
||||
if (categoryId == 'elderly_aid') return ['适老', '长者', '防滑', '扶手', '助浴', '失禁', '生活辅助']
|
||||
if (categoryId == 'anti_slip') return ['防滑', '防跌']
|
||||
if (categoryId == 'elderly_bathroom') return ['卫浴', '扶手', '浴室']
|
||||
if (categoryId == 'eating_aid') return ['助餐', '餐具']
|
||||
if (categoryId == 'bathing_aid') return ['助浴', '洗澡椅', '沐浴']
|
||||
if (categoryId == 'incontinence_care') return ['失禁', '护理垫', '纸尿裤']
|
||||
if (categoryId == 'daily_living_aid') return ['生活辅助', '起身', '坐便']
|
||||
|
||||
if (categoryId == 'nutrition_health') return ['维生素', '钙片', '蛋白粉', '营养', '益生菌', '免疫']
|
||||
if (categoryId == 'vitamin') return ['维生素', '维C', '维D']
|
||||
if (categoryId == 'calcium') return ['钙片', '钙', '钙铁锌', '锌', '硒']
|
||||
if (categoryId == 'protein') return ['蛋白', '蛋白粉']
|
||||
if (categoryId == 'elderly_nutrition') return ['老人营养', '中老年营养']
|
||||
if (categoryId == 'gut_health') return ['益生菌', '肠道']
|
||||
if (categoryId == 'immune_support') return ['免疫', '免疫支持']
|
||||
|
||||
if (categoryId == 'protection_disinfection') return ['口罩', '消毒', '酒精', '湿巾', '手套', '急救包', '棉签', '纱布']
|
||||
if (categoryId == 'mask') return ['口罩']
|
||||
if (categoryId == 'disinfectant') return ['消毒液', '消毒', '酒精']
|
||||
if (categoryId == 'alcohol_wipes') return ['酒精湿巾', '湿巾']
|
||||
if (categoryId == 'gloves') return ['手套']
|
||||
if (categoryId == 'first_aid') return ['急救包']
|
||||
if (categoryId == 'dressing_tools' || categoryId == 'nursing_consumables') return ['棉签', '纱布', '耗材']
|
||||
|
||||
if (categoryId == 'tcm_health') return ['中医', '艾灸', '拔罐', '养生茶', '贴敷', '药膳', '按摩', '泡脚']
|
||||
if (categoryId == 'moxibustion') return ['艾灸', '拔罐', '艾条', '温灸']
|
||||
if (categoryId == 'herbal_drink') return ['养生茶', '茶饮', '草本']
|
||||
if (categoryId == 'tcm_patch') return ['贴敷', '理疗贴', '草本贴']
|
||||
if (categoryId == 'medicated_diet') return ['药膳', '滋补']
|
||||
if (categoryId == 'massage_tools') return ['按摩', '理疗', '刮痧']
|
||||
if (categoryId == 'foot_bath') return ['泡脚', '足浴']
|
||||
|
||||
if (categoryId == 'home_care_daily') return ['护理', '伤口', '口腔', '皮肤', '清洁', '耗材', '健康工具']
|
||||
if (categoryId == 'oral_care') return ['口腔', '牙', '漱口']
|
||||
if (categoryId == 'skin_care') return ['皮肤护理', '修护', '护肤']
|
||||
if (categoryId == 'cleaning_care') return ['清洁护理', '清洁']
|
||||
if (categoryId == 'home_health_tool') return ['健康工具', '家庭健康']
|
||||
|
||||
if (categoryId == 'all_medical' || categoryId == 'recommend') return ['血压计', '血糖仪', '血氧仪', '体温计', '制氧机', '雾化器', '轮椅', '护理床', '感冒药', '退热贴', '止咳', '胃药', '创可贴', '敷料', '纱布', '护具', '康复', '理疗', '慢病', '口罩', '消毒', '酒精', '急救包', '艾灸', '拔罐', '维生素', '钙片', '蛋白粉', '益生菌', '老人营养', '适老', '助浴', '护理']
|
||||
return [] as string[]
|
||||
}
|
||||
|
||||
function containsMedicalMallKeyword(source: string, keywords: string[]): boolean {
|
||||
if (source == '' || keywords.length == 0) {
|
||||
return false
|
||||
}
|
||||
for (let i = 0; i < keywords.length; i++) {
|
||||
if (keywords[i] != '' && source.indexOf(keywords[i]) != -1) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function buildMedicalMallProductText(item: UTSJSONObject): string {
|
||||
const tags = safeGetStringArray(item, 'tags')
|
||||
let tagText = ''
|
||||
for (let i = 0; i < tags.length; i++) {
|
||||
if (tags[i] != '') {
|
||||
tagText += ' ' + tags[i]
|
||||
}
|
||||
}
|
||||
return (
|
||||
safeGetString(item, 'name') + ' ' +
|
||||
safeGetString(item, 'subtitle') + ' ' +
|
||||
safeGetString(item, 'description') + ' ' +
|
||||
safeGetString(item, 'category_name') + ' ' +
|
||||
safeGetString(item, 'specification') + ' ' +
|
||||
safeGetString(item, 'usage') + ' ' +
|
||||
tagText
|
||||
)
|
||||
}
|
||||
|
||||
function isRxHiddenProduct(item: UTSJSONObject): boolean {
|
||||
return safeGetString(item, 'compliance_type') == 'rx_hidden'
|
||||
}
|
||||
|
||||
function matchesMedicalMallFallback(item: UTSJSONObject, categoryId: string): boolean {
|
||||
if (isRxHiddenProduct(item)) {
|
||||
return false
|
||||
}
|
||||
const sourceText = buildMedicalMallProductText(item)
|
||||
return containsMedicalMallKeyword(sourceText, getMedicalMallCategoryKeywords(categoryId))
|
||||
}
|
||||
|
||||
function sortProductsByIdOrder(products: Product[], orderedIds: string[]): Product[] {
|
||||
const productMap = new Map<string, Product>()
|
||||
for (let i = 0; i < products.length; i++) {
|
||||
productMap.set(products[i].id, products[i])
|
||||
}
|
||||
const sorted: Product[] = []
|
||||
for (let i = 0; i < orderedIds.length; i++) {
|
||||
const item = productMap.get(orderedIds[i])
|
||||
if (item != null) {
|
||||
sorted.push(item)
|
||||
}
|
||||
}
|
||||
return sorted
|
||||
}
|
||||
|
||||
function dedupeProducts(products: Product[]): Product[] {
|
||||
const deduped: Product[] = []
|
||||
const seenIds: string[] = []
|
||||
for (let i = 0; i < products.length; i++) {
|
||||
const productId = products[i].id
|
||||
if (productId != '' && seenIds.indexOf(productId) != -1) {
|
||||
continue
|
||||
}
|
||||
if (productId != '') {
|
||||
seenIds.push(productId)
|
||||
}
|
||||
deduped.push(products[i])
|
||||
}
|
||||
return deduped
|
||||
}
|
||||
|
||||
export type ShopOrderResponse = {
|
||||
success: boolean
|
||||
orderIds: string[]
|
||||
@@ -946,6 +1153,373 @@ class SupabaseService {
|
||||
}
|
||||
}
|
||||
|
||||
async getMedicalMallParentCategories(): Promise<Category[]> {
|
||||
try {
|
||||
if (!logConsumerQueryStart('getMedicalMallParentCategories', 'medical_mall_categories', '*')) {
|
||||
return []
|
||||
}
|
||||
const response = await supa
|
||||
.from('medical_mall_categories')
|
||||
.select('*')
|
||||
.is('parent_id', null)
|
||||
.eq('is_active', true)
|
||||
.is('deleted_at', null)
|
||||
.order('sort_order', { ascending: true })
|
||||
.execute()
|
||||
|
||||
if (response.error != null || response.data == null) {
|
||||
logConsumerQueryFailure('getMedicalMallParentCategories', 'medical_mall_categories', response.error)
|
||||
return []
|
||||
}
|
||||
|
||||
const rows = response.data as UTSJSONObject[]
|
||||
const categories: Category[] = []
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
categories.push(parseMedicalMallCategory(JSON.parse(JSON.stringify(rows[i])) as UTSJSONObject))
|
||||
}
|
||||
logConsumerQuerySuccess('getMedicalMallParentCategories', 'medical_mall_categories', categories.length)
|
||||
return categories
|
||||
} catch (error) {
|
||||
logConsumerQueryFailure('getMedicalMallParentCategories', 'medical_mall_categories', error)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
async getMedicalMallCategoryById(categoryId: string): Promise<Category | null> {
|
||||
try {
|
||||
if (categoryId == '') {
|
||||
return null
|
||||
}
|
||||
const response = await supa
|
||||
.from('medical_mall_categories')
|
||||
.select('*')
|
||||
.eq('id', categoryId)
|
||||
.eq('is_active', true)
|
||||
.is('deleted_at', null)
|
||||
.limit(1)
|
||||
.execute()
|
||||
|
||||
if (response.error != null || response.data == null) {
|
||||
logConsumerQueryFailure('getMedicalMallCategoryById', 'medical_mall_categories', response.error)
|
||||
return null
|
||||
}
|
||||
|
||||
const rows = response.data as UTSJSONObject[]
|
||||
if (rows.length == 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
return parseMedicalMallCategory(JSON.parse(JSON.stringify(rows[0])) as UTSJSONObject)
|
||||
} catch (error) {
|
||||
logConsumerQueryFailure('getMedicalMallCategoryById', 'medical_mall_categories', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async getMedicalMallSubCategories(parentId: string): Promise<Category[]> {
|
||||
try {
|
||||
if (!logConsumerQueryStart('getMedicalMallSubCategories', 'medical_mall_categories', '*')) {
|
||||
return []
|
||||
}
|
||||
const response = await supa
|
||||
.from('medical_mall_categories')
|
||||
.select('*')
|
||||
.eq('parent_id', parentId)
|
||||
.eq('is_active', true)
|
||||
.is('deleted_at', null)
|
||||
.order('sort_order', { ascending: true })
|
||||
.execute()
|
||||
|
||||
if (response.error != null || response.data == null) {
|
||||
logConsumerQueryFailure('getMedicalMallSubCategories', 'medical_mall_categories', response.error)
|
||||
return []
|
||||
}
|
||||
|
||||
const rows = response.data as UTSJSONObject[]
|
||||
const categories: Category[] = []
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
categories.push(parseMedicalMallCategory(JSON.parse(JSON.stringify(rows[i])) as UTSJSONObject))
|
||||
}
|
||||
logConsumerQuerySuccess('getMedicalMallSubCategories', 'medical_mall_categories', categories.length)
|
||||
return categories
|
||||
} catch (error) {
|
||||
logConsumerQueryFailure('getMedicalMallSubCategories', 'medical_mall_categories', error)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
async getMedicalMallCategoryChildrenIds(parentId: string): Promise<string[]> {
|
||||
try {
|
||||
let response: any
|
||||
if (parentId == 'all_medical') {
|
||||
response = await supa
|
||||
.from('medical_mall_categories')
|
||||
.select('id')
|
||||
.eq('is_active', true)
|
||||
.is('deleted_at', null)
|
||||
.eq('level', 2)
|
||||
.order('sort_order', { ascending: true })
|
||||
.execute()
|
||||
} else {
|
||||
response = await supa
|
||||
.from('medical_mall_categories')
|
||||
.select('id')
|
||||
.eq('parent_id', parentId)
|
||||
.eq('is_active', true)
|
||||
.is('deleted_at', null)
|
||||
.order('sort_order', { ascending: true })
|
||||
.execute()
|
||||
}
|
||||
|
||||
if (response.error != null || response.data == null) {
|
||||
return []
|
||||
}
|
||||
|
||||
const rows = response.data as UTSJSONObject[]
|
||||
const ids: string[] = []
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const row = JSON.parse(JSON.stringify(rows[i])) as UTSJSONObject
|
||||
const id = safeGetString(row, 'id')
|
||||
if (id != '') {
|
||||
ids.push(id)
|
||||
}
|
||||
}
|
||||
return ids
|
||||
} catch (error) {
|
||||
console.error('获取医疗商城子分类 ID 失败:', error)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
async getMedicalMallProductsByCategory(categoryId: string, page: number = 1, limit: number = 20): Promise<PaginatedResponse<Product>> {
|
||||
try {
|
||||
if (categoryId == 'recommend') {
|
||||
return await this.getMedicalMallSmartRecommendations(page, limit)
|
||||
}
|
||||
if (!logConsumerQueryStart('getMedicalMallProductsByCategory', 'medical_mall_product_categories', '*')) {
|
||||
return emptyProductPage(page, limit)
|
||||
}
|
||||
|
||||
const targetCategoryIds: string[] = []
|
||||
if (categoryId == 'all_medical') {
|
||||
const allChildren = await this.getMedicalMallCategoryChildrenIds('all_medical')
|
||||
for (let i = 0; i < allChildren.length; i++) {
|
||||
targetCategoryIds.push(allChildren[i])
|
||||
}
|
||||
} else {
|
||||
const categoryResponse = await supa
|
||||
.from('medical_mall_categories')
|
||||
.select('id, level')
|
||||
.eq('id', categoryId)
|
||||
.eq('is_active', true)
|
||||
.is('deleted_at', null)
|
||||
.limit(1)
|
||||
.execute()
|
||||
|
||||
targetCategoryIds.push(categoryId)
|
||||
if (categoryResponse.error == null && categoryResponse.data != null) {
|
||||
const categoryRows = categoryResponse.data as UTSJSONObject[]
|
||||
if (categoryRows.length > 0) {
|
||||
const categoryObj = JSON.parse(JSON.stringify(categoryRows[0])) as UTSJSONObject
|
||||
if (safeGetNumber(categoryObj, 'level') == 1) {
|
||||
const childIds = await this.getMedicalMallCategoryChildrenIds(categoryId)
|
||||
for (let i = 0; i < childIds.length; i++) {
|
||||
if (targetCategoryIds.indexOf(childIds[i]) == -1) {
|
||||
targetCategoryIds.push(childIds[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const linkedIds: string[] = []
|
||||
if (targetCategoryIds.length > 0) {
|
||||
const linkResponse = await supa
|
||||
.from('medical_mall_product_categories')
|
||||
.select('product_id, sort_order, created_at')
|
||||
.in('category_id', buildAnyStringList(targetCategoryIds))
|
||||
.is('deleted_at', null)
|
||||
.order('sort_order', { ascending: true })
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(500)
|
||||
.execute()
|
||||
|
||||
if (linkResponse.error == null && linkResponse.data != null) {
|
||||
const linkRows = linkResponse.data as UTSJSONObject[]
|
||||
for (let i = 0; i < linkRows.length; i++) {
|
||||
const row = JSON.parse(JSON.stringify(linkRows[i])) as UTSJSONObject
|
||||
const productId = safeGetString(row, 'product_id')
|
||||
if (productId != '' && linkedIds.indexOf(productId) == -1) {
|
||||
linkedIds.push(productId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let finalProducts: Product[] = []
|
||||
if (linkedIds.length > 0) {
|
||||
const productResponse = await supa
|
||||
.from('ml_products_detail_view')
|
||||
.select('*')
|
||||
.in('id', buildAnyStringList(linkedIds))
|
||||
.eq('status', '1')
|
||||
.execute()
|
||||
|
||||
if (productResponse.error == null && productResponse.data != null) {
|
||||
const rows = productResponse.data as any[]
|
||||
const parsed: Product[] = []
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const rowObj = JSON.parse(JSON.stringify(rows[i])) as UTSJSONObject
|
||||
if (isRxHiddenProduct(rowObj)) {
|
||||
continue
|
||||
}
|
||||
parsed.push(parseProductFromRaw(rows[i]))
|
||||
}
|
||||
finalProducts = sortProductsByIdOrder(parsed, linkedIds)
|
||||
}
|
||||
}
|
||||
|
||||
if (finalProducts.length == 0) {
|
||||
const fallbackResponse = await supa
|
||||
.from('ml_products_detail_view')
|
||||
.select('*')
|
||||
.eq('status', '1')
|
||||
.order('sale_count', { ascending: false })
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(300)
|
||||
.execute()
|
||||
|
||||
if (fallbackResponse.error == null && fallbackResponse.data != null) {
|
||||
const fallbackRows = fallbackResponse.data as any[]
|
||||
for (let i = 0; i < fallbackRows.length; i++) {
|
||||
const rowObj = JSON.parse(JSON.stringify(fallbackRows[i])) as UTSJSONObject
|
||||
if (!matchesMedicalMallFallback(rowObj, categoryId)) {
|
||||
continue
|
||||
}
|
||||
finalProducts.push(parseProductFromRaw(fallbackRows[i]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const deduped = dedupeProducts(finalProducts)
|
||||
const startIndex = (page - 1) * limit
|
||||
const endIndex = startIndex + limit
|
||||
return {
|
||||
data: deduped.slice(startIndex, endIndex),
|
||||
total: deduped.length,
|
||||
page,
|
||||
limit,
|
||||
hasmore: deduped.length > endIndex
|
||||
}
|
||||
} catch (error) {
|
||||
logConsumerQueryFailure('getMedicalMallProductsByCategory', 'medical_mall_product_categories', error)
|
||||
console.error('获取医疗商城分类商品失败:', error)
|
||||
return emptyProductPage(page, limit)
|
||||
}
|
||||
}
|
||||
|
||||
async getMedicalMallSmartRecommendations(page: number = 1, limit: number = 10): Promise<PaginatedResponse<Product>> {
|
||||
try {
|
||||
if (!logConsumerQueryStart('getMedicalMallSmartRecommendations', 'medical_mall_product_categories', '*')) {
|
||||
return emptyProductPage(page, limit)
|
||||
}
|
||||
|
||||
const linkedIds: string[] = []
|
||||
const linkResponse = await supa
|
||||
.from('medical_mall_product_categories')
|
||||
.select('product_id, is_primary, sort_order, created_at')
|
||||
.is('deleted_at', null)
|
||||
.order('is_primary', { ascending: false })
|
||||
.order('sort_order', { ascending: true })
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(500)
|
||||
.execute()
|
||||
|
||||
if (linkResponse.error == null && linkResponse.data != null) {
|
||||
const linkRows = linkResponse.data as UTSJSONObject[]
|
||||
for (let i = 0; i < linkRows.length; i++) {
|
||||
const row = JSON.parse(JSON.stringify(linkRows[i])) as UTSJSONObject
|
||||
const productId = safeGetString(row, 'product_id')
|
||||
if (productId != '' && linkedIds.indexOf(productId) == -1) {
|
||||
linkedIds.push(productId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const merged: Product[] = []
|
||||
const addedIds = new Set<string>()
|
||||
|
||||
if (linkedIds.length > 0) {
|
||||
const linkedProductResponse = await supa
|
||||
.from('ml_products_detail_view')
|
||||
.select('*')
|
||||
.in('id', buildAnyStringList(linkedIds))
|
||||
.eq('status', '1')
|
||||
.execute()
|
||||
|
||||
if (linkedProductResponse.error == null && linkedProductResponse.data != null) {
|
||||
const rows = linkedProductResponse.data as any[]
|
||||
const parsed: Product[] = []
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const rowObj = JSON.parse(JSON.stringify(rows[i])) as UTSJSONObject
|
||||
if (isRxHiddenProduct(rowObj)) {
|
||||
continue
|
||||
}
|
||||
parsed.push(parseProductFromRaw(rows[i]))
|
||||
}
|
||||
const ordered = sortProductsByIdOrder(parsed, linkedIds)
|
||||
for (let i = 0; i < ordered.length; i++) {
|
||||
if (!addedIds.has(ordered[i].id)) {
|
||||
merged.push(ordered[i])
|
||||
addedIds.add(ordered[i].id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (merged.length < page * limit + limit) {
|
||||
const fallbackResponse = await supa
|
||||
.from('ml_products_detail_view')
|
||||
.select('*')
|
||||
.eq('status', '1')
|
||||
.order('sale_count', { ascending: false })
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(300)
|
||||
.execute()
|
||||
|
||||
if (fallbackResponse.error == null && fallbackResponse.data != null) {
|
||||
const rows = fallbackResponse.data as any[]
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const rowObj = JSON.parse(JSON.stringify(rows[i])) as UTSJSONObject
|
||||
if (!matchesMedicalMallFallback(rowObj, 'recommend')) {
|
||||
continue
|
||||
}
|
||||
const product = parseProductFromRaw(rows[i])
|
||||
if (!addedIds.has(product.id)) {
|
||||
merged.push(product)
|
||||
addedIds.add(product.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const startIndex = (page - 1) * limit
|
||||
const endIndex = startIndex + limit
|
||||
return {
|
||||
data: merged.slice(startIndex, endIndex),
|
||||
total: merged.length,
|
||||
page,
|
||||
limit,
|
||||
hasmore: merged.length > endIndex
|
||||
}
|
||||
} catch (error) {
|
||||
logConsumerQueryFailure('getMedicalMallSmartRecommendations', 'medical_mall_product_categories', error)
|
||||
console.error('获取医疗商城推荐商品失败:', error)
|
||||
return emptyProductPage(page, limit)
|
||||
}
|
||||
}
|
||||
|
||||
// 根据商品ID获取SKU列表
|
||||
async getProductSkus(productId: string): Promise<ProductSku[]> {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user