From 1cca27096a4b78611871f803077c33cc5b4b4d3a Mon Sep 17 00:00:00 2001
From: not-like-juvenile <16056107+not-like-juvenile@user.noreply.gitee.com>
Date: Wed, 28 Jan 2026 10:29:09 +0800
Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=BB=E5=88=86=E6=94=AF=E5=90=88?=
=?UTF-8?q?=E5=B9=B6=E5=8F=8A=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package-lock.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/package-lock.json b/package-lock.json
index 4a86479c..507bf6c8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4,6 +4,7 @@
"requires": true,
"packages": {
"": {
+ "name": "mall",
"dependencies": {
"echarts": "^6.0.0"
},
From 76eb96ec0c1c7fb3618e30068060463074f087fb Mon Sep 17 00:00:00 2001
From: not-like-juvenile <16056107+not-like-juvenile@user.noreply.gitee.com>
Date: Wed, 28 Jan 2026 19:13:13 +0800
Subject: [PATCH 2/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=BB=E8=BE=91?=
=?UTF-8?q?=E5=B9=B6=E6=B5=8B=E8=AF=95=E8=BF=9E=E6=8E=A5=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ak/config.uts | 6 +-
pages.json | 28 ++
pages/mall/delivery/about.uvue | 293 +++++++++++++++
pages/mall/delivery/delivery.md | 6 -
pages/mall/delivery/feedback.uvue | 451 +++++++++++++++++++++++
pages/mall/delivery/help-center.uvue | 524 +++++++++++++++++++++++++++
pages/mall/delivery/profile.uvue | 92 ++++-
pages/mall/delivery/test.uvue | 418 +++++++++++++++++++++
8 files changed, 1795 insertions(+), 23 deletions(-)
create mode 100644 pages/mall/delivery/about.uvue
create mode 100644 pages/mall/delivery/feedback.uvue
create mode 100644 pages/mall/delivery/help-center.uvue
create mode 100644 pages/mall/delivery/test.uvue
diff --git a/ak/config.uts b/ak/config.uts
index 7269882b..a24c488a 100644
--- a/ak/config.uts
+++ b/ak/config.uts
@@ -1,12 +1,12 @@
// Supabase 配置
// 内网环境 - 本地部署的 Supabase
-// IP: 192.168.1.63
+// IP: 192.168.1.62
// Kong HTTP Port: 8000
-export const SUPA_URL: string = 'http://192.168.1.63:8000'
+export const SUPA_URL: string = 'http://192.168.1.62:8000'
export const SUPA_KEY: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzY4ODMwNjI0LCJleHAiOjE5MjY1MTA2MjR9.mDVl-kIOdRK9v6VTxo0TDF8r7X7xk3PZXazaavHyVvg'
// WebSocket 实时连接(内网使用 ws:// 而非 wss://)
-export const WS_URL: string = 'ws://192.168.1.63:8000/realtime/v1/websocket'
+export const WS_URL: string = 'ws://192.168.1.62:8000/realtime/v1/websocket'
// 备用配置(已注释,如需切换可取消注释)
// 开发环境 - 其他内网地址
diff --git a/pages.json b/pages.json
index 314253fb..6261795f 100644
--- a/pages.json
+++ b/pages.json
@@ -324,6 +324,34 @@
"navigationStyle": "custom"
}
},
+ {
+ "path": "help-center",
+ "style": {
+ "navigationBarTitleText": "帮助中心",
+ "navigationStyle": "custom"
+ }
+ },
+ {
+ "path": "about",
+ "style": {
+ "navigationBarTitleText": "关于我们",
+ "navigationStyle": "custom"
+ }
+ },
+ {
+ "path": "feedback",
+ "style": {
+ "navigationBarTitleText": "意见反馈",
+ "navigationStyle": "custom"
+ }
+ },
+ {
+ "path": "test",
+ "style": {
+ "navigationBarTitleText": "test",
+ "navigationStyle": "custom"
+ }
+ },
{
"path": "settings",
"style": {
diff --git a/pages/mall/delivery/about.uvue b/pages/mall/delivery/about.uvue
new file mode 100644
index 00000000..8cf90f4c
--- /dev/null
+++ b/pages/mall/delivery/about.uvue
@@ -0,0 +1,293 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 版本: v2.1.5
+
+
+
+
+ 快递配送助手
+ 专为配送员打造的一站式智能配送平台,提升效率,优化服务体验
+
+
+
+
+
+
+
+ 📍
+ 智能路线规划
+
+
+ 📱
+ 实时订单管理
+
+
+ 💰
+ 在线结算系统
+
+
+ ⭐
+ 客户评价反馈
+
+
+
+
+
+
+
+ 公司名称: 快递科技有限公司
+ 成立时间: 2020年
+ 总部地点: 深圳市南山区科技园
+ 联系电话: 400-123-4567
+ 邮箱: support@delivery.com
+
+
+
+
+
+
+ v2.1.5 (2026-01-27)
+ • 修复了地图定位精度问题\n• 优化了任务分配算法\n• 提升了语音播报稳定性
+
+
+ v2.1.4 (2026-01-15)
+ • 新增智能语音助手功能\n• 改进了路线导航算法\n• 修复了部分UI显示异常
+
+
+ v2.1.3 (2025-12-28)
+ • 新增客户满意度评价\n• 优化了离线地图功能\n• 增强了数据同步机制
+
+
+
+
+
+ © 2020-2026 快递科技有限公司 版权所有
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/mall/delivery/delivery.md b/pages/mall/delivery/delivery.md
index 3166bf09..7d275fa1 100644
--- a/pages/mall/delivery/delivery.md
+++ b/pages/mall/delivery/delivery.md
@@ -1,7 +1,3 @@
-✅ 明白了!你不需要完整代码,而是希望我**用简洁的 Markdown 文档形式,解释这个 `delivery` 文件夹下的项目结构和每个页面的功能定位**。
-
----
-
# 🚚 配送端模块项目结构说明(`/pages/mall/delivery/`)
> 本模块为配送员使用的移动端应用核心功能区,涵盖个人中心、任务管理、收入统计、车辆管理等核心功能。
@@ -25,7 +21,6 @@ delivery/
├── vehicle.uvue # 车辆管理主页
├── vehicle-add.uvue # 添加车辆
├── vehicle-edit.uvue # 编辑车辆信息
-└── index.uvue # 首页(与上面重复?应统一命名)
```
> 💡 注:`index.uvue` 出现两次,建议保留一个作为首页入口,另一个可重命名为 `dashboard.uvue` 或 `home.uvue`
@@ -171,7 +166,6 @@ index.uvue
| 问题 | 建议 |
|------|------|
-| `index.uvue` 重复 | 重命名为 `dashboard.uvue` 或 `home.uvue` |
| 页面间参数传递 | 使用 `uni.navigateTo({ url: '?param=value' })` 并在 `onLoad` 中接收 |
| UTS 语法兼容性 | 如遇问题,可临时改用标准 TS 语法调试 |
diff --git a/pages/mall/delivery/feedback.uvue b/pages/mall/delivery/feedback.uvue
new file mode 100644
index 00000000..e11134d7
--- /dev/null
+++ b/pages/mall/delivery/feedback.uvue
@@ -0,0 +1,451 @@
+
+
+
+
+
+
+
+
+
+ 问题类型
+
+ {{ feedbackTypes[selectedTypeIndex] }}
+
+
+
+
+
+ 标题
+
+
+
+
+
+ 详细内容
+
+
+
+
+
+ 上传截图(可选)
+
+ 🖼️
+ 点击上传截图
+ 支持 JPG/PNG,最多3张
+
+
+
+
+
+
+ ×
+
+
+
+
+
+
+ 关联订单号(可选)
+
+
+ {{ selectedOrderIndex === -1 ? '请选择订单' : orderOptions[selectedOrderIndex] }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/mall/delivery/help-center.uvue b/pages/mall/delivery/help-center.uvue
new file mode 100644
index 00000000..7b7b63c2
--- /dev/null
+++ b/pages/mall/delivery/help-center.uvue
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+ 🔍
+
+
+
+
+
+
+
+
+ {{ cat.name }}
+
+
+
+
+
+
+
+
+ 搜索结果:{{ searchResults.length }} 条
+ 清除
+
+
+
+
+
+
+
+ {{ item.content }}
+
+
+
+
+
+
+ ❓
+ 暂无匹配结果
+ 请尝试更换关键词,或查看以下热门问题
+
+ 热门问题:
+ 如何接单?
+ 配送超时怎么办?
+ 如何联系客户?
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/mall/delivery/profile.uvue b/pages/mall/delivery/profile.uvue
index 05e07c0b..7b9094c5 100644
--- a/pages/mall/delivery/profile.uvue
+++ b/pages/mall/delivery/profile.uvue
@@ -4,8 +4,8 @@
-
+
+
📍 {{ currentLocation }}
+
+ ↻
+
@@ -214,7 +218,7 @@ const driverInfo = ref({
})
const workStatus = ref(1) // 1 工作中 0 休息中
-const currentLocation = ref('朝阳区建国门附近')
+const currentLocation = ref('朝阳区建国门附近') // 默认位置
const taskCounts = ref({ total: 0, pending: 0, ongoing: 0, completed: 0 })
@@ -364,6 +368,41 @@ function toggleWorkStatus() {
})
}
+// --- 新增:重新定位逻辑 ---
+function showRelocateConfirm() {
+ uni.showModal({
+ title: '重新定位',
+ content: '确定要更新当前位置吗?',
+ confirmText: '立即定位',
+ success: (res) => {
+ if (res.confirm) {
+ relocate()
+ }
+ }
+ })
+}
+
+function relocate() {
+ uni.showLoading({
+ title: '获取位置中...',
+ mask: true
+ })
+
+ // 模拟定位耗时
+ setTimeout(() => {
+ uni.hideLoading()
+
+ // 模拟定位成功,更新位置(实际项目中应调用API获取真实位置)
+ currentLocation.value = '朝阳区建国门外大街附近'
+
+ uni.showToast({
+ title: '定位成功',
+ icon: 'success',
+ duration: 1500
+ })
+ }, 1200)
+}
+
function contactCustomer() {
uni.showActionSheet({
itemList: ['拨打电话', '发送短信'],
@@ -398,10 +437,10 @@ function goToRatings() {
uni.navigateTo({ url: '/pages/mall/delivery/ratings' })
}
function goToHelp() {
- uni.navigateTo({ url: '/pages/mall/common/help' })
+ uni.navigateTo({ url: '/pages/mall/delivery/help-center' })
}
function goToFeedback() {
- uni.navigateTo({ url: '/pages/mall/common/feedback' })
+ uni.navigateTo({ url: '/pages/mall/delivery/feedback' })
}
@@ -410,7 +449,7 @@ function goToFeedback() {
.profile-header {
position: relative;
}
-.back-box {
+.nav-left {
position: absolute;
left: 30rpx;
top: 50%;
@@ -423,15 +462,15 @@ function goToFeedback() {
align-items: center;
justify-content: center;
}
-.back-box:active {
+.nav-left:active {
background: rgba(0, 0, 0, .3);
}
-.back-icon {
+.nav-icon {
font-size: 40rpx;
color: #fff;
}
-/* ---------- 以下与原样式一致 ---------- */
+/* ---------- 以下与原样式一致,仅修改工作状态区域 ---------- */
.delivery-profile {
padding: 0 0 120rpx 0;
background-color: #f5f5f5;
@@ -541,14 +580,39 @@ function goToFeedback() {
.toggle-switch.active .toggle-handle {
left: 55rpx;
}
-.current-location {
+
+/* --- 修改后的定位信息区域:地址 + 图标 --- */
+.current-location-section {
+ display: flex;
+ align-items: center;
padding: 15rpx 20rpx;
- background: #e8f4fd;
+ background: #e8f4fd; /* 与原样式保持一致 */
border-radius: 15rpx;
}
.location-text {
+ font-size: 24rpx; /* 与截图字号一致 */
+ color: #74b9ff; /* 与截图颜色一致 */
+ flex: 1; /* 让文字占据剩余空间 */
+ margin-right: 16rpx; /* 与图标留空隙 */
+}
+.relocate-icon {
+ width: 40rpx;
+ height: 40rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ background: rgba(116, 185, 255, 0.15); /* 浅蓝底 */
+ color: #74b9ff; /* 主色文字 */
font-size: 24rpx;
- color: #74b9ff;
+ cursor: pointer;
+ transition: all 0.2s ease;
+}
+.relocate-icon:hover {
+ background: rgba(116, 185, 255, 0.3); /* 悬停效果 */
+}
+.relocate-icon:active {
+ background: rgba(116, 185, 255, 0.4); /* 点击效果 */
}
.task-tabs {
@@ -556,10 +620,10 @@ function goToFeedback() {
justify-content: space-between;
}
.task-tab {
+ flex: 1;
display: flex;
flex-direction: column;
align-items: center;
- flex: 1;
position: relative;
}
.tab-icon {
diff --git a/pages/mall/delivery/test.uvue b/pages/mall/delivery/test.uvue
new file mode 100644
index 00000000..ed67b4e9
--- /dev/null
+++ b/pages/mall/delivery/test.uvue
@@ -0,0 +1,418 @@
+
+
+
+
+
+ 当前配置:
+ URL: {{ config.url }}
+ Key: {{ config.keyMasked }}
+
+
+
+
+
+
+
+ 测试结果
+
+ {{ result.success ? '✅' : '❌' }}
+ {{ result.name }}
+ {{ result.message }}
+ {{ result.errorDetails }}
+
+
+
+
+ 单项测试
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From fde3cb0322985253ca2ee52d4ca093d7323a33ae Mon Sep 17 00:00:00 2001
From: not-like-juvenile <16056107+not-like-juvenile@user.noreply.gitee.com>
Date: Fri, 30 Jan 2026 08:32:12 +0800
Subject: [PATCH 3/5] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=BF=9E=E6=8E=A5?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/mall/delivery/test/ak_users.md | 271 +++++++++++++++++++++
pages/mall/delivery/{ => test}/delivery.md | 2 -
2 files changed, 271 insertions(+), 2 deletions(-)
create mode 100644 pages/mall/delivery/test/ak_users.md
rename pages/mall/delivery/{ => test}/delivery.md (97%)
diff --git a/pages/mall/delivery/test/ak_users.md b/pages/mall/delivery/test/ak_users.md
new file mode 100644
index 00000000..e589d6c3
--- /dev/null
+++ b/pages/mall/delivery/test/ak_users.md
@@ -0,0 +1,271 @@
+- 创建正确的触发器和函数
+CREATE OR REPLACE FUNCTION ensure_ak_user()
+RETURNS TRIGGER AS $$
+BEGIN
+ INSERT INTO public.ak_users (user_id, email, nickname)
+ VALUES (NEW.id, NEW.email, COALESCE(NEW.email, '新用户'))
+ ON CONFLICT (user_id) DO UPDATE SET
+ email = EXCLUDED.email,
+ nickname = EXCLUDED.nickname;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE TRIGGER trigger_ensure_ak_user
+ AFTER INSERT ON auth.users
+ FOR EACH ROW
+ EXECUTE FUNCTION ensure_ak_user();
+
+
+
+-- =============================================
+-- 0. 创建 ak_users 表(你的核心用户表)
+-- =============================================
+CREATE TABLE IF NOT EXISTS public.ak_users (
+ id BIGSERIAL PRIMARY KEY,
+ user_id UUID UNIQUE NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
+ email VARCHAR(255) UNIQUE,
+ phone VARCHAR(20),
+ nickname VARCHAR(100),
+ avatar_url TEXT,
+ gender CHAR(1) DEFAULT 'U',
+ birthday DATE,
+ address TEXT,
+ user_type INTEGER DEFAULT 1, -- 1:普通用户, 2:配送员
+ status VARCHAR(20) DEFAULT 'active',
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
+);
+
+-- =============================================
+-- 1. 配送员资料表 (delivery_drivers)
+-- =============================================
+CREATE TABLE IF NOT EXISTS public.delivery_drivers (
+ id BIGSERIAL PRIMARY KEY,
+ user_id UUID UNIQUE NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
+ real_name VARCHAR(100) NOT NULL,
+ id_card VARCHAR(18),
+ driver_license VARCHAR(50),
+ vehicle_type INTEGER DEFAULT 1, -- 1:电动车, 2:摩托车, 3:汽车
+ vehicle_number VARCHAR(20),
+ work_status INTEGER DEFAULT 1, -- 1:空闲, 2:忙碌, 3:休息
+ current_location JSONB, -- {lat: 22.5431, lng: 114.0579, address: "深圳市南山区"}
+ service_areas TEXT[], -- 服务区域数组 ["南山", "福田", "罗湖"]
+ rating DECIMAL(3,2) DEFAULT 5.00, -- 平均评分
+ total_orders INTEGER DEFAULT 0, -- 总完成订单数
+ auth_status INTEGER DEFAULT 1, -- 1:未认证, 2:审核中, 3:已认证
+ online_status BOOLEAN DEFAULT FALSE, -- 是否在线
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
+);
+
+-- =============================================
+-- 2. 订单表 (orders)
+-- =============================================
+CREATE TABLE IF NOT EXISTS public.orders (
+ id BIGSERIAL PRIMARY KEY,
+ order_no VARCHAR(50) UNIQUE NOT NULL, -- 订单号,如 D202501081234
+ user_id UUID NOT NULL REFERENCES auth.users(id), -- 下单用户
+ status INTEGER DEFAULT 1, -- 1:待支付, 2:待接单, 3:配送中, 4:已完成, 5:已取消
+ total_amount DECIMAL(10,2) NOT NULL, -- 订单总金额
+ delivery_fee DECIMAL(10,2) NOT NULL, -- 配送费
+ payable_amount DECIMAL(10,2) NOT NULL, -- 实付金额
+ pickup_address JSONB NOT NULL, -- 取货地址
+ delivery_address JSONB NOT NULL, -- 配送地址
+ pickup_contact JSONB NOT NULL, -- 取货联系人
+ delivery_contact JSONB NOT NULL, -- 配送联系人
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
+);
+
+-- =============================================
+-- 3. 配送任务表 (delivery_tasks)
+-- =============================================
+CREATE TABLE IF NOT EXISTS public.delivery_tasks (
+ id BIGSERIAL PRIMARY KEY,
+ order_id BIGINT NOT NULL REFERENCES orders(id),
+ driver_id BIGINT NOT NULL REFERENCES delivery_drivers(id),
+ task_status INTEGER DEFAULT 1, -- 1:待接取, 2:已接取, 3:取货中, 4:已取货, 5:配送中, 6:已完成
+ pickup_address JSONB NOT NULL, -- 取货地址 {detail: "", area: "", lat: 0, lng: 0}
+ delivery_address JSONB NOT NULL, -- 配送地址 {detail: "", area: "", lat: 0, lng: 0}
+ pickup_contact JSONB NOT NULL, -- 取货联系人 {name: "", phone: ""}
+ delivery_contact JSONB NOT NULL, -- 配送联系人 {name: "", phone: ""}
+ delivery_fee DECIMAL(10,2) NOT NULL, -- 配送费
+ distance DECIMAL(8,2) DEFAULT 0, -- 配送距离(km)
+ estimated_time INTEGER DEFAULT 0, -- 预计配送时间(分钟)
+ pickup_time TIMESTAMP WITH TIME ZONE, -- 实际取货时间
+ delivery_time TIMESTAMP WITH TIME ZONE, -- 实际配送时间
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
+);
+
+-- =============================================
+-- 4. 今日统计表 (daily_stats)
+-- =============================================
+CREATE TABLE IF NOT EXISTS public.daily_stats (
+ id BIGSERIAL PRIMARY KEY,
+ driver_id BIGINT NOT NULL REFERENCES delivery_drivers(id),
+ stat_date DATE NOT NULL,
+ completed_orders INTEGER DEFAULT 0,
+ total_earning DECIMAL(10,2) DEFAULT 0.00,
+ total_distance DECIMAL(8,2) DEFAULT 0.00,
+ avg_rating DECIMAL(3,2) DEFAULT 5.00,
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
+ UNIQUE(driver_id, stat_date) -- 每个司机每天只有一条统计记录
+);
+
+-- =============================================
+-- 5. 启用 RLS
+-- =============================================
+ALTER TABLE public.ak_users ENABLE ROW LEVEL SECURITY;
+ALTER TABLE public.delivery_drivers ENABLE ROW LEVEL SECURITY;
+ALTER TABLE public.orders ENABLE ROW LEVEL SECURITY;
+ALTER TABLE public.delivery_tasks ENABLE ROW LEVEL SECURITY;
+ALTER TABLE public.daily_stats ENABLE ROW LEVEL SECURITY;
+
+-- =============================================
+-- 6. 创建 RLS 策略
+-- =============================================
+CREATE POLICY "Users can view own profile" ON public.ak_users
+ FOR SELECT USING (auth.uid() = user_id);
+
+CREATE POLICY "Drivers can view own profile" ON public.delivery_drivers
+ FOR SELECT USING (auth.uid() = user_id);
+
+CREATE POLICY "Users can view own orders" ON public.orders
+ FOR SELECT USING (auth.uid() = user_id);
+
+CREATE POLICY "Drivers can view own tasks" ON public.delivery_tasks
+ FOR SELECT USING (EXISTS (
+ SELECT 1 FROM delivery_drivers dd
+ WHERE dd.id = delivery_tasks.driver_id AND dd.user_id = auth.uid()
+ ));
+
+CREATE POLICY "Drivers can view own stats" ON public.daily_stats
+ FOR SELECT USING (EXISTS (
+ SELECT 1 FROM delivery_drivers dd
+ WHERE dd.id = daily_stats.driver_id AND dd.user_id = auth.uid()
+ ));
+
+-- =============================================
+-- 7. 创建索引
+-- =============================================
+CREATE INDEX IF NOT EXISTS idx_ak_users_user_id ON public.ak_users(user_id);
+CREATE INDEX IF NOT EXISTS idx_ak_users_email ON public.ak_users(email);
+CREATE INDEX IF NOT EXISTS idx_delivery_drivers_user_id ON public.delivery_drivers(user_id);
+CREATE INDEX IF NOT EXISTS idx_orders_user_id ON public.orders(user_id);
+CREATE INDEX IF NOT EXISTS idx_delivery_tasks_driver_id ON public.delivery_tasks(driver_id);
+CREATE INDEX IF NOT EXISTS idx_daily_stats_driver_date ON public.daily_stats(driver_id, stat_date);
+
+-- =============================================
+-- 8. 创建触发器:当新用户注册时自动创建 ak_users 记录
+-- =============================================
+-- 先删除已存在的(防止重复创建错误)
+DROP TRIGGER IF EXISTS trigger_ensure_ak_user ON auth.users;
+DROP FUNCTION IF EXISTS ensure_ak_user();
+
+-- 创建新的触发器和函数
+CREATE OR REPLACE FUNCTION ensure_ak_user()
+RETURNS TRIGGER AS $$
+BEGIN
+ INSERT INTO public.ak_users (user_id, email, nickname, user_type)
+ VALUES (NEW.id, NEW.email, COALESCE(NEW.email, '新用户'), 1)
+ ON CONFLICT (user_id) DO UPDATE SET
+ email = EXCLUDED.email,
+ nickname = EXCLUDED.nickname;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE TRIGGER trigger_ensure_ak_user
+ AFTER INSERT ON auth.users
+ FOR EACH ROW
+ EXECUTE FUNCTION ensure_ak_user();
+
+-- =============================================
+-- 9. 创建测试数据
+-- =============================================
+DO $$
+DECLARE
+ test_user_id UUID;
+ test_driver_id UUID;
+ test_driver_record_id BIGINT;
+ test_order_id BIGINT;
+BEGIN
+ -- 创建配送员用户
+ INSERT INTO auth.users (
+ instance_id, id, aud, role, email, encrypted_password,
+ email_confirmed_at, created_at, updated_at
+ ) VALUES (
+ '00000000-0000-0000-0000-000000000000',
+ gen_random_uuid(),
+ 'authenticated',
+ 'authenticated',
+ '123@example.com',
+ crypt('Test123456', gen_salt('bf')),
+ NOW(),
+ NOW(),
+ NOW()
+ ) RETURNING id INTO test_driver_id;
+
+ -- 创建配送员资料
+ INSERT INTO public.delivery_drivers (
+ user_id, real_name, vehicle_number, online_status, rating, total_orders
+ ) VALUES (
+ test_driver_id,
+ '张师傅',
+ '粤B12345',
+ TRUE,
+ 4.8,
+ 1250
+ ) RETURNING id INTO test_driver_record_id;
+
+ -- 创建今日统计数据
+ INSERT INTO public.daily_stats (
+ driver_id, stat_date, completed_orders, total_earning, total_distance, avg_rating
+ ) VALUES (
+ test_driver_record_id,
+ CURRENT_DATE,
+ 8,
+ 245.60,
+ 45.0,
+ 4.9
+ );
+
+ -- 创建测试订单
+ INSERT INTO public.orders (
+ order_no, user_id, status, total_amount, delivery_fee, payable_amount,
+ pickup_address, delivery_address, pickup_contact, delivery_contact
+ ) VALUES (
+ 'D202501081234',
+ test_driver_id, -- 为了测试,暂时让司机自己下单
+ 2, -- 已接单
+ 125.50,
+ 8.50,
+ 134.00,
+ '{"detail": "华强北商业区华强电子世界2楼A205", "area": "华强北", "lat": 22.5431, "lng": 114.0579}',
+ '{"detail": "南山区科技园深南大道9999号", "area": "科技园", "lat": 22.5350, "lng": 113.9490}',
+ '{"name": "商家联系人", "phone": "138****5678"}',
+ '{"name": "张先生", "phone": "139****1234"}'
+ ) RETURNING id INTO test_order_id;
+
+ -- 创建配送任务
+ INSERT INTO public.delivery_tasks (
+ order_id, driver_id, task_status, pickup_address, delivery_address,
+ pickup_contact, delivery_contact, delivery_fee, distance, estimated_time
+ ) VALUES (
+ test_order_id,
+ test_driver_record_id,
+ 2, -- 已接取
+ '{"detail": "华强北商业区华强电子世界2楼A205", "area": "华强北", "lat": 22.5431, "lng": 114.0579}',
+ '{"detail": "南山区科技园深南大道9999号", "area": "科技园", "lat": 22.5350, "lng": 113.9490}',
+ '{"name": "商家联系人", "phone": "138****5678"}',
+ '{"name": "张先生", "phone": "139****1234"}',
+ 8.50,
+ 12.5,
+ 35
+ );
+
+ RAISE NOTICE '✅ 配送系统数据库创建完成!';
+END $$;
\ No newline at end of file
diff --git a/pages/mall/delivery/delivery.md b/pages/mall/delivery/test/delivery.md
similarity index 97%
rename from pages/mall/delivery/delivery.md
rename to pages/mall/delivery/test/delivery.md
index 7d275fa1..b65fee31 100644
--- a/pages/mall/delivery/delivery.md
+++ b/pages/mall/delivery/test/delivery.md
@@ -23,8 +23,6 @@ delivery/
├── vehicle-edit.uvue # 编辑车辆信息
```
-> 💡 注:`index.uvue` 出现两次,建议保留一个作为首页入口,另一个可重命名为 `dashboard.uvue` 或 `home.uvue`
-
---
## 🧭 各页面功能说明
From 5f856a96c908172136f1e3135837c3433aa79111 Mon Sep 17 00:00:00 2001
From: not-like-juvenile <16056107+not-like-juvenile@user.noreply.gitee.com>
Date: Fri, 30 Jan 2026 21:11:17 +0800
Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E5=BA=93=E5=B9=B6=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2=E6=A0=B7?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ak/config.uts | 4 +-
pages/mall/delivery/index.uvue | 22 +++---
pages/mall/delivery/order-detail.uvue | 99 ++++++++-------------------
3 files changed, 41 insertions(+), 84 deletions(-)
diff --git a/ak/config.uts b/ak/config.uts
index a24c488a..2b48e5da 100644
--- a/ak/config.uts
+++ b/ak/config.uts
@@ -2,11 +2,11 @@
// 内网环境 - 本地部署的 Supabase
// IP: 192.168.1.62
// Kong HTTP Port: 8000
-export const SUPA_URL: string = 'http://192.168.1.62:8000'
+export const SUPA_URL: string = 'http://192.168.1.62:13000'
export const SUPA_KEY: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzY4ODMwNjI0LCJleHAiOjE5MjY1MTA2MjR9.mDVl-kIOdRK9v6VTxo0TDF8r7X7xk3PZXazaavHyVvg'
// WebSocket 实时连接(内网使用 ws:// 而非 wss://)
-export const WS_URL: string = 'ws://192.168.1.62:8000/realtime/v1/websocket'
+export const WS_URL: string = 'ws://192.168.1.62:13000/realtime/v1/websocket'
// 备用配置(已注释,如需切换可取消注释)
// 开发环境 - 其他内网地址
diff --git a/pages/mall/delivery/index.uvue b/pages/mall/delivery/index.uvue
index 7e785649..0b5f98fe 100644
--- a/pages/mall/delivery/index.uvue
+++ b/pages/mall/delivery/index.uvue
@@ -454,7 +454,7 @@
confirmPickup() {
// TODO: 调用API确认取货
if (this.currentTask) {
- this.currentTask.status = 4 // 更新状态为“已取货”
+ this.currentTask.status = 5 // 更新状态为“已取货”
}
uni.showToast({
title: '取货完成',
@@ -462,16 +462,16 @@
})
},
- startDelivery() {
- // TODO: 调用API开始配送
- if (this.currentTask) {
- this.currentTask.status = 5 // 更新状态为“配送中”
- }
- uni.showToast({
- title: '开始配送',
- icon: 'success'
- })
- },
+ // startDelivery() {
+ // // TODO: 调用API开始配送
+ // if (this.currentTask) {
+ // this.currentTask.status = 5 // 更新状态为“配送中”
+ // }
+ // uni.showToast({
+ // title: '开始配送',
+ // icon: 'success'
+ // })
+ // },
// 显示确认送达弹框
showConfirmDeliveryDialog() {
diff --git a/pages/mall/delivery/order-detail.uvue b/pages/mall/delivery/order-detail.uvue
index 68bc94d4..68a50b34 100644
--- a/pages/mall/delivery/order-detail.uvue
+++ b/pages/mall/delivery/order-detail.uvue
@@ -1,4 +1,3 @@
-
@@ -180,16 +179,6 @@