- 新增后台用车服务配置模块,支持维护服务简介、优势与使用流程 - 新增需求线索管理页面,支持筛选、查看与更新用车线索状态 - 新增小程序用车需求页面,优化登录路径与回跳逻辑 - 优化车型卡片跳转与用车需求提交功能 - 新增服务端API与数据处理逻辑,完善权限校验 - 更新全站配置与API文档,新增相关测试用例
73 lines
1.8 KiB
TypeScript
73 lines
1.8 KiB
TypeScript
import { requireLogin } from "./auth";
|
|
|
|
type QueryValue = string | number | boolean | undefined | null;
|
|
|
|
function withQuery(path: string, query: Record<string, QueryValue> = {}) {
|
|
const params = Object.entries(query)
|
|
.filter(
|
|
([, value]) => value !== undefined && value !== null && value !== "",
|
|
)
|
|
.map(
|
|
([key, value]) =>
|
|
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`,
|
|
)
|
|
.join("&");
|
|
return params ? `${path}?${params}` : path;
|
|
}
|
|
|
|
export function go(path: string, query?: Record<string, QueryValue>) {
|
|
uni.navigateTo({ url: withQuery(path, query) });
|
|
}
|
|
|
|
export function goRoot(path: string, query?: Record<string, QueryValue>) {
|
|
uni.reLaunch({ url: withQuery(path, query) });
|
|
}
|
|
|
|
export function goBack(fallback = "/pages/home/index") {
|
|
const pages = getCurrentPages();
|
|
if (pages.length > 1) {
|
|
uni.navigateBack();
|
|
return;
|
|
}
|
|
goRoot(fallback);
|
|
}
|
|
|
|
export function goWildArchives() {
|
|
go("/pages/wild-archives/index");
|
|
}
|
|
|
|
export function goPlay() {
|
|
uni.switchTab({ url: "/pages/play/index" });
|
|
}
|
|
|
|
export function goConcierge() {
|
|
uni.switchTab({ url: "/pages/concierge/index" });
|
|
}
|
|
|
|
export function goVehicleDemand(vehicleOptionId?: string) {
|
|
const path = "/pages/vehicle-demand";
|
|
const query = vehicleOptionId ? { vehicleOptionId } : undefined;
|
|
const redirect = withQuery(path, query);
|
|
if (requireLogin(redirect)) {
|
|
go(path, query);
|
|
}
|
|
}
|
|
|
|
export function goWildArchiveDetail(archiveId: string) {
|
|
go("/pages/wild-archives/detail", { id: archiveId });
|
|
}
|
|
|
|
export function goTeamBuildingDetail(teamBuildingId: string) {
|
|
go("/pages/team-buildings/detail", { id: teamBuildingId });
|
|
}
|
|
|
|
export function goWanfaRouteDetail(routeId: string) {
|
|
go("/pages/detail/index", { routeId });
|
|
}
|
|
|
|
export function goMine() {
|
|
if (requireLogin("/pages/mine/index")) {
|
|
goRoot("/pages/mine/index");
|
|
}
|
|
}
|