feat(router,auth,components): implement token check and refactor navigation and UI

implement proper token validation in checkToken hook that redirects to login when no token exists
replace uni.navigateTo with vue-router's push for unified page navigation
update route names to camelCase (order_list → orderList) for consistent naming
refactor quick booking page: add named route usage, remove unused z-paging, swap uni-icons to van-icon, fix inline styles
update development environment token for testing
This commit is contained in:
duanshuwen
2026-05-31 17:47:18 +08:00
parent 567776f975
commit 5064d7b444
5 changed files with 32 additions and 26 deletions

View File

@@ -7,7 +7,18 @@ export const goLogin = () => {};
export const goBack = () => {};
// 检测token
export const checkToken = () => {};
export const checkToken = () => {
const token = true || localStorage.getItem("token");
return new Promise((resolve) => {
if (!token) {
goLogin();
return;
}
resolve(token);
});
};
// 登录逻辑
export const onLogin = async () => {};

View File

@@ -15,11 +15,13 @@
<script setup>
import { ref } from "vue";
import { useRouter } from 'vue-router'
import { emitter } from '@/utils/events'
import { Command } from "@/constants/ChatModel";
import { SEND_MESSAGE_COMMAND_TYPE } from "@/constants/constant";
import { checkToken } from "@/hooks/useGoLogin";
const router = useRouter();
const itemList = ref([
{
icon: "",
@@ -53,7 +55,7 @@ const sendReply = (item) => {
// 快速预定
if (item.type === Command.quickBooking) {
checkToken().then(() => {
uni.navigateTo({ url: "/pages-quick/list" });
router.push({ name: "quick" });
});
return;
}
@@ -61,11 +63,12 @@ const sendReply = (item) => {
// 我的订单
if (item.type === Command.myOrder) {
checkToken().then(() => {
uni.navigateTo({ url: "/pages-order/order/list" });
router.push({ name: "orderList" });
});
return;
}
// 呼叫服务
emitter.emit(SEND_MESSAGE_COMMAND_TYPE, item);
};
</script>

View File

@@ -1,11 +1,8 @@
<template>
<z-paging ref="paging" v-model="dataList" use-virtual-list :force-close-inner-list="true" cell-height-mode="dynamic"
safe-area-inset-bottom @query="queryList">
<template #top>
<TopNavBar title="快速预定" :background="$theme - color - 100" />
<Tabs @change="handleTabChange" />
<div>
<TopNavBar title="快速预定" />
<Tabs @change="handleTabChange" />
<div>
<!-- 选择入住离店日期 0:是酒店 -->
<div v-if="didSelectedTabItem && didSelectedTabItem.orderType == 0" class="bg-white flex items-center p-[12px]">
<div class="in flex items-center">
@@ -16,7 +13,8 @@
</div>
<!-- 几晚 -->
<span class="nights bg-E5E8EE text-[11px] font-medium text-ink-600 rounded-[5px] ml-[8px] mr-[8px]">
<span
class="py-[3px] px-[6px] bg-[#E5E8EE] text-[11px] font-medium text-ink-600 rounded-[5px] ml-[8px] mr-[8px]">
{{ selectedDate.totalDays }}
</span>
@@ -28,16 +26,16 @@
</div>
<!-- 日期图标 -->
<uni-icons class="ml-auto" type="calendar" size="24" color="#0CCD58" @click="calendarVisible = true" />
<van-icon class="ml-auto" type="calendar" size="24" color="#0CCD58" @click="calendarVisible = true" />
</div>
</template>
<Card v-for="(item, index) in dataList" :key="index" :item="item" :selectedDate="selectedDate" />
</z-paging>
<Card v-for="(item, index) in dataList" :key="index" :item="item" :selectedDate="selectedDate" />
</div>
<!-- 日历组件 -->
<Calender :visible="calendarVisible" mode="range" :default-value="selectedDate" @close="handleCalendarClose"
@range-select="handleDateSelect" />
<!-- 日历组件 -->
<Calender :visible="calendarVisible" mode="range" :default-value="selectedDate" @close="handleCalendarClose"
@range-select="handleDateSelect" />
</div>
</template>
<script setup lang="ts">
@@ -115,9 +113,3 @@ const handleDateSelect = (data) => {
paging.value.reload();
};
</script>
<style scoped lang="scss">
.nights {
padding: 3px 6px;
}
</style>

View File

@@ -39,7 +39,7 @@ export const routes = [
},
{
path: "/order",
name: "order_list",
name: "orderList",
component: () => import("@/pages/order/order/list.vue"),
},
{