合并 9.9.1 机巢工作台与拍摄交付流程 #1
@@ -0,0 +1,16 @@
|
|||||||
|
[API][Response] GET https://api-test.zhifly.cn/api/app/airport/home?scenic_id=128&store_id=37 status=200
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [],
|
||||||
|
"orders": [],
|
||||||
|
"scenic_id": 128,
|
||||||
|
"today": {
|
||||||
|
"finished_shoot": 0,
|
||||||
|
"order_amount": 0,
|
||||||
|
"order_count": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 14:23:21"
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
[API][Response] GET https://api-test.zhifly.cn/api/app/airport/home?scenic_id=128&store_id=37 status=200
|
||||||
|
{
|
||||||
|
"code" : 100000,
|
||||||
|
"data" : {
|
||||||
|
"airports" : [
|
||||||
|
{
|
||||||
|
"id" : 58,
|
||||||
|
"is_receive_order" : 1,
|
||||||
|
"metrics" : [
|
||||||
|
{
|
||||||
|
"key" : "battery",
|
||||||
|
"label" : "电池电量",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "env_temp",
|
||||||
|
"label" : "环境温度",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "wind_speed",
|
||||||
|
"label" : "风速",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "rainfall",
|
||||||
|
"label" : "雨量",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "signal",
|
||||||
|
"label" : "信号状态",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "satellite",
|
||||||
|
"label" : "搜星状态",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name" : "江布拉克M4D",
|
||||||
|
"online_status" : 1,
|
||||||
|
"scenic_area_id" : 128,
|
||||||
|
"sn_number" : "8UUXN4300A04NY",
|
||||||
|
"task_type" : null,
|
||||||
|
"work_status" : 1,
|
||||||
|
"work_status_label" : "空闲"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"orders" : [
|
||||||
|
|
||||||
|
],
|
||||||
|
"scenic_id" : 128,
|
||||||
|
"today" : {
|
||||||
|
"finished_shoot" : 0,
|
||||||
|
"order_amount" : 0,
|
||||||
|
"order_count" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg" : "success",
|
||||||
|
"time" : "2026-10-27 14:50:18"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 477 KiB |
@@ -0,0 +1,68 @@
|
|||||||
|
[API][Response] GET https://api-test.zhifly.cn/api/app/airport/home?scenic_id=128&store_id=37 status=200
|
||||||
|
{
|
||||||
|
"code" : 100000,
|
||||||
|
"data" : {
|
||||||
|
"airports" : [
|
||||||
|
{
|
||||||
|
"id" : 58,
|
||||||
|
"is_receive_order" : 1,
|
||||||
|
"metrics" : [
|
||||||
|
{
|
||||||
|
"key" : "battery",
|
||||||
|
"label" : "电池电量",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "env_temp",
|
||||||
|
"label" : "环境温度",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "wind_speed",
|
||||||
|
"label" : "风速",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "rainfall",
|
||||||
|
"label" : "雨量",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "signal",
|
||||||
|
"label" : "信号状态",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key" : "satellite",
|
||||||
|
"label" : "搜星状态",
|
||||||
|
"raw" : null,
|
||||||
|
"value" : "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name" : "江布拉克M4D",
|
||||||
|
"online_status" : 1,
|
||||||
|
"scenic_area_id" : 128,
|
||||||
|
"sn_number" : "8UUXN4300A04NY",
|
||||||
|
"task_type" : null,
|
||||||
|
"work_status" : 1,
|
||||||
|
"work_status_label" : "空闲"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"orders" : [
|
||||||
|
|
||||||
|
],
|
||||||
|
"scenic_id" : 128,
|
||||||
|
"today" : {
|
||||||
|
"finished_shoot" : 0,
|
||||||
|
"order_amount" : 0,
|
||||||
|
"order_count" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg" : "success",
|
||||||
|
"time" : "2026-10-27 14:58:15"
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 58,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "江布拉克M4D",
|
||||||
|
"online_status": 1,
|
||||||
|
"scenic_area_id": 128,
|
||||||
|
"sn_number": "8UUXN4300A04NY",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 1,
|
||||||
|
"work_status_label": "空闲"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"scenic_id": 128,
|
||||||
|
"today": {
|
||||||
|
"finished_shoot": 0,
|
||||||
|
"order_amount": 0,
|
||||||
|
"order_count": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 14:58:15"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 479 KiB |
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 58,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "江布拉克M4D",
|
||||||
|
"online_status": 1,
|
||||||
|
"scenic_area_id": 128,
|
||||||
|
"sn_number": "8UUXN4300A04NY",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 1,
|
||||||
|
"work_status_label": "空闲"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"scenic_id": 128,
|
||||||
|
"today": {
|
||||||
|
"finished_shoot": 0,
|
||||||
|
"order_amount": 0,
|
||||||
|
"order_count": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 14:50:18"
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
[API][Response] GET https://api-test.zhifly.cn/api/app/airport/home?scenic_id=128&store_id=37 status=200
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 58,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "江布拉克M4D",
|
||||||
|
"online_status": 1,
|
||||||
|
"scenic_area_id": 128,
|
||||||
|
"sn_number": "8UUXN4300A04NY",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 1,
|
||||||
|
"work_status_label": "空闲"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"scenic_id": 128,
|
||||||
|
"today": {
|
||||||
|
"finished_shoot": 0,
|
||||||
|
"order_amount": 0,
|
||||||
|
"order_count": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 14:38:58"
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 58,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "江布拉克M4D",
|
||||||
|
"online_status": 1,
|
||||||
|
"scenic_area_id": 128,
|
||||||
|
"sn_number": "8UUXN4300A04NY",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 1,
|
||||||
|
"work_status_label": "空闲"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"scenic_id": 128,
|
||||||
|
"today": {
|
||||||
|
"finished_shoot": 0,
|
||||||
|
"order_amount": 0,
|
||||||
|
"order_count": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 14:38:58"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 392 KiB |
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [],
|
||||||
|
"orders": [],
|
||||||
|
"scenic_id": 128,
|
||||||
|
"today": {
|
||||||
|
"finished_shoot": 0,
|
||||||
|
"order_amount": 0,
|
||||||
|
"order_count": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 14:13:24"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 412 KiB |
@@ -0,0 +1,251 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 61,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "河南嵩山",
|
||||||
|
"online_status": 1,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "8UUXN4200A04GF",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 1,
|
||||||
|
"work_status_label": "空闲"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 57,
|
||||||
|
"is_receive_order": 2,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "那拉提M4D",
|
||||||
|
"online_status": 2,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "8UUXN4200A04GC",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 0,
|
||||||
|
"work_status_label": "离线"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"orders": [
|
||||||
|
{
|
||||||
|
"media_status": "none",
|
||||||
|
"media_status_label": "",
|
||||||
|
"order_id": 49059,
|
||||||
|
"order_number": "261023271001",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"primary_action": "start_shoot",
|
||||||
|
"primary_action_label": "开始拍摄",
|
||||||
|
"progress_text": "已拍摄 0/1 次,剩余 1 次",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄",
|
||||||
|
"tourist_label": "游客 132****9413",
|
||||||
|
"tourist_phone_mask": "132****9413",
|
||||||
|
"user_id": 141943
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"media_status": "none",
|
||||||
|
"media_status_label": "",
|
||||||
|
"order_id": 49057,
|
||||||
|
"order_number": "261022271005",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"primary_action": "start_shoot",
|
||||||
|
"primary_action_label": "开始拍摄",
|
||||||
|
"progress_text": "已拍摄 0/1 次,剩余 1 次",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄",
|
||||||
|
"tourist_label": "游客 183****5710",
|
||||||
|
"tourist_phone_mask": "183****5710",
|
||||||
|
"user_id": 141946
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"media_status": "none",
|
||||||
|
"media_status_label": "",
|
||||||
|
"order_id": 49056,
|
||||||
|
"order_number": "261022271004",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"primary_action": "start_shoot",
|
||||||
|
"primary_action_label": "开始拍摄",
|
||||||
|
"progress_text": "已拍摄 0/1 次,剩余 1 次",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄",
|
||||||
|
"tourist_label": "游客 132****9413",
|
||||||
|
"tourist_phone_mask": "132****9413",
|
||||||
|
"user_id": 141943
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"media_status": "none",
|
||||||
|
"media_status_label": "",
|
||||||
|
"order_id": 49054,
|
||||||
|
"order_number": "261022271003",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"primary_action": "start_shoot",
|
||||||
|
"primary_action_label": "开始拍摄",
|
||||||
|
"progress_text": "已拍摄 0/1 次,剩余 1 次",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄",
|
||||||
|
"tourist_label": "游客 192****1413",
|
||||||
|
"tourist_phone_mask": "192****1413",
|
||||||
|
"user_id": 143090
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"media_status": "none",
|
||||||
|
"media_status_label": "",
|
||||||
|
"order_id": 49053,
|
||||||
|
"order_number": "261022271002",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"primary_action": "start_shoot",
|
||||||
|
"primary_action_label": "开始拍摄",
|
||||||
|
"progress_text": "已拍摄 0/1 次,剩余 1 次",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄",
|
||||||
|
"tourist_label": "游客 192****1413",
|
||||||
|
"tourist_phone_mask": "192****1413",
|
||||||
|
"user_id": 143090
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"media_status": "none",
|
||||||
|
"media_status_label": "",
|
||||||
|
"order_id": 49052,
|
||||||
|
"order_number": "261022271001",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"primary_action": "start_shoot",
|
||||||
|
"primary_action_label": "开始拍摄",
|
||||||
|
"progress_text": "已拍摄 0/1 次,剩余 1 次",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄",
|
||||||
|
"tourist_label": "游客 192****1413",
|
||||||
|
"tourist_phone_mask": "192****1413",
|
||||||
|
"user_id": 143090
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"media_status": "none",
|
||||||
|
"media_status_label": "",
|
||||||
|
"order_id": 49051,
|
||||||
|
"order_number": "261021271004",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"primary_action": "start_shoot",
|
||||||
|
"primary_action_label": "开始拍摄",
|
||||||
|
"progress_text": "已拍摄 0/1 次,剩余 1 次",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄",
|
||||||
|
"tourist_label": "游客 192****1413",
|
||||||
|
"tourist_phone_mask": "192****1413",
|
||||||
|
"user_id": 143090
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"media_status": "none",
|
||||||
|
"media_status_label": "",
|
||||||
|
"order_id": 49050,
|
||||||
|
"order_number": "261021271003",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"primary_action": "start_shoot",
|
||||||
|
"primary_action_label": "开始拍摄",
|
||||||
|
"progress_text": "已拍摄 0/1 次,剩余 1 次",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄",
|
||||||
|
"tourist_label": "游客 183****5710",
|
||||||
|
"tourist_phone_mask": "183****5710",
|
||||||
|
"user_id": 141946
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scenic_id": 271,
|
||||||
|
"today": {
|
||||||
|
"finished_shoot": 0,
|
||||||
|
"order_amount": 0,
|
||||||
|
"order_count": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 17:40:30"
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
"date": "2026-10-27",
|
||||||
|
"device": "iPhone 11",
|
||||||
|
"environment": "testing",
|
||||||
|
"endpoint": "GET /api/app/airport/home",
|
||||||
|
"scenic_id": 128,
|
||||||
|
"store_id": 37,
|
||||||
|
"http_status": 200,
|
||||||
|
"business_code": 100000,
|
||||||
|
"response": "airport-home-device-refined-response.json",
|
||||||
|
"screenshot": "airport-home-device-refined.png",
|
||||||
|
"tests": {
|
||||||
|
"related": {
|
||||||
|
"passed": 40,
|
||||||
|
"failed": 0,
|
||||||
|
"xcresult": "/private/tmp/suixinkan-airport-home-tests.xcresult"
|
||||||
|
},
|
||||||
|
"final_ui": {
|
||||||
|
"passed": 3,
|
||||||
|
"failed": 0,
|
||||||
|
"xcresult": "/private/tmp/suixinkan-airport-home-ui-tests-final.xcresult"
|
||||||
|
},
|
||||||
|
"device_cards": {
|
||||||
|
"passed": 49,
|
||||||
|
"failed": 0,
|
||||||
|
"xcresult": "/private/tmp/suixinkan-airport-device-tests.xcresult"
|
||||||
|
},
|
||||||
|
"device_card_visual_regression": {
|
||||||
|
"passed": 9,
|
||||||
|
"failed": 0,
|
||||||
|
"xcresult": "/private/tmp/suixinkan-airport-card-visual-tests.xcresult"
|
||||||
|
},
|
||||||
|
"anonymized_fixtures": {
|
||||||
|
"passed": 20,
|
||||||
|
"failed": 0,
|
||||||
|
"xcresult": "/private/tmp/suixinkan-airport-fixture-tests.xcresult"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"verified": [
|
||||||
|
"真实接口请求及登录鉴权",
|
||||||
|
"真实空列表和零统计展示",
|
||||||
|
"下拉刷新和失败状态",
|
||||||
|
"旧账号/景区/门店/Token回包隔离",
|
||||||
|
"正式入口与演示任务隔离",
|
||||||
|
"按真实设备 ID、名称和工作状态渲染机巢卡片",
|
||||||
|
"六项读数按 metrics.key 映射,未知值显示 —,真实零值保留",
|
||||||
|
"未知电量仅展示灰色轨道,合法 raw 数值才绘制进度",
|
||||||
|
"同 ID 设备刷新清除旧读数与多设备横向分页(真机替身测试)",
|
||||||
|
"真机实际 home 非空设备响应与最终 App 窗口截图"
|
||||||
|
],
|
||||||
|
"pending": [
|
||||||
|
"订单等待后端非空测试数据后再接入",
|
||||||
|
"finished_shoot 的业务统计口径"
|
||||||
|
],
|
||||||
|
"response_time": "2026-10-27 14:58:15",
|
||||||
|
"final_build": {
|
||||||
|
"result": "BUILD SUCCEEDED",
|
||||||
|
"log": "/private/tmp/suixinkan-airport-device-build-final.log",
|
||||||
|
"change_after_tests": "仅 DEBUG 截图延后至 Diffable 画面稳定后执行;已重新构建并真机实测截图"
|
||||||
|
},
|
||||||
|
"device_card_visual_review": {
|
||||||
|
"prototype": "https://voicestudio.suixinkan.cn/",
|
||||||
|
"verified": [
|
||||||
|
"设备状态文字前同色圆点",
|
||||||
|
"底部三项等宽读数之间的两条竖线",
|
||||||
|
"搜星采用网页同款 Tabler satellite SVG",
|
||||||
|
"雨量由普通云改为带雨滴云图标"
|
||||||
|
],
|
||||||
|
"screenshot": "airport-home-device-refined.png"
|
||||||
|
},
|
||||||
|
"source_commit": "40060cd",
|
||||||
|
"artifacts_location": "真实联调响应、日志和截图仅保留本地,未随代码推送"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 37 KiB |
@@ -0,0 +1,108 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 61,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "河南嵩山",
|
||||||
|
"online_status": 2,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "8UUXN4200A04GF",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 0,
|
||||||
|
"work_status_label": "离线"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 57,
|
||||||
|
"is_receive_order": 2,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "那拉提M4D",
|
||||||
|
"online_status": 2,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "8UUXN4200A04GC",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 0,
|
||||||
|
"work_status_label": "离线"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scenic_id": 271
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 15:51:40"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 36 KiB |
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"can_confirm": false,
|
||||||
|
"can_create_task": true,
|
||||||
|
"can_upload_film": false,
|
||||||
|
"confirm_status": 0,
|
||||||
|
"confirmed_at": null,
|
||||||
|
"created_at": "2026-10-27 17:39:10",
|
||||||
|
"film_count": 0,
|
||||||
|
"material_status": 0,
|
||||||
|
"order_number": "261027271004",
|
||||||
|
"order_status": 20,
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"remaining_count": 5,
|
||||||
|
"shoot_count": 5,
|
||||||
|
"shoot_status": "pending",
|
||||||
|
"shot_count": 0,
|
||||||
|
"user_phone": "132****9413"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"can_confirm": false,
|
||||||
|
"can_create_task": true,
|
||||||
|
"can_upload_film": false,
|
||||||
|
"confirm_status": 0,
|
||||||
|
"confirmed_at": null,
|
||||||
|
"created_at": "2026-10-27 17:16:18",
|
||||||
|
"film_count": 0,
|
||||||
|
"material_status": 0,
|
||||||
|
"order_number": "261027271001",
|
||||||
|
"order_status": 20,
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"remaining_count": 5,
|
||||||
|
"shoot_count": 5,
|
||||||
|
"shoot_status": "pending",
|
||||||
|
"shot_count": 0,
|
||||||
|
"user_phone": "183****5710"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"page": 1,
|
||||||
|
"page_size": 20,
|
||||||
|
"total": 2
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 15:51:40"
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"cash_paid": "0.00",
|
||||||
|
"cash_refund": "0.00",
|
||||||
|
"completed_count": 0,
|
||||||
|
"deal_amount": "0.00",
|
||||||
|
"deal_count": 0,
|
||||||
|
"points_net": 0,
|
||||||
|
"points_paid": 0,
|
||||||
|
"points_refund": 0
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 15:51:40"
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"pay_url": "https://vipsky.oss-cn-shanghai.aliyuncs.com/mini_qr/f7490a9cf52193cecc5e9f203b427e27.png",
|
||||||
|
"price": "99.00",
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"shoot_count": 5,
|
||||||
|
"store_id": 38,
|
||||||
|
"store_user_id": 772
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 17:22:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"pay_url": "https://vipsky.oss-cn-shanghai.aliyuncs.com/mini_qr/db12ec21153b5c4f6801fd8eab2402c1.png",
|
||||||
|
"price": "99.00",
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"shoot_count": 5,
|
||||||
|
"store_id": 38,
|
||||||
|
"store_user_id": 772
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 17:22:32"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[API][Response] POST https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/pay-code status=200
|
||||||
|
{
|
||||||
|
"code" : 100000,
|
||||||
|
"data" : {
|
||||||
|
"pay_url" : "https:\/\/api-test.zhifly.cn\/wma\/multi-plane\/pay?project_id=386&price=99.00&store_user_id=772&store_id=38",
|
||||||
|
"price" : "99.00",
|
||||||
|
"project_id" : 386,
|
||||||
|
"project_name" : "多点位航拍",
|
||||||
|
"shoot_count" : 5,
|
||||||
|
"store_id" : 38,
|
||||||
|
"store_user_id" : 772
|
||||||
|
},
|
||||||
|
"msg" : "success",
|
||||||
|
"time" : "2026-10-27 15:37:45"
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"pay_url": "https://api-test.zhifly.cn/wma/multi-plane/pay?project_id=386&price=99.00&store_user_id=772&store_id=38",
|
||||||
|
"price": "99.00",
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"shoot_count": 5,
|
||||||
|
"store_id": 38,
|
||||||
|
"store_user_id": 772
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:37:45"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 578 KiB |
|
After Width: | Height: | Size: 471 KiB |
|
After Width: | Height: | Size: 487 KiB |
|
After Width: | Height: | Size: 630 KiB |
|
After Width: | Height: | Size: 48 KiB |
@@ -0,0 +1,9 @@
|
|||||||
|
[API][Response] GET https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/projects?scenic_id=128 status=200
|
||||||
|
{
|
||||||
|
"code" : 100000,
|
||||||
|
"data" : [
|
||||||
|
|
||||||
|
],
|
||||||
|
"msg" : "success",
|
||||||
|
"time" : "2026-10-27 15:29:31"
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": [],
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:29:31"
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[API][Response] GET https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/projects?scenic_id=271 status=200
|
||||||
|
{
|
||||||
|
"code" : 100000,
|
||||||
|
"data" : [
|
||||||
|
{
|
||||||
|
"id" : 386,
|
||||||
|
"name" : "多点位航拍",
|
||||||
|
"price" : "99.00",
|
||||||
|
"shoot_count" : 5
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"msg" : "success",
|
||||||
|
"time" : "2026-10-27 15:37:44"
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 386,
|
||||||
|
"name": "多点位航拍",
|
||||||
|
"price": "99.00",
|
||||||
|
"shoot_count": 5
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:37:44"
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
[API][Response] GET https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?scenic_id=128&page=1 status=200
|
||||||
|
{
|
||||||
|
"code" : 100000,
|
||||||
|
"data" : {
|
||||||
|
"records" : {
|
||||||
|
"current_page" : 1,
|
||||||
|
"data" : [
|
||||||
|
|
||||||
|
],
|
||||||
|
"first_page_url" : "https:\/\/api-test.zhifly.cn\/api\/yf-handset-app\/photog\/multi-plane\/receipts?page=1",
|
||||||
|
"from" : null,
|
||||||
|
"last_page" : 1,
|
||||||
|
"last_page_url" : "https:\/\/api-test.zhifly.cn\/api\/yf-handset-app\/photog\/multi-plane\/receipts?page=1",
|
||||||
|
"links" : [
|
||||||
|
{
|
||||||
|
"active" : false,
|
||||||
|
"label" : "« Previous",
|
||||||
|
"page" : null,
|
||||||
|
"url" : null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active" : true,
|
||||||
|
"label" : "1",
|
||||||
|
"page" : 1,
|
||||||
|
"url" : "https:\/\/api-test.zhifly.cn\/api\/yf-handset-app\/photog\/multi-plane\/receipts?page=1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active" : false,
|
||||||
|
"label" : "Next »",
|
||||||
|
"page" : null,
|
||||||
|
"url" : null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"next_page_url" : null,
|
||||||
|
"path" : "https:\/\/api-test.zhifly.cn\/api\/yf-handset-app\/photog\/multi-plane\/receipts",
|
||||||
|
"per_page" : 20,
|
||||||
|
"prev_page_url" : null,
|
||||||
|
"to" : null,
|
||||||
|
"total" : 0
|
||||||
|
},
|
||||||
|
"summary" : {
|
||||||
|
"cash_net" : "0.00",
|
||||||
|
"cash_paid" : "0.00",
|
||||||
|
"cash_refund" : "0.00",
|
||||||
|
"count" : 0,
|
||||||
|
"point_amount" : "0.00",
|
||||||
|
"points_net" : 0,
|
||||||
|
"points_paid" : 0,
|
||||||
|
"points_refund" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg" : "success",
|
||||||
|
"time" : "2026-10-27 15:30:15"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 297 KiB |
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"records": {
|
||||||
|
"current_page": 1,
|
||||||
|
"data": [],
|
||||||
|
"first_page_url": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?page=1",
|
||||||
|
"from": null,
|
||||||
|
"last_page": 1,
|
||||||
|
"last_page_url": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?page=1",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"active": false,
|
||||||
|
"label": "« Previous",
|
||||||
|
"page": null,
|
||||||
|
"url": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active": true,
|
||||||
|
"label": "1",
|
||||||
|
"page": 1,
|
||||||
|
"url": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?page=1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active": false,
|
||||||
|
"label": "Next »",
|
||||||
|
"page": null,
|
||||||
|
"url": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"next_page_url": null,
|
||||||
|
"path": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts",
|
||||||
|
"per_page": 20,
|
||||||
|
"prev_page_url": null,
|
||||||
|
"to": null,
|
||||||
|
"total": 0
|
||||||
|
},
|
||||||
|
"summary": {
|
||||||
|
"cash_net": "0.00",
|
||||||
|
"cash_paid": "0.00",
|
||||||
|
"cash_refund": "0.00",
|
||||||
|
"count": 0,
|
||||||
|
"point_amount": "0.00",
|
||||||
|
"points_net": 0,
|
||||||
|
"points_paid": 0,
|
||||||
|
"points_refund": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:30:15"
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
[API][Response] GET https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?scenic_id=271&page=1 status=200
|
||||||
|
{
|
||||||
|
"code" : 100000,
|
||||||
|
"data" : {
|
||||||
|
"records" : {
|
||||||
|
"current_page" : 1,
|
||||||
|
"data" : [
|
||||||
|
|
||||||
|
],
|
||||||
|
"first_page_url" : "https:\/\/api-test.zhifly.cn\/api\/yf-handset-app\/photog\/multi-plane\/receipts?page=1",
|
||||||
|
"from" : null,
|
||||||
|
"last_page" : 1,
|
||||||
|
"last_page_url" : "https:\/\/api-test.zhifly.cn\/api\/yf-handset-app\/photog\/multi-plane\/receipts?page=1",
|
||||||
|
"links" : [
|
||||||
|
{
|
||||||
|
"active" : false,
|
||||||
|
"label" : "« Previous",
|
||||||
|
"page" : null,
|
||||||
|
"url" : null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active" : true,
|
||||||
|
"label" : "1",
|
||||||
|
"page" : 1,
|
||||||
|
"url" : "https:\/\/api-test.zhifly.cn\/api\/yf-handset-app\/photog\/multi-plane\/receipts?page=1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active" : false,
|
||||||
|
"label" : "Next »",
|
||||||
|
"page" : null,
|
||||||
|
"url" : null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"next_page_url" : null,
|
||||||
|
"path" : "https:\/\/api-test.zhifly.cn\/api\/yf-handset-app\/photog\/multi-plane\/receipts",
|
||||||
|
"per_page" : 20,
|
||||||
|
"prev_page_url" : null,
|
||||||
|
"to" : null,
|
||||||
|
"total" : 0
|
||||||
|
},
|
||||||
|
"summary" : {
|
||||||
|
"cash_net" : "0.00",
|
||||||
|
"cash_paid" : "0.00",
|
||||||
|
"cash_refund" : "0.00",
|
||||||
|
"count" : 0,
|
||||||
|
"point_amount" : "0.00",
|
||||||
|
"points_net" : 0,
|
||||||
|
"points_paid" : 0,
|
||||||
|
"points_refund" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg" : "success",
|
||||||
|
"time" : "2026-10-27 15:34:27"
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"records": {
|
||||||
|
"current_page": 1,
|
||||||
|
"data": [],
|
||||||
|
"first_page_url": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?page=1",
|
||||||
|
"from": null,
|
||||||
|
"last_page": 1,
|
||||||
|
"last_page_url": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?page=1",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"active": false,
|
||||||
|
"label": "« Previous",
|
||||||
|
"page": null,
|
||||||
|
"url": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active": true,
|
||||||
|
"label": "1",
|
||||||
|
"page": 1,
|
||||||
|
"url": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?page=1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active": false,
|
||||||
|
"label": "Next »",
|
||||||
|
"page": null,
|
||||||
|
"url": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"next_page_url": null,
|
||||||
|
"path": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts",
|
||||||
|
"per_page": 20,
|
||||||
|
"prev_page_url": null,
|
||||||
|
"to": null,
|
||||||
|
"total": 0
|
||||||
|
},
|
||||||
|
"summary": {
|
||||||
|
"cash_net": "0.00",
|
||||||
|
"cash_paid": "0.00",
|
||||||
|
"cash_refund": "0.00",
|
||||||
|
"count": 0,
|
||||||
|
"point_amount": "0.00",
|
||||||
|
"points_net": 0,
|
||||||
|
"points_paid": 0,
|
||||||
|
"points_refund": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:34:27"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,111 @@
|
|||||||
|
{
|
||||||
|
"environment": "https://api-test.zhifly.cn",
|
||||||
|
"scenic_id": 271,
|
||||||
|
"scenic_name": "北大科技园",
|
||||||
|
"interfaces": [
|
||||||
|
{
|
||||||
|
"method": "GET",
|
||||||
|
"path": "/api/yf-handset-app/photog/multi-plane/projects",
|
||||||
|
"request": {
|
||||||
|
"scenic_id": 271
|
||||||
|
},
|
||||||
|
"http_status": 200,
|
||||||
|
"response": {
|
||||||
|
"code": 100000,
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 386,
|
||||||
|
"name": "多点位航拍",
|
||||||
|
"price": "99.00",
|
||||||
|
"shoot_count": 5
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:37:44"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"method": "POST",
|
||||||
|
"path": "/api/yf-handset-app/photog/multi-plane/pay-code",
|
||||||
|
"request": {
|
||||||
|
"scenic_id": 271,
|
||||||
|
"project_id": 386
|
||||||
|
},
|
||||||
|
"http_status": 200,
|
||||||
|
"response": {
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"pay_url": "https://api-test.zhifly.cn/wma/multi-plane/pay?project_id=386&price=99.00&store_user_id=772&store_id=38",
|
||||||
|
"price": "99.00",
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"shoot_count": 5,
|
||||||
|
"store_id": 38,
|
||||||
|
"store_user_id": 772
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:37:45"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"method": "GET",
|
||||||
|
"path": "/api/yf-handset-app/photog/multi-plane/receipts",
|
||||||
|
"request": {
|
||||||
|
"scenic_id": 271,
|
||||||
|
"page": 1
|
||||||
|
},
|
||||||
|
"http_status": 200,
|
||||||
|
"response": {
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"records": {
|
||||||
|
"current_page": 1,
|
||||||
|
"data": [],
|
||||||
|
"first_page_url": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?page=1",
|
||||||
|
"from": null,
|
||||||
|
"last_page": 1,
|
||||||
|
"last_page_url": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?page=1",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"active": false,
|
||||||
|
"label": "« Previous",
|
||||||
|
"page": null,
|
||||||
|
"url": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active": true,
|
||||||
|
"label": "1",
|
||||||
|
"page": 1,
|
||||||
|
"url": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts?page=1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"active": false,
|
||||||
|
"label": "Next »",
|
||||||
|
"page": null,
|
||||||
|
"url": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"next_page_url": null,
|
||||||
|
"path": "https://api-test.zhifly.cn/api/yf-handset-app/photog/multi-plane/receipts",
|
||||||
|
"per_page": 20,
|
||||||
|
"prev_page_url": null,
|
||||||
|
"to": null,
|
||||||
|
"total": 0
|
||||||
|
},
|
||||||
|
"summary": {
|
||||||
|
"cash_net": "0.00",
|
||||||
|
"cash_paid": "0.00",
|
||||||
|
"cash_refund": "0.00",
|
||||||
|
"count": 0,
|
||||||
|
"point_amount": "0.00",
|
||||||
|
"points_net": 0,
|
||||||
|
"points_paid": 0,
|
||||||
|
"points_refund": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:34:27"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
{
|
||||||
|
"date": "2026-10-27",
|
||||||
|
"device": "iPhone 11",
|
||||||
|
"environment": "testing",
|
||||||
|
"current_scenic_id": 271,
|
||||||
|
"current_store_id": 38,
|
||||||
|
"current_scenic_name": "北大科技园",
|
||||||
|
"requests": {
|
||||||
|
"projects": {
|
||||||
|
"response": "projects-scenic271-response.json",
|
||||||
|
"code": 100000,
|
||||||
|
"time": "2026-10-27 15:37:44",
|
||||||
|
"http_status": 200
|
||||||
|
},
|
||||||
|
"pay-code": {
|
||||||
|
"response": "pay-code-scenic271-response.json",
|
||||||
|
"code": 100000,
|
||||||
|
"time": "2026-10-27 15:37:45",
|
||||||
|
"http_status": 200
|
||||||
|
},
|
||||||
|
"receipts": {
|
||||||
|
"response": "receipts-scenic271-response.json",
|
||||||
|
"code": 100000,
|
||||||
|
"time": "2026-10-27 15:34:27",
|
||||||
|
"http_status": 200
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"earlier_scenic128": {
|
||||||
|
"projects": [],
|
||||||
|
"receipts_total": 0
|
||||||
|
},
|
||||||
|
"tests": {
|
||||||
|
"related": {
|
||||||
|
"passed": 47,
|
||||||
|
"failed": 0,
|
||||||
|
"xcresult": "/private/tmp/suixinkan-dock-payment-tests.xcresult"
|
||||||
|
},
|
||||||
|
"final_ui": {
|
||||||
|
"passed": 8,
|
||||||
|
"failed": 0,
|
||||||
|
"xcresult": "/private/tmp/suixinkan-dock-payment-ui-final.xcresult"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"screenshots": [
|
||||||
|
"payment-code-real.png",
|
||||||
|
"receipts-empty-real.png"
|
||||||
|
],
|
||||||
|
"pending": [
|
||||||
|
"非空真实收款记录的联调",
|
||||||
|
"游客实际支付和到账关联(当前为可重复购买链接,无单笔会话契约)",
|
||||||
|
"收款方名称的数据来源",
|
||||||
|
"类型25到账语音事件"
|
||||||
|
],
|
||||||
|
"note": "真实接口响应与截图仅本地保留。请求付款链接不创建订单或拍摄任务,未执行付款。",
|
||||||
|
"qr_decode_verification": {
|
||||||
|
"tool": "Apple Vision VNDetectBarcodesRequest",
|
||||||
|
"detected_qr_count": 1,
|
||||||
|
"matches_server_pay_url": true,
|
||||||
|
"screenshot": "payment-code-real.png"
|
||||||
|
},
|
||||||
|
"all_responses": "three-interface-responses.json",
|
||||||
|
"simulator_verification": {
|
||||||
|
"date": "2026-10-27",
|
||||||
|
"device": "iPhone 18 Pro",
|
||||||
|
"runtime": "iOS 27.0",
|
||||||
|
"scheme": "suixinkan-Simulator",
|
||||||
|
"configuration": "SimulatorDebug",
|
||||||
|
"tests": {
|
||||||
|
"passed": 47,
|
||||||
|
"failed": 0,
|
||||||
|
"skipped": 0,
|
||||||
|
"xcresult": "/Users/hanqiu/Library/Developer/XcodeBuildMCP/workspaces/suixinkan-a3033d697ba3/result-bundles/test_sim_2026-10-27T07-47-38-057Z_pid11893_efcc5bc6.xcresult"
|
||||||
|
},
|
||||||
|
"live_api": {
|
||||||
|
"scenic_id": 271,
|
||||||
|
"project_id": 386,
|
||||||
|
"projects_code": 100000,
|
||||||
|
"pay_code_code": 100000,
|
||||||
|
"receipts_code": 100000,
|
||||||
|
"price": "99.00",
|
||||||
|
"shoot_count": 5,
|
||||||
|
"receipts_total": 0
|
||||||
|
},
|
||||||
|
"screenshots": [
|
||||||
|
"payment-simulator.jpg",
|
||||||
|
"receipts-simulator.jpg"
|
||||||
|
],
|
||||||
|
"note": "按用户最新要求改用模拟器。真实接口和套餐选择、确认、收款记录跳转已验证,未执行付款。"
|
||||||
|
},
|
||||||
|
"mini_program_code_adaptation": {
|
||||||
|
"date": "2026-10-27",
|
||||||
|
"device": "iPhone 18 Pro Simulator",
|
||||||
|
"runtime": "iOS 27.0",
|
||||||
|
"tests": {
|
||||||
|
"related_passed": 54,
|
||||||
|
"failed": 0,
|
||||||
|
"final_ui_passed": 15,
|
||||||
|
"related_xcresult": "/Users/hanqiu/Library/Developer/XcodeBuildMCP/workspaces/suixinkan-a3033d697ba3/result-bundles/test_sim_2026-10-27T09-18-36-229Z_pid11893_88f50b3f.xcresult",
|
||||||
|
"final_ui_xcresult": "/Users/hanqiu/Library/Developer/XcodeBuildMCP/workspaces/suixinkan-a3033d697ba3/result-bundles/test_sim_2026-10-27T09-20-42-957Z_pid11893_a4ad6f52.xcresult"
|
||||||
|
},
|
||||||
|
"real_response_file": "pay-code-mini-program-responses.json",
|
||||||
|
"screenshot": "payment-mini-program-simulator.png",
|
||||||
|
"scenic_id": 271,
|
||||||
|
"project_id": 386,
|
||||||
|
"price": "99.00",
|
||||||
|
"shoot_count": 5,
|
||||||
|
"regeneration_verified": true,
|
||||||
|
"note": "展示后端小程序码原图;原普通二维码记录仅为旧契约历史。未执行游客扫码、付款或向系统相册写图。"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 347 KiB |
@@ -0,0 +1,182 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 61,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "河南嵩山",
|
||||||
|
"online_status": 2,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "8UUXN4200A04GF",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 0,
|
||||||
|
"work_status_label": "离线"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 57,
|
||||||
|
"is_receive_order": 2,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "那拉提M4D",
|
||||||
|
"online_status": 2,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "8UUXN4200A04GC",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 0,
|
||||||
|
"work_status_label": "离线"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"order_number": "261023271001",
|
||||||
|
"order_progress": {
|
||||||
|
"order_number": "261023271001",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄"
|
||||||
|
},
|
||||||
|
"recommend_plane": null,
|
||||||
|
"scenic_id": 271,
|
||||||
|
"shoot_gate": {
|
||||||
|
"can_shoot": false,
|
||||||
|
"code": "dock_offline",
|
||||||
|
"message": "机巢未连接",
|
||||||
|
"primary_action": "blocked",
|
||||||
|
"primary_action_label": "机巢未连接"
|
||||||
|
},
|
||||||
|
"spots": [
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 301,
|
||||||
|
"estimated_fly_time": 279,
|
||||||
|
"fly_type": 1,
|
||||||
|
"line_video_duration": 14,
|
||||||
|
"name": "vue3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"distance_label": "3311.1 km",
|
||||||
|
"distance_m": 3311086,
|
||||||
|
"in_range": false,
|
||||||
|
"name": "测试打卡点",
|
||||||
|
"scenic_spot_id": 411,
|
||||||
|
"shot_count": 0,
|
||||||
|
"shot_status_label": "未拍摄"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 302,
|
||||||
|
"estimated_fly_time": 376,
|
||||||
|
"fly_type": 1,
|
||||||
|
"line_video_duration": 25,
|
||||||
|
"name": "天门寻梦"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"distance_label": "3310.7 km",
|
||||||
|
"distance_m": 3310714,
|
||||||
|
"in_range": false,
|
||||||
|
"name": "天门寻梦",
|
||||||
|
"scenic_spot_id": 412,
|
||||||
|
"shot_count": 0,
|
||||||
|
"shot_status_label": "未拍摄"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 304,
|
||||||
|
"estimated_fly_time": 426,
|
||||||
|
"fly_type": 1,
|
||||||
|
"line_video_duration": 39,
|
||||||
|
"name": "天门远山"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"distance_label": "3310.7 km",
|
||||||
|
"distance_m": 3310691,
|
||||||
|
"in_range": false,
|
||||||
|
"name": "天门远山",
|
||||||
|
"scenic_spot_id": 413,
|
||||||
|
"shot_count": 0,
|
||||||
|
"shot_status_label": "未拍摄"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tips": "每次拍摄成功后扣减 1 次,未成功不扣次数。"
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 14:47:44"
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 61,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "河南嵩山",
|
||||||
|
"online_status": 2,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "8UUXN4200A04GF",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 0,
|
||||||
|
"work_status_label": "离线"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 57,
|
||||||
|
"is_receive_order": 2,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "那拉提M4D",
|
||||||
|
"online_status": 2,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "8UUXN4200A04GC",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 0,
|
||||||
|
"work_status_label": "离线"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"order_number": "261023271001",
|
||||||
|
"order_progress": {
|
||||||
|
"order_number": "261023271001",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄"
|
||||||
|
},
|
||||||
|
"recommend_plane": null,
|
||||||
|
"scenic_id": 271,
|
||||||
|
"shoot_gate": {
|
||||||
|
"can_shoot": false,
|
||||||
|
"code": "dock_offline",
|
||||||
|
"message": "机巢未连接",
|
||||||
|
"primary_action": "blocked",
|
||||||
|
"primary_action_label": "机巢未连接"
|
||||||
|
},
|
||||||
|
"spots": [
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 301,
|
||||||
|
"estimated_fly_time": 279,
|
||||||
|
"fly_type": 1,
|
||||||
|
"line_video_duration": 14,
|
||||||
|
"name": "vue3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"distance_label": "3311.1 km",
|
||||||
|
"distance_m": 3311086,
|
||||||
|
"in_range": false,
|
||||||
|
"name": "测试打卡点",
|
||||||
|
"scenic_spot_id": 411,
|
||||||
|
"shot_count": 0,
|
||||||
|
"shot_status_label": "未拍摄"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 302,
|
||||||
|
"estimated_fly_time": 376,
|
||||||
|
"fly_type": 1,
|
||||||
|
"line_video_duration": 25,
|
||||||
|
"name": "天门寻梦"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"distance_label": "3310.7 km",
|
||||||
|
"distance_m": 3310714,
|
||||||
|
"in_range": false,
|
||||||
|
"name": "天门寻梦",
|
||||||
|
"scenic_spot_id": 412,
|
||||||
|
"shot_count": 0,
|
||||||
|
"shot_status_label": "未拍摄"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 304,
|
||||||
|
"estimated_fly_time": 426,
|
||||||
|
"fly_type": 1,
|
||||||
|
"line_video_duration": 39,
|
||||||
|
"name": "天门远山"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"distance_label": "3310.7 km",
|
||||||
|
"distance_m": 3310691,
|
||||||
|
"in_range": false,
|
||||||
|
"name": "天门远山",
|
||||||
|
"scenic_spot_id": 413,
|
||||||
|
"shot_count": 0,
|
||||||
|
"shot_status_label": "未拍摄"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tips": "每次拍摄成功后扣减 1 次,未成功不扣次数。"
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 14:06:21"
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 36 KiB |
@@ -0,0 +1,100 @@
|
|||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"can_confirm": false,
|
||||||
|
"can_create_task": true,
|
||||||
|
"can_upload_film": false,
|
||||||
|
"confirm_status": 0,
|
||||||
|
"confirmed_at": null,
|
||||||
|
"created_at": "2026-10-27 17:39:10",
|
||||||
|
"film_count": 0,
|
||||||
|
"material_status": 0,
|
||||||
|
"order_number": "261027271004",
|
||||||
|
"order_status": 20,
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"remaining_count": 5,
|
||||||
|
"shoot_count": 5,
|
||||||
|
"shoot_status": "pending",
|
||||||
|
"shot_count": 0,
|
||||||
|
"spot": [
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 302,
|
||||||
|
"air_line_name": "天门寻梦",
|
||||||
|
"available": true,
|
||||||
|
"samples": [
|
||||||
|
{
|
||||||
|
"cover_url": "https://fly-picture.tos-cn-beijing.volces.com/202604/17762401434725.png",
|
||||||
|
"id": 318,
|
||||||
|
"name": "天门寻梦",
|
||||||
|
"preview_url": "https://zhongchuan-picture.oss-cn-beijing.aliyuncs.com/simplepic/202604/1776240058674_lgjimv.mp4"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"unavailable_reason": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"available": true,
|
||||||
|
"cover_url": "",
|
||||||
|
"region": {
|
||||||
|
"address": "江苏省扬州市邗江区城北街道北大科技园花都汇商务中心",
|
||||||
|
"lat": 32.429597,
|
||||||
|
"lot": 119.440283,
|
||||||
|
"scenic_spot_str": "北大科技园"
|
||||||
|
},
|
||||||
|
"sample_piece_ids": [
|
||||||
|
318
|
||||||
|
],
|
||||||
|
"samples": [
|
||||||
|
{
|
||||||
|
"id": 318,
|
||||||
|
"name": "天门寻梦"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scenic_spot_id": 412,
|
||||||
|
"scenic_spot_name": "天门寻梦"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 304,
|
||||||
|
"air_line_name": "天门远山",
|
||||||
|
"available": true,
|
||||||
|
"samples": [
|
||||||
|
{
|
||||||
|
"cover_url": "https://fly-picture.tos-cn-beijing.volces.com/202604/17768529312831.png",
|
||||||
|
"id": 319,
|
||||||
|
"name": "天门远山",
|
||||||
|
"preview_url": "https://zhongchuan-picture.oss-cn-beijing.aliyuncs.com/simplepic/202604/1776852306874_5jh4xz.mp4"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"unavailable_reason": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"available": true,
|
||||||
|
"cover_url": "",
|
||||||
|
"region": {
|
||||||
|
"address": "江苏省扬州市邗江区城北街道花都汇商务中心",
|
||||||
|
"lat": 32.429872,
|
||||||
|
"lot": 119.440194,
|
||||||
|
"scenic_spot_str": "天门远山"
|
||||||
|
},
|
||||||
|
"sample_piece_ids": [
|
||||||
|
319
|
||||||
|
],
|
||||||
|
"samples": [
|
||||||
|
{
|
||||||
|
"id": 319,
|
||||||
|
"name": "天门远山"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scenic_spot_id": 413,
|
||||||
|
"scenic_spot_name": "天门远山"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"user_phone": "132****9413"
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 16:23:11"
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"code": 100099,
|
||||||
|
"data": [],
|
||||||
|
"msg": "多点位航拍请使用专用订单接口",
|
||||||
|
"time": "2026-10-28 16:23:21"
|
||||||
|
}
|
||||||
@@ -2,12 +2,12 @@ import Foundation
|
|||||||
|
|
||||||
/// 拍摄准备页只读数据源,不创建订单任务或发送飞行控制指令。
|
/// 拍摄准备页只读数据源,不创建订单任务或发送飞行控制指令。
|
||||||
protocol DroneDockPreparationServing: Sendable {
|
protocol DroneDockPreparationServing: Sendable {
|
||||||
/// 获取指定订单的点位、航线与召唤门禁;无有效定位时省略坐标。
|
/// 读取该订单实际购买的套餐、点位和航线,不使用当前上架项目替代购买快照。
|
||||||
@MainActor
|
@MainActor
|
||||||
func workbench(scenicID: Int, orderNumber: String, coordinate: DroneDockPreparationCoordinate?) async throws -> DroneDockPreparationResponse
|
func projectInfo(scenicID: Int, projectID: Int, orderNumber: String) async throws -> DroneDockProjectInfoResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 朱工的拍摄准备接口,登录凭证由统一客户端注入。
|
/// 张工购买快照的只读接口,登录凭证由统一客户端注入。
|
||||||
@MainActor
|
@MainActor
|
||||||
final class DroneDockPreparationAPI: DroneDockPreparationServing {
|
final class DroneDockPreparationAPI: DroneDockPreparationServing {
|
||||||
private let client: APIClient
|
private let client: APIClient
|
||||||
@@ -15,18 +15,23 @@ final class DroneDockPreparationAPI: DroneDockPreparationServing {
|
|||||||
/// 注入统一客户端,正式页面和测试使用相同请求构造。
|
/// 注入统一客户端,正式页面和测试使用相同请求构造。
|
||||||
init(client: APIClient) { self.client = client }
|
init(client: APIClient) { self.client = client }
|
||||||
|
|
||||||
/// 只读取准备快照,未知位置不会补零或替换成景区坐标。
|
/// 订单号必传;响应必须属于请求的订单与项目,避免展示其他购买范围。
|
||||||
func workbench(scenicID: Int, orderNumber: String, coordinate: DroneDockPreparationCoordinate?) async throws -> DroneDockPreparationResponse {
|
func projectInfo(scenicID: Int, projectID: Int, orderNumber: String) async throws -> DroneDockProjectInfoResponse {
|
||||||
guard scenicID > 0, !orderNumber.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
let trimmedNumber = orderNumber.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
throw APIError.networkFailed("缺少当前景区或订单信息,请返回重试")
|
guard scenicID > 0, projectID > 0, !trimmedNumber.isEmpty,
|
||||||
|
trimmedNumber == orderNumber, orderNumber.count <= 128 else {
|
||||||
|
throw APIError.networkFailed("缺少有效景区、项目或订单信息,请返回工作台重新进入")
|
||||||
}
|
}
|
||||||
var query = [URLQueryItem(name: "scenic_id", value: String(scenicID)),
|
let response: DroneDockProjectInfoResponse = try await client.send(APIRequest(
|
||||||
URLQueryItem(name: "order_number", value: orderNumber)]
|
method: .get, path: "/api/yf-handset-app/photog/multi-plane/project-info",
|
||||||
if let coordinate {
|
queryItems: [URLQueryItem(name: "scenic_id", value: String(scenicID)),
|
||||||
guard coordinate.isValid else { throw APIError.networkFailed("定位结果无效,请重新定位") }
|
URLQueryItem(name: "project_id", value: String(projectID)),
|
||||||
query.append(URLQueryItem(name: "lat", value: String(coordinate.latitude)))
|
URLQueryItem(name: "order_number", value: orderNumber)]
|
||||||
query.append(URLQueryItem(name: "lng", value: String(coordinate.longitude)))
|
))
|
||||||
|
guard response.order.orderNumber == orderNumber, response.order.projectID == projectID else {
|
||||||
|
throw APIError.decodeFailed("套餐信息与当前订单或项目不一致,请刷新重试")
|
||||||
}
|
}
|
||||||
return try await client.send(APIRequest(method: .get, path: "/api/app/airport/workbench", queryItems: query))
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,142 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// 张工 project-info 的订单购买快照,权威提供次数、可选点位与航线。
|
||||||
|
struct DroneDockProjectInfoResponse: Decodable, Equatable, Sendable {
|
||||||
|
/// 根级订单摘要,与首页 orders 使用同一业务字段和权限口径。
|
||||||
|
let order: DroneDockHomeOrder
|
||||||
|
/// 购买快照中的点位,保持服务端顺序,不拼入其他来源的额外点位。
|
||||||
|
let spots: [DroneDockPurchasedSpot]
|
||||||
|
|
||||||
|
/// 购买点位数组使用单数 spot 字段。
|
||||||
|
private enum CodingKeys: String, CodingKey { case spots = "spot" }
|
||||||
|
|
||||||
|
/// 要求项目身份和点位数组存在,空数组才表示真实空态。
|
||||||
|
init(from decoder: Decoder) throws {
|
||||||
|
order = try DroneDockHomeOrder(from: decoder)
|
||||||
|
guard order.projectID != nil else {
|
||||||
|
throw DecodingError.dataCorrupted(.init(codingPath: decoder.codingPath,
|
||||||
|
debugDescription: "购买快照缺少项目 ID"))
|
||||||
|
}
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
spots = try container.decode([DroneDockPurchasedSpot].self, forKey: .spots)
|
||||||
|
guard Set(spots.map(\.id)).count == spots.count else {
|
||||||
|
throw DecodingError.dataCorruptedError(forKey: .spots, in: container, debugDescription: "购买点位 ID 重复")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 订单购买范围内的拍摄点;是否可选由 available 明确返回,不由位置或次数推导。
|
||||||
|
struct DroneDockPurchasedSpot: Decodable, Equatable, Sendable {
|
||||||
|
/// 拍摄点稳定 ID。
|
||||||
|
let id: Int
|
||||||
|
/// 购买快照的点位名称。
|
||||||
|
let name: String
|
||||||
|
/// 当前点位是否可用;缺失保留未知。
|
||||||
|
let available: Bool?
|
||||||
|
/// 点位封面地址,可缺失或为空。
|
||||||
|
let coverURL: String?
|
||||||
|
/// 购买范围内的航线,按服务端顺序展示。
|
||||||
|
let airLines: [DroneDockPurchasedAirLine]
|
||||||
|
|
||||||
|
/// 张工购买点位字段,不接收 workbench 的 name 作为替代。
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id = "scenic_spot_id", name = "scenic_spot_name", available
|
||||||
|
case coverURL = "cover_url", airLines = "air_lines"
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 点位与本点位航线身份必须有效且唯一,空航线数组保留为空。
|
||||||
|
init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try container.positivePurchasedID(forKey: .id)
|
||||||
|
name = try container.decode(String.self, forKey: .name)
|
||||||
|
available = try container.decodeIfPresent(Bool.self, forKey: .available)
|
||||||
|
coverURL = try container.decodeIfPresent(String.self, forKey: .coverURL)
|
||||||
|
airLines = try container.decode([DroneDockPurchasedAirLine].self, forKey: .airLines)
|
||||||
|
guard Set(airLines.map(\.id)).count == airLines.count else {
|
||||||
|
throw DecodingError.dataCorruptedError(forKey: .airLines, in: container, debugDescription: "购买点位内航线 ID 重复")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 订单已购航线及样片配置;不可用原因直接用于页面说明。
|
||||||
|
struct DroneDockPurchasedAirLine: Decodable, Equatable, Sendable {
|
||||||
|
/// 航线稳定 ID。
|
||||||
|
let id: Int
|
||||||
|
/// 航线名称。
|
||||||
|
let name: String
|
||||||
|
/// 当前航线是否可用,未知不自动视为可用。
|
||||||
|
let available: Bool?
|
||||||
|
/// 后端说明当前不可用的原因。
|
||||||
|
let unavailableReason: String?
|
||||||
|
/// 与该购买航线关联的样片,缺失或 null 表示没有可展示样片。
|
||||||
|
let samples: [DroneDockPurchasedSample]
|
||||||
|
|
||||||
|
/// 张工购买航线字段。
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id = "air_line_id", name = "air_line_name", available
|
||||||
|
case unavailableReason = "unavailable_reason", samples
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 不替换未知可用状态或缺失样片地址,也不使用旧接口名称字段。
|
||||||
|
init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try container.positivePurchasedID(forKey: .id)
|
||||||
|
name = try container.decode(String.self, forKey: .name)
|
||||||
|
available = try container.decodeIfPresent(Bool.self, forKey: .available)
|
||||||
|
unavailableReason = try container.decodeIfPresent(String.self, forKey: .unavailableReason)
|
||||||
|
samples = try container.decodeIfPresent([DroneDockPurchasedSample].self, forKey: .samples) ?? []
|
||||||
|
guard Set(samples.map(\.id)).count == samples.count else {
|
||||||
|
throw DecodingError.dataCorruptedError(forKey: .samples, in: container, debugDescription: "航线内样片 ID 重复")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 航线样片的服务端展示信息,不自行拼接预览或封面地址。
|
||||||
|
struct DroneDockPurchasedSample: Decodable, Equatable, Sendable {
|
||||||
|
/// 样片稳定 ID。
|
||||||
|
let id: Int
|
||||||
|
/// 样片名称,缺失时保留未知。
|
||||||
|
let name: String?
|
||||||
|
/// 样片封面地址。
|
||||||
|
let coverURL: String?
|
||||||
|
/// 样片视频预览地址。
|
||||||
|
let previewURL: String?
|
||||||
|
|
||||||
|
/// 样片字段名。
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id, name, coverURL = "cover_url", previewURL = "preview_url"
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 校验样片身份并兼容缺失、null 与空字符串的展示字段。
|
||||||
|
init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try container.positivePurchasedID(forKey: .id)
|
||||||
|
name = try container.decodeIfPresent(String.self, forKey: .name)
|
||||||
|
coverURL = try container.decodeIfPresent(String.self, forKey: .coverURL)
|
||||||
|
previewURL = try container.decodeIfPresent(String.self, forKey: .previewURL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 购买配置 ID 的整数读取器,兼容整数字符串但拒绝布尔、分数和任意文本。
|
||||||
|
private struct DroneDockPurchasedInteger: Decodable {
|
||||||
|
let value: Int
|
||||||
|
|
||||||
|
/// 读取确定的整数值,正数约束由字段读取处校验。
|
||||||
|
init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.singleValueContainer()
|
||||||
|
if let number = try? container.decode(Int.self) { value = number }
|
||||||
|
else if let text = try? container.decode(String.self), let number = Int(text) { value = number }
|
||||||
|
else { throw DecodingError.dataCorruptedError(in: container, debugDescription: "需要整数或整数字符串") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private extension KeyedDecodingContainer {
|
||||||
|
/// 用于点位、航线、样片稳定身份的正整数。
|
||||||
|
func positivePurchasedID(forKey key: Key) throws -> Int {
|
||||||
|
let value = try decode(DroneDockPurchasedInteger.self, forKey: key).value
|
||||||
|
guard value > 0 else {
|
||||||
|
throw DecodingError.dataCorruptedError(forKey: key, in: self, debugDescription: "购买配置 ID 必须为正整数")
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,187 +1,154 @@
|
|||||||
import CoreLocation
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// 真实拍摄准备状态:读取订单、定位和点位航线,选择过程不创建或执行飞行任务。
|
/// 拍摄准备状态:只读取张工的已购配置,不创建飞行任务。
|
||||||
final class DroneDockPreparationViewModel {
|
final class DroneDockPreparationViewModel {
|
||||||
/// 页面进入时固定的账号、景区及门店范围。
|
/// 页面进入时固定的账号、景区及门店范围。
|
||||||
let context: DroneDockHomeContext
|
let context: DroneDockHomeContext
|
||||||
/// 首页选中的真实订单,仅用于身份及进入时的摘要展示。
|
/// 首页订单仅提供身份和初次加载时的摘要。
|
||||||
let order: DroneDockHomeOrder
|
let order: DroneDockHomeOrder
|
||||||
/// 最新通过身份校验的准备信息。
|
/// 张工返回的订单购买范围及最新次数。
|
||||||
private(set) var response: DroneDockPreparationResponse?
|
private(set) var projectInfo: DroneDockProjectInfoResponse?
|
||||||
/// 是否正在定位或读取准备信息。
|
/// 购买配置是否尚未读取完成。
|
||||||
private(set) var isLoading = false
|
private(set) var isLoading = false
|
||||||
/// 加载失败或身份改变时的提示。
|
/// 购买配置或请求身份错误。
|
||||||
private(set) var errorMessage: String?
|
private(set) var errorMessage: String?
|
||||||
/// 没有取得有效位置时的说明,不使用后端无坐标时返回的距离。
|
/// 已购且可用的当前点位。
|
||||||
private(set) var locationMessage: String?
|
|
||||||
/// 当前响应是否基于本次成功定位的坐标。
|
|
||||||
private(set) var hasLocation = false
|
|
||||||
/// 当前点位与航线的稳定身份。
|
|
||||||
private(set) var selectedSpotID: Int?
|
private(set) var selectedSpotID: Int?
|
||||||
/// 航线只属于当前选中的点位。
|
/// 当前点位下已购且可用的航线。
|
||||||
private(set) var selectedRouteID: Int?
|
private(set) var selectedRouteID: Int?
|
||||||
|
|
||||||
private let service: any DroneDockPreparationServing
|
private let service: any DroneDockPreparationServing
|
||||||
private let locationProvider: any LocationProviding
|
|
||||||
private let currentContext: @MainActor @Sendable () -> DroneDockHomeContext
|
private let currentContext: @MainActor @Sendable () -> DroneDockHomeContext
|
||||||
private var generation = 0
|
private var generation = 0
|
||||||
|
|
||||||
/// 注入真实只读接口、可替换定位服务和最新登录范围。
|
/// 注入只读接口及最新会话,不绑定默认 MainActor。
|
||||||
init(context: DroneDockHomeContext, order: DroneDockHomeOrder,
|
init(context: DroneDockHomeContext, order: DroneDockHomeOrder,
|
||||||
service: any DroneDockPreparationServing, locationProvider: any LocationProviding,
|
service: any DroneDockPreparationServing,
|
||||||
currentContext: @escaping @MainActor @Sendable () -> DroneDockHomeContext) {
|
currentContext: @escaping @MainActor @Sendable () -> DroneDockHomeContext) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.order = order
|
self.order = order
|
||||||
self.service = service
|
self.service = service
|
||||||
self.locationProvider = locationProvider
|
|
||||||
self.currentContext = currentContext
|
self.currentContext = currentContext
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 当前订单的点位,保持服务端顺序。
|
/// 只展示购买快照中的点位,保持张工返回顺序。
|
||||||
var spots: [DroneDockPreparationSpot] { response?.spots ?? [] }
|
var spots: [DroneDockPurchasedSpot] { projectInfo?.spots ?? [] }
|
||||||
/// 当前选中点位,刷新后不再存在时会重新选择。
|
/// 当前有效点位。
|
||||||
var selectedSpot: DroneDockPreparationSpot? { spots.first { $0.id == selectedSpotID } }
|
var selectedSpot: DroneDockPurchasedSpot? { spots.first { $0.id == selectedSpotID } }
|
||||||
/// 只展示当前点位所属的航线。
|
/// 只展示当前已购点位中的航线。
|
||||||
var routes: [DroneDockPreparationAirLine] { selectedSpot?.airLines ?? [] }
|
var routes: [DroneDockPurchasedAirLine] { selectedSpot?.airLines ?? [] }
|
||||||
/// 当前选中航线,不跨点位保留旧选择。
|
/// 当前有效航线。
|
||||||
var selectedRoute: DroneDockPreparationAirLine? { routes.first { $0.id == selectedRouteID } }
|
var selectedRoute: DroneDockPurchasedAirLine? { routes.first { $0.id == selectedRouteID } }
|
||||||
|
/// 进入页面后直接请求购买快照,不等待定位或设备接口。
|
||||||
/// 获取一次位置和准备快照;定位失败仍可浏览点位航线,但范围保持未知。
|
|
||||||
func refresh() async {
|
func refresh() async {
|
||||||
generation &+= 1
|
generation &+= 1
|
||||||
let requestGeneration = generation
|
let requestGeneration = generation
|
||||||
isLoading = true
|
isLoading = true
|
||||||
errorMessage = nil
|
errorMessage = nil
|
||||||
locationMessage = nil
|
|
||||||
hasLocation = false
|
|
||||||
defer { if generation == requestGeneration { isLoading = false } }
|
defer { if generation == requestGeneration { isLoading = false } }
|
||||||
guard await accepts(requestGeneration) else { return }
|
guard await accepts(requestGeneration) else { return }
|
||||||
guard context.canLoad, let number = DroneDockHomeMetric.usableText(order.orderNumber) else {
|
guard context.canLoad, let number = DroneDockHomeMetric.usableText(order.orderNumber),
|
||||||
clearResponse()
|
let projectID = order.projectID, projectID > 0 else {
|
||||||
errorMessage = "缺少当前景区或订单信息,请返回工作台重新进入"
|
clearProject()
|
||||||
|
errorMessage = "缺少当前景区、订单或套餐信息,请返回工作台重新进入"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var coordinate: DroneDockPreparationCoordinate?
|
let projectResult: Result<DroneDockProjectInfoResponse, Error>
|
||||||
do {
|
do {
|
||||||
let result = try await locationProvider.requestCoordinate(desiredAccuracy: kCLLocationAccuracyBest)
|
projectResult = .success(try await service.projectInfo(scenicID: context.scenicID, projectID: projectID, orderNumber: number))
|
||||||
let value = DroneDockPreparationCoordinate(latitude: result.latitude, longitude: result.longitude)
|
|
||||||
guard value.isValid else { throw LocationProviderError.locationFailed }
|
|
||||||
coordinate = value
|
|
||||||
} catch {
|
} catch {
|
||||||
guard await accepts(requestGeneration) else { return }
|
projectResult = .failure(error)
|
||||||
locationMessage = "\(error.localizedDescription),距离和拍摄范围待确认"
|
|
||||||
}
|
}
|
||||||
guard await accepts(requestGeneration) else { return }
|
guard await accepts(requestGeneration) else { return }
|
||||||
do {
|
switch projectResult {
|
||||||
let result = try await service.workbench(scenicID: context.scenicID, orderNumber: number, coordinate: coordinate)
|
case .success(let value) where value.order.orderNumber == number && value.order.projectID == projectID:
|
||||||
guard await accepts(requestGeneration) else { return }
|
projectInfo = value
|
||||||
guard result.scenicID == context.scenicID, result.orderNumber == number,
|
restoreValidSelection()
|
||||||
result.orderProgress?.orderNumber == nil || result.orderProgress?.orderNumber == number else {
|
case .success:
|
||||||
clearResponse()
|
clearProject()
|
||||||
errorMessage = "接口返回的景区或订单与当前订单不一致,请刷新重试"
|
errorMessage = "接口返回的订单或套餐与当前订单不一致,请刷新重试"
|
||||||
return
|
case .failure(let error):
|
||||||
}
|
clearProject()
|
||||||
response = result
|
errorMessage = Self.message(for: error)
|
||||||
hasLocation = coordinate != nil
|
|
||||||
if !spots.contains(where: { $0.id == selectedSpotID }) { selectedSpotID = spots.first?.id }
|
|
||||||
if !routes.contains(where: { $0.id == selectedRouteID }) { selectedRouteID = routes.first?.id }
|
|
||||||
} catch {
|
|
||||||
guard await accepts(requestGeneration) else { return }
|
|
||||||
clearResponse()
|
|
||||||
errorMessage = error.localizedDescription
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 选择现有点位,切点后航线重置为该点位的第一条,不复用另一点位的航线。
|
/// 不可用或可用性未知的点位不能选中,切点后选择首条明确可用的已购航线。
|
||||||
func selectSpot(id: Int) {
|
func selectSpot(id: Int) {
|
||||||
guard !isLoading, spots.contains(where: { $0.id == id }), selectedSpotID != id else { return }
|
guard !isLoading, spots.contains(where: { $0.id == id && $0.available == true }), selectedSpotID != id else { return }
|
||||||
selectedSpotID = id
|
selectedSpotID = id
|
||||||
selectedRouteID = routes.first?.id
|
selectedRouteID = routes.first(where: { $0.available == true })?.id
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 选择当前点位中的航线,忽略过期或不属于该点位的点击。
|
/// 忽略其他点位、不可用及身份不明的航线选择。
|
||||||
func selectRoute(id: Int) {
|
func selectRoute(id: Int) {
|
||||||
guard !isLoading, routes.contains(where: { $0.id == id }) else { return }
|
guard !isLoading, selectedSpot?.available == true,
|
||||||
|
routes.contains(where: { $0.id == id && $0.available == true }) else { return }
|
||||||
selectedRouteID = id
|
selectedRouteID = id
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 页面离开后使定位和网络的迟到结果失效。
|
/// 离开后使购买快照请求失效,避免旧响应回填。
|
||||||
func invalidate() {
|
func invalidate() {
|
||||||
generation &+= 1
|
generation &+= 1
|
||||||
isLoading = false
|
isLoading = false
|
||||||
errorMessage = nil
|
errorMessage = nil
|
||||||
locationMessage = nil
|
clearProject()
|
||||||
clearResponse()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 根据实际机巢摘要展示连接状态,不将 can_shoot 当作设备连接证明。
|
/// 当前接口没有机巢连接信息,不能由购买权限推导设备状态。
|
||||||
var connectionTitle: String {
|
var connectionTitle: String { "机巢连接待确认" }
|
||||||
guard let airports = response?.airports, !airports.isEmpty else { return "机巢连接待确认" }
|
/// 设备连接未知时使用中性色。
|
||||||
if airports.contains(where: { $0.onlineStatus == 1 }) { return "有机巢在线" }
|
var connectionTone: DroneDockStatusTone { .gray }
|
||||||
if airports.allSatisfy({ $0.onlineStatus == 2 }) { return "机巢未连接" }
|
/// 当前未读取位置与范围数据。
|
||||||
return "机巢连接待确认"
|
var rangeTitle: String { "位置待确认" }
|
||||||
}
|
/// 范围未知时使用中性色。
|
||||||
/// 只为明确在线的设备摘要显示绿色状态。
|
var rangeTone: DroneDockStatusTone { .gray }
|
||||||
var connectionTone: DroneDockStatusTone {
|
/// 以购买快照中的名称展示当前选择。
|
||||||
response?.airports.contains(where: { $0.onlineStatus == 1 }) == true ? .green : .gray
|
|
||||||
}
|
|
||||||
/// 只有请求携带有效定位时才采用服务端范围结论。
|
|
||||||
var rangeTitle: String {
|
|
||||||
guard hasLocation else { return "位置待确认" }
|
|
||||||
guard let selectedSpot else { return "请选择拍摄点" }
|
|
||||||
switch selectedSpot.inRange {
|
|
||||||
case true: return "在拍摄范围内"
|
|
||||||
case false: return "不在拍摄范围内"
|
|
||||||
default: return "拍摄范围待确认"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// 未知位置或范围不显示绿色。
|
|
||||||
var rangeTone: DroneDockStatusTone { hasLocation && selectedSpot?.inRange == true ? .green : .gray }
|
|
||||||
/// 当前航线选择的展示摘要。
|
|
||||||
var selectionSummary: String {
|
var selectionSummary: String {
|
||||||
guard let selectedSpot else { return "请选择拍摄点" }
|
guard let selectedSpot else { return "请选择拍摄点" }
|
||||||
guard let selectedRoute else { return "\(selectedSpot.name) · 未选航线" }
|
guard let selectedRoute else { return "\(selectedSpot.name) · 未选航线" }
|
||||||
return "\(selectedSpot.name) · \(selectedRoute.name)"
|
return "\(selectedSpot.name) · \(selectedRoute.name)"
|
||||||
}
|
}
|
||||||
/// 多机状态一致时展示该状态,不假定某台机巢已被选派。
|
/// 当前未读取设备状态,也尚未派机。
|
||||||
var deviceStatusText: String {
|
var deviceStatusText: String { "状态待确认" }
|
||||||
let labels = Set(response?.airports.map(\.statusTitle) ?? [])
|
/// 准备阶段尚未派机。
|
||||||
return labels.count == 1 ? labels.first! : "状态待确认"
|
|
||||||
}
|
|
||||||
/// 准备阶段尚未派机,状态标签使用中性色。
|
|
||||||
var deviceTone: DroneDockStatusTone { .gray }
|
var deviceTone: DroneDockStatusTone { .gray }
|
||||||
/// 保留后端明确的阻止原因,允许准备时展示下一步按钮标题。
|
/// 文案反映购买权限,不开放实际召唤操作。
|
||||||
var primaryButtonTitle: String {
|
var primaryButtonTitle: String {
|
||||||
if let gate = response?.shootGate, gate.canShoot == false {
|
if projectInfo?.order.shotRemain == 0 { return "拍摄次数已用完" }
|
||||||
return DroneDockHomeMetric.usableText(gate.primaryActionLabel) ?? "暂不可召唤"
|
if let info = projectInfo, info.order.canCreateTask != true { return "暂不可召唤" }
|
||||||
}
|
|
||||||
return "确认并召唤"
|
return "确认并召唤"
|
||||||
}
|
}
|
||||||
/// 展示当前阻止原因;本阶段仅对接准备信息,不发送召唤指令。
|
/// 检查购买范围与额度;条件有效后仍提示召唤尚未开放。
|
||||||
var admissionMessage: String {
|
var admissionMessage: String {
|
||||||
if isLoading { return "正在获取位置和拍摄准备信息" }
|
if isLoading { return "正在获取拍摄准备信息" }
|
||||||
if let errorMessage { return errorMessage }
|
if let errorMessage { return errorMessage }
|
||||||
guard let response else { return "正在加载拍摄准备信息" }
|
guard let info = projectInfo else { return "正在加载拍摄准备信息" }
|
||||||
if let gate = response.shootGate, gate.canShoot == false {
|
if info.order.shotRemain == 0 { return "当前订单拍摄次数已用完" }
|
||||||
return DroneDockHomeMetric.usableText(gate.message)
|
guard let remaining = info.order.shotRemain, remaining > 0, info.order.shotTotal != nil else { return "拍摄次数待确认,请刷新状态" }
|
||||||
?? DroneDockHomeMetric.usableText(gate.primaryActionLabel) ?? "当前暂不可召唤,请刷新状态"
|
guard info.order.canCreateTask == true else { return "当前订单暂不可新增拍摄任务,请刷新状态" }
|
||||||
}
|
|
||||||
if let locationMessage { return locationMessage }
|
|
||||||
if spots.isEmpty { return "当前暂无可用拍摄点" }
|
if spots.isEmpty { return "当前暂无可用拍摄点" }
|
||||||
|
guard let spot = selectedSpot, spot.available == true else { return "请选择可用拍摄点" }
|
||||||
if routes.isEmpty { return "当前拍摄点暂无可用航线" }
|
if routes.isEmpty { return "当前拍摄点暂无可用航线" }
|
||||||
if !hasLocation || selectedSpot?.inRange == nil { return "拍摄范围待确认,请重新定位" }
|
guard selectedRoute?.available == true else { return "请选择可用航线" }
|
||||||
if selectedSpot?.inRange == false { return "请前往所选拍摄点的拍摄范围内" }
|
|
||||||
guard response.shootGate?.canShoot == true else { return "拍摄条件待确认,请刷新状态" }
|
|
||||||
return "召唤功能暂未开放"
|
return "召唤功能暂未开放"
|
||||||
}
|
}
|
||||||
|
|
||||||
private func clearResponse() {
|
private func restoreValidSelection() {
|
||||||
response = nil
|
if !spots.contains(where: { $0.id == selectedSpotID && $0.available == true }) {
|
||||||
|
selectedSpotID = spots.first(where: { $0.available == true })?.id
|
||||||
|
selectedRouteID = nil
|
||||||
|
}
|
||||||
|
if !routes.contains(where: { $0.id == selectedRouteID && $0.available == true }) {
|
||||||
|
selectedRouteID = routes.first(where: { $0.available == true })?.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func clearProject() {
|
||||||
|
projectInfo = nil
|
||||||
selectedSpotID = nil
|
selectedSpotID = nil
|
||||||
selectedRouteID = nil
|
selectedRouteID = nil
|
||||||
hasLocation = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func accepts(_ requestGeneration: Int) async -> Bool {
|
private func accepts(_ requestGeneration: Int) async -> Bool {
|
||||||
@@ -189,12 +156,15 @@ final class DroneDockPreparationViewModel {
|
|||||||
let latest = await currentContext()
|
let latest = await currentContext()
|
||||||
guard generation == requestGeneration, !Task.isCancelled else { return false }
|
guard generation == requestGeneration, !Task.isCancelled else { return false }
|
||||||
guard context.hasSameIdentity(as: latest) else {
|
guard context.hasSameIdentity(as: latest) else {
|
||||||
generation &+= 1
|
invalidate()
|
||||||
isLoading = false
|
|
||||||
clearResponse()
|
|
||||||
errorMessage = "账号或景区已变化,请返回工作台重新进入"
|
errorMessage = "账号或景区已变化,请返回工作台重新进入"
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static func message(for error: Error) -> String? {
|
||||||
|
error is CancellationError ? nil : error.localizedDescription
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import UIKit
|
|||||||
final class DroneDockDeviceCardView: UIView {
|
final class DroneDockDeviceCardView: UIView {
|
||||||
private let nameLabel = DroneDockStyle.label(size: 15, weight: .semibold)
|
private let nameLabel = DroneDockStyle.label(size: 15, weight: .semibold)
|
||||||
private let statusLabel = DroneDockDeviceStatusView()
|
private let statusLabel = DroneDockDeviceStatusView()
|
||||||
|
private let detailLabel = DroneDockStyle.label(size: 11, color: DroneDockStyle.secondary)
|
||||||
private let batteryView = DroneDockBatteryView()
|
private let batteryView = DroneDockBatteryView()
|
||||||
private let signalValue = DroneDockStyle.label(size: 19, weight: .semibold)
|
private let signalValue = DroneDockStyle.label(size: 19, weight: .semibold)
|
||||||
private let satelliteValue = DroneDockStyle.label(size: 19, weight: .semibold)
|
private let satelliteValue = DroneDockStyle.label(size: 19, weight: .semibold)
|
||||||
@@ -28,6 +29,7 @@ final class DroneDockDeviceCardView: UIView {
|
|||||||
|
|
||||||
/// 未知读数由模型提供破折号,不以零代替未知。
|
/// 未知读数由模型提供破折号,不以零代替未知。
|
||||||
func apply(device: DroneDockDevice) {
|
func apply(device: DroneDockDevice) {
|
||||||
|
detailLabel.isHidden = true
|
||||||
nameLabel.text = device.name
|
nameLabel.text = device.name
|
||||||
statusLabel.apply(title: device.state.title, tone: device.state.tone)
|
statusLabel.apply(title: device.state.title, tone: device.state.tone)
|
||||||
batteryView.apply(telemetry: device.telemetry)
|
batteryView.apply(telemetry: device.telemetry)
|
||||||
@@ -42,6 +44,7 @@ final class DroneDockDeviceCardView: UIView {
|
|||||||
|
|
||||||
/// 展示 home 返回的机巢名称、工作状态及格式化读数,不根据展示状态推断起飞许可。
|
/// 展示 home 返回的机巢名称、工作状态及格式化读数,不根据展示状态推断起飞许可。
|
||||||
func apply(airport: DroneDockHomeAirport) {
|
func apply(airport: DroneDockHomeAirport) {
|
||||||
|
detailLabel.isHidden = true
|
||||||
nameLabel.text = airport.name
|
nameLabel.text = airport.name
|
||||||
statusLabel.apply(title: airport.statusTitle, tone: airport.statusTone)
|
statusLabel.apply(title: airport.statusTitle, tone: airport.statusTone)
|
||||||
batteryView.apply(text: airport.metricText(for: "battery"), progress: airport.batteryProgress)
|
batteryView.apply(text: airport.metricText(for: "battery"), progress: airport.batteryProgress)
|
||||||
@@ -54,13 +57,31 @@ final class DroneDockDeviceCardView: UIView {
|
|||||||
accessibilityLabel = "\(airport.name),\(airport.statusTitle)"
|
accessibilityLabel = "\(airport.name),\(airport.statusTitle)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 没有设备快照时保留完整遥测卡,读数保持未知并展示当前加载结果。
|
||||||
|
func applyPlaceholder(status: String, detail: String) {
|
||||||
|
nameLabel.text = "暂无无人机"
|
||||||
|
statusLabel.apply(title: status, tone: .gray)
|
||||||
|
detailLabel.text = detail
|
||||||
|
detailLabel.isHidden = false
|
||||||
|
batteryView.apply(telemetry: .unknown)
|
||||||
|
signalValue.text = "—"
|
||||||
|
satelliteValue.text = "—"
|
||||||
|
temperatureValue.text = "—"
|
||||||
|
windValue.text = "—"
|
||||||
|
rainValue.text = "—"
|
||||||
|
accessibilityIdentifier = "drone.device.empty"
|
||||||
|
accessibilityLabel = "暂无无人机,\(status),\(detail)"
|
||||||
|
}
|
||||||
|
|
||||||
private func setupUI() {
|
private func setupUI() {
|
||||||
temperatureValue.accessibilityIdentifier = "drone.metric.env_temp"
|
temperatureValue.accessibilityIdentifier = "drone.metric.env_temp"
|
||||||
windValue.accessibilityIdentifier = "drone.metric.wind_speed"
|
windValue.accessibilityIdentifier = "drone.metric.wind_speed"
|
||||||
rainValue.accessibilityIdentifier = "drone.metric.rainfall"
|
rainValue.accessibilityIdentifier = "drone.metric.rainfall"
|
||||||
signalValue.accessibilityIdentifier = "drone.metric.signal"
|
signalValue.accessibilityIdentifier = "drone.metric.signal"
|
||||||
satelliteValue.accessibilityIdentifier = "drone.metric.satellite"
|
satelliteValue.accessibilityIdentifier = "drone.metric.satellite"
|
||||||
[nameLabel, statusLabel, batteryView].forEach(addSubview)
|
detailLabel.isHidden = true
|
||||||
|
detailLabel.lineBreakMode = .byTruncatingMiddle
|
||||||
|
[nameLabel, statusLabel, detailLabel, batteryView].forEach(addSubview)
|
||||||
nameLabel.snp.makeConstraints { make in
|
nameLabel.snp.makeConstraints { make in
|
||||||
make.top.leading.equalToSuperview().inset(16)
|
make.top.leading.equalToSuperview().inset(16)
|
||||||
make.trailing.lessThanOrEqualTo(statusLabel.snp.leading).offset(-8)
|
make.trailing.lessThanOrEqualTo(statusLabel.snp.leading).offset(-8)
|
||||||
@@ -69,6 +90,10 @@ final class DroneDockDeviceCardView: UIView {
|
|||||||
make.centerY.equalTo(nameLabel)
|
make.centerY.equalTo(nameLabel)
|
||||||
make.trailing.equalToSuperview().inset(16)
|
make.trailing.equalToSuperview().inset(16)
|
||||||
}
|
}
|
||||||
|
detailLabel.snp.makeConstraints { make in
|
||||||
|
make.top.equalTo(nameLabel.snp.bottom).offset(2)
|
||||||
|
make.leading.trailing.equalToSuperview().inset(16)
|
||||||
|
}
|
||||||
batteryView.snp.makeConstraints { make in
|
batteryView.snp.makeConstraints { make in
|
||||||
make.leading.equalToSuperview().inset(20)
|
make.leading.equalToSuperview().inset(20)
|
||||||
make.top.equalTo(nameLabel.snp.bottom).offset(16)
|
make.top.equalTo(nameLabel.snp.bottom).offset(16)
|
||||||
|
|||||||
@@ -131,6 +131,18 @@ final class DroneDockHomeViewController: BaseViewController {
|
|||||||
private func configureDataSource() {
|
private func configureDataSource() {
|
||||||
dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { [weak self] collection, path, item in
|
dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { [weak self] collection, path, item in
|
||||||
guard let self else { return nil }
|
guard let self else { return nil }
|
||||||
|
if item == .devices {
|
||||||
|
let cell = collection.dequeueReusableCell(withReuseIdentifier: "device", for: path) as! DroneDockDeviceCell
|
||||||
|
let error = self.viewModel.deviceErrorMessage ?? self.viewModel.errorMessage
|
||||||
|
if self.isRefreshing || error == nil && self.viewModel.response == nil {
|
||||||
|
cell.cardView.applyPlaceholder(status: "正在加载", detail: "正在获取最新数据")
|
||||||
|
} else if let error {
|
||||||
|
cell.cardView.applyPlaceholder(status: "设备加载失败", detail: error + ",请下拉重试")
|
||||||
|
} else {
|
||||||
|
cell.cardView.applyPlaceholder(status: "暂无数据", detail: "当前景区暂无设备数据")
|
||||||
|
}
|
||||||
|
return cell
|
||||||
|
}
|
||||||
if case .device(let id) = item {
|
if case .device(let id) = item {
|
||||||
let cell = collection.dequeueReusableCell(withReuseIdentifier: "device", for: path) as! DroneDockDeviceCell
|
let cell = collection.dequeueReusableCell(withReuseIdentifier: "device", for: path) as! DroneDockDeviceCell
|
||||||
if let airport = self.viewModel.response?.airports.first(where: { $0.id == id }) {
|
if let airport = self.viewModel.response?.airports.first(where: { $0.id == id }) {
|
||||||
@@ -162,9 +174,9 @@ final class DroneDockHomeViewController: BaseViewController {
|
|||||||
cell.applyLoadMore(isLoading: self.isLoadingOrdersPage,
|
cell.applyLoadMore(isLoading: self.isLoadingOrdersPage,
|
||||||
error: self.viewModel.ordersLoadMoreErrorMessage,
|
error: self.viewModel.ordersLoadMoreErrorMessage,
|
||||||
enabled: !self.isRefreshing) { [weak self] in self?.loadMoreOrders() }
|
enabled: !self.isRefreshing) { [weak self] in self?.loadMoreOrders() }
|
||||||
case .devices, .orders:
|
case .orders:
|
||||||
self.applyDataState(to: cell, isDevice: item == .devices)
|
self.applyOrderState(to: cell)
|
||||||
case .device, .order: break
|
case .devices, .device, .order: break
|
||||||
}
|
}
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
@@ -183,15 +195,15 @@ final class DroneDockHomeViewController: BaseViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func applyDataState(to cell: DroneDockHomeContentCell, isDevice: Bool) {
|
private func applyOrderState(to cell: DroneDockHomeContentCell) {
|
||||||
let hasResponse = isDevice ? viewModel.response != nil : viewModel.ordersResponse != nil
|
let hasResponse = viewModel.ordersResponse != nil
|
||||||
let error = (isDevice ? viewModel.deviceErrorMessage : viewModel.ordersErrorMessage) ?? viewModel.errorMessage
|
let error = viewModel.ordersErrorMessage ?? viewModel.errorMessage
|
||||||
if isRefreshing, !hasResponse {
|
if isRefreshing, !hasResponse {
|
||||||
cell.applyMessage(symbol: "arrow.triangle.2.circlepath", title: "正在加载", detail: "正在获取最新数据")
|
cell.applyMessage(symbol: "arrow.triangle.2.circlepath", title: "正在加载", detail: "正在获取最新数据")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if let error {
|
if let error {
|
||||||
cell.applyMessage(symbol: "wifi.exclamationmark", title: isDevice ? "设备加载失败" : "订单加载失败",
|
cell.applyMessage(symbol: "wifi.exclamationmark", title: "订单加载失败",
|
||||||
detail: error + ",请下拉重试")
|
detail: error + ",请下拉重试")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -199,9 +211,7 @@ final class DroneDockHomeViewController: BaseViewController {
|
|||||||
cell.applyMessage(symbol: "arrow.triangle.2.circlepath", title: "正在加载", detail: "正在获取最新数据")
|
cell.applyMessage(symbol: "arrow.triangle.2.circlepath", title: "正在加载", detail: "正在获取最新数据")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cell.applyMessage(symbol: isDevice ? "airplane" : "doc.text",
|
cell.applyMessage(symbol: "doc.text", title: "暂无拍摄订单", detail: "当前景区暂无拍摄订单数据")
|
||||||
title: isDevice ? "暂无无人机" : "暂无拍摄订单",
|
|
||||||
detail: isDevice ? "当前景区暂无设备数据" : "当前景区暂无拍摄订单数据")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func applySnapshot(animated: Bool, completion: (() -> Void)? = nil) {
|
private func applySnapshot(animated: Bool, completion: (() -> Void)? = nil) {
|
||||||
@@ -244,9 +254,8 @@ final class DroneDockHomeViewController: BaseViewController {
|
|||||||
UICollectionViewCompositionalLayout { [weak self] index, environment in
|
UICollectionViewCompositionalLayout { [weak self] index, environment in
|
||||||
guard let section = Section(rawValue: index) else { return nil }
|
guard let section = Section(rawValue: index) else { return nil }
|
||||||
let deviceCount = self?.viewModel.response?.airports.count ?? 0
|
let deviceCount = self?.viewModel.response?.airports.count ?? 0
|
||||||
let hasDevices = section == .devices && deviceCount > 0
|
|
||||||
let multipleDevices = section == .devices && deviceCount > 1
|
let multipleDevices = section == .devices && deviceCount > 1
|
||||||
let height: NSCollectionLayoutDimension = hasDevices ? .absolute(248) : section == .context ? .estimated(40) : .estimated(132)
|
let height: NSCollectionLayoutDimension = section == .devices ? .absolute(248) : section == .context ? .estimated(40) : .estimated(132)
|
||||||
let item = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: height))
|
let item = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: height))
|
||||||
let width: NSCollectionLayoutDimension = multipleDevices ? .absolute(environment.container.effectiveContentSize.width - 48) : .fractionalWidth(1)
|
let width: NSCollectionLayoutDimension = multipleDevices ? .absolute(environment.container.effectiveContentSize.width - 48) : .fractionalWidth(1)
|
||||||
let group = NSCollectionLayoutGroup.horizontal(layoutSize: NSCollectionLayoutSize(widthDimension: width, heightDimension: height), subitems: [item])
|
let group = NSCollectionLayoutGroup.horizontal(layoutSize: NSCollectionLayoutSize(widthDimension: width, heightDimension: height), subitems: [item])
|
||||||
@@ -295,7 +304,6 @@ final class DroneDockHomeViewController: BaseViewController {
|
|||||||
viewModel: DroneDockPreparationViewModel(
|
viewModel: DroneDockPreparationViewModel(
|
||||||
context: context, order: order,
|
context: context, order: order,
|
||||||
service: DroneDockPreparationAPI(client: NetworkServices.shared.apiClient),
|
service: DroneDockPreparationAPI(client: NetworkServices.shared.apiClient),
|
||||||
locationProvider: LocationProvider.shared,
|
|
||||||
currentContext: { Self.currentContext() }
|
currentContext: { Self.currentContext() }
|
||||||
))
|
))
|
||||||
navigationController?.pushViewController(controller, animated: true)
|
navigationController?.pushViewController(controller, animated: true)
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import SnapKit
|
import SnapKit
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
/// 读取 workbench 的真实拍摄准备页,点位和航线选择只影响页面展示。
|
/// 进入页面后通过 project-info 读取已购套餐、点位和航线。
|
||||||
@MainActor
|
@MainActor
|
||||||
final class DroneDockRemotePreparationViewController: BaseViewController {
|
final class DroneDockRemotePreparationViewController: BaseViewController {
|
||||||
/// 当前订单与准备页的真实读取状态。
|
/// 当前订单与准备页的真实读取状态。
|
||||||
let viewModel: DroneDockPreparationViewModel
|
let viewModel: DroneDockPreparationViewModel
|
||||||
|
|
||||||
/// 点位与航线沿用原准备页顺序,状态区单独承载加载、错误和定位说明。
|
/// 点位与航线沿用原准备页顺序,状态区单独承载加载和错误说明。
|
||||||
private enum Section: Int, CaseIterable { case order, points, routes, status }
|
private enum Section: Int, CaseIterable { case order, points, routes, status }
|
||||||
/// 点位与航线使用后端稳定 ID,刷新时保留有效选择。
|
/// 点位与航线使用后端稳定 ID,刷新时保留有效选择。
|
||||||
private enum Item: Hashable { case order, point(Int), route(Int), emptyPoints, emptyRoutes, status }
|
private enum Item: Hashable { case order, point(Int), route(Int), emptyPoints, emptyRoutes, status }
|
||||||
@@ -90,7 +90,7 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
|
|||||||
isRefreshing = true
|
isRefreshing = true
|
||||||
refreshTask = Task { @MainActor [weak self] in
|
refreshTask = Task { @MainActor [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
let isInitialLoad = self.viewModel.response == nil
|
let isInitialLoad = self.viewModel.projectInfo == nil
|
||||||
self.applySnapshot(animated: false)
|
self.applySnapshot(animated: false)
|
||||||
await self.viewModel.refresh()
|
await self.viewModel.refresh()
|
||||||
guard !Task.isCancelled else { return }
|
guard !Task.isCancelled else { return }
|
||||||
@@ -115,13 +115,13 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
|
|||||||
switch item {
|
switch item {
|
||||||
case .order:
|
case .order:
|
||||||
let cell = list.dequeueReusableCell(withReuseIdentifier: "order", for: path) as! DronePreparationOrderCell
|
let cell = list.dequeueReusableCell(withReuseIdentifier: "order", for: path) as! DronePreparationOrderCell
|
||||||
cell.apply(homeOrder: self.viewModel.order, progress: self.viewModel.response?.orderProgress,
|
cell.apply(homeOrder: self.viewModel.order, summary: self.viewModel.projectInfo?.order,
|
||||||
usesHomeSnapshot: self.viewModel.response == nil && self.viewModel.errorMessage == nil)
|
usesHomeSnapshot: self.viewModel.projectInfo == nil && self.viewModel.errorMessage == nil)
|
||||||
return cell
|
return cell
|
||||||
case .point(let id):
|
case .point(let id):
|
||||||
let cell = list.dequeueReusableCell(withReuseIdentifier: "point", for: path) as! DronePreparationPointCell
|
let cell = list.dequeueReusableCell(withReuseIdentifier: "point", for: path) as! DronePreparationPointCell
|
||||||
if let spot = self.viewModel.spots.first(where: { $0.id == id }) {
|
if let spot = self.viewModel.spots.first(where: { $0.id == id }) {
|
||||||
cell.apply(spot: spot, selected: self.viewModel.selectedSpotID == id, hasLocation: self.viewModel.hasLocation)
|
cell.apply(spot: spot, selected: self.viewModel.selectedSpotID == id)
|
||||||
}
|
}
|
||||||
return cell
|
return cell
|
||||||
case .route(let id):
|
case .route(let id):
|
||||||
@@ -135,7 +135,7 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
|
|||||||
if item == .status {
|
if item == .status {
|
||||||
self.applyStatus(to: cell)
|
self.applyStatus(to: cell)
|
||||||
} else if item == .emptyPoints {
|
} else if item == .emptyPoints {
|
||||||
cell.apply(title: "暂无可用拍摄点", detail: "当前订单暂无拍摄点配置,请刷新重试")
|
cell.apply(title: "暂无可用拍摄点", detail: "当前套餐暂无已购拍摄点,请刷新重试")
|
||||||
} else if self.viewModel.selectedSpot == nil {
|
} else if self.viewModel.selectedSpot == nil {
|
||||||
cell.apply(title: "请选择拍摄点", detail: "选择拍摄点后查看对应航线")
|
cell.apply(title: "请选择拍摄点", detail: "选择拍摄点后查看对应航线")
|
||||||
} else {
|
} else {
|
||||||
@@ -153,12 +153,10 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func applyStatus(to cell: DronePreparationEmptyCell) {
|
private func applyStatus(to cell: DronePreparationEmptyCell) {
|
||||||
if isRefreshing, viewModel.response == nil {
|
if isRefreshing, viewModel.projectInfo == nil {
|
||||||
cell.apply(title: "正在加载", detail: "正在获取拍摄点、航线和设备状态")
|
cell.apply(title: "正在加载", detail: "正在获取已购套餐、拍摄点和航线")
|
||||||
} else if let error = viewModel.errorMessage {
|
} else if let error = viewModel.errorMessage {
|
||||||
cell.apply(title: "准备信息加载失败", detail: error + ",请下拉或点击刷新状态重试")
|
cell.apply(title: "准备信息加载失败", detail: error + ",请下拉或点击刷新状态重试")
|
||||||
} else if let message = viewModel.locationMessage, viewModel.response != nil {
|
|
||||||
cell.apply(title: "位置待确认", detail: message)
|
|
||||||
} else {
|
} else {
|
||||||
cell.apply(title: "正在加载", detail: "正在获取拍摄准备信息")
|
cell.apply(title: "正在加载", detail: "正在获取拍摄准备信息")
|
||||||
}
|
}
|
||||||
@@ -171,12 +169,11 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
|
|||||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||||
snapshot.appendSections(Section.allCases)
|
snapshot.appendSections(Section.allCases)
|
||||||
snapshot.appendItems([.order], toSection: .order)
|
snapshot.appendItems([.order], toSection: .order)
|
||||||
if viewModel.response != nil, viewModel.errorMessage == nil {
|
if viewModel.projectInfo != nil, viewModel.errorMessage == nil {
|
||||||
snapshot.appendItems(viewModel.spots.isEmpty ? [.emptyPoints] : viewModel.spots.map { .point($0.id) }, toSection: .points)
|
snapshot.appendItems(viewModel.spots.isEmpty ? [.emptyPoints] : viewModel.spots.map { .point($0.id) }, toSection: .points)
|
||||||
if !viewModel.spots.isEmpty {
|
if !viewModel.spots.isEmpty {
|
||||||
snapshot.appendItems(viewModel.routes.isEmpty ? [.emptyRoutes] : viewModel.routes.map { .route($0.id) }, toSection: .routes)
|
snapshot.appendItems(viewModel.routes.isEmpty ? [.emptyRoutes] : viewModel.routes.map { .route($0.id) }, toSection: .routes)
|
||||||
}
|
}
|
||||||
if viewModel.locationMessage != nil { snapshot.appendItems([.status], toSection: .status) }
|
|
||||||
} else {
|
} else {
|
||||||
snapshot.appendItems([.status], toSection: .status)
|
snapshot.appendItems([.status], toSection: .status)
|
||||||
}
|
}
|
||||||
@@ -212,7 +209,7 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
|
|||||||
height = .absolute(self.viewModel.spots.isEmpty ? 150 : 80)
|
height = .absolute(self.viewModel.spots.isEmpty ? 150 : 80)
|
||||||
width = self.viewModel.spots.isEmpty ? .fractionalWidth(1) : .absolute(160)
|
width = self.viewModel.spots.isEmpty ? .fractionalWidth(1) : .absolute(160)
|
||||||
case .routes:
|
case .routes:
|
||||||
height = .absolute(self.viewModel.routes.isEmpty ? 160 : 64)
|
height = self.viewModel.routes.isEmpty ? .absolute(160) : .estimated(64)
|
||||||
width = .fractionalWidth(1)
|
width = .fractionalWidth(1)
|
||||||
case .status: height = .absolute(160); width = .fractionalWidth(1)
|
case .status: height = .absolute(160); width = .fractionalWidth(1)
|
||||||
}
|
}
|
||||||
@@ -224,7 +221,7 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
|
|||||||
layout.orthogonalScrollingBehavior = .continuous
|
layout.orthogonalScrollingBehavior = .continuous
|
||||||
layout.interGroupSpacing = 8
|
layout.interGroupSpacing = 8
|
||||||
}
|
}
|
||||||
let showsHeading = self.viewModel.response != nil && self.viewModel.errorMessage == nil
|
let showsHeading = self.viewModel.projectInfo != nil && self.viewModel.errorMessage == nil
|
||||||
&& (section == .points || (section == .routes && !self.viewModel.spots.isEmpty))
|
&& (section == .points || (section == .routes && !self.viewModel.spots.isEmpty))
|
||||||
if showsHeading {
|
if showsHeading {
|
||||||
layout.boundarySupplementaryItems = [NSCollectionLayoutBoundarySupplementaryItem(
|
layout.boundarySupplementaryItems = [NSCollectionLayoutBoundarySupplementaryItem(
|
||||||
@@ -268,7 +265,13 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
|
|||||||
extension DroneDockRemotePreparationViewController: UICollectionViewDelegate {
|
extension DroneDockRemotePreparationViewController: UICollectionViewDelegate {
|
||||||
/// 点位和航线只在当前成功快照中选择,刷新期间不切换旧配置。
|
/// 点位和航线只在当前成功快照中选择,刷新期间不切换旧配置。
|
||||||
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
||||||
!isRefreshing && viewModel.response != nil && viewModel.errorMessage == nil
|
guard !isRefreshing, viewModel.projectInfo != nil, viewModel.errorMessage == nil,
|
||||||
|
let item = dataSource.itemIdentifier(for: indexPath) else { return false }
|
||||||
|
switch item {
|
||||||
|
case .point(let id): return viewModel.spots.first { $0.id == id }?.available == true
|
||||||
|
case .route(let id): return viewModel.routes.first { $0.id == id }?.available == true
|
||||||
|
default: return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 更新本地点位、航线及底部摘要,不创建拍摄任务。
|
/// 更新本地点位、航线及底部摘要,不创建拍摄任务。
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import Kingfisher
|
||||||
import SnapKit
|
import SnapKit
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@@ -67,17 +68,19 @@ final class DronePreparationOrderCell: UICollectionViewCell {
|
|||||||
accessibilityLabel = "\(order.customerName),含\(order.totalShootingCount)次拍摄,已拍摄\(order.successfulShootingCount)次,剩余\(order.remainingShootingCount)次"
|
accessibilityLabel = "\(order.customerName),含\(order.totalShootingCount)次拍摄,已拍摄\(order.successfulShootingCount)次,剩余\(order.remainingShootingCount)次"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 使用真实首页游客信息与准备页最新次数;准备响应中的未知次数不回填成旧值。
|
/// 使用 project-info 的最新购买摘要;缺失次数不回退旧订单或 workbench 统计。
|
||||||
func apply(homeOrder: DroneDockHomeOrder, progress: DroneDockPreparationOrderProgress?, usesHomeSnapshot: Bool = false) {
|
func apply(homeOrder: DroneDockHomeOrder, summary: DroneDockHomeOrder?, usesHomeSnapshot: Bool = false) {
|
||||||
let total = usesHomeSnapshot ? homeOrder.shotTotal : progress?.shotTotal
|
let snapshot = usesHomeSnapshot ? homeOrder : summary
|
||||||
let used = usesHomeSnapshot ? homeOrder.shotUsed : progress?.shotUsed
|
let total = snapshot?.shotTotal
|
||||||
let remaining = usesHomeSnapshot ? homeOrder.shotRemain : progress?.shotRemain
|
let used = snapshot?.shotUsed
|
||||||
let package = progress == nil ? homeOrder.packageTitle : progress?.packageName
|
let remaining = snapshot?.shotRemain
|
||||||
customerLabel.text = homeOrder.touristTitle
|
let package = snapshot?.packageName
|
||||||
|
let tourist = summary?.touristTitle ?? homeOrder.touristTitle
|
||||||
|
customerLabel.text = tourist
|
||||||
packageLabel.text = package?.isEmpty == false ? package : "含 \(total.map(String.init) ?? "—") 次拍摄"
|
packageLabel.text = package?.isEmpty == false ? package : "含 \(total.map(String.init) ?? "—") 次拍摄"
|
||||||
completedLabel.text = "已拍摄 \(used.map(String.init) ?? "—") 次"
|
completedLabel.text = "已拍摄 \(used.map(String.init) ?? "—") 次"
|
||||||
remainingLabel.attributedText = remainingText(remaining.map(String.init) ?? "—")
|
remainingLabel.attributedText = remainingText(remaining.map(String.init) ?? "—")
|
||||||
accessibilityLabel = "\(homeOrder.touristTitle),\(packageLabel.text ?? ""),已拍摄\(used.map(String.init) ?? "—")次,剩余\(remaining.map(String.init) ?? "—")次"
|
accessibilityLabel = "\(tourist),\(packageLabel.text ?? ""),已拍摄\(used.map(String.init) ?? "—")次,剩余\(remaining.map(String.init) ?? "—")次"
|
||||||
accessibilityIdentifier = "drone.preparation.order"
|
accessibilityIdentifier = "drone.preparation.order"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,6 +145,8 @@ final class DronePreparationPointCell: UICollectionViewCell {
|
|||||||
|
|
||||||
/// 仅映射模型提供的范围和次数,已拍摄的点位仍保持可选择。
|
/// 仅映射模型提供的范围和次数,已拍摄的点位仍保持可选择。
|
||||||
func apply(point: DroneShootingPoint, selected: Bool) {
|
func apply(point: DroneShootingPoint, selected: Bool) {
|
||||||
|
thumbnail.kf.cancelDownloadTask()
|
||||||
|
contentView.alpha = 1
|
||||||
nameLabel.text = point.name
|
nameLabel.text = point.name
|
||||||
thumbnail.contentMode = .scaleAspectFill
|
thumbnail.contentMode = .scaleAspectFill
|
||||||
thumbnail.image = UIImage(named: point.id == "point-jinque" ? "drone_demo_pagoda" : "drone_demo_mountain")
|
thumbnail.image = UIImage(named: point.id == "point-jinque" ? "drone_demo_pagoda" : "drone_demo_mountain")
|
||||||
@@ -160,39 +165,47 @@ final class DronePreparationPointCell: UICollectionViewCell {
|
|||||||
accessibilityIdentifier = "drone.preparation.point.\(point.id)"
|
accessibilityIdentifier = "drone.preparation.point.\(point.id)"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 距离只在请求携带有效定位时展示,服务端未提供点位图片时不使用演示山景。
|
/// 展示已购点位;当前接口未提供距离与点位已拍次数,保持未知占位。
|
||||||
func apply(spot: DroneDockPreparationSpot, selected: Bool, hasLocation: Bool) {
|
func apply(spot: DroneDockPurchasedSpot, selected: Bool) {
|
||||||
nameLabel.text = spot.name
|
nameLabel.text = spot.name
|
||||||
|
thumbnail.kf.cancelDownloadTask()
|
||||||
thumbnail.image = UIImage(systemName: "mappin.and.ellipse")
|
thumbnail.image = UIImage(systemName: "mappin.and.ellipse")
|
||||||
thumbnail.contentMode = .center
|
thumbnail.contentMode = .center
|
||||||
thumbnail.tintColor = DroneDockStyle.secondary
|
thumbnail.tintColor = DroneDockStyle.secondary
|
||||||
if hasLocation {
|
if let text = spot.coverURL, let url = URL(string: text),
|
||||||
rangeLabel.text = spot.distanceLabel?.isEmpty == false ? spot.distanceLabel : "距离待确认"
|
let scheme = url.scheme?.lowercased(), ["https", "http"].contains(scheme), url.host != nil {
|
||||||
rangeLabel.textColor = spot.inRange == true ? DroneDockStyle.success : DroneDockStyle.secondary
|
thumbnail.contentMode = .scaleAspectFill
|
||||||
} else {
|
thumbnail.kf.setImage(with: url, placeholder: UIImage(systemName: "mappin.and.ellipse"))
|
||||||
rangeLabel.text = "待定位"
|
|
||||||
rangeLabel.textColor = DroneDockStyle.warning
|
|
||||||
}
|
}
|
||||||
|
rangeLabel.text = "距离待确认"
|
||||||
|
rangeLabel.textColor = DroneDockStyle.secondary
|
||||||
locationIcon.tintColor = rangeLabel.textColor
|
locationIcon.tintColor = rangeLabel.textColor
|
||||||
if let status = spot.shotStatusLabel, !status.isEmpty {
|
if spot.available != true {
|
||||||
countLabel.text = status
|
countLabel.text = spot.available == false ? "拍摄点不可用" : "可用性待确认"
|
||||||
} else if let count = spot.shotCount {
|
|
||||||
countLabel.text = count == 0 ? "未拍摄" : "已拍摄 \(count) 次"
|
|
||||||
} else {
|
} else {
|
||||||
countLabel.text = "已拍摄 — 次"
|
countLabel.text = "已拍摄 — 次"
|
||||||
}
|
}
|
||||||
contentView.backgroundColor = selected ? DroneDockStyle.primary.withAlphaComponent(0.07) : .white
|
contentView.backgroundColor = selected ? DroneDockStyle.primary.withAlphaComponent(0.07) : .white
|
||||||
contentView.layer.borderColor = (selected ? DroneDockStyle.primary : DroneDockStyle.border).cgColor
|
contentView.layer.borderColor = (selected ? DroneDockStyle.primary : DroneDockStyle.border).cgColor
|
||||||
|
contentView.alpha = spot.available == true ? 1 : 0.55
|
||||||
accessibilityLabel = "\(spot.name),\(rangeLabel.text ?? ""),\(countLabel.text ?? "")"
|
accessibilityLabel = "\(spot.name),\(rangeLabel.text ?? ""),\(countLabel.text ?? "")"
|
||||||
accessibilityTraits = selected ? [.button, .selected] : .button
|
accessibilityTraits = selected ? [.button, .selected] : .button
|
||||||
|
if spot.available != true { accessibilityTraits.insert(.notEnabled) }
|
||||||
accessibilityIdentifier = "drone.preparation.point.\(spot.id)"
|
accessibilityIdentifier = "drone.preparation.point.\(spot.id)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func prepareForReuse() {
|
||||||
|
super.prepareForReuse()
|
||||||
|
thumbnail.kf.cancelDownloadTask()
|
||||||
|
thumbnail.image = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 纵向单选航线行,点击整行后由 ViewModel 保留有效选择。
|
/// 纵向单选航线行,点击整行后由 ViewModel 保留有效选择。
|
||||||
@MainActor
|
@MainActor
|
||||||
final class DronePreparationRouteCell: UICollectionViewCell {
|
final class DronePreparationRouteCell: UICollectionViewCell {
|
||||||
private let nameLabel = DroneDockStyle.label(size: 16, weight: .semibold)
|
private let nameLabel = DroneDockStyle.label(size: 16, weight: .semibold)
|
||||||
|
private let unavailableLabel = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
||||||
private let routeIcon = DronePreparationRouteIconView()
|
private let routeIcon = DronePreparationRouteIconView()
|
||||||
private let checkmark = UIImageView()
|
private let checkmark = UIImageView()
|
||||||
private let separator = UIView()
|
private let separator = UIView()
|
||||||
@@ -203,16 +216,24 @@ final class DronePreparationRouteCell: UICollectionViewCell {
|
|||||||
contentView.layer.cornerCurve = .continuous
|
contentView.layer.cornerCurve = .continuous
|
||||||
checkmark.contentMode = .scaleAspectFit
|
checkmark.contentMode = .scaleAspectFit
|
||||||
separator.backgroundColor = DroneDockStyle.border
|
separator.backgroundColor = DroneDockStyle.border
|
||||||
[routeIcon, nameLabel, checkmark, separator].forEach(contentView.addSubview)
|
nameLabel.numberOfLines = 0
|
||||||
|
unavailableLabel.numberOfLines = 0
|
||||||
|
unavailableLabel.isHidden = true
|
||||||
|
let labels = UIStackView(arrangedSubviews: [nameLabel, unavailableLabel])
|
||||||
|
labels.axis = .vertical
|
||||||
|
labels.spacing = 5
|
||||||
|
[routeIcon, labels, checkmark, separator].forEach(contentView.addSubview)
|
||||||
routeIcon.snp.makeConstraints { make in
|
routeIcon.snp.makeConstraints { make in
|
||||||
make.leading.equalToSuperview().offset(12)
|
make.leading.equalToSuperview().offset(12)
|
||||||
make.centerY.equalToSuperview()
|
make.centerY.equalToSuperview()
|
||||||
make.size.equalTo(40)
|
make.size.equalTo(40)
|
||||||
}
|
}
|
||||||
nameLabel.snp.makeConstraints { make in
|
labels.snp.makeConstraints { make in
|
||||||
make.leading.equalTo(routeIcon.snp.trailing).offset(14)
|
make.leading.equalTo(routeIcon.snp.trailing).offset(14)
|
||||||
make.centerY.equalToSuperview()
|
make.centerY.equalToSuperview()
|
||||||
make.trailing.lessThanOrEqualTo(checkmark.snp.leading).offset(-12)
|
make.top.greaterThanOrEqualToSuperview().offset(12)
|
||||||
|
make.bottom.lessThanOrEqualToSuperview().inset(12)
|
||||||
|
make.trailing.equalTo(checkmark.snp.leading).offset(-12)
|
||||||
}
|
}
|
||||||
checkmark.snp.makeConstraints { make in
|
checkmark.snp.makeConstraints { make in
|
||||||
make.trailing.equalToSuperview().inset(14)
|
make.trailing.equalToSuperview().inset(14)
|
||||||
@@ -229,8 +250,21 @@ final class DronePreparationRouteCell: UICollectionViewCell {
|
|||||||
@available(*, unavailable)
|
@available(*, unavailable)
|
||||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||||
|
|
||||||
|
/// 航线原因允许换行,自适应高度时保持列表提供的整行宽度。
|
||||||
|
override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
|
||||||
|
let width = layoutAttributes.size.width
|
||||||
|
let attributes = layoutAttributes.copy() as! UICollectionViewLayoutAttributes
|
||||||
|
let size = contentView.systemLayoutSizeFitting(
|
||||||
|
CGSize(width: width, height: 0),
|
||||||
|
withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel)
|
||||||
|
attributes.size = CGSize(width: width, height: max(64, ceil(size.height)))
|
||||||
|
return attributes
|
||||||
|
}
|
||||||
|
|
||||||
/// 选中样式仅反映现有选择,重复点击不会在视图中取消单选。
|
/// 选中样式仅反映现有选择,重复点击不会在视图中取消单选。
|
||||||
func apply(route: DroneShootingRoute, selected: Bool) {
|
func apply(route: DroneShootingRoute, selected: Bool) {
|
||||||
|
unavailableLabel.isHidden = true
|
||||||
|
contentView.alpha = 1
|
||||||
nameLabel.text = route.name
|
nameLabel.text = route.name
|
||||||
nameLabel.textColor = selected ? DroneDockStyle.primary : DroneDockStyle.text
|
nameLabel.textColor = selected ? DroneDockStyle.primary : DroneDockStyle.text
|
||||||
routeIcon.apply(selected: selected)
|
routeIcon.apply(selected: selected)
|
||||||
@@ -244,16 +278,23 @@ final class DronePreparationRouteCell: UICollectionViewCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 展示当前真实点位的航线选择,不从行点击发起任何飞行操作。
|
/// 展示当前真实点位的航线选择,不从行点击发起任何飞行操作。
|
||||||
func apply(route: DroneDockPreparationAirLine, selected: Bool) {
|
func apply(route: DroneDockPurchasedAirLine, selected: Bool) {
|
||||||
nameLabel.text = route.name
|
nameLabel.text = route.name
|
||||||
|
let reason = route.available == false
|
||||||
|
? DroneDockHomeMetric.usableText(route.unavailableReason) ?? "航线暂不可用"
|
||||||
|
: "可用性待确认"
|
||||||
|
unavailableLabel.text = reason
|
||||||
|
unavailableLabel.isHidden = route.available == true
|
||||||
|
contentView.alpha = route.available == true ? 1 : 0.55
|
||||||
nameLabel.textColor = selected ? DroneDockStyle.primary : DroneDockStyle.text
|
nameLabel.textColor = selected ? DroneDockStyle.primary : DroneDockStyle.text
|
||||||
routeIcon.apply(selected: selected)
|
routeIcon.apply(selected: selected)
|
||||||
checkmark.image = UIImage(systemName: selected ? "checkmark.circle.fill" : "circle")
|
checkmark.image = UIImage(systemName: selected ? "checkmark.circle.fill" : "circle")
|
||||||
checkmark.tintColor = selected ? DroneDockStyle.primary : UIColor(hex: 0xA4ABB8)
|
checkmark.tintColor = selected ? DroneDockStyle.primary : UIColor(hex: 0xA4ABB8)
|
||||||
contentView.backgroundColor = selected ? DroneDockStyle.primary.withAlphaComponent(0.08) : .white
|
contentView.backgroundColor = selected ? DroneDockStyle.primary.withAlphaComponent(0.08) : .white
|
||||||
separator.isHidden = selected
|
separator.isHidden = selected
|
||||||
accessibilityLabel = route.name
|
accessibilityLabel = route.available == true ? route.name : "\(route.name),\(reason)"
|
||||||
accessibilityTraits = selected ? [.button, .selected] : .button
|
accessibilityTraits = selected ? [.button, .selected] : .button
|
||||||
|
if route.available != true { accessibilityTraits.insert(.notEnabled) }
|
||||||
accessibilityIdentifier = "drone.preparation.route.\(route.id)"
|
accessibilityIdentifier = "drone.preparation.route.\(route.id)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,103 +2,9 @@ import Foundation
|
|||||||
import XCTest
|
import XCTest
|
||||||
@testable import suixinkan
|
@testable import suixinkan
|
||||||
|
|
||||||
/// 使用匿名 workbench 样例验证真实字段与只读请求,全部网络由替身提供。
|
/// 保留旧准备 DTO 的解码回归,不发起 workbench 或其他网络请求。
|
||||||
@MainActor
|
@MainActor
|
||||||
final class DroneDockPreparationAPITests: XCTestCase {
|
final class DroneDockPreparationAPITests: XCTestCase {
|
||||||
/// 有定位时发送当前订单及坐标,使用既有 token 注入且只发送一次 GET。
|
|
||||||
func testWorkbenchReadsObservedShapeWithOrderAndCoordinate() async throws {
|
|
||||||
let session = MockURLSession(responses: [envelope(Self.payload)])
|
|
||||||
let client = APIClient(environment: .testing, session: session)
|
|
||||||
client.bindAuthTokenProvider { "preparation-test-token" }
|
|
||||||
let api = DroneDockPreparationAPI(client: client)
|
|
||||||
|
|
||||||
let response = try await api.workbench(scenicID: 128, orderNumber: "TEST-ORDER-001",
|
|
||||||
coordinate: DroneDockPreparationCoordinate(latitude: 31.25, longitude: 121.5))
|
|
||||||
|
|
||||||
XCTAssertEqual(session.requests.count, 1)
|
|
||||||
let request = try XCTUnwrap(session.requests.first)
|
|
||||||
XCTAssertEqual(request.httpMethod, "GET")
|
|
||||||
XCTAssertEqual(request.url?.host, "api-test.zhifly.cn")
|
|
||||||
XCTAssertEqual(request.url?.path, "/api/app/airport/workbench")
|
|
||||||
XCTAssertEqual(try query(request), ["scenic_id": "128", "order_number": "TEST-ORDER-001", "lat": "31.25", "lng": "121.5"])
|
|
||||||
XCTAssertEqual(request.value(forHTTPHeaderField: "token"), "preparation-test-token")
|
|
||||||
XCTAssertNil(request.httpBody)
|
|
||||||
XCTAssertEqual(response.scenicID, 128)
|
|
||||||
XCTAssertEqual(response.orderNumber, "TEST-ORDER-001")
|
|
||||||
XCTAssertEqual(response.orderProgress?.packageName, "测试套餐 · 含 1 次拍摄")
|
|
||||||
XCTAssertEqual(response.orderProgress?.shotUsed, 0)
|
|
||||||
XCTAssertEqual(response.orderProgress?.shotRemain, 1)
|
|
||||||
XCTAssertEqual(response.airports.first?.statusTitle, "离线")
|
|
||||||
XCTAssertEqual(response.spots.map(\.id), [201, 202])
|
|
||||||
let spot = try XCTUnwrap(response.spots.first)
|
|
||||||
XCTAssertEqual(spot.name, "测试点位一")
|
|
||||||
XCTAssertEqual(spot.distanceM, 123.5)
|
|
||||||
XCTAssertEqual(spot.distanceLabel, "123.5 m")
|
|
||||||
XCTAssertEqual(spot.inRange, false)
|
|
||||||
XCTAssertEqual(spot.shotCount, 0)
|
|
||||||
XCTAssertEqual(spot.shotStatusLabel, "未拍摄")
|
|
||||||
XCTAssertEqual(spot.airLines.first?.id, 301)
|
|
||||||
XCTAssertEqual(spot.airLines.first?.name, "测试航线一")
|
|
||||||
XCTAssertEqual(spot.airLines.first?.estimatedFlyTime, 279)
|
|
||||||
XCTAssertEqual(spot.airLines.first?.lineVideoDuration, 14)
|
|
||||||
XCTAssertEqual(spot.airLines.first?.flyType, 1)
|
|
||||||
XCTAssertEqual(response.shootGate?.canShoot, false)
|
|
||||||
XCTAssertEqual(response.shootGate?.code, "dock_offline")
|
|
||||||
XCTAssertEqual(response.shootGate?.message, "机巢未连接")
|
|
||||||
XCTAssertEqual(response.shootGate?.primaryAction, "blocked")
|
|
||||||
XCTAssertEqual(response.shootGate?.primaryActionLabel, "机巢未连接")
|
|
||||||
XCTAssertEqual(response.tips, "测试拍摄规则")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 未定位也可读取准备信息,但不会上传零点、景区中心或其他伪造位置。
|
|
||||||
func testUnknownCoordinateOmitsBothLocationParameters() async throws {
|
|
||||||
let session = MockURLSession(responses: [envelope(Self.payload)])
|
|
||||||
_ = try await DroneDockPreparationAPI(client: APIClient(environment: .testing, session: session))
|
|
||||||
.workbench(scenicID: 128, orderNumber: "TEST-ORDER-001", coordinate: nil)
|
|
||||||
XCTAssertEqual(try query(XCTUnwrap(session.requests.first)), ["scenic_id": "128", "order_number": "TEST-ORDER-001"])
|
|
||||||
XCTAssertEqual(session.requests.count, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 请求范围或定位无效时在网络前失败,不能查询其他景区或使用占位坐标。
|
|
||||||
func testInvalidScopeAndCoordinatesDoNotSendNetworkRequests() async {
|
|
||||||
let session = MockURLSession(responses: [])
|
|
||||||
let api = DroneDockPreparationAPI(client: APIClient(environment: .testing, session: session))
|
|
||||||
for (scenicID, orderNumber) in [(0, "TEST-ORDER-001"), (-1, "TEST-ORDER-001"), (128, " \n")] {
|
|
||||||
do {
|
|
||||||
_ = try await api.workbench(scenicID: scenicID, orderNumber: orderNumber, coordinate: nil)
|
|
||||||
XCTFail("无效范围必须拒绝请求")
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
for coordinate in [
|
|
||||||
DroneDockPreparationCoordinate(latitude: 0, longitude: 0),
|
|
||||||
DroneDockPreparationCoordinate(latitude: 91, longitude: 100),
|
|
||||||
DroneDockPreparationCoordinate(latitude: 30, longitude: -181),
|
|
||||||
DroneDockPreparationCoordinate(latitude: .nan, longitude: 100),
|
|
||||||
DroneDockPreparationCoordinate(latitude: 30, longitude: .infinity)
|
|
||||||
] {
|
|
||||||
XCTAssertFalse(coordinate.isValid)
|
|
||||||
do {
|
|
||||||
_ = try await api.workbench(scenicID: 128, orderNumber: "TEST-ORDER-001", coordinate: coordinate)
|
|
||||||
XCTFail("无效定位必须拒绝请求")
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
XCTAssertTrue(DroneDockPreparationCoordinate(latitude: 0, longitude: 100).isValid)
|
|
||||||
XCTAssertTrue(session.requests.isEmpty)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 保留后端业务错误,不将拒绝访问当成没有点位。
|
|
||||||
func testBackendFailureKeepsBusinessMessage() async throws {
|
|
||||||
let session = MockURLSession(responses: [try TestJSON.errorEnvelope(code: 160001, msg: "当前订单不可访问")])
|
|
||||||
do {
|
|
||||||
_ = try await DroneDockPreparationAPI(client: APIClient(environment: .testing, session: session))
|
|
||||||
.workbench(scenicID: 128, orderNumber: "TEST-ORDER-001", coordinate: nil)
|
|
||||||
XCTFail("业务错误不能作为准备快照返回")
|
|
||||||
} catch let APIError.serverCode(code, message) {
|
|
||||||
XCTAssertEqual(code, 160001)
|
|
||||||
XCTAssertEqual(message, "当前订单不可访问")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 整数字符串与真实零值均能解析;剩余次数独立读取,不用总数重算。
|
/// 整数字符串与真实零值均能解析;剩余次数独立读取,不用总数重算。
|
||||||
func testNumericStringsAndZeroValuesRemainAccurate() throws {
|
func testNumericStringsAndZeroValuesRemainAccurate() throws {
|
||||||
let response = try decode(#"""
|
let response = try decode(#"""
|
||||||
@@ -197,33 +103,9 @@ final class DroneDockPreparationAPITests: XCTestCase {
|
|||||||
XCTAssertNil(response.shootGate?.canShoot)
|
XCTAssertNil(response.shootGate?.canShoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 与实测字段形状一致的匿名夹具,不包含真实设备、游客或业务订单。
|
|
||||||
private static let payload = #"""
|
|
||||||
{"scenic_id":128,"order_number":"TEST-ORDER-001",
|
|
||||||
"airports":[{"id":51,"name":"测试机巢","sn_number":"test-airport-sn","online_status":2,"work_status":0,"work_status_label":"离线","metrics":[]}],
|
|
||||||
"order_progress":{"order_number":"TEST-ORDER-001","package_name":"测试套餐 · 含 1 次拍摄","shot_total":1,"shot_used":0,"shot_remain":1,"status_label":"待拍摄"},
|
|
||||||
"recommend_plane":null,
|
|
||||||
"shoot_gate":{"can_shoot":false,"code":"dock_offline","message":"机巢未连接","primary_action":"blocked","primary_action_label":"机巢未连接"},
|
|
||||||
"spots":[{"scenic_spot_id":201,"name":"测试点位一","distance_label":"123.5 m","distance_m":123.5,"in_range":false,"shot_count":0,"shot_status_label":"未拍摄",
|
|
||||||
"air_lines":[{"air_line_id":301,"name":"测试航线一","estimated_fly_time":279,"line_video_duration":14,"fly_type":1}]},
|
|
||||||
{"scenic_spot_id":202,"name":"测试点位二","air_lines":[]}],
|
|
||||||
"tips":"测试拍摄规则"}
|
|
||||||
"""#
|
|
||||||
|
|
||||||
/// 为匿名载荷补齐业务响应外层。
|
|
||||||
private func envelope(_ payload: String) -> Data {
|
|
||||||
Data("{\"code\":100000,\"msg\":\"success\",\"data\":\(payload)}".utf8)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 解码独立准备载荷,便于定位字段错误。
|
/// 解码独立准备载荷,便于定位字段错误。
|
||||||
private func decode(_ payload: String) throws -> DroneDockPreparationResponse {
|
private func decode(_ payload: String) throws -> DroneDockPreparationResponse {
|
||||||
try JSONDecoder().decode(DroneDockPreparationResponse.self, from: Data(payload.utf8))
|
try JSONDecoder().decode(DroneDockPreparationResponse.self, from: Data(payload.utf8))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 读取请求查询参数,不依赖 URL 参数顺序。
|
|
||||||
private func query(_ request: URLRequest) throws -> [String: String] {
|
|
||||||
let url = try XCTUnwrap(request.url)
|
|
||||||
let items = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems ?? []
|
|
||||||
return Dictionary(uniqueKeysWithValues: items.map { ($0.name, $0.value ?? "") })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,419 +1,369 @@
|
|||||||
import CoreLocation
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import XCTest
|
import XCTest
|
||||||
@testable import suixinkan
|
@testable import suixinkan
|
||||||
|
|
||||||
/// 验证真实准备页的选择、定位缺失与请求身份隔离,不访问后端或发送飞行操作。
|
/// 验证准备页只读取购买配置、选择约束及异步身份隔离。
|
||||||
@MainActor
|
@MainActor
|
||||||
final class DroneDockPreparationViewModelTests: XCTestCase {
|
final class DroneDockPreparationViewModelTests: XCTestCase {
|
||||||
/// 最新准备快照保留零次,初次按服务端顺序选取点位和航线。
|
/// 次数和配置来自购买快照,首页旧额度不会覆盖五次套餐。
|
||||||
func testSuccessfulSnapshotPreservesZeroCountsAndSelectsFirstSpotAndRoute() async throws {
|
func testPurchasedSnapshotOwnsCountsPointsAndRoutes() async throws {
|
||||||
let scope = PreparationContextBox(context())
|
let service = try ImmediatePreparationService()
|
||||||
let service = ImmediatePreparationService(result: .success(try response()))
|
let model = try makeModel(service: service)
|
||||||
let location = MockLocationProvider()
|
|
||||||
let model = try makeModel(scope: scope, service: service, location: location)
|
|
||||||
XCTAssertNil(model.response)
|
|
||||||
XCTAssertNil(model.selectedSpotID)
|
|
||||||
XCTAssertNil(model.selectedRouteID)
|
|
||||||
|
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
|
XCTAssertEqual(model.projectInfo?.order.shotTotal, 5)
|
||||||
XCTAssertEqual(model.response?.orderProgress?.shotUsed, 0)
|
XCTAssertEqual(model.projectInfo?.order.shotUsed, 0)
|
||||||
XCTAssertEqual(model.response?.orderProgress?.shotRemain, 1)
|
XCTAssertEqual(model.projectInfo?.order.shotRemain, 5)
|
||||||
XCTAssertEqual(model.spots.map(\.id), [201, 202])
|
XCTAssertEqual(model.spots.map(\.id), [201, 202])
|
||||||
XCTAssertEqual(model.selectedSpotID, 201)
|
XCTAssertEqual(model.selectedSpotID, 201)
|
||||||
XCTAssertEqual(model.selectedRouteID, 301)
|
XCTAssertEqual(model.selectedRouteID, 301)
|
||||||
|
XCTAssertEqual(model.selectedSpot?.name, "已购点位 201")
|
||||||
XCTAssertEqual(model.routes.map(\.id), [301, 302])
|
XCTAssertEqual(model.routes.map(\.id), [301, 302])
|
||||||
XCTAssertTrue(model.hasLocation)
|
|
||||||
XCTAssertNil(model.errorMessage)
|
XCTAssertNil(model.errorMessage)
|
||||||
XCTAssertNil(model.locationMessage)
|
XCTAssertEqual(service.projectRequests.first?.projectID, 101)
|
||||||
XCTAssertEqual(service.requests.count, 1)
|
XCTAssertEqual(service.projectRequests.first?.orderNumber, "TEST-PREPARATION-001")
|
||||||
XCTAssertEqual(service.requests.first?.scenicID, 128)
|
XCTAssertEqual(service.projectRequests.count, 1)
|
||||||
XCTAssertEqual(service.requests.first?.orderNumber, "TEST-PREPARATION-001")
|
|
||||||
XCTAssertEqual(service.requests.first?.coordinate?.latitude, location.coordinate.latitude)
|
|
||||||
XCTAssertEqual(service.requests.first?.coordinate?.longitude, location.coordinate.longitude)
|
|
||||||
XCTAssertEqual(location.requestedAccuracies.count, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 点位切换重选所属航线,非法身份与其他点位的航线不会影响当前选择。
|
/// 页面刷新只发 project-info GET,不触发定位、旧设备入口或任务写入。
|
||||||
func testChangingSpotResetsRouteAndUnknownSelectionsAreIgnored() async throws {
|
func testRefreshOnlyRequestsProjectInfo() async throws {
|
||||||
let scope = PreparationContextBox(context())
|
let payload = Data(#"{"code":100000,"msg":"success","data":{"order_number":"TEST-PREPARATION-001","project_id":101,"project_name":"已购五次套餐","shoot_count":5,"shot_count":0,"remaining_count":5,"can_create_task":true,"spot":[]}}"#.utf8)
|
||||||
let service = ImmediatePreparationService(result: .success(try response()))
|
let session = MockURLSession(responses: [payload])
|
||||||
let model = try makeModel(scope: scope, service: service)
|
let api = DroneDockPreparationAPI(client: APIClient(environment: .testing, session: session))
|
||||||
|
let model = try makeModel(service: api)
|
||||||
|
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
|
|
||||||
|
XCTAssertEqual(session.requests.count, 1)
|
||||||
|
let request = try XCTUnwrap(session.requests.first)
|
||||||
|
XCTAssertEqual(request.httpMethod, "GET")
|
||||||
|
XCTAssertEqual(request.url?.path, "/api/yf-handset-app/photog/multi-plane/project-info")
|
||||||
|
let items = try XCTUnwrap(URLComponents(url: XCTUnwrap(request.url), resolvingAgainstBaseURL: false)?.queryItems)
|
||||||
|
XCTAssertEqual(Dictionary(uniqueKeysWithValues: items.map { ($0.name, $0.value ?? "") }),
|
||||||
|
["scenic_id": "128", "project_id": "101", "order_number": "TEST-PREPARATION-001"])
|
||||||
|
XCTAssertNotNil(model.projectInfo)
|
||||||
|
XCTAssertNil(model.errorMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 已购配置不包含实时设备与定位数据,展示保持未知且不开放召唤。
|
||||||
|
func testValidPurchaseKeepsDeviceAndLocationUnknown() async throws {
|
||||||
|
let model = try makeModel(service: ImmediatePreparationService())
|
||||||
|
await model.refresh()
|
||||||
|
|
||||||
|
XCTAssertEqual(model.connectionTitle, "机巢连接待确认")
|
||||||
|
XCTAssertEqual(model.connectionTone, .gray)
|
||||||
|
XCTAssertEqual(model.deviceStatusText, "状态待确认")
|
||||||
|
XCTAssertEqual(model.deviceTone, .gray)
|
||||||
|
XCTAssertEqual(model.rangeTitle, "位置待确认")
|
||||||
|
XCTAssertEqual(model.rangeTone, .gray)
|
||||||
|
XCTAssertEqual(model.primaryButtonTitle, "确认并召唤")
|
||||||
|
XCTAssertEqual(model.admissionMessage, "召唤功能暂未开放")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 点位切换重选所属航线,未知及不可用航线不能成为当前选择。
|
||||||
|
func testChangingSpotRejectsUnavailableAndForeignRoutes() async throws {
|
||||||
|
let service = try ImmediatePreparationService()
|
||||||
|
var second = PreparationFixture.point(202, routes: [401, 402, 403])
|
||||||
|
var routes = try XCTUnwrap(second["air_lines"] as? [[String: Any]])
|
||||||
|
routes[0]["available"] = false
|
||||||
|
routes[2]["available"] = NSNull()
|
||||||
|
second["air_lines"] = routes
|
||||||
|
service.projectResult = .success(try PreparationFixture.project(spots: [PreparationFixture.point(201), second]))
|
||||||
|
let model = try makeModel(service: service)
|
||||||
|
await model.refresh()
|
||||||
model.selectRoute(id: 302)
|
model.selectRoute(id: 302)
|
||||||
XCTAssertEqual(model.selectedRouteID, 302)
|
XCTAssertEqual(model.selectedRouteID, 302)
|
||||||
model.selectSpot(id: 202)
|
model.selectSpot(id: 202)
|
||||||
XCTAssertEqual(model.selectedSpotID, 202)
|
|
||||||
XCTAssertEqual(model.selectedRouteID, 401)
|
|
||||||
XCTAssertEqual(model.routes.map(\.id), [401, 402])
|
|
||||||
model.selectRoute(id: 402)
|
|
||||||
model.selectSpot(id: 999)
|
|
||||||
model.selectRoute(id: 301)
|
|
||||||
model.selectRoute(id: 999)
|
|
||||||
|
|
||||||
XCTAssertEqual(model.selectedSpotID, 202)
|
|
||||||
XCTAssertEqual(model.selectedRouteID, 402)
|
XCTAssertEqual(model.selectedRouteID, 402)
|
||||||
XCTAssertEqual(model.selectedSpot?.id, 202)
|
for id in [301, 401, 403, 999] { model.selectRoute(id: id) }
|
||||||
XCTAssertEqual(model.selectedRoute?.id, 402)
|
XCTAssertEqual(model.selectedRouteID, 402)
|
||||||
XCTAssertEqual(service.requests.count, 1, "选择仅更新本地准备状态,不创建或召唤任务")
|
XCTAssertEqual(service.projectRequests.count, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 刷新保留仍有效的选择,已移除的航线或点位回落到服务端首项,空列表清除选择。
|
/// 刷新保留仍可用选择,已停用点位或航线回落到首个明确可用项。
|
||||||
func testRefreshPreservesValidSelectionsAndReplacesRemovedSelections() async throws {
|
func testRefreshRevalidatesAvailabilityAndSelection() async throws {
|
||||||
let scope = PreparationContextBox(context())
|
let service = try ImmediatePreparationService()
|
||||||
let service = ImmediatePreparationService(result: .success(try response()))
|
let model = try makeModel(service: service)
|
||||||
let model = try makeModel(scope: scope, service: service)
|
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
model.selectSpot(id: 202)
|
model.selectSpot(id: 202)
|
||||||
model.selectRoute(id: 402)
|
model.selectRoute(id: 402)
|
||||||
|
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
XCTAssertEqual(model.selectedSpotID, 202)
|
|
||||||
XCTAssertEqual(model.selectedRouteID, 402)
|
XCTAssertEqual(model.selectedRouteID, 402)
|
||||||
|
service.projectResult = .success(try PreparationFixture.project(spots: [PreparationFixture.point(202, routes: [401])]))
|
||||||
var changed = spots()
|
|
||||||
changed[1]["air_lines"] = [route(id: 401)]
|
|
||||||
service.result = .success(try response(spots: changed))
|
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
XCTAssertEqual(model.selectedSpotID, 202)
|
XCTAssertEqual(model.selectedSpotID, 202)
|
||||||
XCTAssertEqual(model.selectedRouteID, 401)
|
XCTAssertEqual(model.selectedRouteID, 401)
|
||||||
|
service.projectResult = .success(try PreparationFixture.project(spots: [PreparationFixture.point(201, routes: [301, 401])]))
|
||||||
service.result = .success(try response(spots: [spots()[0]]))
|
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
XCTAssertEqual(model.selectedSpotID, 201)
|
XCTAssertEqual(model.selectedSpotID, 201)
|
||||||
XCTAssertEqual(model.selectedRouteID, 301)
|
XCTAssertEqual(model.selectedRouteID, 301, "点位被替换时不沿用旧点位的航线选择")
|
||||||
|
var unavailable = PreparationFixture.point(202)
|
||||||
service.result = .success(try response(spots: []))
|
unavailable["available"] = false
|
||||||
|
service.projectResult = .success(try PreparationFixture.project(spots: [unavailable, PreparationFixture.point(201)]))
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
XCTAssertTrue(model.spots.isEmpty)
|
model.selectSpot(id: 202)
|
||||||
|
XCTAssertEqual(model.selectedSpotID, 201)
|
||||||
|
service.projectResult = .success(try PreparationFixture.project(spots: []))
|
||||||
|
await model.refresh()
|
||||||
|
XCTAssertNil(model.selectedSpotID)
|
||||||
|
XCTAssertNil(model.selectedRouteID)
|
||||||
XCTAssertTrue(model.routes.isEmpty)
|
XCTAssertTrue(model.routes.isEmpty)
|
||||||
XCTAssertNil(model.selectedSpotID)
|
|
||||||
XCTAssertNil(model.selectedRouteID)
|
|
||||||
XCTAssertNil(model.selectedSpot)
|
|
||||||
XCTAssertNil(model.selectedRoute)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 网络失败后旧准备数据与选项失效,重试成功才重新展示点位。
|
/// 可用性未知时不猜测可拍,仍保留已购配置供页面解释。
|
||||||
func testRefreshFailureClearsSnapshotAndSelectionsAndCanRetry() async throws {
|
func testUnknownAvailabilityDoesNotSelectPoint() async throws {
|
||||||
let scope = PreparationContextBox(context())
|
let service = try ImmediatePreparationService()
|
||||||
let service = ImmediatePreparationService(result: .success(try response()))
|
var point = PreparationFixture.point(201)
|
||||||
let model = try makeModel(scope: scope, service: service)
|
point.removeValue(forKey: "available")
|
||||||
|
service.projectResult = .success(try PreparationFixture.project(spots: [point]))
|
||||||
|
let model = try makeModel(service: service)
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
model.selectSpot(id: 202)
|
model.selectSpot(id: 201)
|
||||||
service.result = .failure(APIError.networkFailed("测试准备请求超时"))
|
XCTAssertEqual(model.spots.count, 1)
|
||||||
|
|
||||||
await model.refresh()
|
|
||||||
|
|
||||||
XCTAssertNil(model.response)
|
|
||||||
XCTAssertNil(model.selectedSpotID)
|
XCTAssertNil(model.selectedSpotID)
|
||||||
XCTAssertNil(model.selectedRouteID)
|
XCTAssertNil(model.selectedRouteID)
|
||||||
|
XCTAssertEqual(model.admissionMessage, "请选择可用拍摄点")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 购买配置失败后清空次数与选择,不继续沿用旧快照。
|
||||||
|
func testProjectFailureClearsPurchasedDataAndRetryRestoresIt() async throws {
|
||||||
|
let service = try ImmediatePreparationService()
|
||||||
|
let model = try makeModel(service: service)
|
||||||
|
await model.refresh()
|
||||||
|
service.projectResult = .failure(APIError.networkFailed("购买配置暂不可用"))
|
||||||
|
await model.refresh()
|
||||||
|
XCTAssertNil(model.projectInfo)
|
||||||
XCTAssertTrue(model.spots.isEmpty)
|
XCTAssertTrue(model.spots.isEmpty)
|
||||||
XCTAssertTrue(model.errorMessage?.contains("测试准备请求超时") == true)
|
XCTAssertNil(model.selectedSpotID)
|
||||||
|
XCTAssertTrue(model.errorMessage?.contains("购买配置暂不可用") == true)
|
||||||
service.result = .success(try response())
|
service.projectResult = .success(try PreparationFixture.project())
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
XCTAssertNotNil(model.response)
|
XCTAssertEqual(model.projectInfo?.order.shotRemain, 5)
|
||||||
XCTAssertNil(model.errorMessage)
|
XCTAssertNil(model.errorMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 刷新期间保留旧选择供展示,但不能切换尚未重新确认的配置。
|
||||||
|
func testPendingRefreshBlocksSelectionUntilPurchaseReturns() async throws {
|
||||||
|
let service = SuspendedPreparationService()
|
||||||
|
let firstStarted = expectation(description: "首次购买请求")
|
||||||
|
let secondStarted = expectation(description: "购买刷新挂起")
|
||||||
|
service.requestStarted = { if $0 == 0 { firstStarted.fulfill() } else { secondStarted.fulfill() } }
|
||||||
|
defer { service.cancelAll() }
|
||||||
|
let model = try makeModel(service: service)
|
||||||
|
let first = Task { await model.refresh() }
|
||||||
|
await fulfillment(of: [firstStarted], timeout: 2)
|
||||||
|
XCTAssertEqual(model.admissionMessage, "正在获取拍摄准备信息")
|
||||||
|
try service.finish(index: 0)
|
||||||
|
await first.value
|
||||||
|
model.selectRoute(id: 302)
|
||||||
|
|
||||||
|
let second = Task { await model.refresh() }
|
||||||
|
await fulfillment(of: [secondStarted], timeout: 2)
|
||||||
|
model.selectSpot(id: 202)
|
||||||
|
model.selectRoute(id: 301)
|
||||||
XCTAssertEqual(model.selectedSpotID, 201)
|
XCTAssertEqual(model.selectedSpotID, 201)
|
||||||
XCTAssertEqual(model.selectedRouteID, 301)
|
XCTAssertEqual(model.selectedRouteID, 302)
|
||||||
|
try service.finish(index: 1)
|
||||||
|
await second.value
|
||||||
|
XCTAssertEqual(model.selectedRouteID, 302)
|
||||||
|
XCTAssertFalse(model.isLoading)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 未定位时仍可读取点位;请求不伪造坐标,界面不信任后端缺坐标时返回的距离或范围。
|
/// 购买快照必须同时属于当前订单和项目。
|
||||||
func testLocationFailureOmitsCoordinatesAndKeepsRangeUnknown() async throws {
|
func testMismatchedResponseIdentitiesAreRejected() async throws {
|
||||||
let location = MockLocationProvider()
|
let service = try ImmediatePreparationService()
|
||||||
location.requestCoordinateError = LocationProviderError.permissionDenied
|
let model = try makeModel(service: service)
|
||||||
let session = MockURLSession(responses: [try envelope()])
|
service.projectResult = .success(try PreparationFixture.project(projectID: 999))
|
||||||
let api = DroneDockPreparationAPI(client: APIClient(environment: .testing, session: session))
|
|
||||||
let scope = PreparationContextBox(context())
|
|
||||||
let model = try makeModel(scope: scope, service: api, location: location)
|
|
||||||
|
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
|
XCTAssertNil(model.projectInfo)
|
||||||
XCTAssertNotNil(model.response)
|
XCTAssertNotNil(model.errorMessage)
|
||||||
XCTAssertFalse(model.hasLocation)
|
service.projectResult = .success(try PreparationFixture.project(number: "OTHER-ORDER"))
|
||||||
XCTAssertNotNil(model.locationMessage)
|
await model.refresh()
|
||||||
XCTAssertEqual(model.rangeTitle, "位置待确认")
|
XCTAssertNil(model.projectInfo)
|
||||||
|
service.projectResult = .success(try PreparationFixture.project())
|
||||||
|
await model.refresh()
|
||||||
|
XCTAssertNotNil(model.projectInfo)
|
||||||
XCTAssertNil(model.errorMessage)
|
XCTAssertNil(model.errorMessage)
|
||||||
let request = try XCTUnwrap(session.requests.first)
|
|
||||||
XCTAssertEqual(session.requests.count, 1)
|
|
||||||
XCTAssertEqual(request.httpMethod, "GET")
|
|
||||||
XCTAssertEqual(request.url?.path, "/api/app/airport/workbench")
|
|
||||||
XCTAssertNil(request.httpBody)
|
|
||||||
let queryItems = URLComponents(url: try XCTUnwrap(request.url), resolvingAgainstBaseURL: false)?.queryItems ?? []
|
|
||||||
let query = Dictionary(uniqueKeysWithValues: queryItems.map { ($0.name, $0.value ?? "") })
|
|
||||||
XCTAssertEqual(query["scenic_id"], "128")
|
|
||||||
XCTAssertEqual(query["order_number"], "TEST-PREPARATION-001")
|
|
||||||
XCTAssertNil(query["lat"])
|
|
||||||
XCTAssertNil(query["lng"])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 定位恢复后新请求携带新位置,原位置错误不残留在准备状态中。
|
/// 购买权限与次数各自独立,未知或已耗尽不能允许新增任务。
|
||||||
func testLocationRecoveryRefreshesCoordinateAndClearsLocationError() async throws {
|
func testAdmissionUsesPurchasedPermissionAndKnownQuota() async throws {
|
||||||
let location = MockLocationProvider()
|
let service = try ImmediatePreparationService()
|
||||||
location.requestCoordinateError = LocationProviderError.locationFailed
|
let model = try makeModel(service: service)
|
||||||
let scope = PreparationContextBox(context())
|
service.projectResult = .success(try PreparationFixture.project(remaining: 0))
|
||||||
let service = ImmediatePreparationService(result: .success(try response()))
|
|
||||||
let model = try makeModel(scope: scope, service: service, location: location)
|
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
XCTAssertFalse(model.hasLocation)
|
XCTAssertEqual(model.primaryButtonTitle, "拍摄次数已用完")
|
||||||
XCTAssertNil(service.requests.first?.coordinate)
|
service.projectResult = .success(try PreparationFixture.project(remaining: nil))
|
||||||
|
|
||||||
location.requestCoordinateError = nil
|
|
||||||
location.coordinate = CLLocationCoordinate2D(latitude: 30.1, longitude: 120.2)
|
|
||||||
await model.refresh()
|
await model.refresh()
|
||||||
|
XCTAssertEqual(model.admissionMessage, "拍摄次数待确认,请刷新状态")
|
||||||
XCTAssertTrue(model.hasLocation)
|
service.projectResult = .success(try PreparationFixture.project(canCreate: false))
|
||||||
XCTAssertNil(model.locationMessage)
|
await model.refresh()
|
||||||
XCTAssertEqual(service.requests.last?.coordinate, DroneDockPreparationCoordinate(latitude: 30.1, longitude: 120.2))
|
XCTAssertEqual(model.admissionMessage, "当前订单暂不可新增拍摄任务,请刷新状态")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 景区、顶层订单号或嵌套进度订单号不匹配时,不能展示成当前订单的准备数据。
|
/// 账号、景区、门店、凭证变化后,旧购买响应失效。
|
||||||
func testMismatchedScenicAndOrderResponsesAreRejected() async throws {
|
func testIdentityChangesRejectInFlightResponse() async throws {
|
||||||
let invalidResponses = try [
|
for changed in [context(userID: "other"), context(scenicID: 129), context(storeID: 38), context(token: "other-token")] {
|
||||||
envelope(scenicID: 999),
|
|
||||||
envelope(orderNumber: "TEST-OTHER-ORDER"),
|
|
||||||
envelope(progressOrderNumber: "TEST-OTHER-PROGRESS")
|
|
||||||
]
|
|
||||||
for payload in invalidResponses {
|
|
||||||
let scope = PreparationContextBox(context())
|
|
||||||
let session = MockURLSession(responses: [payload])
|
|
||||||
let api = DroneDockPreparationAPI(client: APIClient(environment: .testing, session: session))
|
|
||||||
let model = try makeModel(scope: scope, service: api)
|
|
||||||
|
|
||||||
await model.refresh()
|
|
||||||
|
|
||||||
XCTAssertNil(model.response)
|
|
||||||
XCTAssertNil(model.selectedSpotID)
|
|
||||||
XCTAssertNil(model.selectedRouteID)
|
|
||||||
XCTAssertNotNil(model.errorMessage)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 账号、景区、门店或凭证在等待期间变化,旧请求完成后不得展示旧订单准备数据。
|
|
||||||
func testIdentityChangesRejectInFlightResponses() async throws {
|
|
||||||
let changedContexts = [
|
|
||||||
context(userID: "second-test-user"), context(scenicID: 129),
|
|
||||||
context(storeID: 38), context(token: "second-test-token")
|
|
||||||
]
|
|
||||||
for (index, changedContext) in changedContexts.enumerated() {
|
|
||||||
let scope = PreparationContextBox(context())
|
let scope = PreparationContextBox(context())
|
||||||
let service = SuspendedPreparationService()
|
let service = SuspendedPreparationService()
|
||||||
let started = expectation(description: "准备请求已挂起 \(index)")
|
let started = expectation(description: "购买请求已挂起")
|
||||||
service.requestStarted = { _ in started.fulfill() }
|
service.requestStarted = { _ in started.fulfill() }
|
||||||
defer { service.cancelAll() }
|
defer { service.cancelAll() }
|
||||||
let model = try makeModel(scope: scope, service: service)
|
let model = try makeModel(service: service, scope: scope)
|
||||||
let pending = Task { await model.refresh() }
|
let pending = Task { await model.refresh() }
|
||||||
await fulfillment(of: [started], timeout: 2)
|
await fulfillment(of: [started], timeout: 2)
|
||||||
|
scope.value = changed
|
||||||
scope.value = changedContext
|
try service.finish(index: 0)
|
||||||
service.finish(index: 0, result: .success(try response()))
|
|
||||||
await pending.value
|
await pending.value
|
||||||
|
XCTAssertNil(model.projectInfo)
|
||||||
XCTAssertNil(model.response)
|
|
||||||
XCTAssertNil(model.selectedSpotID)
|
XCTAssertNil(model.selectedSpotID)
|
||||||
XCTAssertNil(model.selectedRouteID)
|
|
||||||
XCTAssertNotNil(model.errorMessage)
|
XCTAssertNotNil(model.errorMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 离页使当前请求失效,迟到的成功响应不能重新填充已清空的页面。
|
/// 页面取消和主动失效后迟到的回包不能重填数据。
|
||||||
func testInvalidationRejectsLateResponse() async throws {
|
func testCancellationAndInvalidationRejectLateResponses() async throws {
|
||||||
let scope = PreparationContextBox(context())
|
for invalidate in [false, true] {
|
||||||
let service = SuspendedPreparationService()
|
let service = SuspendedPreparationService()
|
||||||
let started = expectation(description: "待失效准备请求已挂起")
|
let started = expectation(description: "待取消请求")
|
||||||
service.requestStarted = { _ in started.fulfill() }
|
service.requestStarted = { _ in started.fulfill() }
|
||||||
defer { service.cancelAll() }
|
defer { service.cancelAll() }
|
||||||
let model = try makeModel(scope: scope, service: service)
|
let model = try makeModel(service: service)
|
||||||
let pending = Task { await model.refresh() }
|
let pending = Task { await model.refresh() }
|
||||||
await fulfillment(of: [started], timeout: 2)
|
await fulfillment(of: [started], timeout: 2)
|
||||||
|
if invalidate { model.invalidate() } else { pending.cancel() }
|
||||||
model.invalidate()
|
try service.finish(index: 0)
|
||||||
service.finish(index: 0, result: .success(try response()))
|
await pending.value
|
||||||
await pending.value
|
XCTAssertNil(model.projectInfo)
|
||||||
|
XCTAssertNil(model.selectedSpotID)
|
||||||
XCTAssertNil(model.response)
|
XCTAssertFalse(model.isLoading)
|
||||||
XCTAssertNil(model.selectedSpotID)
|
}
|
||||||
XCTAssertNil(model.selectedRouteID)
|
|
||||||
XCTAssertNil(model.errorMessage)
|
|
||||||
XCTAssertEqual(scope.value, context(), "页面失效不得修改登录或景区选择")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 较早请求最后返回时,不覆盖已经完成的新准备快照。
|
/// 新刷新先完成时,旧购买配置不能覆盖最新选择与次数。
|
||||||
func testOlderRefreshCannotOverwriteNewerSnapshot() async throws {
|
func testOlderRefreshCannotOverwriteNewerPurchasedSnapshot() async throws {
|
||||||
let scope = PreparationContextBox(context())
|
|
||||||
let service = SuspendedPreparationService()
|
let service = SuspendedPreparationService()
|
||||||
let firstStarted = expectation(description: "第一个准备请求已挂起")
|
let firstStarted = expectation(description: "首批请求")
|
||||||
let secondStarted = expectation(description: "第二个准备请求已挂起")
|
let secondStarted = expectation(description: "第二批请求")
|
||||||
service.requestStarted = { index in
|
service.requestStarted = { if $0 == 0 { firstStarted.fulfill() } else { secondStarted.fulfill() } }
|
||||||
if index == 0 { firstStarted.fulfill() }
|
|
||||||
if index == 1 { secondStarted.fulfill() }
|
|
||||||
}
|
|
||||||
defer { service.cancelAll() }
|
defer { service.cancelAll() }
|
||||||
let model = try makeModel(scope: scope, service: service)
|
let model = try makeModel(service: service)
|
||||||
let first = Task { await model.refresh() }
|
let first = Task { await model.refresh() }
|
||||||
await fulfillment(of: [firstStarted], timeout: 2)
|
await fulfillment(of: [firstStarted], timeout: 2)
|
||||||
let second = Task { await model.refresh() }
|
let second = Task { await model.refresh() }
|
||||||
await fulfillment(of: [secondStarted], timeout: 2)
|
await fulfillment(of: [secondStarted], timeout: 2)
|
||||||
|
try service.finish(index: 1, project: PreparationFixture.project(spots: [PreparationFixture.point(202, routes: [401])], remaining: 2))
|
||||||
service.finish(index: 1, result: .success(try response(spots: [spots()[1]])))
|
|
||||||
await second.value
|
await second.value
|
||||||
service.finish(index: 0, result: .success(try response()))
|
try service.finish(index: 0)
|
||||||
await first.value
|
await first.value
|
||||||
|
|
||||||
XCTAssertEqual(model.spots.map(\.id), [202])
|
XCTAssertEqual(model.spots.map(\.id), [202])
|
||||||
XCTAssertEqual(model.selectedSpotID, 202)
|
|
||||||
XCTAssertEqual(model.selectedRouteID, 401)
|
XCTAssertEqual(model.selectedRouteID, 401)
|
||||||
|
XCTAssertEqual(model.projectInfo?.order.shotRemain, 2)
|
||||||
XCTAssertNil(model.errorMessage)
|
XCTAssertNil(model.errorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 身份或订单编号不完整时不发出范围不明的准备请求。
|
/// 缺少项目或会话时本地拦截,不请求当前上架项目代替购买快照。
|
||||||
func testMissingIdentityOrOrderNumberDoesNotCallService() async throws {
|
func testMissingProjectOrSessionDoesNotCallServices() async throws {
|
||||||
for scopeValue in [context(scenicID: 0), context(token: "")] {
|
let service = try ImmediatePreparationService()
|
||||||
let scope = PreparationContextBox(scopeValue)
|
let missingProject = try makeModel(service: service, projectID: nil)
|
||||||
let service = ImmediatePreparationService(result: .success(try response()))
|
await missingProject.refresh()
|
||||||
let model = try makeModel(scope: scope, service: service)
|
XCTAssertNotNil(missingProject.errorMessage)
|
||||||
await model.refresh()
|
let missingSession = try makeModel(service: service, scope: PreparationContextBox(context(token: "")))
|
||||||
XCTAssertTrue(service.requests.isEmpty)
|
await missingSession.refresh()
|
||||||
XCTAssertNil(model.response)
|
XCTAssertNotNil(missingSession.errorMessage)
|
||||||
XCTAssertNotNil(model.errorMessage)
|
XCTAssertTrue(service.projectRequests.isEmpty)
|
||||||
}
|
|
||||||
let scope = PreparationContextBox(context())
|
|
||||||
let service = ImmediatePreparationService(result: .success(try response()))
|
|
||||||
XCTAssertThrowsError(try makeModel(scope: scope, service: service, orderNumber: nil))
|
|
||||||
XCTAssertTrue(service.requests.isEmpty)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 注入只在本例内变化的身份、网络及定位替身。
|
/// 每例使用内存订单和会话,不接触真实账号。
|
||||||
private func makeModel(scope: PreparationContextBox, service: any DroneDockPreparationServing,
|
private func makeModel(service: any DroneDockPreparationServing, scope: PreparationContextBox? = nil,
|
||||||
location: MockLocationProvider = MockLocationProvider(),
|
projectID: Int? = 101) throws -> DroneDockPreparationViewModel {
|
||||||
orderNumber: String? = "TEST-PREPARATION-001") throws -> DroneDockPreparationViewModel {
|
let scope = scope ?? PreparationContextBox(context())
|
||||||
var object: [String: Any] = [
|
var order: [String: Any] = ["order_number": "TEST-PREPARATION-001", "project_name": "旧列表套餐",
|
||||||
"project_id": 101, "user_phone": "130****0001", "project_name": "旧列表套餐",
|
"shoot_count": 9, "shot_count": 2, "remaining_count": 7]
|
||||||
"shoot_count": 5, "shot_count": 2, "remaining_count": 3,
|
order["project_id"] = projectID
|
||||||
"shoot_status": "processing", "order_status": 20, "can_create_task": true
|
let decoded = try JSONDecoder().decode(DroneDockHomeOrder.self, from: JSONSerialization.data(withJSONObject: order))
|
||||||
]
|
return DroneDockPreparationViewModel(context: scope.value, order: decoded, service: service,
|
||||||
object["order_number"] = orderNumber
|
currentContext: { scope.value })
|
||||||
let order = try JSONDecoder().decode(DroneDockHomeOrder.self, from: JSONSerialization.data(withJSONObject: object))
|
|
||||||
return DroneDockPreparationViewModel(context: scope.value, order: order, service: service,
|
|
||||||
locationProvider: location, currentContext: { scope.value })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 使用匿名且独立的会话,避免污染模拟器上的实际账号。
|
/// 身份参数仅在本例测试对象中变化。
|
||||||
private func context(userID: String = "preparation-test-user", scenicID: Int = 128,
|
private func context(userID: String = "preparation-test-user", scenicID: Int = 128, storeID: Int = 37,
|
||||||
storeID: Int = 37, token: String = "preparation-test-token") -> DroneDockHomeContext {
|
token: String = "preparation-test-token") -> DroneDockHomeContext {
|
||||||
DroneDockHomeContext(userID: userID, accountType: "store_user", scenicID: scenicID,
|
DroneDockHomeContext(userID: userID, accountType: "store_user", scenicID: scenicID,
|
||||||
scenicName: "测试景区", storeID: storeID, photographerName: "测试工作人员", token: token)
|
scenicName: "测试景区", storeID: storeID, photographerName: "测试人员", token: token)
|
||||||
}
|
|
||||||
|
|
||||||
/// 构造与实测字段一致的匿名准备响应。
|
|
||||||
private func payload(scenicID: Int = 128, orderNumber: String = "TEST-PREPARATION-001",
|
|
||||||
progressOrderNumber: String? = nil, spots: [[String: Any]]? = nil) -> [String: Any] {
|
|
||||||
[
|
|
||||||
"scenic_id": scenicID, "order_number": orderNumber,
|
|
||||||
"order_progress": ["order_number": progressOrderNumber ?? orderNumber,
|
|
||||||
"package_name": "测试单次套餐", "shot_total": 1, "shot_used": 0,
|
|
||||||
"shot_remain": 1, "status_label": "待拍摄"],
|
|
||||||
"airports": [["id": 51, "name": "测试机巢", "sn_number": "test-preparation-airport",
|
|
||||||
"online_status": 2, "work_status": 0, "work_status_label": "离线", "metrics": []]],
|
|
||||||
"recommend_plane": NSNull(), "spots": spots ?? self.spots(),
|
|
||||||
"shoot_gate": ["can_shoot": false, "code": "dock_offline", "message": "机巢未连接",
|
|
||||||
"primary_action": "blocked", "primary_action_label": "机巢未连接"],
|
|
||||||
"tips": "测试规则提示"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 成功响应的内存模型供可挂起的服务替身返回。
|
|
||||||
private func response(spots: [[String: Any]]? = nil) throws -> DroneDockPreparationResponse {
|
|
||||||
try JSONDecoder().decode(DroneDockPreparationResponse.self,
|
|
||||||
from: JSONSerialization.data(withJSONObject: payload(spots: spots)))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 为真实 APIClient 替身构造响应包裹,验证请求及响应范围校验。
|
|
||||||
private func envelope(scenicID: Int = 128, orderNumber: String = "TEST-PREPARATION-001",
|
|
||||||
progressOrderNumber: String? = nil) throws -> Data {
|
|
||||||
try JSONSerialization.data(withJSONObject: [
|
|
||||||
"code": 100000, "msg": "success",
|
|
||||||
"data": payload(scenicID: scenicID, orderNumber: orderNumber, progressOrderNumber: progressOrderNumber)
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 两个匿名点位各有两条航线,便于验证跨点位选择隔离。
|
|
||||||
private func spots() -> [[String: Any]] {
|
|
||||||
[
|
|
||||||
["scenic_spot_id": 201, "name": "测试点位一", "distance_label": "0 m", "distance_m": 0,
|
|
||||||
"in_range": true, "shot_count": 0, "shot_status_label": "未拍摄", "air_lines": [route(id: 301), route(id: 302)]],
|
|
||||||
["scenic_spot_id": 202, "name": "测试点位二", "distance_label": "100 m", "distance_m": 100,
|
|
||||||
"in_range": false, "shot_count": 0, "shot_status_label": "未拍摄", "air_lines": [route(id: 401), route(id: 402)]]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 提供真实接口字段名的匿名航线。
|
|
||||||
private func route(id: Int) -> [String: Any] {
|
|
||||||
["air_line_id": id, "name": "测试航线 \(id)", "estimated_fly_time": 120,
|
|
||||||
"fly_type": 1, "line_video_duration": 15]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 主线程上的可变会话替身,只影响当前测试模型。
|
/// 购买数据使用不同于首页的名称与额度,以检测旧快照回填。
|
||||||
|
private enum PreparationFixture {
|
||||||
|
/// 购买快照使用五次额度,刻意与首页旧数据不同。
|
||||||
|
static func project(spots: [[String: Any]]? = nil, projectID: Int = 101,
|
||||||
|
number: String = "TEST-PREPARATION-001", remaining: Int? = 5,
|
||||||
|
canCreate: Bool = true) throws -> DroneDockProjectInfoResponse {
|
||||||
|
var value: [String: Any] = ["order_number": number, "project_id": projectID, "project_name": "已购五次套餐",
|
||||||
|
"shoot_count": 5, "shot_count": 0, "can_create_task": canCreate,
|
||||||
|
"spot": spots ?? [point(201), point(202, routes: [401, 402])]]
|
||||||
|
value["remaining_count"] = remaining
|
||||||
|
return try JSONDecoder().decode(DroneDockProjectInfoResponse.self, from: JSONSerialization.data(withJSONObject: value))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 已购点位和航线具备明确可用性。
|
||||||
|
static func point(_ id: Int, routes: [Int] = [301, 302]) -> [String: Any] {
|
||||||
|
["scenic_spot_id": id, "scenic_spot_name": "已购点位 \(id)", "available": true,
|
||||||
|
"air_lines": routes.map { id -> [String: Any] in
|
||||||
|
["air_line_id": id, "air_line_name": "已购航线 \(id)", "available": true, "samples": []]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 主线程上的可变会话替身。
|
||||||
@MainActor
|
@MainActor
|
||||||
private final class PreparationContextBox {
|
private final class PreparationContextBox {
|
||||||
var value: DroneDockHomeContext
|
var value: DroneDockHomeContext
|
||||||
|
|
||||||
/// 保存本例当前会话。
|
|
||||||
init(_ value: DroneDockHomeContext) { self.value = value }
|
init(_ value: DroneDockHomeContext) { self.value = value }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 准备请求参数快照,用于确认定位与订单范围不被替换。
|
/// 单一购买配置读取服务,记录当前请求身份。
|
||||||
private struct PreparationRequestRecord {
|
|
||||||
let scenicID: Int
|
|
||||||
let orderNumber: String
|
|
||||||
let coordinate: DroneDockPreparationCoordinate?
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 返回可替换结果的只读准备服务,不具备创建任务或控制飞行的方法。
|
|
||||||
@MainActor
|
@MainActor
|
||||||
private final class ImmediatePreparationService: DroneDockPreparationServing {
|
private final class ImmediatePreparationService: DroneDockPreparationServing {
|
||||||
var result: Result<DroneDockPreparationResponse, Error>
|
var projectResult: Result<DroneDockProjectInfoResponse, Error>
|
||||||
private(set) var requests: [PreparationRequestRecord] = []
|
private(set) var projectRequests: [(scenicID: Int, projectID: Int, orderNumber: String)] = []
|
||||||
|
|
||||||
/// 注入本例初始响应。
|
/// 使用匿名购买快照作为默认结果。
|
||||||
init(result: Result<DroneDockPreparationResponse, Error>) { self.result = result }
|
init() throws { projectResult = .success(try PreparationFixture.project()) }
|
||||||
|
|
||||||
/// 记录读取参数并返回当前响应。
|
/// 记录唯一的数据读取请求,不提供设备或飞行控制入口。
|
||||||
func workbench(scenicID: Int, orderNumber: String,
|
func projectInfo(scenicID: Int, projectID: Int, orderNumber: String) async throws -> DroneDockProjectInfoResponse {
|
||||||
coordinate: DroneDockPreparationCoordinate?) async throws -> DroneDockPreparationResponse {
|
projectRequests.append((scenicID, projectID, orderNumber))
|
||||||
requests.append(PreparationRequestRecord(scenicID: scenicID, orderNumber: orderNumber, coordinate: coordinate))
|
return try projectResult.get()
|
||||||
return try result.get()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 由测试显式完成的准备请求,用于验证乱序返回与离页后的结果失效。
|
/// 由测试明确完成单个购买请求,精确控制乱序与取消。
|
||||||
@MainActor
|
@MainActor
|
||||||
private final class SuspendedPreparationService: DroneDockPreparationServing {
|
private final class SuspendedPreparationService: DroneDockPreparationServing {
|
||||||
var requestStarted: ((Int) -> Void)?
|
var requestStarted: ((Int) -> Void)?
|
||||||
private var continuations: [CheckedContinuation<DroneDockPreparationResponse, Error>?] = []
|
private var projects: [CheckedContinuation<DroneDockProjectInfoResponse, Error>?] = []
|
||||||
|
|
||||||
/// 挂起当前请求,等待测试模拟后端回包。
|
/// 挂起购买读取,允许测试更改身份或发出后续刷新。
|
||||||
func workbench(scenicID: Int, orderNumber: String,
|
func projectInfo(scenicID: Int, projectID: Int, orderNumber: String) async throws -> DroneDockProjectInfoResponse {
|
||||||
coordinate: DroneDockPreparationCoordinate?) async throws -> DroneDockPreparationResponse {
|
|
||||||
try await withCheckedThrowingContinuation { continuation in
|
try await withCheckedThrowingContinuation { continuation in
|
||||||
let index = continuations.count
|
projects.append(continuation)
|
||||||
continuations.append(continuation)
|
requestStarted?(projects.count - 1)
|
||||||
requestStarted?(index)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 完成指定请求一次,防止 continuation 重复恢复。
|
/// 只完成指定请求,保留其他尚未返回的请求。
|
||||||
func finish(index: Int, result: Result<DroneDockPreparationResponse, Error>) {
|
func finish(index: Int, project: DroneDockProjectInfoResponse? = nil) throws {
|
||||||
guard continuations.indices.contains(index), let continuation = continuations[index] else { return }
|
let value = try project ?? PreparationFixture.project()
|
||||||
continuations[index] = nil
|
let continuation = projects[index]
|
||||||
continuation.resume(with: result)
|
projects[index] = nil
|
||||||
|
continuation?.resume(returning: value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 在测试退出时恢复尚未完成的请求,避免泄漏等待任务。
|
/// 失败退出时释放全部 continuation,避免污染其他测试。
|
||||||
func cancelAll() {
|
func cancelAll() {
|
||||||
for index in continuations.indices { finish(index: index, result: .failure(CancellationError())) }
|
projects.forEach { $0?.resume(throwing: CancellationError()) }
|
||||||
|
projects = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,19 @@ import UIKit
|
|||||||
import XCTest
|
import XCTest
|
||||||
@testable import suixinkan
|
@testable import suixinkan
|
||||||
|
|
||||||
/// 验证真实准备页的字段、点位航线选择及错误状态,全部接口与定位均使用替身。
|
/// 验证准备页仅请求购买快照,以及点位航线选择、刷新和错误状态。
|
||||||
@MainActor
|
@MainActor
|
||||||
final class DroneDockPreparationViewTests: XCTestCase {
|
final class DroneDockPreparationViewTests: XCTestCase {
|
||||||
private weak var previousKeyWindow: UIWindow?
|
private weak var previousKeyWindow: UIWindow?
|
||||||
|
|
||||||
/// 准备页使用后端最新额度和设备原因,召唤按钮不会进入演示或发送飞行请求。
|
/// 页面显示后仅请求项目购买快照,额度和配置来自真实接口字段,召唤仍禁用。
|
||||||
func testServerSnapshotDisplaysOrderPointsRoutesAndOfflineGate() async throws {
|
func testProjectSnapshotDisplaysOrderPointsRoutesAfterPageAppears() async throws {
|
||||||
let (controller, session) = try makeController(responses: [DroneDockPreparationViewFixtures.envelope()])
|
let (controller, session) = try makeController(responses: [DroneDockPreparationViewFixtures.projectEnvelope()])
|
||||||
|
XCTAssertTrue(session.requests.isEmpty, "准备页尚未显示时不预先请求或创建任务")
|
||||||
let window = makeWindow(root: controller)
|
let window = makeWindow(root: controller)
|
||||||
defer { close(window) }
|
defer { close(window) }
|
||||||
let list = try collection(in: controller)
|
let list = try collection(in: controller)
|
||||||
try await settle(window) { controller.viewModel.response != nil && list.numberOfItems(inSection: 2) == 2 }
|
try await settle(window) { controller.viewModel.projectInfo != nil && list.numberOfItems(inSection: 2) == 2 }
|
||||||
|
|
||||||
let texts = visibleTexts(in: controller.view)
|
let texts = visibleTexts(in: controller.view)
|
||||||
XCTAssertEqual(controller.title, "拍摄准备")
|
XCTAssertEqual(controller.title, "拍摄准备")
|
||||||
@@ -23,24 +24,29 @@ final class DroneDockPreparationViewTests: XCTestCase {
|
|||||||
XCTAssertTrue(texts.contains("剩余 1 次"))
|
XCTAssertTrue(texts.contains("剩余 1 次"))
|
||||||
XCTAssertTrue(texts.contains("测试点一"))
|
XCTAssertTrue(texts.contains("测试点一"))
|
||||||
XCTAssertTrue(texts.contains("测试航线甲"))
|
XCTAssertTrue(texts.contains("测试航线甲"))
|
||||||
XCTAssertTrue(texts.contains("机巢未连接"))
|
XCTAssertTrue(texts.contains("距离待确认"))
|
||||||
|
XCTAssertTrue(texts.contains("机巢连接待确认"))
|
||||||
|
XCTAssertTrue(texts.contains("位置待确认"))
|
||||||
|
XCTAssertFalse(texts.contains("机巢未连接"))
|
||||||
|
XCTAssertFalse(texts.contains("在拍摄范围内"))
|
||||||
|
XCTAssertTrue(texts.contains("召唤功能暂未开放"))
|
||||||
XCTAssertEqual(list.numberOfItems(inSection: 1), 2)
|
XCTAssertEqual(list.numberOfItems(inSection: 1), 2)
|
||||||
XCTAssertNil(controller.navigationItem.rightBarButtonItem, "真实准备页不显示演示状态菜单")
|
XCTAssertNil(controller.navigationItem.rightBarButtonItem, "真实准备页不显示演示状态菜单")
|
||||||
let summon = try button(in: controller.view, id: "drone.preparation.summon")
|
let summon = try button(in: controller.view, id: "drone.preparation.summon")
|
||||||
XCTAssertFalse(summon.isEnabled)
|
XCTAssertFalse(summon.isEnabled)
|
||||||
XCTAssertEqual(summon.title(for: .normal), "机巢未连接")
|
XCTAssertEqual(summon.title(for: .normal), "确认并召唤")
|
||||||
summon.sendActions(for: .touchUpInside)
|
summon.sendActions(for: .touchUpInside)
|
||||||
XCTAssertEqual(controller.navigationController?.viewControllers.count, 1)
|
XCTAssertEqual(controller.navigationController?.viewControllers.count, 1)
|
||||||
XCTAssertNil(controller.presentedViewController)
|
XCTAssertNil(controller.presentedViewController)
|
||||||
XCTAssertEqual(session.requests.count, 1)
|
XCTAssertEqual(session.requests.count, 1)
|
||||||
assertOnlyWorkbenchReads(session)
|
assertOnlyPreparationReads(session)
|
||||||
assertUnambiguousLayout(in: controller.view)
|
assertUnambiguousLayout(in: controller.view)
|
||||||
capture(window, name: "真实准备页-订单点位航线与离线提示")
|
capture(window, name: "真实准备页-购买快照与点位航线")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 点击点位切换航线和标题,选择航线只更新本地状态且不沿用其他点位的航线。
|
/// 点击点位切换航线和标题,选择航线只更新本地状态且不沿用其他点位的航线。
|
||||||
func testSelectingPointReplacesRoutesAndKeepsSingleSelection() async throws {
|
func testSelectingPointReplacesRoutesAndKeepsSingleSelection() async throws {
|
||||||
let (controller, session) = try makeController(responses: [DroneDockPreparationViewFixtures.envelope()])
|
let (controller, session) = try makeController(responses: [DroneDockPreparationViewFixtures.projectEnvelope()])
|
||||||
let window = makeWindow(root: controller)
|
let window = makeWindow(root: controller)
|
||||||
defer { close(window) }
|
defer { close(window) }
|
||||||
let list = try collection(in: controller)
|
let list = try collection(in: controller)
|
||||||
@@ -65,45 +71,22 @@ final class DroneDockPreparationViewTests: XCTestCase {
|
|||||||
XCTAssertFalse(visibleTexts(in: route).contains("测试航线乙"))
|
XCTAssertFalse(visibleTexts(in: route).contains("测试航线乙"))
|
||||||
XCTAssertTrue(visibleTexts(in: controller.view).contains("测试点二 · 测试航线丙"))
|
XCTAssertTrue(visibleTexts(in: controller.view).contains("测试点二 · 测试航线丙"))
|
||||||
XCTAssertEqual(session.requests.count, 1)
|
XCTAssertEqual(session.requests.count, 1)
|
||||||
assertOnlyWorkbenchReads(session)
|
assertOnlyPreparationReads(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 定位失败仍可看点位航线,但不显示无坐标响应中的距离或在范围内结论。
|
/// 项目接口失败会移除旧购买配置,不把加载失败当作空套餐或沿用旧额度。
|
||||||
func testLocationFailureHidesUntrustedDistanceAndRange() async throws {
|
|
||||||
let location = MockLocationProvider()
|
|
||||||
location.requestCoordinateError = LocationProviderError.permissionDenied
|
|
||||||
let (controller, session) = try makeController(responses: [DroneDockPreparationViewFixtures.envelope(canShoot: true)], location: location)
|
|
||||||
let window = makeWindow(root: controller)
|
|
||||||
defer { close(window) }
|
|
||||||
let list = try collection(in: controller)
|
|
||||||
try await settle(window) { controller.viewModel.response != nil && list.numberOfItems(inSection: 1) == 2 }
|
|
||||||
|
|
||||||
let texts = visibleTexts(in: controller.view)
|
|
||||||
XCTAssertTrue(texts.contains("待定位"))
|
|
||||||
XCTAssertTrue(texts.contains("位置待确认"))
|
|
||||||
XCTAssertFalse(texts.contains("12 m"))
|
|
||||||
XCTAssertFalse(texts.contains("24 m"))
|
|
||||||
XCTAssertFalse(texts.contains("在拍摄范围内"))
|
|
||||||
XCTAssertFalse(try button(in: controller.view, id: "drone.preparation.summon").isEnabled)
|
|
||||||
let request = try XCTUnwrap(session.requests.first)
|
|
||||||
let query = URLComponents(url: try XCTUnwrap(request.url), resolvingAgainstBaseURL: false)?.queryItems ?? []
|
|
||||||
XCTAssertFalse(query.contains { $0.name == "lat" || $0.name == "lng" })
|
|
||||||
assertOnlyWorkbenchReads(session)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 请求失败会移除旧点位航线,刷新成功后才重新显示,不将错误当作成功空态。
|
|
||||||
func testRefreshFailureClearsOldOptionsAndRetryRestoresThem() async throws {
|
func testRefreshFailureClearsOldOptionsAndRetryRestoresThem() async throws {
|
||||||
let payload = try DroneDockPreparationViewFixtures.envelope()
|
let project = try DroneDockPreparationViewFixtures.projectEnvelope()
|
||||||
let failure = try TestJSON.errorEnvelope(code: 160001, msg: "测试准备信息暂不可用")
|
let failure = try TestJSON.errorEnvelope(code: 160001, msg: "测试准备信息暂不可用")
|
||||||
let (controller, session) = try makeController(responses: [payload, failure, payload])
|
let (controller, session) = try makeController(responses: [project, failure, project])
|
||||||
let window = makeWindow(root: controller)
|
let window = makeWindow(root: controller)
|
||||||
defer { close(window) }
|
defer { close(window) }
|
||||||
let list = try collection(in: controller)
|
let list = try collection(in: controller)
|
||||||
try await settle(window) { controller.viewModel.response != nil && list.numberOfItems(inSection: 1) == 2 }
|
try await settle(window) { controller.viewModel.projectInfo != nil && list.numberOfItems(inSection: 1) == 2 }
|
||||||
|
|
||||||
try button(in: controller.view, id: "drone.preparation.refreshSummon").sendActions(for: .touchUpInside)
|
try button(in: controller.view, id: "drone.preparation.refreshSummon").sendActions(for: .touchUpInside)
|
||||||
try await settle(window) { self.visibleTexts(in: controller.view).contains("准备信息加载失败") }
|
try await settle(window) { self.visibleTexts(in: controller.view).contains("准备信息加载失败") }
|
||||||
XCTAssertNil(controller.viewModel.response)
|
XCTAssertNil(controller.viewModel.projectInfo)
|
||||||
XCTAssertEqual(list.numberOfItems(inSection: 1), 0)
|
XCTAssertEqual(list.numberOfItems(inSection: 1), 0)
|
||||||
XCTAssertEqual(list.numberOfItems(inSection: 2), 0)
|
XCTAssertEqual(list.numberOfItems(inSection: 2), 0)
|
||||||
XCTAssertFalse(visibleTexts(in: controller.view).contains("暂无可用拍摄点"))
|
XCTAssertFalse(visibleTexts(in: controller.view).contains("暂无可用拍摄点"))
|
||||||
@@ -115,20 +98,20 @@ final class DroneDockPreparationViewTests: XCTestCase {
|
|||||||
XCTAssertFalse(visibleTexts(in: failedSummary).contains("剩余 1 次"))
|
XCTAssertFalse(visibleTexts(in: failedSummary).contains("剩余 1 次"))
|
||||||
|
|
||||||
try button(in: controller.view, id: "drone.preparation.refreshSummon").sendActions(for: .touchUpInside)
|
try button(in: controller.view, id: "drone.preparation.refreshSummon").sendActions(for: .touchUpInside)
|
||||||
try await settle(window) { controller.viewModel.response != nil && list.numberOfItems(inSection: 1) == 2 }
|
try await settle(window) { controller.viewModel.projectInfo != nil && list.numberOfItems(inSection: 1) == 2 }
|
||||||
XCTAssertNil(controller.viewModel.errorMessage)
|
XCTAssertNil(controller.viewModel.errorMessage)
|
||||||
XCTAssertFalse(visibleTexts(in: controller.view).contains("准备信息加载失败"))
|
XCTAssertFalse(visibleTexts(in: controller.view).contains("准备信息加载失败"))
|
||||||
XCTAssertEqual(session.requests.count, 3)
|
XCTAssertEqual(session.requests.count, 3)
|
||||||
assertOnlyWorkbenchReads(session)
|
assertOnlyPreparationReads(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 没有点位和已选点位没有航线使用不同空态,空态刷新不残留旧选择。
|
/// 购买快照没有点位和已选点位没有航线使用不同空态,刷新不残留旧配置。
|
||||||
func testEmptyPointsAndEmptyRoutesHaveDistinctMessages() async throws {
|
func testEmptyPointsAndEmptyRoutesHaveDistinctMessages() async throws {
|
||||||
var pointWithoutRoutes = DroneDockPreparationViewFixtures.spots()[0]
|
var pointWithoutRoutes = DroneDockPreparationViewFixtures.purchasedSpots()[0]
|
||||||
pointWithoutRoutes["air_lines"] = []
|
pointWithoutRoutes["air_lines"] = []
|
||||||
let (controller, session) = try makeController(responses: [
|
let (controller, session) = try makeController(responses: [
|
||||||
DroneDockPreparationViewFixtures.envelope(spots: []),
|
DroneDockPreparationViewFixtures.projectEnvelope(spots: []),
|
||||||
DroneDockPreparationViewFixtures.envelope(spots: [pointWithoutRoutes])
|
DroneDockPreparationViewFixtures.projectEnvelope(spots: [pointWithoutRoutes])
|
||||||
])
|
])
|
||||||
let window = makeWindow(root: controller)
|
let window = makeWindow(root: controller)
|
||||||
defer { close(window) }
|
defer { close(window) }
|
||||||
@@ -145,37 +128,83 @@ final class DroneDockPreparationViewTests: XCTestCase {
|
|||||||
XCTAssertFalse(visibleTexts(in: controller.view).contains("暂无可用拍摄点"))
|
XCTAssertFalse(visibleTexts(in: controller.view).contains("暂无可用拍摄点"))
|
||||||
XCTAssertFalse(try button(in: controller.view, id: "drone.preparation.summon").isEnabled)
|
XCTAssertFalse(try button(in: controller.view, id: "drone.preparation.summon").isEnabled)
|
||||||
XCTAssertEqual(session.requests.count, 2)
|
XCTAssertEqual(session.requests.count, 2)
|
||||||
assertOnlyWorkbenchReads(session)
|
assertOnlyPreparationReads(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 进度对象缺失、为 null 或缺少次数时均显示未知,不用首页旧次数填充最新额度。
|
/// 项目摘要缺少或返回 null 次数时显示未知,不用首页旧次数填充。
|
||||||
func testMissingProgressCountsDoNotReuseHomeCounts() async throws {
|
func testMissingProjectCountsDoNotReuseHomeCounts() async throws {
|
||||||
let incomplete = try DroneDockPreparationViewFixtures.envelope(progress: ["package_name": "待核对套餐"])
|
for counts in [[:], ["shoot_count": NSNull(), "shot_count": NSNull(), "remaining_count": NSNull()]] as [[String: Any]] {
|
||||||
var envelope = try XCTUnwrap(JSONSerialization.jsonObject(with: incomplete) as? [String: Any])
|
let project = try DroneDockPreparationViewFixtures.projectEnvelope(summary: counts.merging(["project_name": "待核对套餐"]) { _, new in new })
|
||||||
var data = try XCTUnwrap(envelope["data"] as? [String: Any])
|
let (controller, session) = try makeController(responses: [project])
|
||||||
data["order_progress"] = NSNull()
|
|
||||||
envelope["data"] = data
|
|
||||||
let nullProgress = try JSONSerialization.data(withJSONObject: envelope)
|
|
||||||
data.removeValue(forKey: "order_progress")
|
|
||||||
envelope["data"] = data
|
|
||||||
let missingProgress = try JSONSerialization.data(withJSONObject: envelope)
|
|
||||||
|
|
||||||
for payload in [incomplete, nullProgress, missingProgress] {
|
|
||||||
let (controller, session) = try makeController(responses: [payload])
|
|
||||||
let window = makeWindow(root: controller)
|
let window = makeWindow(root: controller)
|
||||||
defer { close(window) }
|
defer { close(window) }
|
||||||
try await settle(window) { controller.viewModel.response != nil && self.visibleTexts(in: controller.view).contains("已拍摄 — 次") }
|
try await settle(window) { controller.viewModel.projectInfo != nil && self.visibleTexts(in: controller.view).contains("已拍摄 — 次") }
|
||||||
let summary = try XCTUnwrap(find(in: controller.view, id: "drone.preparation.order"))
|
let summary = try XCTUnwrap(find(in: controller.view, id: "drone.preparation.order"))
|
||||||
XCTAssertTrue(visibleTexts(in: summary).contains("剩余 — 次"))
|
XCTAssertTrue(visibleTexts(in: summary).contains("剩余 — 次"))
|
||||||
XCTAssertFalse(visibleTexts(in: summary).contains("已拍摄 0 次"))
|
XCTAssertFalse(visibleTexts(in: summary).contains("已拍摄 0 次"))
|
||||||
XCTAssertFalse(visibleTexts(in: summary).contains("剩余 1 次"))
|
XCTAssertFalse(visibleTexts(in: summary).contains("剩余 1 次"))
|
||||||
assertOnlyWorkbenchReads(session)
|
assertOnlyPreparationReads(session)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 已购名称、航线和次数只来自 project-info,首页摘要不能覆盖最新购买快照。
|
||||||
|
func testProjectInfoOwnsNamesRoutesAndQuota() async throws {
|
||||||
|
var point = DroneDockPreparationViewFixtures.purchasedSpots()[0]
|
||||||
|
point["scenic_spot_name"] = "已购测试点"
|
||||||
|
point["air_lines"] = [["air_line_id": 202, "air_line_name": "已购唯一航线", "available": true, "samples": []]]
|
||||||
|
let project = try DroneDockPreparationViewFixtures.projectEnvelope(spots: [point], summary: [
|
||||||
|
"project_name": "已购三次套餐", "shoot_count": 3, "shot_count": 1, "remaining_count": 2,
|
||||||
|
"user_phone": "130****0002", "can_create_task": true
|
||||||
|
])
|
||||||
|
let (controller, session) = try makeController(responses: [project])
|
||||||
|
let window = makeWindow(root: controller)
|
||||||
|
defer { close(window) }
|
||||||
|
let list = try collection(in: controller)
|
||||||
|
try await settle(window) { controller.viewModel.projectInfo != nil && !controller.viewModel.isLoading }
|
||||||
|
XCTAssertEqual(list.numberOfItems(inSection: 1), 1)
|
||||||
|
XCTAssertEqual(list.numberOfItems(inSection: 2), 1)
|
||||||
|
XCTAssertEqual(controller.viewModel.selectedRouteID, 202)
|
||||||
|
let texts = visibleTexts(in: controller.view)
|
||||||
|
XCTAssertTrue(texts.contains("已购三次套餐"))
|
||||||
|
XCTAssertTrue(texts.contains("已拍摄 1 次"))
|
||||||
|
XCTAssertTrue(texts.contains("剩余 2 次"))
|
||||||
|
XCTAssertTrue(texts.contains("已购测试点"))
|
||||||
|
XCTAssertTrue(texts.contains("已购唯一航线"))
|
||||||
|
XCTAssertFalse(texts.contains("测试套餐 · 含 1 次拍摄"))
|
||||||
|
XCTAssertFalse(texts.contains("测试点二"))
|
||||||
|
XCTAssertFalse(texts.contains("测试航线甲"))
|
||||||
|
assertOnlyPreparationReads(session)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 不可用点位和航线仍可查看原因,但不得被选择或恢复为默认选中项。
|
||||||
|
func testUnavailablePurchasedOptionsCannotBeSelected() async throws {
|
||||||
|
var points = DroneDockPreparationViewFixtures.purchasedSpots()
|
||||||
|
var routes = try XCTUnwrap(points[0]["air_lines"] as? [[String: Any]])
|
||||||
|
routes[0]["available"] = false
|
||||||
|
routes[0]["unavailable_reason"] = "航线暂停使用"
|
||||||
|
points[0]["air_lines"] = routes
|
||||||
|
points[1]["available"] = false
|
||||||
|
let project = try DroneDockPreparationViewFixtures.projectEnvelope(spots: points)
|
||||||
|
let (controller, session) = try makeController(responses: [project])
|
||||||
|
let window = makeWindow(root: controller)
|
||||||
|
defer { close(window) }
|
||||||
|
let list = try collection(in: controller)
|
||||||
|
try await settle(window) { controller.viewModel.selectedRouteID == 202 && !controller.viewModel.isLoading }
|
||||||
|
XCTAssertEqual(controller.viewModel.selectedSpotID, 101)
|
||||||
|
XCTAssertFalse(list.delegate?.collectionView?(list, shouldSelectItemAt: IndexPath(item: 0, section: 2)) ?? true)
|
||||||
|
XCTAssertFalse(list.delegate?.collectionView?(list, shouldSelectItemAt: IndexPath(item: 1, section: 1)) ?? true)
|
||||||
|
list.delegate?.collectionView?(list, didSelectItemAt: IndexPath(item: 0, section: 2))
|
||||||
|
list.delegate?.collectionView?(list, didSelectItemAt: IndexPath(item: 1, section: 1))
|
||||||
|
XCTAssertEqual(controller.viewModel.selectedRouteID, 202)
|
||||||
|
XCTAssertEqual(controller.viewModel.selectedSpotID, 101)
|
||||||
|
XCTAssertTrue(visibleTexts(in: controller.view).contains { $0.contains("航线暂停使用") })
|
||||||
|
XCTAssertFalse(try button(in: controller.view, id: "drone.preparation.summon").isEnabled)
|
||||||
|
assertOnlyPreparationReads(session)
|
||||||
|
}
|
||||||
|
|
||||||
/// 创建固定身份和只使用匿名替身的准备页。
|
/// 创建固定身份和只使用匿名替身的准备页。
|
||||||
private func makeController(responses: [Data], location: MockLocationProvider = MockLocationProvider()) throws -> (DroneDockRemotePreparationViewController, MockURLSession) {
|
private func makeController(responses: [Data]) throws -> (DroneDockRemotePreparationViewController, MockURLSession) {
|
||||||
try DroneDockPreparationViewFixtures.controller(context: DroneDockPreparationViewFixtures.context(), order: DroneDockPreparationViewFixtures.order(), responses: responses, location: location)
|
try DroneDockPreparationViewFixtures.controller(context: DroneDockPreparationViewFixtures.context(), order: DroneDockPreparationViewFixtures.order(), responses: responses)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func collection(in controller: UIViewController) throws -> UICollectionView {
|
private func collection(in controller: UIViewController) throws -> UICollectionView {
|
||||||
@@ -240,9 +269,19 @@ final class DroneDockPreparationViewTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func assertOnlyWorkbenchReads(_ session: MockURLSession, file: StaticString = #filePath, line: UInt = #line) {
|
/// 所有准备页网络请求只能是 project-info GET,且携带本次订单与项目身份。
|
||||||
|
private func assertOnlyPreparationReads(_ session: MockURLSession, file: StaticString = #filePath, line: UInt = #line) {
|
||||||
XCTAssertFalse(session.requests.isEmpty, file: file, line: line)
|
XCTAssertFalse(session.requests.isEmpty, file: file, line: line)
|
||||||
XCTAssertTrue(session.requests.allSatisfy { $0.httpMethod == "GET" && $0.url?.path == "/api/app/airport/workbench" && $0.httpBody == nil }, file: file, line: line)
|
XCTAssertTrue(session.requests.allSatisfy { $0.httpMethod == "GET" && $0.url?.path == "/api/yf-handset-app/photog/multi-plane/project-info" && $0.httpBody == nil }, file: file, line: line)
|
||||||
|
for request in session.requests {
|
||||||
|
let items = URLComponents(url: request.url!, resolvingAgainstBaseURL: false)?.queryItems ?? []
|
||||||
|
let query = Dictionary(uniqueKeysWithValues: items.map { ($0.name, $0.value ?? "") })
|
||||||
|
XCTAssertEqual(query["scenic_id"], "128", file: file, line: line)
|
||||||
|
XCTAssertEqual(query["project_id"], "101", file: file, line: line)
|
||||||
|
XCTAssertEqual(query["order_number"], "TEST-PREPARATION-001", file: file, line: line)
|
||||||
|
XCTAssertNil(query["lat"], file: file, line: line)
|
||||||
|
XCTAssertNil(query["lng"], file: file, line: line)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func assertUnambiguousLayout(in root: UIView, file: StaticString = #filePath, line: UInt = #line) {
|
private func assertUnambiguousLayout(in root: UIView, file: StaticString = #filePath, line: UInt = #line) {
|
||||||
@@ -273,40 +312,42 @@ enum DroneDockPreparationViewFixtures {
|
|||||||
try JSONDecoder().decode(DroneDockHomeOrder.self, from: Data(#"{"order_number":"TEST-PREPARATION-001","project_id":101,"user_phone":"130****0001","project_name":"测试套餐 · 含 1 次拍摄","shoot_count":1,"shot_count":0,"remaining_count":1,"shoot_status":"pending","order_status":20,"can_create_task":true,"can_upload_film":false,"can_confirm":false}"#.utf8))
|
try JSONDecoder().decode(DroneDockHomeOrder.self, from: Data(#"{"order_number":"TEST-PREPARATION-001","project_id":101,"user_phone":"130****0001","project_name":"测试套餐 · 含 1 次拍摄","shoot_count":1,"shot_count":0,"remaining_count":1,"shoot_status":"pending","order_status":20,"can_create_task":true,"can_upload_film":false,"can_confirm":false}"#.utf8))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 每个点位含自身航线,用于验证切换后不沿用原航线。
|
/// 张工购买快照中的点位和航线,供选择及未知配置测试使用。
|
||||||
static func spots() -> [[String: Any]] {
|
static func purchasedSpots() -> [[String: Any]] {
|
||||||
[
|
[
|
||||||
["scenic_spot_id": 101, "name": "测试点一", "distance_label": "12 m", "distance_m": 12, "in_range": true,
|
["scenic_spot_id": 101, "scenic_spot_name": "测试点一", "available": true, "cover_url": "", "samples": [],
|
||||||
"shot_count": 0, "shot_status_label": "未拍摄", "air_lines": [["air_line_id": 201, "name": "测试航线甲"], ["air_line_id": 202, "name": "测试航线乙"]]],
|
"air_lines": [
|
||||||
["scenic_spot_id": 102, "name": "测试点二", "distance_label": "24 m", "distance_m": 24, "in_range": false,
|
["air_line_id": 201, "air_line_name": "测试航线甲", "available": true, "unavailable_reason": "", "samples": []],
|
||||||
"shot_count": 0, "shot_status_label": "未拍摄", "air_lines": [["air_line_id": 301, "name": "测试航线丙"]]]
|
["air_line_id": 202, "air_line_name": "测试航线乙", "available": true, "unavailable_reason": "", "samples": []]
|
||||||
|
]],
|
||||||
|
["scenic_spot_id": 102, "scenic_spot_name": "测试点二", "available": true, "cover_url": "", "samples": [],
|
||||||
|
"air_lines": [["air_line_id": 301, "air_line_name": "测试航线丙", "available": true, "unavailable_reason": "", "samples": []]]]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 按实际结构生成匿名响应,可替换点位、门禁和进度以覆盖状态变化。
|
/// 根级订单摘要与购买点位;可独立覆盖摘要以验证未知字段不会被设备数据填充。
|
||||||
static func envelope(orderNumber: String = "TEST-PREPARATION-001", scenicID: Int = 128,
|
static func projectEnvelope(orderNumber: String = "TEST-PREPARATION-001", projectID: Int = 101,
|
||||||
spots: [[String: Any]]? = nil, canShoot: Bool = false,
|
spots: [[String: Any]]? = nil, summary: [String: Any]? = nil) throws -> Data {
|
||||||
progress: [String: Any]? = nil) throws -> Data {
|
var data = summary ?? [
|
||||||
let data: [String: Any] = [
|
"project_name": "测试套餐 · 含 1 次拍摄", "user_phone": "130****0001",
|
||||||
"scenic_id": scenicID, "order_number": orderNumber,
|
"shoot_count": 1, "shot_count": 0, "remaining_count": 1, "shoot_status": "pending",
|
||||||
"order_progress": progress ?? ["order_number": orderNumber, "package_name": "测试套餐 · 含 1 次拍摄", "shot_total": 1, "shot_used": 0, "shot_remain": 1],
|
"order_status": 20, "can_create_task": true, "can_upload_film": false, "can_confirm": false
|
||||||
"airports": [["id": 1, "name": "测试机巢", "online_status": 2, "work_status": 0, "work_status_label": "离线", "metrics": []]],
|
|
||||||
"spots": spots ?? Self.spots(),
|
|
||||||
"shoot_gate": ["can_shoot": canShoot, "code": canShoot ? "ok" : "dock_offline", "message": canShoot ? "" : "机巢未连接", "primary_action": canShoot ? "shoot" : "blocked", "primary_action_label": canShoot ? "确认并召唤" : "机巢未连接"]
|
|
||||||
]
|
]
|
||||||
|
data["order_number"] = orderNumber
|
||||||
|
data["project_id"] = projectID
|
||||||
|
data["spot"] = spots ?? purchasedSpots()
|
||||||
return try JSONSerialization.data(withJSONObject: ["code": 100000, "msg": "success", "data": data])
|
return try JSONSerialization.data(withJSONObject: ["code": 100000, "msg": "success", "data": data])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 创建使用真实请求构造和替身传输的页面,便于验证导航参数与请求范围。
|
/// 创建只请求项目购买快照的准备页,替身记录所有请求以发现额外接口调用。
|
||||||
static func controller(context: DroneDockHomeContext, order: DroneDockHomeOrder,
|
static func controller(context: DroneDockHomeContext, order: DroneDockHomeOrder,
|
||||||
responses: [Data]? = nil, location: MockLocationProvider = MockLocationProvider()) throws -> (DroneDockRemotePreparationViewController, MockURLSession) {
|
responses: [Data]? = nil) throws -> (DroneDockRemotePreparationViewController, MockURLSession) {
|
||||||
let payloads = try responses ?? [envelope(orderNumber: order.orderNumber ?? "", scenicID: context.scenicID)]
|
let payloads = try responses ?? [projectEnvelope(orderNumber: order.orderNumber ?? "", projectID: order.projectID ?? 101)]
|
||||||
let session = MockURLSession(responses: payloads)
|
let session = MockURLSession(responses: payloads)
|
||||||
let client = APIClient(environment: .testing, session: session, notificationCenter: NotificationCenter())
|
let client = APIClient(environment: .testing, session: session, notificationCenter: NotificationCenter())
|
||||||
client.bindAuthTokenProvider { "preparation-test-token" }
|
client.bindAuthTokenProvider { "preparation-test-token" }
|
||||||
let model = DroneDockPreparationViewModel(context: context, order: order,
|
let model = DroneDockPreparationViewModel(context: context, order: order,
|
||||||
service: DroneDockPreparationAPI(client: client), locationProvider: location,
|
service: DroneDockPreparationAPI(client: client), currentContext: { context })
|
||||||
currentContext: { context })
|
|
||||||
return (DroneDockRemotePreparationViewController(viewModel: model), session)
|
return (DroneDockRemotePreparationViewController(viewModel: model), session)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,242 @@
|
|||||||
|
import Foundation
|
||||||
|
import XCTest
|
||||||
|
@testable import suixinkan
|
||||||
|
|
||||||
|
/// 使用匿名购买快照验证张工 project-info 的请求、身份隔离及可选配置。
|
||||||
|
@MainActor
|
||||||
|
final class DroneDockProjectInfoAPITests: XCTestCase {
|
||||||
|
/// 准备页始终携带订单号,读取购买快照并复用统一登录凭证。
|
||||||
|
func testProjectInfoRequestsPurchasedSnapshotAndReadsSummaryAndRoutes() async throws {
|
||||||
|
let session = MockURLSession(responses: [try envelope(Self.payload)])
|
||||||
|
let client = APIClient(environment: .testing, session: session)
|
||||||
|
client.bindAuthTokenProvider { "project-info-test-token" }
|
||||||
|
|
||||||
|
let value = try await DroneDockPreparationAPI(client: client)
|
||||||
|
.projectInfo(scenicID: 128, projectID: 101, orderNumber: "TEST-PROJECT-001")
|
||||||
|
|
||||||
|
XCTAssertEqual(session.requests.count, 1)
|
||||||
|
let request = try XCTUnwrap(session.requests.first)
|
||||||
|
XCTAssertEqual(request.httpMethod, "GET")
|
||||||
|
XCTAssertEqual(request.url?.host, "api-test.zhifly.cn")
|
||||||
|
XCTAssertEqual(request.url?.path, "/api/yf-handset-app/photog/multi-plane/project-info")
|
||||||
|
let items = try XCTUnwrap(URLComponents(url: XCTUnwrap(request.url), resolvingAgainstBaseURL: false)?.queryItems)
|
||||||
|
XCTAssertEqual(Dictionary(uniqueKeysWithValues: items.map { ($0.name, $0.value ?? "") }),
|
||||||
|
["scenic_id": "128", "project_id": "101", "order_number": "TEST-PROJECT-001"])
|
||||||
|
XCTAssertEqual(request.value(forHTTPHeaderField: "token"), "project-info-test-token")
|
||||||
|
XCTAssertNil(request.httpBody)
|
||||||
|
XCTAssertEqual(value.order.orderID, "TEST-PROJECT-001")
|
||||||
|
XCTAssertEqual(value.order.projectID, 101)
|
||||||
|
XCTAssertEqual(value.order.packageTitle, "已购测试套餐")
|
||||||
|
XCTAssertEqual(value.order.shotTotal, 5)
|
||||||
|
XCTAssertEqual(value.order.shotUsed, 1)
|
||||||
|
XCTAssertEqual(value.order.shotRemain, 4)
|
||||||
|
XCTAssertEqual(value.order.canCreateTask, true)
|
||||||
|
let spot = try XCTUnwrap(value.spots.first)
|
||||||
|
XCTAssertEqual(spot.id, 201)
|
||||||
|
XCTAssertEqual(spot.name, "已购测试点")
|
||||||
|
XCTAssertEqual(spot.available, true)
|
||||||
|
XCTAssertEqual(spot.coverURL, "https://example.com/spot.jpg")
|
||||||
|
let route = try XCTUnwrap(spot.airLines.first)
|
||||||
|
XCTAssertEqual(route.id, 301)
|
||||||
|
XCTAssertEqual(route.name, "已购测试航线")
|
||||||
|
XCTAssertEqual(route.available, true)
|
||||||
|
XCTAssertEqual(route.samples.first?.id, 401)
|
||||||
|
XCTAssertEqual(route.samples.first?.name, "测试样片")
|
||||||
|
XCTAssertEqual(route.samples.first?.coverURL, "https://example.com/sample.jpg")
|
||||||
|
XCTAssertEqual(route.samples.first?.previewURL, "https://example.com/sample.mp4")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 缺少景区、项目或完整订单号时不得退化成浏览上架项目的请求。
|
||||||
|
func testInvalidRequestScopeDoesNotSendNetworkRequests() async {
|
||||||
|
let session = MockURLSession(responses: [])
|
||||||
|
let api = DroneDockPreparationAPI(client: APIClient(environment: .testing, session: session))
|
||||||
|
for (scenic, project, number) in [
|
||||||
|
(0, 101, "TEST-PROJECT-001"), (128, 0, "TEST-PROJECT-001"),
|
||||||
|
(128, -1, "TEST-PROJECT-001"), (128, 101, ""), (128, 101, " \n"),
|
||||||
|
(128, 101, " TEST-PROJECT-001"), (128, 101, String(repeating: "T", count: 129))
|
||||||
|
] {
|
||||||
|
do {
|
||||||
|
_ = try await api.projectInfo(scenicID: scenic, projectID: project, orderNumber: number)
|
||||||
|
XCTFail("无效购买范围必须在请求前拒绝")
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
XCTAssertTrue(session.requests.isEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 返回其他订单或项目时拒绝使用其购买范围,项目缺失也不能用请求值回填。
|
||||||
|
func testMismatchedOrMissingPurchaseIdentityIsRejected() async throws {
|
||||||
|
for (key, value) in [("order_number", "ANOTHER-ORDER" as Any), ("project_id", 102 as Any),
|
||||||
|
("project_id", NSNull() as Any)] {
|
||||||
|
var payload = Self.payload
|
||||||
|
payload[key] = value
|
||||||
|
let session = MockURLSession(responses: [try envelope(payload)])
|
||||||
|
do {
|
||||||
|
_ = try await DroneDockPreparationAPI(client: APIClient(environment: .testing, session: session))
|
||||||
|
.projectInfo(scenicID: 128, projectID: 101, orderNumber: "TEST-PROJECT-001")
|
||||||
|
XCTFail("错配或缺失的购买身份必须拒绝")
|
||||||
|
} catch {}
|
||||||
|
XCTAssertEqual(session.requests.count, 1)
|
||||||
|
}
|
||||||
|
var missingProject = Self.payload
|
||||||
|
missingProject.removeValue(forKey: "project_id")
|
||||||
|
XCTAssertThrowsError(try decode(missingProject))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 后端拒绝购买范围时保留业务错误,不能转换成成功空列表。
|
||||||
|
func testBackendFailurePreservesBusinessMessage() async throws {
|
||||||
|
let session = MockURLSession(responses: [try TestJSON.errorEnvelope(code: 160001, msg: "该订单不属于当前项目")])
|
||||||
|
do {
|
||||||
|
_ = try await DroneDockPreparationAPI(client: APIClient(environment: .testing, session: session))
|
||||||
|
.projectInfo(scenicID: 128, projectID: 101, orderNumber: "TEST-PROJECT-001")
|
||||||
|
XCTFail("应保留后端业务拒绝")
|
||||||
|
} catch let APIError.serverCode(code, message) {
|
||||||
|
XCTAssertEqual(code, 160001)
|
||||||
|
XCTAssertEqual(message, "该订单不属于当前项目")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 明确空点位和空航线是可展示空态,不扩充来自其他接口的配置。
|
||||||
|
func testExplicitEmptyPurchasedListsArePreserved() throws {
|
||||||
|
var payload = Self.payload
|
||||||
|
payload["spot"] = [] as [Any]
|
||||||
|
XCTAssertTrue(try decode(payload).spots.isEmpty)
|
||||||
|
payload["spot"] = [["scenic_spot_id": 201, "scenic_spot_name": "测试点", "air_lines": []]]
|
||||||
|
XCTAssertTrue(try decode(payload).spots[0].airLines.isEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 错误结构和旧 workbench 名称不能冒充张工的购买快照。
|
||||||
|
func testMissingAndMalformedRequiredConfigurationIsRejected() throws {
|
||||||
|
var missingSpots = Self.payload
|
||||||
|
missingSpots.removeValue(forKey: "spot")
|
||||||
|
XCTAssertThrowsError(try decode(missingSpots))
|
||||||
|
for value: Any in [NSNull(), [:] as [String: Any],
|
||||||
|
[["scenic_spot_id": 201, "scenic_spot_name": "测试点"]],
|
||||||
|
[["scenic_spot_id": 201, "name": "旧接口点位", "air_lines": []]],
|
||||||
|
[["scenic_spot_id": 201, "scenic_spot_name": "测试点", "air_lines": NSNull()]],
|
||||||
|
[["scenic_spot_id": 201, "scenic_spot_name": "测试点", "air_lines": [["air_line_id": 301, "name": "旧接口航线"]]]]] {
|
||||||
|
var payload = Self.payload
|
||||||
|
payload["spot"] = value
|
||||||
|
XCTAssertThrowsError(try decode(payload))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 点位、航线和样片身份需为正整数,各自列表不得出现重复项。
|
||||||
|
func testInvalidAndDuplicateConfigurationIdentitiesAreRejected() throws {
|
||||||
|
for invalid: Any in [0, -1, 1.5, true, "invalid"] {
|
||||||
|
var payload = Self.payload
|
||||||
|
payload["spot"] = [["scenic_spot_id": invalid, "scenic_spot_name": "测试点", "air_lines": []]]
|
||||||
|
XCTAssertThrowsError(try decode(payload))
|
||||||
|
}
|
||||||
|
let sample: [String: Any] = ["id": 401]
|
||||||
|
let route: [String: Any] = ["air_line_id": 301, "air_line_name": "测试航线"]
|
||||||
|
let spot: [String: Any] = ["scenic_spot_id": 201, "scenic_spot_name": "测试点", "air_lines": []]
|
||||||
|
for spots: [[String: Any]] in [
|
||||||
|
[spot, spot],
|
||||||
|
[["scenic_spot_id": 201, "scenic_spot_name": "测试点", "air_lines": [route, route]]],
|
||||||
|
[["scenic_spot_id": 201, "scenic_spot_name": "测试点", "air_lines": [
|
||||||
|
["air_line_id": 301, "air_line_name": "测试航线", "samples": [sample, sample]]]]]
|
||||||
|
] {
|
||||||
|
var payload = Self.payload
|
||||||
|
payload["spot"] = spots
|
||||||
|
XCTAssertThrowsError(try decode(payload))
|
||||||
|
}
|
||||||
|
for invalid: Any in [0, -1, true, "1.5"] {
|
||||||
|
let routeData = try JSONSerialization.data(withJSONObject: ["air_line_id": invalid, "air_line_name": "测试航线"])
|
||||||
|
XCTAssertThrowsError(try JSONDecoder().decode(DroneDockPurchasedAirLine.self, from: routeData))
|
||||||
|
let sampleData = try JSONSerialization.data(withJSONObject: ["id": invalid])
|
||||||
|
XCTAssertThrowsError(try JSONDecoder().decode(DroneDockPurchasedSample.self, from: sampleData))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 同一航线可出现在不同购买点位中,整数字符串也保持稳定身份。
|
||||||
|
func testNumericStringIdentitiesAndRoutesSharedAcrossPointsAreAccepted() throws {
|
||||||
|
var payload = Self.payload
|
||||||
|
payload["project_id"] = "101"
|
||||||
|
payload["spot"] = [201, 202].map { id in
|
||||||
|
["scenic_spot_id": String(id), "scenic_spot_name": "测试点\(id)", "air_lines": [
|
||||||
|
["air_line_id": "301", "air_line_name": "同一航线", "samples": [["id": "401"]]]]] as [String: Any]
|
||||||
|
}
|
||||||
|
let response = try decode(payload)
|
||||||
|
XCTAssertEqual(response.spots.map(\.id), [201, 202])
|
||||||
|
XCTAssertEqual(response.spots.map { $0.airLines[0].id }, [301, 301])
|
||||||
|
XCTAssertEqual(response.spots[0].airLines[0].samples[0].id, 401)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 不可用及原因按原值保留;未知状态不能自动变为可用,未知地址不拼接。
|
||||||
|
func testUnavailableAndUnknownOptionalFieldsRemainDistinct() throws {
|
||||||
|
var payload = Self.payload
|
||||||
|
payload["spot"] = [["scenic_spot_id": 201, "scenic_spot_name": "停用点位", "available": false,
|
||||||
|
"cover_url": NSNull(), "air_lines": [
|
||||||
|
["air_line_id": 301, "air_line_name": "停用航线", "available": false,
|
||||||
|
"unavailable_reason": "航线已停用", "samples": NSNull()],
|
||||||
|
["air_line_id": 302, "air_line_name": "未知航线", "samples": [["id": 402, "cover_url": "", "preview_url": NSNull()]]]
|
||||||
|
]]]
|
||||||
|
let response = try decode(payload)
|
||||||
|
let spot = try XCTUnwrap(response.spots.first)
|
||||||
|
XCTAssertEqual(spot.available, false)
|
||||||
|
XCTAssertNil(spot.coverURL)
|
||||||
|
XCTAssertEqual(spot.airLines[0].available, false)
|
||||||
|
XCTAssertEqual(spot.airLines[0].unavailableReason, "航线已停用")
|
||||||
|
XCTAssertTrue(spot.airLines[0].samples.isEmpty)
|
||||||
|
XCTAssertNil(spot.airLines[1].available)
|
||||||
|
XCTAssertNil(spot.airLines[1].unavailableReason)
|
||||||
|
XCTAssertEqual(spot.airLines[1].samples[0].coverURL, "")
|
||||||
|
XCTAssertNil(spot.airLines[1].samples[0].previewURL)
|
||||||
|
XCTAssertNil(spot.airLines[1].samples[0].name)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 可用状态和地址类型错误时拒绝解码,不放宽为可选航线。
|
||||||
|
func testMalformedAvailabilitySamplesAndURLsAreRejected() throws {
|
||||||
|
for extra: [String: Any] in [["available": "true"], ["available": 1], ["samples": [:]],
|
||||||
|
["samples": [["id": 401, "preview_url": 123]]]] {
|
||||||
|
var route: [String: Any] = ["air_line_id": 301, "air_line_name": "测试航线"]
|
||||||
|
route.merge(extra) { _, new in new }
|
||||||
|
XCTAssertThrowsError(try JSONDecoder().decode(DroneDockPurchasedAirLine.self,
|
||||||
|
from: JSONSerialization.data(withJSONObject: route)))
|
||||||
|
}
|
||||||
|
for extra: [String: Any] in [["available": "false"], ["cover_url": 123]] {
|
||||||
|
var spot: [String: Any] = ["scenic_spot_id": 201, "scenic_spot_name": "测试点", "air_lines": []]
|
||||||
|
spot.merge(extra) { _, new in new }
|
||||||
|
XCTAssertThrowsError(try JSONDecoder().decode(DroneDockPurchasedSpot.self,
|
||||||
|
from: JSONSerialization.data(withJSONObject: spot)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 次数与套餐只取张工根级摘要,旧 workbench 字段和额外点位不会成为备用数据。
|
||||||
|
func testLegacyWorkbenchFieldsDoNotSupplyPurchaseData() throws {
|
||||||
|
let response = try decode([
|
||||||
|
"order_number": "TEST-PROJECT-001", "project_id": 101, "spot": [],
|
||||||
|
"package_name": "旧套餐", "shot_total": 99, "shot_used": 88, "shot_remain": 11,
|
||||||
|
"order_progress": ["package_name": "旧套餐", "shot_total": 99],
|
||||||
|
"spots": [["scenic_spot_id": 999, "name": "未购买点位", "air_lines": []]]
|
||||||
|
])
|
||||||
|
XCTAssertNil(response.order.packageName)
|
||||||
|
XCTAssertNil(response.order.shotTotal)
|
||||||
|
XCTAssertNil(response.order.shotUsed)
|
||||||
|
XCTAssertNil(response.order.shotRemain)
|
||||||
|
XCTAssertNil(response.order.canCreateTask)
|
||||||
|
XCTAssertTrue(response.spots.isEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 固定匿名购买快照,与实际账号、景区和设备无关。
|
||||||
|
private static var payload: [String: Any] {
|
||||||
|
["order_number": "TEST-PROJECT-001", "project_id": 101, "project_name": "已购测试套餐",
|
||||||
|
"shoot_count": 5, "shot_count": 1, "remaining_count": 4, "can_create_task": true,
|
||||||
|
"spot": [["scenic_spot_id": 201, "scenic_spot_name": "已购测试点", "available": true,
|
||||||
|
"cover_url": "https://example.com/spot.jpg", "air_lines": [
|
||||||
|
["air_line_id": 301, "air_line_name": "已购测试航线", "available": true,
|
||||||
|
"unavailable_reason": "", "samples": [["id": 401, "name": "测试样片",
|
||||||
|
"cover_url": "https://example.com/sample.jpg",
|
||||||
|
"preview_url": "https://example.com/sample.mp4"]]]]]]]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 构造标准成功响应,网络由 MockURLSession 提供。
|
||||||
|
private func envelope(_ payload: [String: Any]) throws -> Data {
|
||||||
|
try JSONSerialization.data(withJSONObject: ["code": 100000, "msg": "success", "data": payload])
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 直接读取模型以验证响应结构,无额外网络调用。
|
||||||
|
private func decode(_ payload: [String: Any]) throws -> DroneDockProjectInfoResponse {
|
||||||
|
try JSONDecoder().decode(DroneDockProjectInfoResponse.self, from: JSONSerialization.data(withJSONObject: payload))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,41 @@ import XCTest
|
|||||||
final class DroneDockRemoteHomeViewTests: XCTestCase {
|
final class DroneDockRemoteHomeViewTests: XCTestCase {
|
||||||
private weak var previousKeyWindow: UIWindow?
|
private weak var previousKeyWindow: UIWindow?
|
||||||
|
|
||||||
|
/// 设备请求尚未返回时先展示等高空卡片,返回设备后下方模块不跳动。
|
||||||
|
func testPendingDeviceRequestKeepsPlaceholderCardAtFullDeviceHeight() async throws {
|
||||||
|
let gate = HomeDeviceResponseGate()
|
||||||
|
defer { Task { await gate.release() } }
|
||||||
|
let (controller, session) = makeController(responses: [populatedEnvelope], deviceResponseGate: gate)
|
||||||
|
let window = makeWindow(root: controller)
|
||||||
|
defer { close(window) }
|
||||||
|
let collection = try XCTUnwrap(find(in: controller.view, identifier: "drone.home.remote.list") as? UICollectionView)
|
||||||
|
let path = IndexPath(item: 0, section: 1)
|
||||||
|
|
||||||
|
try await settle(window: window) {
|
||||||
|
session.requests.count == 3 && controller.viewModel.isLoading
|
||||||
|
&& (collection.cellForItem(at: path) as? DroneDockDeviceCell)?.cardView.accessibilityIdentifier == "drone.device.empty"
|
||||||
|
}
|
||||||
|
let placeholder = try XCTUnwrap((collection.cellForItem(at: path) as? DroneDockDeviceCell)?.cardView)
|
||||||
|
let frame = try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: path)).frame
|
||||||
|
XCTAssertEqual(collection.numberOfItems(inSection: 1), 1)
|
||||||
|
XCTAssertEqual(frame.height, 248, accuracy: 0.5)
|
||||||
|
XCTAssertNil(controller.viewModel.response)
|
||||||
|
XCTAssertTrue(visibleTexts(in: placeholder).contains("暂无无人机"))
|
||||||
|
XCTAssertTrue(visibleTexts(in: placeholder).contains("正在加载"))
|
||||||
|
XCTAssertEqual(metricTexts(in: placeholder), Dictionary(uniqueKeysWithValues: metricKeys.map { ($0, "—") }))
|
||||||
|
assertUnambiguousVisibleLayout(in: placeholder)
|
||||||
|
|
||||||
|
await gate.release()
|
||||||
|
try await settle(window: window) {
|
||||||
|
(collection.cellForItem(at: path) as? DroneDockDeviceCell)?.cardView.accessibilityIdentifier == "drone.device.58"
|
||||||
|
&& !collection.hasUncommittedUpdates
|
||||||
|
}
|
||||||
|
let loadedFrame = try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: path)).frame
|
||||||
|
XCTAssertEqual(loadedFrame.minY, frame.minY, accuracy: 0.5)
|
||||||
|
XCTAssertEqual(loadedFrame.height, frame.height, accuracy: 0.5)
|
||||||
|
assertOnlyReadHomepageRequests(session)
|
||||||
|
}
|
||||||
|
|
||||||
/// 成功空响应显示接口零值,不混入演示设备、订单或演示统计。
|
/// 成功空响应显示接口零值,不混入演示设备、订单或演示统计。
|
||||||
func testSuccessfulEmptyHomeDisplaysZeroStatisticsWithoutDemoData() async throws {
|
func testSuccessfulEmptyHomeDisplaysZeroStatisticsWithoutDemoData() async throws {
|
||||||
let (controller, session) = makeController(responses: [emptyEnvelope])
|
let (controller, session) = makeController(responses: [emptyEnvelope])
|
||||||
@@ -14,7 +49,7 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
defer { close(window) }
|
defer { close(window) }
|
||||||
|
|
||||||
try await settle(window: window) {
|
try await settle(window: window) {
|
||||||
self.visibleTexts(in: controller.view).contains("¥0.00")
|
controller.viewModel.response != nil && controller.viewModel.today != nil
|
||||||
&& self.visibleTexts(in: controller.view).contains("暂无拍摄订单")
|
&& self.visibleTexts(in: controller.view).contains("暂无拍摄订单")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,10 +57,13 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
XCTAssertEqual(controller.title, "机巢工作台")
|
XCTAssertEqual(controller.title, "机巢工作台")
|
||||||
XCTAssertTrue(texts.contains("测试景区 · 测试工作人员"))
|
XCTAssertTrue(texts.contains("测试景区 · 测试工作人员"))
|
||||||
XCTAssertTrue(texts.contains("暂无无人机"))
|
XCTAssertTrue(texts.contains("暂无无人机"))
|
||||||
XCTAssertTrue(texts.contains("成交订单"))
|
let collection = try XCTUnwrap(find(in: controller.view, identifier: "drone.home.remote.list") as? UICollectionView)
|
||||||
XCTAssertTrue(texts.contains("成交金额"))
|
let placeholder = try XCTUnwrap(find(in: controller.view, identifier: "drone.device.empty"))
|
||||||
XCTAssertTrue(texts.contains("完成拍摄"))
|
XCTAssertTrue(visibleTexts(in: placeholder).contains("暂无数据"))
|
||||||
XCTAssertEqual(texts.filter { $0 == "0" }.count, 2)
|
XCTAssertEqual(metricTexts(in: placeholder), Dictionary(uniqueKeysWithValues: metricKeys.map { ($0, "—") }))
|
||||||
|
XCTAssertEqual(collection.numberOfItems(inSection: 1), 1)
|
||||||
|
XCTAssertEqual(try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: IndexPath(item: 0, section: 1))).frame.height, 248, accuracy: 0.5)
|
||||||
|
assertUnambiguousVisibleLayout(in: placeholder)
|
||||||
XCTAssertFalse(texts.contains("演示状态 ⌄"))
|
XCTAssertFalse(texts.contains("演示状态 ⌄"))
|
||||||
XCTAssertFalse(texts.contains("01号无人机"))
|
XCTAssertFalse(texts.contains("01号无人机"))
|
||||||
XCTAssertFalse(texts.contains("¥1,896"))
|
XCTAssertFalse(texts.contains("¥1,896"))
|
||||||
@@ -33,6 +71,13 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
XCTAssertTrue(controller.viewModel.orders.isEmpty)
|
XCTAssertTrue(controller.viewModel.orders.isEmpty)
|
||||||
assertOnlyReadHomepageRequests(session)
|
assertOnlyReadHomepageRequests(session)
|
||||||
capture(window, named: "机巢真实首页-成功空态和零值统计")
|
capture(window, named: "机巢真实首页-成功空态和零值统计")
|
||||||
|
let statistics = try await statisticsCard(in: collection, window: window)
|
||||||
|
let statisticsTexts = visibleTexts(in: statistics)
|
||||||
|
XCTAssertTrue(statisticsTexts.contains("成交订单"))
|
||||||
|
XCTAssertTrue(statisticsTexts.contains("成交金额"))
|
||||||
|
XCTAssertTrue(statisticsTexts.contains("完成拍摄"))
|
||||||
|
XCTAssertTrue(statisticsTexts.contains("¥0.00"))
|
||||||
|
XCTAssertEqual(statisticsTexts.filter { $0 == "0" }.count, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 设备接口失败只影响顶部,订单空态和统计仍展示各自接口的成功结果。
|
/// 设备接口失败只影响顶部,订单空态和统计仍展示各自接口的成功结果。
|
||||||
@@ -44,17 +89,74 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
|
|
||||||
try await settle(window: window) {
|
try await settle(window: window) {
|
||||||
self.visibleTexts(in: controller.view).contains("设备加载失败")
|
self.visibleTexts(in: controller.view).contains("设备加载失败")
|
||||||
&& self.visibleTexts(in: controller.view).contains("¥0.00")
|
&& controller.viewModel.today != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let texts = visibleTexts(in: controller.view)
|
let texts = visibleTexts(in: controller.view)
|
||||||
XCTAssertTrue(texts.contains { $0.contains("机巢首页暂不可用") && $0.contains("请下拉重试") })
|
XCTAssertTrue(texts.contains { $0.contains("机巢首页暂不可用") && $0.contains("请下拉重试") })
|
||||||
XCTAssertFalse(texts.contains("暂无无人机"))
|
XCTAssertTrue(texts.contains("暂无无人机"))
|
||||||
XCTAssertTrue(texts.contains("暂无拍摄订单"))
|
XCTAssertTrue(texts.contains("暂无拍摄订单"))
|
||||||
|
let collection = try XCTUnwrap(find(in: controller.view, identifier: "drone.home.remote.list") as? UICollectionView)
|
||||||
|
let placeholder = try XCTUnwrap(find(in: controller.view, identifier: "drone.device.empty"))
|
||||||
|
XCTAssertEqual(metricTexts(in: placeholder), Dictionary(uniqueKeysWithValues: metricKeys.map { ($0, "—") }))
|
||||||
|
XCTAssertEqual(try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: IndexPath(item: 0, section: 1))).frame.height, 248, accuracy: 0.5)
|
||||||
|
assertUnambiguousVisibleLayout(in: placeholder)
|
||||||
XCTAssertNil(controller.viewModel.response)
|
XCTAssertNil(controller.viewModel.response)
|
||||||
XCTAssertNotNil(controller.viewModel.ordersResponse)
|
XCTAssertNotNil(controller.viewModel.ordersResponse)
|
||||||
XCTAssertNotNil(controller.viewModel.today)
|
XCTAssertNotNil(controller.viewModel.today)
|
||||||
assertOnlyReadHomepageRequests(session)
|
assertOnlyReadHomepageRequests(session)
|
||||||
|
let statistics = try await statisticsCard(in: collection, window: window)
|
||||||
|
XCTAssertTrue(visibleTexts(in: statistics).contains("¥0.00"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 空设备与真实设备互相切换时维持顶部位置,并清除上一架设备的读数。
|
||||||
|
func testRefreshingBetweenEmptyAndPopulatedDevicesKeepsCardSpaceAndClearsReadings() async throws {
|
||||||
|
let readings: [String: (Double, String)] = [
|
||||||
|
"battery": (88, "88%"), "env_temp": (21.5, "21.5°C"), "wind_speed": (4.2, "4.2m/s"),
|
||||||
|
"rainfall": (1, "小雨"), "signal": (4, "良好"), "satellite": (32, "32颗")
|
||||||
|
]
|
||||||
|
let (controller, session) = makeController(responses: [emptyEnvelope, try deviceEnvelope(metricValues: readings), emptyEnvelope])
|
||||||
|
let window = makeWindow(root: controller)
|
||||||
|
defer { close(window) }
|
||||||
|
let collection = try XCTUnwrap(find(in: controller.view, identifier: "drone.home.remote.list") as? UICollectionView)
|
||||||
|
let devicePath = IndexPath(item: 0, section: 1)
|
||||||
|
let orderPath = IndexPath(item: 0, section: 2)
|
||||||
|
try await settle(window: window) {
|
||||||
|
controller.viewModel.response?.airports.isEmpty == true
|
||||||
|
&& (collection.cellForItem(at: devicePath) as? DroneDockDeviceCell)?.cardView.accessibilityIdentifier == "drone.device.empty"
|
||||||
|
}
|
||||||
|
let emptyFrame = try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: devicePath)).frame
|
||||||
|
let orderY = try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: orderPath)).frame.minY
|
||||||
|
let refresh = try XCTUnwrap(collection.refreshControl)
|
||||||
|
refresh.sendActions(for: .valueChanged)
|
||||||
|
try await settle(window: window) {
|
||||||
|
(collection.cellForItem(at: devicePath) as? DroneDockDeviceCell)?.cardView.accessibilityIdentifier == "drone.device.58"
|
||||||
|
&& self.metricTexts(in: controller.view) == readings.mapValues { $0.1 }
|
||||||
|
&& !collection.hasUncommittedUpdates
|
||||||
|
}
|
||||||
|
let loadedFrame = try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: devicePath)).frame
|
||||||
|
XCTAssertEqual(loadedFrame.minY, emptyFrame.minY, accuracy: 0.5)
|
||||||
|
XCTAssertEqual(loadedFrame.height, emptyFrame.height, accuracy: 0.5)
|
||||||
|
XCTAssertEqual(try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: orderPath)).frame.minY, orderY, accuracy: 0.5)
|
||||||
|
|
||||||
|
refresh.sendActions(for: .valueChanged)
|
||||||
|
try await settle(window: window) {
|
||||||
|
controller.viewModel.response?.airports.isEmpty == true
|
||||||
|
&& (collection.cellForItem(at: devicePath) as? DroneDockDeviceCell)?.cardView.accessibilityIdentifier == "drone.device.empty"
|
||||||
|
&& !collection.hasUncommittedUpdates
|
||||||
|
}
|
||||||
|
let placeholder = try XCTUnwrap((collection.cellForItem(at: devicePath) as? DroneDockDeviceCell)?.cardView)
|
||||||
|
let finalFrame = try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: devicePath)).frame
|
||||||
|
XCTAssertEqual(finalFrame.minY, emptyFrame.minY, accuracy: 0.5)
|
||||||
|
XCTAssertEqual(finalFrame.height, 248, accuracy: 0.5)
|
||||||
|
XCTAssertEqual(try XCTUnwrap(collection.collectionViewLayout.layoutAttributesForItem(at: orderPath)).frame.minY, orderY, accuracy: 0.5)
|
||||||
|
XCTAssertEqual(collection.numberOfItems(inSection: 1), 1)
|
||||||
|
XCTAssertEqual(metricTexts(in: placeholder), Dictionary(uniqueKeysWithValues: metricKeys.map { ($0, "—") }))
|
||||||
|
XCTAssertFalse(visibleTexts(in: placeholder).contains("测试机巢M4D"))
|
||||||
|
XCTAssertFalse(visibleTexts(in: placeholder).contains("88%"))
|
||||||
|
XCTAssertTrue(visibleTexts(in: placeholder).contains("暂无数据"))
|
||||||
|
XCTAssertEqual(session.requests.count, 9)
|
||||||
|
assertOnlyReadHomepageRequests(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 收款入口继续进入独立真实收款页;订单分页不再显示未接入的查看全部入口。
|
/// 收款入口继续进入独立真实收款页;订单分页不再显示未接入的查看全部入口。
|
||||||
@@ -290,7 +392,7 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
button.sendActions(for: .touchUpInside)
|
button.sendActions(for: .touchUpInside)
|
||||||
|
|
||||||
try await settle(window: window) {
|
try await settle(window: window) {
|
||||||
(controller.navigationController?.topViewController as? DroneDockRemotePreparationViewController)?.viewModel.response != nil
|
(controller.navigationController?.topViewController as? DroneDockRemotePreparationViewController)?.viewModel.projectInfo != nil
|
||||||
&& controller.navigationController?.transitionCoordinator == nil
|
&& controller.navigationController?.transitionCoordinator == nil
|
||||||
}
|
}
|
||||||
let preparation = try XCTUnwrap(controller.navigationController?.topViewController as? DroneDockRemotePreparationViewController)
|
let preparation = try XCTUnwrap(controller.navigationController?.topViewController as? DroneDockRemotePreparationViewController)
|
||||||
@@ -299,17 +401,23 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
XCTAssertEqual(preparation.viewModel.order.orderNumber, "TEST-ORDER-701")
|
XCTAssertEqual(preparation.viewModel.order.orderNumber, "TEST-ORDER-701")
|
||||||
XCTAssertEqual(preparation.viewModel.context.scenicID, 128)
|
XCTAssertEqual(preparation.viewModel.context.scenicID, 128)
|
||||||
XCTAssertEqual(preparation.viewModel.context.storeID, 37)
|
XCTAssertEqual(preparation.viewModel.context.storeID, 37)
|
||||||
XCTAssertEqual(preparation.viewModel.response?.orderNumber, "TEST-ORDER-701")
|
|
||||||
XCTAssertEqual(controller.navigationController?.viewControllers.count, 2)
|
XCTAssertEqual(controller.navigationController?.viewControllers.count, 2)
|
||||||
XCTAssertNil(controller.presentedViewController)
|
XCTAssertNil(controller.presentedViewController)
|
||||||
XCTAssertFalse(try XCTUnwrap(find(in: preparation.view, identifier: "drone.preparation.summon") as? UIButton).isEnabled)
|
XCTAssertFalse(try XCTUnwrap(find(in: preparation.view, identifier: "drone.preparation.summon") as? UIButton).isEnabled)
|
||||||
let request = try XCTUnwrap(preparationSession?.requests.first)
|
XCTAssertEqual(preparation.viewModel.projectInfo?.order.orderNumber, "TEST-ORDER-701")
|
||||||
XCTAssertEqual(preparationSession?.requests.count, 1)
|
XCTAssertEqual(preparation.viewModel.projectInfo?.order.projectID, 101)
|
||||||
XCTAssertEqual(request.httpMethod, "GET")
|
let requests = try XCTUnwrap(preparationSession?.requests)
|
||||||
XCTAssertEqual(request.url?.path, "/api/app/airport/workbench")
|
XCTAssertEqual(requests.count, 1)
|
||||||
let query = URLComponents(url: try XCTUnwrap(request.url), resolvingAgainstBaseURL: false)?.queryItems ?? []
|
XCTAssertEqual(Set(requests.compactMap { $0.url?.path }), ["/api/yf-handset-app/photog/multi-plane/project-info"])
|
||||||
XCTAssertEqual(query.first { $0.name == "order_number" }?.value, "TEST-ORDER-701")
|
for request in requests {
|
||||||
XCTAssertEqual(query.first { $0.name == "scenic_id" }?.value, "128")
|
XCTAssertEqual(request.httpMethod, "GET")
|
||||||
|
XCTAssertNil(request.httpBody)
|
||||||
|
let query = URLComponents(url: try XCTUnwrap(request.url), resolvingAgainstBaseURL: false)?.queryItems ?? []
|
||||||
|
XCTAssertEqual(query.first { $0.name == "order_number" }?.value, "TEST-ORDER-701")
|
||||||
|
XCTAssertEqual(query.first { $0.name == "scenic_id" }?.value, "128")
|
||||||
|
XCTAssertEqual(query.first { $0.name == "project_id" }?.value, "101")
|
||||||
|
XCTAssertFalse(query.contains { $0.name == "lat" || $0.name == "lng" })
|
||||||
|
}
|
||||||
XCTAssertEqual(session.requests.count, 3)
|
XCTAssertEqual(session.requests.count, 3)
|
||||||
assertOnlyReadHomepageRequests(session)
|
assertOnlyReadHomepageRequests(session)
|
||||||
}
|
}
|
||||||
@@ -383,10 +491,13 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
let texts = visibleTexts(in: controller.view)
|
let texts = visibleTexts(in: controller.view)
|
||||||
XCTAssertTrue(texts.contains("暂无无人机"))
|
XCTAssertTrue(texts.contains("暂无无人机"))
|
||||||
XCTAssertEqual(texts.filter { $0 == "—" }.count, 3)
|
|
||||||
XCTAssertFalse(texts.contains("¥0.00"))
|
XCTAssertFalse(texts.contains("¥0.00"))
|
||||||
XCTAssertFalse(texts.contains("88"))
|
XCTAssertFalse(texts.contains("88"))
|
||||||
XCTAssertTrue(texts.contains { $0.contains("统计加载失败") })
|
let collection = try XCTUnwrap(find(in: controller.view, identifier: "drone.home.remote.list") as? UICollectionView)
|
||||||
|
let statistics = try await statisticsCard(in: collection, window: window)
|
||||||
|
let statisticsTexts = visibleTexts(in: statistics)
|
||||||
|
XCTAssertEqual(statisticsTexts.filter { $0 == "—" }.count, 3)
|
||||||
|
XCTAssertTrue(statisticsTexts.contains { $0.contains("统计加载失败") })
|
||||||
assertOnlyReadHomepageRequests(session)
|
assertOnlyReadHomepageRequests(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,6 +559,14 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
return try XCTUnwrap(collection.cellForItem(at: path))
|
return try XCTUnwrap(collection.cellForItem(at: path))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 将统计卡片滚入视口,避免设备模块占位高度改变后误读未创建的复用内容。
|
||||||
|
private func statisticsCard(in collection: UICollectionView, window: UIWindow) async throws -> UICollectionViewCell {
|
||||||
|
let path = IndexPath(item: 0, section: 3)
|
||||||
|
collection.scrollToItem(at: path, at: .centeredVertically, animated: false)
|
||||||
|
try await settle(window: window) { collection.cellForItem(at: path) != nil }
|
||||||
|
return try XCTUnwrap(collection.cellForItem(at: path))
|
||||||
|
}
|
||||||
|
|
||||||
/// 只读取当前可见索引对应的订单卡,排除集合视图复用池中暂存的已删除单元格。
|
/// 只读取当前可见索引对应的订单卡,排除集合视图复用池中暂存的已删除单元格。
|
||||||
private func visibleOrderCardIdentifiers(in collection: UICollectionView) -> [String] {
|
private func visibleOrderCardIdentifiers(in collection: UICollectionView) -> [String] {
|
||||||
collection.indexPathsForVisibleItems.filter { $0.section == 2 }.sorted().compactMap { path in
|
collection.indexPathsForVisibleItems.filter { $0.section == 2 }.sorted().compactMap { path in
|
||||||
@@ -460,7 +579,7 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
/// 检查实际展示的卡片内容约束,隐藏素材栏和按钮不参与可见布局检查。
|
/// 检查实际展示的卡片内容约束,隐藏素材栏和按钮不参与可见布局检查。
|
||||||
private func assertUnambiguousVisibleLayout(in card: UIView, file: StaticString = #filePath, line: UInt = #line) {
|
private func assertUnambiguousVisibleLayout(in card: UIView, file: StaticString = #filePath, line: UInt = #line) {
|
||||||
let ambiguous = allViews(in: card).filter { !isHiddenByAncestor($0) && $0.hasAmbiguousLayout }
|
let ambiguous = allViews(in: card).filter { !isHiddenByAncestor($0) && $0.hasAmbiguousLayout }
|
||||||
XCTAssertTrue(ambiguous.isEmpty, "订单卡片存在布局歧义:\(ambiguous.map { String(describing: type(of: $0)) })", file: file, line: line)
|
XCTAssertTrue(ambiguous.isEmpty, "卡片存在布局歧义:\(ambiguous.map { String(describing: type(of: $0)) })", file: file, line: line)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 服务端确定的六项读数键,按标识查找而不依赖数组排序。
|
/// 服务端确定的六项读数键,按标识查找而不依赖数组排序。
|
||||||
@@ -516,6 +635,7 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
|
|
||||||
/// 创建按 URL 路由的三接口替身,不依赖并行请求的发出顺序。
|
/// 创建按 URL 路由的三接口替身,不依赖并行请求的发出顺序。
|
||||||
private func makeController(responses: [Data], ordersResponses: [Data]? = nil, statsResponses: [Data]? = nil,
|
private func makeController(responses: [Data], ordersResponses: [Data]? = nil, statsResponses: [Data]? = nil,
|
||||||
|
deviceResponseGate: HomeDeviceResponseGate? = nil,
|
||||||
preparationControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil) -> (DroneDockHomeViewController, HomeViewURLSession) {
|
preparationControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil) -> (DroneDockHomeViewController, HomeViewURLSession) {
|
||||||
let context = DroneDockHomeContext(
|
let context = DroneDockHomeContext(
|
||||||
userID: "remote-home-ui-test", accountType: "store_user", scenicID: 128,
|
userID: "remote-home-ui-test", accountType: "store_user", scenicID: 128,
|
||||||
@@ -527,7 +647,7 @@ final class DroneDockRemoteHomeViewTests: XCTestCase {
|
|||||||
"/api/app/airport/home": responses,
|
"/api/app/airport/home": responses,
|
||||||
"/api/yf-handset-app/photog/multi-plane/orders": ordersResponses ?? Array(repeating: emptyOrders, count: responses.count),
|
"/api/yf-handset-app/photog/multi-plane/orders": ordersResponses ?? Array(repeating: emptyOrders, count: responses.count),
|
||||||
"/api/yf-handset-app/photog/multi-plane/today-stats": statsResponses ?? Array(repeating: emptyStats, count: responses.count)
|
"/api/yf-handset-app/photog/multi-plane/today-stats": statsResponses ?? Array(repeating: emptyStats, count: responses.count)
|
||||||
])
|
], deviceResponseGate: deviceResponseGate)
|
||||||
let client = APIClient(environment: .testing, session: session, notificationCenter: NotificationCenter())
|
let client = APIClient(environment: .testing, session: session, notificationCenter: NotificationCenter())
|
||||||
client.bindAuthTokenProvider { "test-token" }
|
client.bindAuthTokenProvider { "test-token" }
|
||||||
let viewModel = DroneDockHomeViewModel(context: context, service: DroneDockAPI(client: client), currentContext: { context })
|
let viewModel = DroneDockHomeViewModel(context: context, service: DroneDockAPI(client: client), currentContext: { context })
|
||||||
@@ -625,16 +745,20 @@ private final class HomeViewURLSession: URLSessionProtocol {
|
|||||||
private var recordedRequests: [URLRequest] = []
|
private var recordedRequests: [URLRequest] = []
|
||||||
private let responses: [String: [Data]]
|
private let responses: [String: [Data]]
|
||||||
private var indices: [String: Int] = [:]
|
private var indices: [String: Int] = [:]
|
||||||
|
private let deviceResponseGate: HomeDeviceResponseGate?
|
||||||
|
|
||||||
/// 读取请求快照时与并行写入互斥。
|
/// 读取请求快照时与并行写入互斥。
|
||||||
var requests: [URLRequest] { lock.withLock { recordedRequests } }
|
var requests: [URLRequest] { lock.withLock { recordedRequests } }
|
||||||
|
|
||||||
/// 保存每个接口的独立响应序列。
|
/// 保存每个接口的独立响应序列。
|
||||||
init(responses: [String: [Data]]) { self.responses = responses }
|
init(responses: [String: [Data]], deviceResponseGate: HomeDeviceResponseGate? = nil) {
|
||||||
|
self.responses = responses
|
||||||
|
self.deviceResponseGate = deviceResponseGate
|
||||||
|
}
|
||||||
|
|
||||||
/// 请求必须命中所配置路径,不能从其他接口借用下一条响应。
|
/// 请求必须命中所配置路径,不能从其他接口借用下一条响应。
|
||||||
func data(for request: URLRequest) async throws -> (Data, URLResponse) {
|
func data(for request: URLRequest) async throws -> (Data, URLResponse) {
|
||||||
try lock.withLock {
|
let result = try lock.withLock {
|
||||||
recordedRequests.append(request)
|
recordedRequests.append(request)
|
||||||
guard let url = request.url else { throw URLError(.badURL) }
|
guard let url = request.url else { throw URLError(.badURL) }
|
||||||
let index = indices[url.path, default: 0]
|
let index = indices[url.path, default: 0]
|
||||||
@@ -643,5 +767,26 @@ private final class HomeViewURLSession: URLSessionProtocol {
|
|||||||
let response = HTTPURLResponse(url: url, statusCode: 200, httpVersion: nil, headerFields: nil)!
|
let response = HTTPURLResponse(url: url, statusCode: 200, httpVersion: nil, headerFields: nil)!
|
||||||
return (queue[index], response)
|
return (queue[index], response)
|
||||||
}
|
}
|
||||||
|
if request.url?.path == "/api/app/airport/home" { await deviceResponseGate?.wait() }
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 确定性挂起设备响应,供测试检查请求期间的真实布局。
|
||||||
|
private actor HomeDeviceResponseGate {
|
||||||
|
private var isReleased = false
|
||||||
|
private var continuation: CheckedContinuation<Void, Never>?
|
||||||
|
|
||||||
|
/// 仅在测试显式放行后结束等待,不依赖网络或固定延迟。
|
||||||
|
func wait() async {
|
||||||
|
guard !isReleased else { return }
|
||||||
|
await withCheckedContinuation { continuation = $0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 恢复挂起请求;重复调用不会重复恢复 continuation。
|
||||||
|
func release() {
|
||||||
|
isReleased = true
|
||||||
|
continuation?.resume()
|
||||||
|
continuation = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,792 @@
|
|||||||
|
# 机巢工作台页面接口对接记录
|
||||||
|
|
||||||
|
> 更新日期:2026-10-28
|
||||||
|
> 核对范围:当前工作区,准备页仅调用 `project-info`,已停用 `workbench` 及其定位请求。
|
||||||
|
> 用途:记录每个页面实际调用的接口、提供人、调用时机、请求参数和返回 JSON,供 iOS 与后端持续联调。
|
||||||
|
|
||||||
|
## 1. 阅读说明
|
||||||
|
|
||||||
|
- **已接入**:当前正式页面已发出请求并处理响应。
|
||||||
|
- **历史已停用**:保留此前联调响应供追溯,当前正式页面不再调用。
|
||||||
|
- **未接入**:只有演示 UI 或后端文档设计,当前正式页面没有调用对应业务接口。
|
||||||
|
- 本文“实测示例”来自已保存的控制台响应,标注各自时间;本次整理文档没有重新调用业务接口。空记录只代表采样时的情况。
|
||||||
|
- JSON 均可独立解析。设备序列号、订单号、手机号、工作人员 ID、付款码/样片地址和点位位置已替换为测试值;景区 `271`、项目 `386`、点位/航线 ID、业务字段、数值类型、空值及业务错误保持原结构。`TEST-ORDER-001` 在首页与准备页中表示同一笔采样订单。
|
||||||
|
- `example.com` 地址只是字段格式示例,不能用于实际收款或播放。未记录登录 Token。
|
||||||
|
- 本地原始响应目录目前属于联调资料,未纳入此前代码提交;克隆仓库后这些原始文件链接可能不可用,正文仍包含必要 JSON。
|
||||||
|
|
||||||
|
## 2. 页面与接口总览
|
||||||
|
|
||||||
|
当前机巢专用接入共 **4 个正式页面、7 个接口**。
|
||||||
|
|
||||||
|
| 页面/区域 | 提供人 | 方法与完整路径 | 当前状态 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| 首页:顶部无人机 | 朱工 | `GET /api/app/airport/home` | 已接入,仅使用设备信息 |
|
||||||
|
| 首页:我的拍摄订单 | 张工 | `GET /api/yf-handset-app/photog/multi-plane/orders` | 已接入,支持分页 |
|
||||||
|
| 首页:今日统计 | 张工 | `GET /api/yf-handset-app/photog/multi-plane/today-stats` | 已接入 |
|
||||||
|
| 机巢套餐收款页:套餐选择 | 张工 | `GET /api/yf-handset-app/photog/multi-plane/projects` | 已接入 |
|
||||||
|
| 机巢套餐收款页:生成小程序收款码 | 张工 | `POST /api/yf-handset-app/photog/multi-plane/pay-code` | 已接入 |
|
||||||
|
| 收款记录页 | 张工 | `GET /api/yf-handset-app/photog/multi-plane/receipts` | 已接入,支持分页 |
|
||||||
|
| 拍摄准备页:已购套餐、点位、航线、次数 | 张工 | `GET /api/yf-handset-app/photog/multi-plane/project-info` | 已接入 |
|
||||||
|
|
||||||
|
准备页已停用朱工 `workbench`,历史响应保留在第 7.3 节。实时设备、距离与召唤条件的读取入口尚待接入。其余独立订单列表、拍摄任务、素材、交付等页面的真实接口尚未接入,详见第 8 节。
|
||||||
|
|
||||||
|
## 3. 公共约定
|
||||||
|
|
||||||
|
| 项目 | 当前约定 |
|
||||||
|
| --- | --- |
|
||||||
|
| 测试环境 | `https://api-test.zhifly.cn` |
|
||||||
|
| 生产环境 | `https://api.zhifly.cn` |
|
||||||
|
| 当前 App 鉴权 | 统一 `APIClient` 注入 HTTP Header `token: <当前登录凭证>` |
|
||||||
|
| 其他公共请求头 | `Accept: application/json`、`Content-Type: application/json`、`X-APP-VERSION`、`X-OS-TYPE` |
|
||||||
|
| GET 参数 | URL 查询串 |
|
||||||
|
| POST 参数 | JSON body |
|
||||||
|
| 成功判断 | HTTP 成功后还需检查业务 `code == 100000`;其他业务码显示 `msg` |
|
||||||
|
| 返回包裹 | `code`、`msg`、`data`,通常还有 `time`;`data` 的对象/数组类型由具体接口决定 |
|
||||||
|
| 账号范围 | 当前登录的门店工作人员及当前景区;不通过传其他工作人员 ID 切换归属 |
|
||||||
|
| 页面隔离 | 账号、Token、景区、门店变化后,旧请求结果不能回填当前页面 |
|
||||||
|
|
||||||
|
朱工文档顶部写有 `YFHandSetAppToken` 鉴权标识;**当前 App 实际发送的请求头名是 `token`**,不要把两者混写成已验证的两套 HTTP Header。
|
||||||
|
|
||||||
|
代码依据:[APIClient.swift](suixinkan/Core/Networking/APIClient.swift)。
|
||||||
|
|
||||||
|
## 4. 机巢工作台首页
|
||||||
|
|
||||||
|
页面:[DroneDockHomeViewController.swift](suixinkan/UI/DroneDock/DroneDockHomeViewController.swift)
|
||||||
|
API:[DroneDockAPI.swift](suixinkan/Features/DroneDock/API/DroneDockAPI.swift)
|
||||||
|
状态:[DroneDockHomeViewModel.swift](suixinkan/Features/DroneDock/ViewModels/DroneDockHomeViewModel.swift)
|
||||||
|
|
||||||
|
页面出现、返回首页或下拉刷新时,并行读取设备、订单第一页和今日统计。三个请求分别处理失败,某一区域失败不会清空其他区域的成功结果;本轮请求结束后统一刷新界面。点击“加载更多订单”只读取 `orders` 下一页。
|
||||||
|
|
||||||
|
### 4.1 顶部无人机:朱工 home
|
||||||
|
|
||||||
|
`GET /api/app/airport/home?scenic_id=271`
|
||||||
|
|
||||||
|
| 参数 | 必填 | 当前使用 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `scenic_id` | 是 | 当前景区 ID |
|
||||||
|
|
||||||
|
新版请求不再发送 `store_id`。代码保留门店 ID 仅用于本地身份有效性校验。
|
||||||
|
|
||||||
|
**实测响应:2026-10-28 15:51:40,成功。** 原响应有两台设备,以下截取一台,保留单台设备的全部字段与六项读数。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 61,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "河南嵩山",
|
||||||
|
"online_status": 2,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "TEST-AIRPORT-61",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 0,
|
||||||
|
"work_status_label": "离线"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scenic_id": 271
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 15:51:40"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
响应来源:[本地联调存档](docs/9.9.1/home-split-integration-2026-10-28/home-response.json)。
|
||||||
|
|
||||||
|
页面使用 `name`、`work_status_label`、`metrics` 等字段。六项读数按 `battery/env_temp/wind_speed/rainfall/signal/satellite` 匹配;缺失或未知显示“—”,不显示为 0。当前样本两台设备均离线。
|
||||||
|
|
||||||
|
新版首页**不再从 home 读取订单和统计,也不以旧字段作为失败回退数据**。
|
||||||
|
|
||||||
|
### 4.2 我的拍摄订单:张工 orders
|
||||||
|
|
||||||
|
`GET /api/yf-handset-app/photog/multi-plane/orders?scenic_id=271&status=all&page=1&page_size=20`
|
||||||
|
|
||||||
|
| 参数 | 必填 | 当前 App 使用 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `scenic_id` | 是 | 当前景区 ID |
|
||||||
|
| `status` | 否 | 首页固定 `all`;后端另支持 `pending/processing/completed` |
|
||||||
|
| `page` | 否 | 首次 1,后续递增 |
|
||||||
|
| `page_size` | 否 | 当前 20;后端最大 100 |
|
||||||
|
|
||||||
|
**实测响应:2026-10-28 15:51:40,成功;总共两笔订单。**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"can_confirm": false,
|
||||||
|
"can_create_task": true,
|
||||||
|
"can_upload_film": false,
|
||||||
|
"confirm_status": 0,
|
||||||
|
"confirmed_at": null,
|
||||||
|
"created_at": "2026-10-27 17:39:10",
|
||||||
|
"film_count": 0,
|
||||||
|
"material_status": 0,
|
||||||
|
"order_number": "TEST-ORDER-001",
|
||||||
|
"order_status": 20,
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"remaining_count": 5,
|
||||||
|
"shoot_count": 5,
|
||||||
|
"shoot_status": "pending",
|
||||||
|
"shot_count": 0,
|
||||||
|
"user_phone": "130****0001"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"can_confirm": false,
|
||||||
|
"can_create_task": true,
|
||||||
|
"can_upload_film": false,
|
||||||
|
"confirm_status": 0,
|
||||||
|
"confirmed_at": null,
|
||||||
|
"created_at": "2026-10-27 17:16:18",
|
||||||
|
"film_count": 0,
|
||||||
|
"material_status": 0,
|
||||||
|
"order_number": "TEST-ORDER-002",
|
||||||
|
"order_status": 20,
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"remaining_count": 5,
|
||||||
|
"shoot_count": 5,
|
||||||
|
"shoot_status": "pending",
|
||||||
|
"shot_count": 0,
|
||||||
|
"user_phone": "130****0001"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"page": 1,
|
||||||
|
"page_size": 20,
|
||||||
|
"total": 2
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 15:51:40"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
响应来源:[本地联调存档](docs/9.9.1/home-split-integration-2026-10-28/orders-response.json)。
|
||||||
|
|
||||||
|
字段与页面对应:
|
||||||
|
|
||||||
|
| 返回字段 | 用途 |
|
||||||
|
| --- | --- |
|
||||||
|
| `order_number` | 订单编号,也是 Diffable 列表稳定身份 |
|
||||||
|
| `project_id` | 已购项目 ID,随订单传给准备页 |
|
||||||
|
| `project_name`、`user_phone` | 套餐名称、已脱敏游客手机号 |
|
||||||
|
| `shoot_count/shot_count/remaining_count` | 总次数、已成功拍摄次数、剩余次数,直接使用后端值 |
|
||||||
|
| `shoot_status` | `pending` 待拍摄、`processing` 进行中、`completed` 已完成 |
|
||||||
|
| `can_create_task` | 为 true 时提供“开始拍摄”入口;不是起飞许可 |
|
||||||
|
| `can_confirm`、`can_upload_film` | 当前用于动作入口映射,后续真实交付/素材动作尚未接入 |
|
||||||
|
| `material_status` | 0 未开始、1 已完成、2 上传中、3 上传失败;不等于订单完成状态 |
|
||||||
|
| `total` | 标题中的订单总数,不能用当前页 `list.count` 代替 |
|
||||||
|
|
||||||
|
“开始拍摄”当前只负责打开准备页,传入景区、订单号、项目 ID;**跳转前不发创建任务或召唤请求**,也没有额外调用 `orders/detail`。
|
||||||
|
|
||||||
|
### 4.3 今日统计:张工 today-stats
|
||||||
|
|
||||||
|
`GET /api/yf-handset-app/photog/multi-plane/today-stats?scenic_id=271`
|
||||||
|
|
||||||
|
必填参数只有 `scenic_id`,App 不传本地日期。
|
||||||
|
|
||||||
|
**实测响应:2026-10-28 15:51:40,成功。**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"cash_paid": "0.00",
|
||||||
|
"cash_refund": "0.00",
|
||||||
|
"completed_count": 0,
|
||||||
|
"deal_amount": "0.00",
|
||||||
|
"deal_count": 0,
|
||||||
|
"points_net": 0,
|
||||||
|
"points_paid": 0,
|
||||||
|
"points_refund": 0
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 15:51:40"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
响应来源:[本地联调存档](docs/9.9.1/home-split-integration-2026-10-28/today-stats-response.json)。
|
||||||
|
|
||||||
|
| 首页文案 | 返回字段 | 统计口径(张工文档) |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 成交订单 | `deal_count` | 今天付款,当前仍为已付款/已完成的订单数 |
|
||||||
|
| 成交金额 | `deal_amount` | 上述订单现金实收减成功现金退款 |
|
||||||
|
| 完成拍摄 | `completed_count` | 今天经游客确认完成、当前状态为已完成的订单数;并非飞行成功任务数 |
|
||||||
|
|
||||||
|
仅统计本人、当前景区、类型 25;日界限为 `Asia/Shanghai` 当天。当前样本均为 0。接口失败保持未知占位和错误提示,不能显示成成功零值。
|
||||||
|
|
||||||
|
## 5. 机巢套餐收款页
|
||||||
|
|
||||||
|
页面:[DroneDockPaymentViewController.swift](suixinkan/UI/DroneDock/DroneDockPaymentViewController.swift)
|
||||||
|
API:[DroneDockPaymentAPI.swift](suixinkan/Features/DroneDock/API/DroneDockPaymentAPI.swift)
|
||||||
|
|
||||||
|
### 5.1 获取可售套餐:张工 projects
|
||||||
|
|
||||||
|
`GET /api/yf-handset-app/photog/multi-plane/projects?scenic_id=271`
|
||||||
|
|
||||||
|
- 必填 `scenic_id`,没有分页。
|
||||||
|
- 首次进入、身份变化及套餐加载失败重试时读取。
|
||||||
|
- 正式页面进入时仅加载套餐,**不会自动生成付款码**。
|
||||||
|
|
||||||
|
**实测响应:2026-10-27 15:37:44,成功。**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 386,
|
||||||
|
"name": "多点位航拍",
|
||||||
|
"price": "99.00",
|
||||||
|
"shoot_count": 5
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:37:44"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
响应来源:[本地联调存档](docs/9.9.1/payment-integration-2026-10-27/projects-scenic271-response.json)。
|
||||||
|
|
||||||
|
`price` 为元字符串,`shoot_count` 为整个套餐共享次数。成功但 `data: []` 表示暂无可售套餐,页面显示空态。
|
||||||
|
|
||||||
|
### 5.2 生成小程序收款码:张工 pay-code
|
||||||
|
|
||||||
|
`POST /api/yf-handset-app/photog/multi-plane/pay-code`
|
||||||
|
|
||||||
|
| body 字段 | 必填 | 当前使用 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `scenic_id` | 是 | 当前景区 |
|
||||||
|
| `project_id` | 是 | 选中的可售套餐 |
|
||||||
|
| `price` | 否 | 本次报价字符串;省略时使用后端默认售价,不发空串或 null |
|
||||||
|
|
||||||
|
使用套餐默认价的请求示例:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"scenic_id": 271,
|
||||||
|
"project_id": 386
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
修改报价的请求格式示例(并非下方实测响应对应的请求):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"scenic_id": 271,
|
||||||
|
"project_id": 386,
|
||||||
|
"price": "88.00"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
调用时机:确认套餐、确认修改金额、生成失败重试、点击“重新生成”。付款码图片下载失败后的“重新加载图片”只重试图片,不重新创建付款码。
|
||||||
|
|
||||||
|
**实测响应:2026-10-27 17:22:00,成功;小程序码图片版本。**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"pay_url": "https://example.com/mini_qr/pay-code.png",
|
||||||
|
"price": "99.00",
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"shoot_count": 5,
|
||||||
|
"store_id": 38,
|
||||||
|
"store_user_id": 51
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 17:22:00"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
响应来源:[本地联调存档](docs/9.9.1/payment-integration-2026-10-27/pay-code-mini-program-responses.json)。
|
||||||
|
|
||||||
|
`pay_url` 是后端生成的**微信小程序码图片 URL**,App 直接加载图片,不把 URL 字符串再次编码成二维码。生成成功只表示得到收款码,不表示游客已付款。同一码可被多人购买,实际收款需查看收款记录。
|
||||||
|
|
||||||
|
旧存档 `pay-code-scenic271-response.json` 返回的是 `/wma/multi-plane/pay?...` 地址,属于早期合同,**不能作为当前图片展示接口的依据**。
|
||||||
|
|
||||||
|
Debug 联调参数 `--dock-payment-probe` 下存在自动选首套餐生成码的逻辑,仅用于联调,不属于正常页面行为。
|
||||||
|
|
||||||
|
## 6. 收款记录页
|
||||||
|
|
||||||
|
页面:[DroneDockReceiptsViewController.swift](suixinkan/UI/DroneDock/DroneDockReceiptsViewController.swift)
|
||||||
|
状态:[DroneDockReceiptsViewModel.swift](suixinkan/Features/DroneDock/ViewModels/DroneDockReceiptsViewModel.swift)
|
||||||
|
|
||||||
|
### 6.1 查询收款记录:张工 receipts
|
||||||
|
|
||||||
|
`GET /api/yf-handset-app/photog/multi-plane/receipts?scenic_id=271&page=1`
|
||||||
|
|
||||||
|
| 参数 | 当前 App 使用 |
|
||||||
|
| --- | --- |
|
||||||
|
| `scenic_id` | 必填,当前景区 |
|
||||||
|
| `page` | 第一页为 1,加载更多递增 |
|
||||||
|
| `project_id` | 可选;顶部“收款记录”不传,码区域“刷新收款记录”传当前码的项目 ID |
|
||||||
|
| `start_date/end_date/page_size` | 后端支持,但当前页面不传,使用后端默认值 |
|
||||||
|
|
||||||
|
页面出现、下拉刷新、加载更多时调用。后端文档默认日期为最近 7 天、每页 20 条。汇总取后端 `summary`,不累加当前已加载页。
|
||||||
|
|
||||||
|
**实测响应:2026-10-27 15:34:27,成功空态。** 以下仅省略分页导航 URL、`links/from/to/path` 等辅助字段,保留当前 App 使用的完整分页与汇总字段。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"records": {
|
||||||
|
"current_page": 1,
|
||||||
|
"data": [],
|
||||||
|
"last_page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"total": 0
|
||||||
|
},
|
||||||
|
"summary": {
|
||||||
|
"cash_net": "0.00",
|
||||||
|
"cash_paid": "0.00",
|
||||||
|
"cash_refund": "0.00",
|
||||||
|
"count": 0,
|
||||||
|
"point_amount": "0.00",
|
||||||
|
"points_net": 0,
|
||||||
|
"points_paid": 0,
|
||||||
|
"points_refund": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-27 15:34:27"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
响应来源:[本地联调存档](docs/9.9.1/payment-integration-2026-10-27/receipts-scenic271-response.json)。
|
||||||
|
|
||||||
|
该样本不能说明目前仍没有收款记录。为便于后续非空数据联调,下面附**张工接口文档的 `data` 非空示例**(不是实测响应,不含外层 `code/msg/time`):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"records": {
|
||||||
|
"current_page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"total": 1,
|
||||||
|
"last_page": 1,
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"project_id": 101,
|
||||||
|
"project_name": "三点位航拍",
|
||||||
|
"order_number": "HT202610270001",
|
||||||
|
"order_status": 20,
|
||||||
|
"pay_time": 1793066400,
|
||||||
|
"payer": "张**",
|
||||||
|
"cash_paid": "88.00",
|
||||||
|
"cash_refund": "8.00",
|
||||||
|
"cash_net": "80.00",
|
||||||
|
"points_paid": 0,
|
||||||
|
"points_refund": 0,
|
||||||
|
"points_net": 0,
|
||||||
|
"point_amount": "0.00"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"summary": {
|
||||||
|
"count": 1,
|
||||||
|
"cash_paid": "88.00",
|
||||||
|
"cash_refund": "8.00",
|
||||||
|
"cash_net": "80.00",
|
||||||
|
"points_paid": 0,
|
||||||
|
"points_refund": 0,
|
||||||
|
"points_net": 0,
|
||||||
|
"point_amount": "0.00"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
注意:收款分页是 `data.records.data`,首页拍摄订单分页是 `data.list`,两者不能共用同一解析结构。`pay_time` 为 Unix 秒,金额为元字符串。收款记录不能直接判定“当前展示的小程序码刚刚支付成功”。
|
||||||
|
|
||||||
|
## 7. 拍摄准备页
|
||||||
|
|
||||||
|
页面:[DroneDockRemotePreparationViewController.swift](suixinkan/UI/DroneDock/DroneDockRemotePreparationViewController.swift)
|
||||||
|
API:[DroneDockPreparationAPI.swift](suixinkan/Features/DroneDock/API/DroneDockPreparationAPI.swift)
|
||||||
|
购买模型:[DroneDockProjectInfoModels.swift](suixinkan/Features/DroneDock/Models/DroneDockProjectInfoModels.swift)
|
||||||
|
状态:[DroneDockPreparationViewModel.swift](suixinkan/Features/DroneDock/ViewModels/DroneDockPreparationViewModel.swift)
|
||||||
|
|
||||||
|
### 7.1 调用顺序与数据归属
|
||||||
|
|
||||||
|
1. 首页点击“开始拍摄”,先跳转到准备页。
|
||||||
|
2. 准备页出现后仅请求张工 `project-info`,读取已购配置;不请求定位,也不调用 `workbench`。
|
||||||
|
3. 请求结束后刷新 UI。页面下拉或点击“刷新状态”仅重新读取 `project-info`。
|
||||||
|
|
||||||
|
| 页面内容 | 权威数据来源 |
|
||||||
|
| --- | --- |
|
||||||
|
| 套餐名称、总次数、已拍次数、剩余次数、订单操作权限 | 张工 `project-info` 的根级订单摘要 |
|
||||||
|
| 可选点位、可选航线及可用性 | 张工 `project-info.spot` |
|
||||||
|
| 点位封面 | `spot[].cover_url`;为空时使用中性占位 |
|
||||||
|
| 样片元数据 | `air_lines[].samples` 已解析保留,当前准备页尚未新增样片播放入口 |
|
||||||
|
| 机巢连接、工作状态、召唤门禁 | 实时读取入口尚待接入,保持未知,不据此允许召唤 |
|
||||||
|
| 距离、范围、点位已拍信息 | `project-info` 未提供;不再使用历史 workbench 响应补充,缺失值保持未知 |
|
||||||
|
|
||||||
|
已购点位、航线和次数仅使用 `project-info`,不使用历史 workbench 数据回填。`available=false` 或缺失时不可选择;航线不可用原因直接展示后端文案。
|
||||||
|
|
||||||
|
### 7.2 获取已购配置:张工 project-info
|
||||||
|
|
||||||
|
`GET /api/yf-handset-app/photog/multi-plane/project-info?scenic_id=271&project_id=386&order_number=TEST-ORDER-001`
|
||||||
|
|
||||||
|
| 参数 | 必填 | 来源 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `scenic_id` | 是 | 当前景区 |
|
||||||
|
| `project_id` | 是 | 首页 orders 返回的项目 ID |
|
||||||
|
| `order_number` | 拍摄准备必须传 | 首页选中订单号,必须与项目对应 |
|
||||||
|
|
||||||
|
缺少项目 ID 或订单号时在本地拦截,不改成查询当前在售套餐;不另调 `orders/detail`。响应中的订单号、项目 ID 必须与本次请求一致。
|
||||||
|
|
||||||
|
**实测响应:2026-10-28 16:23:11,成功。** 当前订单有两个已购点位,各一条航线;总次数 5、已拍 0、剩余 5。以下完整保留字段结构,位置和媒体地址已替换为示例值。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"can_confirm": false,
|
||||||
|
"can_create_task": true,
|
||||||
|
"can_upload_film": false,
|
||||||
|
"confirm_status": 0,
|
||||||
|
"confirmed_at": null,
|
||||||
|
"created_at": "2026-10-27 17:39:10",
|
||||||
|
"film_count": 0,
|
||||||
|
"material_status": 0,
|
||||||
|
"order_number": "TEST-ORDER-001",
|
||||||
|
"order_status": 20,
|
||||||
|
"project_id": 386,
|
||||||
|
"project_name": "多点位航拍",
|
||||||
|
"remaining_count": 5,
|
||||||
|
"shoot_count": 5,
|
||||||
|
"shoot_status": "pending",
|
||||||
|
"shot_count": 0,
|
||||||
|
"spot": [
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 302,
|
||||||
|
"air_line_name": "天门寻梦",
|
||||||
|
"available": true,
|
||||||
|
"samples": [
|
||||||
|
{
|
||||||
|
"cover_url": "https://example.com/samples/318.png",
|
||||||
|
"id": 318,
|
||||||
|
"name": "天门寻梦",
|
||||||
|
"preview_url": "https://example.com/samples/318.mp4"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"unavailable_reason": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"available": true,
|
||||||
|
"cover_url": "",
|
||||||
|
"region": {
|
||||||
|
"address": "测试景区拍摄点",
|
||||||
|
"lat": 32.4,
|
||||||
|
"lot": 119.4,
|
||||||
|
"scenic_spot_str": "测试点位"
|
||||||
|
},
|
||||||
|
"sample_piece_ids": [
|
||||||
|
318
|
||||||
|
],
|
||||||
|
"samples": [
|
||||||
|
{
|
||||||
|
"id": 318,
|
||||||
|
"name": "天门寻梦"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scenic_spot_id": 412,
|
||||||
|
"scenic_spot_name": "天门寻梦"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 304,
|
||||||
|
"air_line_name": "天门远山",
|
||||||
|
"available": true,
|
||||||
|
"samples": [
|
||||||
|
{
|
||||||
|
"cover_url": "https://example.com/samples/319.png",
|
||||||
|
"id": 319,
|
||||||
|
"name": "天门远山",
|
||||||
|
"preview_url": "https://example.com/samples/319.mp4"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"unavailable_reason": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"available": true,
|
||||||
|
"cover_url": "",
|
||||||
|
"region": {
|
||||||
|
"address": "测试景区拍摄点",
|
||||||
|
"lat": 32.4,
|
||||||
|
"lot": 119.4,
|
||||||
|
"scenic_spot_str": "测试点位"
|
||||||
|
},
|
||||||
|
"sample_piece_ids": [
|
||||||
|
319
|
||||||
|
],
|
||||||
|
"samples": [
|
||||||
|
{
|
||||||
|
"id": 319,
|
||||||
|
"name": "天门远山"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scenic_spot_id": 413,
|
||||||
|
"scenic_spot_name": "天门远山"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"user_phone": "130****0001"
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 16:23:11"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
响应来源:[本地联调存档](docs/9.9.1/project-info-integration-2026-10-28/project-info-response.json)。
|
||||||
|
|
||||||
|
关键差异:
|
||||||
|
|
||||||
|
- 购买点位数组字段是单数 **`spot`**,不是 `spots`。
|
||||||
|
- 点位名称字段是 **`scenic_spot_name`**;航线名称字段是 **`air_line_name`**。
|
||||||
|
- `region` 本次真实返回为对象,文档允许缺失/空值;当前页面不根据该字段自行计算距离或拍摄半径。
|
||||||
|
- 点位 `cover_url` 本次为空;航线样片中有 `cover_url/preview_url`,不能把点位缺图描述成后端完全没有样片图片。
|
||||||
|
- 项目后续编辑、改价、下架不应扩大或收回已购范围;后端仍需校验点位、航线的当前可用性。
|
||||||
|
- 项目接口失败时清除购买配置与选中项,不回退到朱工列表或历史缓存中的设备响应。
|
||||||
|
|
||||||
|
### 7.3 历史已停用:朱工 workbench
|
||||||
|
|
||||||
|
**当前准备页不再调用此接口,也不再为此请求定位。** 以下仅保留停用前的请求参数与真实响应,供追溯接口分工和旧数据结构。
|
||||||
|
|
||||||
|
`GET /api/app/airport/workbench?scenic_id=271&order_number=TEST-ORDER-001`
|
||||||
|
|
||||||
|
| 参数 | 停用前的请求方式 |
|
||||||
|
| --- | --- |
|
||||||
|
| `scenic_id` | 必填,当前景区 |
|
||||||
|
| `order_number` | 必填,选中订单号 |
|
||||||
|
| `lat/lng` | 定位成功后成对传入;失败时两者都省略 |
|
||||||
|
|
||||||
|
**停用前多点位订单的历史真实响应:2026-10-28 16:23:21。HTTP 为 200,但业务失败,不能按成功解析。**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 100099,
|
||||||
|
"data": [],
|
||||||
|
"msg": "多点位航拍请使用专用订单接口",
|
||||||
|
"time": "2026-10-28 16:23:21"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
响应来源:[本地联调存档](docs/9.9.1/project-info-integration-2026-10-28/workbench-response.json)。
|
||||||
|
|
||||||
|
当前页面显示 `project-info` 返回的已购套餐、点位和航线;设备、距离与范围保持未知,不再展示这次历史业务失败作为当前请求错误。
|
||||||
|
|
||||||
|
**待朱工与张工确认:**类型 25 的实时设备、距离和召唤条件读取入口尚待接入。`project-info` 本身不提供这些实时设备字段,不能据此判断起飞条件满足。
|
||||||
|
|
||||||
|
下面为**此前另一笔订单的历史成功响应节选**(2026-10-28 14:47:44),只用于说明旧 workbench 结构,不代表当前多点位订单已经支持。设备数组和点位数组各保留一项:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 100000,
|
||||||
|
"data": {
|
||||||
|
"airports": [
|
||||||
|
{
|
||||||
|
"id": 61,
|
||||||
|
"is_receive_order": 1,
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"key": "battery",
|
||||||
|
"label": "电池电量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "env_temp",
|
||||||
|
"label": "环境温度",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "wind_speed",
|
||||||
|
"label": "风速",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "rainfall",
|
||||||
|
"label": "雨量",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "signal",
|
||||||
|
"label": "信号状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "satellite",
|
||||||
|
"label": "搜星状态",
|
||||||
|
"raw": null,
|
||||||
|
"value": "—"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "河南嵩山",
|
||||||
|
"online_status": 2,
|
||||||
|
"scenic_area_id": 271,
|
||||||
|
"sn_number": "TEST-AIRPORT-61",
|
||||||
|
"task_type": null,
|
||||||
|
"work_status": 0,
|
||||||
|
"work_status_label": "离线"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"order_number": "LEGACY-ORDER-001",
|
||||||
|
"order_progress": {
|
||||||
|
"order_number": "LEGACY-ORDER-001",
|
||||||
|
"package_name": "单次航拍 · 含 1 次拍摄",
|
||||||
|
"shot_remain": 1,
|
||||||
|
"shot_total": 1,
|
||||||
|
"shot_used": 0,
|
||||||
|
"status_label": "待拍摄"
|
||||||
|
},
|
||||||
|
"recommend_plane": null,
|
||||||
|
"scenic_id": 271,
|
||||||
|
"shoot_gate": {
|
||||||
|
"can_shoot": false,
|
||||||
|
"code": "dock_offline",
|
||||||
|
"message": "机巢未连接",
|
||||||
|
"primary_action": "blocked",
|
||||||
|
"primary_action_label": "机巢未连接"
|
||||||
|
},
|
||||||
|
"spots": [
|
||||||
|
{
|
||||||
|
"air_lines": [
|
||||||
|
{
|
||||||
|
"air_line_id": 301,
|
||||||
|
"estimated_fly_time": 279,
|
||||||
|
"fly_type": 1,
|
||||||
|
"line_video_duration": 14,
|
||||||
|
"name": "vue3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"distance_label": "3311.1 km",
|
||||||
|
"distance_m": 3311086,
|
||||||
|
"in_range": false,
|
||||||
|
"name": "测试打卡点",
|
||||||
|
"scenic_spot_id": 411,
|
||||||
|
"shot_count": 0,
|
||||||
|
"shot_status_label": "未拍摄"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tips": "每次拍摄成功后扣减 1 次,未成功不扣次数。"
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"time": "2026-10-28 14:47:44"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
响应来源:[本地联调存档](docs/9.9.1/preparation-integration-2026-10-28/workbench-latest-response.json)。
|
||||||
|
|
||||||
|
这次历史请求未传经纬度,却返回约 3311 公里及 `in_range=false`。当前准备页不再读取或使用这类 workbench 距离/范围结果。后续对接实时入口时,需明确无定位的未知值语义,以及坐标系和范围校验规则。
|
||||||
|
|
||||||
|
### 7.4 “确认并召唤”的当前边界
|
||||||
|
|
||||||
|
准备页目前只完成信息读取和本地选择,**“确认并召唤”按钮仍禁用**,没有发送以下请求:
|
||||||
|
|
||||||
|
- 张工 `POST /api/yf-handset-app/photog/multi-plane/tasks/create`。
|
||||||
|
- 朱工 `POST /api/app/airport/shoot`。
|
||||||
|
- 朱工 `POST /api/app/airport/start-shoot`。
|
||||||
|
|
||||||
|
后续先统一任务创建与绑定:张工 `tasks/create` 创建待飞任务并要求飞行模块复用 `task_id`;朱工文档的 `shoot` 仍描述自行创建任务。不能直接把两者串接而重复创建。`start-shoot` 属于到达后的开始拍摄,不应在进入准备页时调用。
|
||||||
|
|
||||||
|
以上接口尚无本轮真实成功 JSON,本记录不编造召唤响应。
|
||||||
|
|
||||||
|
## 8. 其他页面与尚未接入的功能
|
||||||
|
|
||||||
|
以下是模块已有演示页面和后端文档候选接口,**不计入前述 7 个已调用接口**,也不代表已确定最终对接方案。
|
||||||
|
|
||||||
|
| 页面/功能 | 当前实现状态 | 文档中的后续候选接口与提供人 | 返回 JSON 记录 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| 独立拍摄订单列表 `DroneShootingOrdersViewController` | 仍用 `DroneDockDemoStore`;首页自己的订单分页已接真实接口 | 张工 `GET /orders` | 已有接口结构见 4.2,但独立页面尚未调用 |
|
||||||
|
| 拍摄任务页 `DroneShootingTaskViewController` | 召唤、到达、拍摄、暂停、返航仍为演示流程 | 朱工 `/airport/shooting`、`/airport/status`、`/airport/live`、`/airport/start-shoot`、`/airport/command` | 暂无本页真实响应,不填模拟 JSON 冒充实测 |
|
||||||
|
| 订单素材列表/预览/下载 `DroneMaterialsViewController`、`DroneMaterialPreviewViewController` | 仍为演示链路;正式首页“查看素材”显示暂未开放 | 类型 25 可用张工 `GET /orders/detail`、`GET /tasks`;朱工文档另有 `/scenic-media/order-materials`,适用范围待统一 | 尚无本页联调响应 |
|
||||||
|
| 成片上传、交付与确认 `DroneDeliveryUploadViewController`、`DroneDeliveryReviewViewController` | 仍为演示链路;正式动作未接入 | 张工 `POST /tasks/film`、`POST /orders/confirm-code`、`GET /orders/detail` | 尚无本页联调响应 |
|
||||||
|
| 收款页“线下收款” | 跳转既有 `OfflineCollectionRegistrationViewController` | 复用原通用线下收款模块,不属于本次机巢类型 25 专用接口接入 | 本文未审计该旧模块 JSON,不将它记为新接口已打通 |
|
||||||
|
|
||||||
|
表中张工短路径前缀为 `/api/yf-handset-app/photog/multi-plane`;朱工短路径前缀为 `/api/app`。景区空镜库为另一个模块,不纳入本文页面清单。
|
||||||
|
|
||||||
|
## 9. 当前联调问题与约定
|
||||||
|
|
||||||
|
| 事项 | 当前证据/约定 | 责任归属/后续 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 多点位订单实时准备信息 | 当前仅请求 `project-info`;`workbench` 已停用,其业务码 100099 响应仅为历史记录 | 朱工、张工确认类型 25 的设备/距离/门禁读取入口,后续再接入 |
|
||||||
|
| 任务创建和召唤衔接 | 一个接口要求绑定已有任务,另一个文档仍自行建任务 | 两位统一同一订单飞行任务 ID、类型 25 支持、失败重试及去重规则 |
|
||||||
|
| 权威次数 | 类型 25 以张工订单摘要为准;仅有效成功任务计次 | 不回退朱工旧 `project_count/capture_num` 口径 |
|
||||||
|
| 位置与范围 | 准备页已移除仅服务 workbench 的定位请求;距离、范围当前未知 | 后续实时接口需明确未知语义、坐标系和服务端范围校验 |
|
||||||
|
| 付款码返回语义 | 新返回为小程序码图片 URL,旧支付链接存档已过时 | 按最新图片合同展示,不能重新编码 URL |
|
||||||
|
| 空收款记录样本 | 本地有 10 月 27 日空态响应 | 后续取得非空真实响应时补充;当前非空 JSON 仅引用后端文档 |
|
||||||
|
|
||||||
|
## 10. 维护与证据索引
|
||||||
|
|
||||||
|
每接入一个页面或后端修改字段时,更新以下内容:
|
||||||
|
|
||||||
|
1. 页面/动作与接口提供人,完整路径、方法、实际参数和触发时机。
|
||||||
|
2. 成功、空态、业务失败的 JSON;标明实测时间或“后端文档示例”。
|
||||||
|
3. 页面使用哪些字段,哪些值可缺失、哪些权限必须明确为 true。
|
||||||
|
4. 当前错误与待后端确认事项,避免把旧样本或演示状态写成已完成联调。
|
||||||
|
|
||||||
|
### 10.1 本文依据
|
||||||
|
|
||||||
|
- 张工提供:`multi-plane-app-integration.md`,本机输入文件位于 Desktop;以用户最新确认的接口分工为准。
|
||||||
|
- 朱工提供:`随心瞰9.9.1-App机巢与素材库接口.md`,本机输入文件位于 Desktop。
|
||||||
|
- 当前 App 的 API、ViewModel 与正式页面代码,正文各节已附项目内链接。
|
||||||
|
|
||||||
|
### 10.2 本地响应目录
|
||||||
|
|
||||||
|
| 目录 | 内容 |
|
||||||
|
| --- | --- |
|
||||||
|
| [home-split-integration-2026-10-28](docs/9.9.1/home-split-integration-2026-10-28/) | 首页三个新接口响应及截图 |
|
||||||
|
| [payment-integration-2026-10-27](docs/9.9.1/payment-integration-2026-10-27/) | 套餐、付款码、收款记录的历史响应;付款码以 mini-program 文件为准 |
|
||||||
|
| [project-info-integration-2026-10-28](docs/9.9.1/project-info-integration-2026-10-28/) | project-info 成功样本;停用前的 workbench 业务失败与页面截图 |
|
||||||
|
| [preparation-integration-2026-10-28](docs/9.9.1/preparation-integration-2026-10-28/) | 旧订单 workbench 成功样本,不能当作类型 25 成功证据 |
|
||||||
|
|
||||||
|
本次停用 `workbench` 后,模拟器构建通过,准备页 API/Model、ViewModel、页面、首页入口及共用拍摄页面相关 **59 项测试全部通过**,覆盖首次进入、刷新和重试仅请求 `project-info`。测试替身验证与真实后端响应分别记录,单元测试通过不代表已完成真实飞行或支付交付。
|
||||||