diff --git a/.env b/.env
index 63909f7..e5a31ef 100644
--- a/.env
+++ b/.env
@@ -5,8 +5,8 @@ SHOPRO_VERSION=v2.3.0
SHOPRO_BASE_URL = http://api.jnmall.zq-hightech.com
# 后端接口 - 测试环境(通过 process.env.NODE_ENV = development)
-SHOPRO_DEV_BASE_URL = https://icepacker.52cfzy.com
-# SHOPRO_DEV_BASE_URL = http://delivery-test.huichibao.com
+# SHOPRO_DEV_BASE_URL = https://icepacker.52cfzy.com
+SHOPRO_DEV_BASE_URL = http://delivery-test.huichibao.com
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
SHOPRO_UPLOAD_TYPE=server
diff --git a/pages/index/index.vue b/pages/index/index.vue
index f1d6bea..6d1dbe7 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -9,8 +9,10 @@
-
- {{ driverInfo.isOnline ? '在线中' : '离线' }}
+
+
+ {{ driverInfo.onlineStatus == 0 ? '离线' : (driverInfo.onlineStatus == 1 ? '在线' : '待审核') }}
+
@@ -48,10 +50,10 @@
取
- {{ order.pickupAddress }}
- 商家已出餐 · {{ order.pickupNote || '' }}
+ {{ order.shopAddress }}
+ 商家 · {{ order.shopPhone || '' }}
- 导航
+ 导航
送
@@ -62,11 +64,6 @@
导航
-
-
-
- 顾客:{{ order.note }}
-
@@ -74,9 +71,12 @@
联系
-
+
确认到店
+
+ 确认取餐
+
@@ -94,6 +94,7 @@ import { ref, computed, onMounted } from 'vue';
import sheep from '@/sheep';
import { onShow } from '@dcloudio/uni-app';
import OrderCodePopup from './components/order-code-popup.vue';
+import DeliveryOrderApi from '@/sheep/api/member/deliveryOrder';
// 驿站/骑手信息(从 store 获取或 mock)
const driverInfo = ref({
@@ -107,56 +108,119 @@ const defaultAvatar = 'https://huichibao.oss-cn-guangzhou.aliyuncs.com/1/materia
// 页面状态
const activeTab = ref('pickup'); // 'pickup' | 'delivering'
const listHeight = ref(600);
+const loading = ref(false);
+const noMore = ref(false);
-// Mock 订单数据(真实项目应从后端接口拉取 / store)
-const orders = ref([
- {
- id: 1001,
- type: 'pickup',
- statusText: '待取货',
- shopName: '取货点店铺名称',
- pickupAddress: '广东省广州市天河区学院站荷光路118-121号',
- pickupLat: 23.1,
- pickupLng: 113.3,
- pickupNote: '商家已出餐',
- deliveryAddress: '广东省广州市天河区华景新城软件园区',
- deliveryLat: 23.12,
- deliveryLng: 113.31,
- receiverName: '张先生',
- receiverPhone: '13900001234',
- note: '根据餐量提供餐具'
- },
- {
- id: 1002,
- type: 'pickup',
- statusText: '待取货',
- shopName: '乐易购(学院店)',
- pickupAddress: '广东省广州市天河区学院站荷光路118--121号',
- pickupLat: 23.11,
- pickupLng: 113.32,
- pickupNote: '',
- deliveryAddress: '广东省广州市天河区某小区',
- deliveryLat: 23.13,
- deliveryLng: 113.33,
- receiverName: '李女士',
- receiverPhone: '13900005678',
- note: ''
- }
-]);
+// 配送单列表数据
+const orders = ref([]);
+const pagination = ref({
+ pageNo: 1,
+ pageSize: 10,
+ total: 0
+});
-// 计算各 tab 数量与过滤列表
+// deliveryStatus 到页面 type 的映射
+const statusToTypeMap = {
+ '3': 'pickup', // 骑手待取货 -> 待取货
+ '4': 'delivering', // 配送中待送达交接点 -> 配送中
+ '5': 'delivering', // 配送中送达交接点待分配 -> 配送中
+ '6': 'delivering' // 配送中待送达顾客 -> 配送中
+};
+
+// deliveryStatus 状态文本映射
+const deliveryStatusTextMap = {
+ '-1': '配送异常',
+ '0': '已取消',
+ '1': '待接单',
+ '2': '骑手待到店',
+ '3': '待取货',
+ '4': '待送达交接点',
+ '5': '送达交接点待分配',
+ '6': '待送达顾客',
+ '7': '已完成'
+};
+
+// 计算各 tab 数量
const pickupCount = computed(() => orders.value.filter(o => o.type === 'pickup').length);
const deliveringCount = computed(() => orders.value.filter(o => o.type === 'delivering').length);
-const filteredOrders = computed(() => {
- if (activeTab.value === 'pickup') {
- return orders.value.filter(o => o.type === 'pickup');
+const filteredOrders = computed(() => orders.value);
+
+// 加载订单列表数据
+async function loadOrders(isLoadMore = false) {
+ if (loading.value) return;
+
+ loading.value = true;
+
+ // 根据当前 tab 确定接口参数 status
+ const status = activeTab.value === 'pickup' ? 1 : 2;
+
+ try {
+ const res = await DeliveryOrderApi.getPageByDeliveryManId({
+ pageNo: pagination.value.pageNo,
+ pageSize: pagination.value.pageSize,
+ status: status
+ });
+
+ if (res.code === 0 && res.data) {
+ const records = res.data.records || [];
+
+ // 转换接口数据为页面所需格式
+ const transformedOrders = records.map(item => {
+ const deliveryStatus = String(item.deliveryStatus);
+ return {
+ id: item.id,
+ type: statusToTypeMap[deliveryStatus] || 'pickup',
+ statusText: deliveryStatusTextMap[deliveryStatus] || '未知状态',
+ shopName: item.shopName || '',
+ shopAddress: item.shopAddress || '',
+ shopLat: item.shopLatitude || null,
+ shopLng: item.shopLongitude || null,
+ shopPhone: item.shopPhone || '',
+ shopShipmentStatus: item.shopShipmentStatus,
+ deliveryAddress: item.receiverAddress || '',
+ deliveryLat: item.receiverLatitude || null,
+ deliveryLng: item.receiverLongitude || null,
+ receiverName: item.receiverName || '',
+ receiverPhone: item.receiverPhone || '',
+ deliveryStatus: item.deliveryStatus
+ };
+ });
+
+ if (isLoadMore) {
+ orders.value = [...orders.value, ...transformedOrders];
+ } else {
+ orders.value = transformedOrders;
+ }
+
+ // 更新分页信息
+ pagination.value.total = res.data.total || 0;
+ pagination.value.pageNo = res.data.current || 1;
+
+ // 判断是否还有更多数据
+ noMore.value = orders.value.length >= pagination.value.total;
+ } else {
+ sheep.$helper.toast(res.msg || '加载失败');
+ }
+ } catch (error) {
+ console.error('加载订单列表异常:', error);
+ sheep.$helper.toast('加载失败,请重试');
+ } finally {
+ loading.value = false;
}
- return orders.value.filter(o => o.type === 'delivering');
-});
+}
+
+// 刷新列表
+function refreshOrders() {
+ pagination.value.pageNo = 1;
+ noMore.value = false;
+ loadOrders(false);
+}
// 切换 tab
function switchTab(tab) {
+ if (activeTab.value === tab) return;
activeTab.value = tab;
+ refreshOrders();
}
// 切换上线/下线(简单 UI 切换,建议接入后端)
@@ -165,15 +229,49 @@ function toggleOnline() {
sheep.$helper && sheep.$helper.toast && sheep.$helper.toast(driverInfo.value.isOnline ? '已上线' : '已下线');
}
-// 确认到店(演示:改变订单状态)
-function confirmArrive(orderId) {
+// 确认到店
+async function confirmArrive(orderId) {
const order = orders.value.find(o => o.id === orderId);
if (!order) return;
- // 示例逻辑:到店后将类型改为 delivering
- if (order.type === 'pickup') {
- order.type = 'delivering';
- order.statusText = '配送中';
- sheep.$helper && sheep.$helper.toast && sheep.$helper.toast('已确认到店,开始配送');
+
+ if (order.type !== 'pickup') return;
+
+ try {
+ const res = await DeliveryOrderApi.riderConfirmArrival(orderId);
+ if (res.code === 0 && res.data === true) {
+ // 接口返回成功,更新本地订单状态
+ order.type = 'delivering';
+ order.statusText = '配送中';
+ order.deliveryStatus = 4; // 状态更新为待送达交接点
+ sheep.$helper.toast('已确认到店,开始配送');
+ } else {
+ sheep.$helper.toast(res.msg || '确认到店失败');
+ }
+ } catch (error) {
+ console.error('确认到店异常:', error);
+ sheep.$helper.toast('操作异常,请重试');
+ }
+}
+
+// 确认取餐
+async function confirmPickup(orderId) {
+ const order = orders.value.find(o => o.id === orderId);
+ if (!order) return;
+
+ try {
+ const res = await DeliveryOrderApi.riderConfirmPickup(orderId);
+ if (res.code === 0 && res.data === true) {
+ // 接口返回成功,更新本地订单状态为配送中
+ order.type = 'delivering';
+ order.statusText = '配送中';
+ order.deliveryStatus = 4; // 状态更新为待送达交接点
+ sheep.$helper.toast('已确认取餐,开始配送');
+ } else {
+ sheep.$helper.toast(res.msg || '确认取餐失败');
+ }
+ } catch (error) {
+ console.error('确认取餐异常:', error);
+ sheep.$helper.toast('操作异常,请重试');
}
}
@@ -262,6 +360,8 @@ onMounted(() => {
onShow(() => {
// 每次页面显示时重新计算(兼容热更或状态变化)
setHeaderSafeArea();
+ // 加载订单列表
+ refreshOrders();
});
diff --git a/pages/index/user.vue b/pages/index/user.vue
index 997e585..21fc20e 100644
--- a/pages/index/user.vue
+++ b/pages/index/user.vue
@@ -6,9 +6,13 @@
-
+
顾客:{{ order.note }}
-
+
-
+
交接记录
-
+
-
+
@@ -82,7 +82,7 @@
确认到店
-
+