Commit 28ba4e9f by chenwq1

feat: 添加登出确认弹窗及相关逻辑

- 新增 `LogoutConfirmModal` 组件,提供用户登出确认功能。
- 更新用户登出逻辑,确保在登出时清除用户信息并通知宿主 WebView。
- 修改路由配置,优化车辆详情和工单详情的路由路径。
- 添加多张图片资源以支持登出确认弹窗的视觉效果。
- 优化表单输入逻辑,确保手机号和验证码仅接受数字输入。
1 parent fea3fb4d
Pipeline #103 for 28ba4e9f failed in 0 seconds
...@@ -68,7 +68,7 @@ export function login(params: LoginParams) { ...@@ -68,7 +68,7 @@ export function login(params: LoginParams) {
} }
export function logout() { export function logout() {
return post<void>("/api/user/logout"); return post<void>("/rest/auth/logout", {});
} }
export function getUserInfo() { export function getUserInfo() {
......
...@@ -11,6 +11,7 @@ declare module 'vue' { ...@@ -11,6 +11,7 @@ declare module 'vue' {
CustomizeUploadFile: typeof import('./components/customizeForm/customizeUploadFile.vue')['default'] CustomizeUploadFile: typeof import('./components/customizeForm/customizeUploadFile.vue')['default']
Index: typeof import('./components/customizeForm/Index.vue')['default'] Index: typeof import('./components/customizeForm/Index.vue')['default']
Layouts: typeof import('./layouts/index.vue')['default'] Layouts: typeof import('./layouts/index.vue')['default']
LogoutConfirmModal: typeof import('./components/LogoutConfirmModal.vue')['default']
PageTitle: typeof import('./components/PageTitle.vue')['default'] PageTitle: typeof import('./components/PageTitle.vue')['default']
PageTop: typeof import('./components/PageTop.vue')['default'] PageTop: typeof import('./components/PageTop.vue')['default']
RadioSelect: typeof import('./components/customizeForm/radioSelect.vue')['default'] RadioSelect: typeof import('./components/customizeForm/radioSelect.vue')['default']
......
<template>
<van-popup class="logout-confirm-popup"
:close-on-click-overlay="true"
position="center"
round
:show="show"
@update:show="emit('update:show', $event)">
<div class="logout-confirm">
<van-icon class="logout-confirm__close"
name="cross"
@click="close" />
<div class="logout-confirm__top">
<img alt=""
class="logout-confirm__bg"
:src="popupBg" />
<div class="logout-confirm__hero">
<img alt=""
class="logout-confirm__icon"
:src="logoutWarningIcon" />
</div>
<h2 class="logout-confirm__title">
退出登录
</h2>
<p class="logout-confirm__desc">
是否确认退出登录?
</p>
</div>
<div class="logout-confirm__actions">
<button class="logout-confirm__btn logout-confirm__btn--cancel"
type="button"
@click="close">
取消
</button>
<button class="logout-confirm__btn logout-confirm__btn--confirm"
type="button"
@click="onConfirm">
确认
</button>
</div>
</div>
</van-popup>
</template>
<script setup lang="ts">
import logoutWarningIcon from "@/assets/image/logout-warning-icon.png";
import popupBg from "@/assets/image/popup-bg.png";
defineProps<{
show: boolean;
}>();
const emit = defineEmits<{
"update:show": [value: boolean];
confirm: [];
}>();
function close() {
emit("update:show", false);
}
function onConfirm() {
emit("confirm");
}
</script>
<style lang="scss" scoped>
@use "@assets/styles/variables" as *;
.logout-confirm-popup {
box-sizing: border-box;
width: calc(100vw - 48px);
max-width: 320px;
padding: 0;
overflow: visible;
background: transparent;
}
.logout-confirm {
position: relative;
padding: 0 0 20px;
overflow: hidden;
background: #fff;
border-radius: 18px;
box-shadow: $shadow-lg;
}
.logout-confirm__close {
position: absolute;
top: 12px;
right: 12px;
z-index: 3;
padding: 4px;
font-size: 20px;
color: #969799;
}
.logout-confirm__top {
position: relative;
z-index: 0;
padding-bottom: 4px;
overflow: hidden;
border-radius: 18px 18px 0 0;
}
.logout-confirm__bg {
position: absolute;
inset: 0;
z-index: 0;
display: block;
width: 100%;
height: 100%;
object-fit: cover;
object-position: top center;
pointer-events: none;
}
.logout-confirm__hero {
position: relative;
z-index: 1;
display: flex;
align-items: flex-end;
justify-content: center;
min-height: 132px;
padding: 28px 24px 0;
}
.logout-confirm__icon {
width: 88px;
height: auto;
margin-bottom: 4px;
}
.logout-confirm__title {
position: relative;
z-index: 1;
margin: 8px 20px 0;
font-size: 18px;
font-weight: 700;
line-height: 1.3;
color: #1a2744;
text-align: center;
}
.logout-confirm__desc {
position: relative;
z-index: 1;
margin: 10px 24px 0;
font-size: 14px;
line-height: 1.45;
color: $color-text-secondary;
text-align: center;
}
.logout-confirm__actions {
position: relative;
z-index: 1;
display: flex;
gap: 12px;
padding: 24px 20px 4px;
background: #fff;
border-radius: 0 0 18px 18px;
}
.logout-confirm__btn {
flex: 1;
height: 44px;
padding: 0 16px;
font-size: 16px;
line-height: 44px;
text-align: center;
cursor: pointer;
border: none;
border-radius: $radius-full;
transition: $transition-fast;
&:active {
opacity: 0.88;
}
}
.logout-confirm__btn--cancel {
font-weight: 400;
color: $color-text-secondary;
background: #f2f3f5;
}
.logout-confirm__btn--confirm {
font-weight: 500;
color: #fff;
background: $color-primary;
}
</style>
...@@ -31,7 +31,9 @@ const auditTag = computed(() => { ...@@ -31,7 +31,9 @@ const auditTag = computed(() => {
if (props.auditStatus === undefined) return null; if (props.auditStatus === undefined) return null;
if (props.status !== 2 && props.status !== 3) return null; if (props.status !== 2 && props.status !== 3) return null;
// auditStatus: 1待审批;2审批中;3审批通过;4审批驳回 // auditStatus: 1待审批;2审批中;3审批通过;4审批驳回
// 待审核(待审批/审批中)仅在「检测完成」Tab 展示,检测中不显示
if (props.auditStatus === 1 || props.auditStatus === 2) { if (props.auditStatus === 1 || props.auditStatus === 2) {
if (props.status !== 3) return null;
return { text: "待审核", bg: "#f0eefd", color: "#6A56F0", icon: "clock" as const }; return { text: "待审核", bg: "#f0eefd", color: "#6A56F0", icon: "clock" as const };
} }
if (props.auditStatus === 3) { if (props.auditStatus === 3) {
......
/*
* @Author: cen
* @Date: 2026-03-24 17:37:44
* @Description:
* @FilePath: /venus-usedcar-h5/apps/web/venus-usedcar-quality/src/router/routes.ts
* @LastEditTime: 2026-03-25 19:41:22
* @LastEditors: cenchengwei@foreverht.com
* 可以输入预定的版权声明、个性签名、空行等
*/
import type { RouteRecordRaw } from "vue-router"; import type { RouteRecordRaw } from "vue-router";
const routes: RouteRecordRaw[] = [ const routes: RouteRecordRaw[] = [
...@@ -48,37 +57,29 @@ const routes: RouteRecordRaw[] = [ ...@@ -48,37 +57,29 @@ const routes: RouteRecordRaw[] = [
showTabBar: true, showTabBar: true,
}, },
}, },
{
path: "car-detail/:id",
name: "CarDetail",
component: () => import("@views/car-detail/index.vue"),
meta: {
title: "车辆详情",
keepAlive: false,
showTabBar: false,
},
},
{
path: "word-order-detail/:id",
name: "WorkOrderDetail",
component: () => import("@views/word-order-detail/index.vue"),
meta: {
title: "工单详情",
keepAlive: false,
showTabBar: false,
},
},
], ],
}, },
{ {
path: "/car-detail/:id",
name: "CarDetail",
component: () => import("@views/car-detail/index.vue"),
meta: {
title: "车辆详情",
showTabBar: false,
},
},
/** 开发自测:OSS 分片上传 */
{
path: "/upload-demo",
name: "UploadDemo",
component: () => import("@views/upload-demo/index.vue"),
meta: {
title: "OSS 上传 Demo",
showTabBar: false,
},
},
{
path: "/word-order-detail/:id",
name: "WorkOrderDetail",
component: () => import("@views/word-order-detail/index.vue"),
meta: {
title: "工单详情",
showTabBar: false,
},
},
{
path: "/:pathMatch(.*)*", path: "/:pathMatch(.*)*",
name: "NotFound", name: "NotFound",
component: () => import("@views/404/index.vue"), component: () => import("@views/404/index.vue"),
......
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { ref, computed } from "vue"; import { ref, computed } from "vue";
import { logout as requestAuthLogout } from "@/api/modules/user";
import { notifyHostLogout } from "@/utils/webviewBridge";
const TOKEN_KEY = "venus_usedcar_token"; const TOKEN_KEY = "venus_usedcar_token";
/** 与 `router/index.ts`、登录页一致,登出时清掉避免沿用旧回跳地址 */
const LOGIN_REDIRECT_KEY = "venus_usedcar_login_redirect";
export interface UserInfo { export interface UserInfo {
id: number; id: number;
...@@ -32,10 +37,23 @@ export const useUserStore = defineStore( ...@@ -32,10 +37,23 @@ export const useUserStore = defineStore(
userInfo.value = info; userInfo.value = info;
} }
function logout() { /** 调服务端登出后清空 token、用户信息、本地缓存,并通知宿主 WebView */
token.value = ""; async function logout() {
userInfo.value = null; try {
localStorage.removeItem(TOKEN_KEY); if (token.value) {
await requestAuthLogout();
}
} catch {
// 接口失败仍执行本地登出
} finally {
token.value = "";
userInfo.value = null;
localStorage.removeItem(TOKEN_KEY);
notifyHostLogout();
}
sessionStorage.removeItem(LOGIN_REDIRECT_KEY);
const { default: router } = await import("@/router");
await router.replace({ path: "/login" });
} }
return { return {
......
...@@ -109,7 +109,7 @@ export function initTokenBridge() { ...@@ -109,7 +109,7 @@ export function initTokenBridge() {
} }
} }
if (type === "LOGOUT") { if (type === "LOGOUT") {
userStore.logout(); void userStore.logout();
} }
}); });
} }
......
...@@ -55,7 +55,9 @@ ...@@ -55,7 +55,9 @@
@click="openRatingGuide('frame')" @click="openRatingGuide('frame')"
@keydown.enter.prevent="openRatingGuide('frame')" @keydown.enter.prevent="openRatingGuide('frame')"
@keydown.space.prevent="openRatingGuide('frame')"> @keydown.space.prevent="openRatingGuide('frame')">
参考 <img alt="指引"
class="score-ref-icon"
:src="systemTipImg" />
</span> </span>
</div> </div>
<div class="rating-btns"> <div class="rating-btns">
...@@ -64,11 +66,11 @@ ...@@ -64,11 +66,11 @@
class="rating-btn" class="rating-btn"
:class="{ active: form.frameRating === opt }" :class="{ active: form.frameRating === opt }"
@click="form.frameRating = opt"> @click="form.frameRating = opt">
<span v-if="form.frameRating === opt" <img v-if="form.frameRating === opt"
aria-hidden="true" alt=""
class="rating-btn-check"> aria-hidden="true"
☑️ class="rating-btn-check"
</span> :src="ratingSelectedCheckImg" />
{{ opt }} {{ opt }}
</div> </div>
</div> </div>
...@@ -93,7 +95,9 @@ ...@@ -93,7 +95,9 @@
@click="openRatingGuide('interior')" @click="openRatingGuide('interior')"
@keydown.enter.prevent="openRatingGuide('interior')" @keydown.enter.prevent="openRatingGuide('interior')"
@keydown.space.prevent="openRatingGuide('interior')"> @keydown.space.prevent="openRatingGuide('interior')">
参考 <img alt="指引"
class="score-ref-icon"
:src="systemTipImg" />
</span> </span>
</div> </div>
<div class="rating-btns"> <div class="rating-btns">
...@@ -102,11 +106,11 @@ ...@@ -102,11 +106,11 @@
class="rating-btn" class="rating-btn"
:class="{ active: form.interiorRating === opt }" :class="{ active: form.interiorRating === opt }"
@click="form.interiorRating = opt"> @click="form.interiorRating = opt">
<span v-if="form.interiorRating === opt" <img v-if="form.interiorRating === opt"
aria-hidden="true" alt=""
class="rating-btn-check"> aria-hidden="true"
☑️ class="rating-btn-check"
</span> :src="ratingSelectedCheckImg" />
{{ opt }} {{ opt }}
</div> </div>
</div> </div>
...@@ -180,6 +184,8 @@ import type { RatingGuideConfig } from "./rating-guide-content"; ...@@ -180,6 +184,8 @@ import type { RatingGuideConfig } from "./rating-guide-content";
import { reactive, ref, watch } from "vue"; import { reactive, ref, watch } from "vue";
import ratingSelectedCheckImg from "@/assets/image/rating-selected-check.png";
import systemTipImg from "@/assets/image/system-tip.png";
import { SCORE_RATING_OPTIONS as RATING_OPTIONS } from "@/types/views/car-detail"; import { SCORE_RATING_OPTIONS as RATING_OPTIONS } from "@/types/views/car-detail";
import { getInspectionChildren } from "@api"; import { getInspectionChildren } from "@api";
import { isRequestFailureAlreadyHandled } from "@utils/request"; import { isRequestFailureAlreadyHandled } from "@utils/request";
...@@ -422,12 +428,16 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -422,12 +428,16 @@ defineExpose({ validate, getCompleteInspectionPayload });
} }
.score-ref { .score-ref {
padding: 2px 8px; display: inline-flex;
font-size: 12px; align-items: center;
color: #185efe; justify-content: center;
cursor: pointer; cursor: pointer;
border: 1px solid #185efe; }
border-radius: 4px;
.score-ref-icon {
display: block;
height: 16px;
width: auto;
} }
.score-slider-wrap { .score-slider-wrap {
...@@ -485,8 +495,9 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -485,8 +495,9 @@ defineExpose({ validate, getCompleteInspectionPayload });
position: absolute; position: absolute;
top: 2px; top: 2px;
right: 2px; right: 2px;
font-size: 10px; width: 14px;
line-height: 1; height: 14px;
object-fit: contain;
pointer-events: none; pointer-events: none;
} }
} }
......
...@@ -475,13 +475,22 @@ function leafRecordFromValidateNode(raw: CustomizeFormValidateNode): LeafNodeRec ...@@ -475,13 +475,22 @@ function leafRecordFromValidateNode(raw: CustomizeFormValidateNode): LeafNodeRec
async function saveCurrentLeafInspectionRecord(nextFlag: boolean): Promise<boolean> { async function saveCurrentLeafInspectionRecord(nextFlag: boolean): Promise<boolean> {
const saved = (await customizeFormRef.value?.saveData?.()) as CustomizeFormValidateResult | undefined; const saved = (await customizeFormRef.value?.saveData?.()) as CustomizeFormValidateResult | undefined;
const rows = saved?.data; const rows = saved?.data;
console.log("saveCurrentLeafInspectionRecord", rows);
if (!rows?.length) return false; if (!rows?.length) return false;
const leafNodes = rows.map((row) => leafRecordFromValidateNode(row)); const leafNodes = rows.map((row) => leafRecordFromValidateNode(row));
await saveInspectionRecord(buildInspectionSavePayload(leafNodes, nextFlag)); await saveInspectionRecord(buildInspectionSavePayload(leafNodes, nextFlag));
return true; return true;
} }
/** 下一步保存成功后同步当前二级 Tab 完成态,避免进度条与 Tab 勾选依赖再次拉模板 */
function markActiveSubTabCompletedLocally() {
if (activeBigKey.value === SCORE_BIG_KEY) return;
const mod = bigModules.value.find((m) => m.key === activeBigKey.value);
const sub = mod?.subTabs.find((s) => s.key === activeSubKey.value);
if (sub) {
sub.completedFlag = 1;
}
}
/** 切换大项 / 二级项前静默落库当前叶子数据 */ /** 切换大项 / 二级项前静默落库当前叶子数据 */
async function persistCurrentSubTabSilently() { async function persistCurrentSubTabSilently() {
if (activeBigKey.value === SCORE_BIG_KEY) return; if (activeBigKey.value === SCORE_BIG_KEY) return;
...@@ -524,6 +533,7 @@ async function onNext() { ...@@ -524,6 +533,7 @@ async function onNext() {
showToast("未获取到表单数据"); showToast("未获取到表单数据");
return; return;
} }
markActiveSubTabCompletedLocally();
advanceInspectionStep(); advanceInspectionStep();
} catch (error) { } catch (error) {
if (!isRequestFailureAlreadyHandled(error)) { if (!isRequestFailureAlreadyHandled(error)) {
......
<script setup lang="ts"> <script setup lang="ts">
import { onActivated, ref, watch } from "vue"; import type { ReportItem } from "@/types/views/car-list";
import { computed, onActivated, ref, watch } from "vue";
import { useRouter } from "vue-router";
import { getInspectReportPage } from "@/api/modules/inspect-report.ts"; import { getInspectReportPage } from "@/api/modules/inspect-report.ts";
import PageTop from "@/components/PageTop.vue"; import PageTop from "@/components/PageTop.vue";
import type { ReportItem } from "@/types/views/car-list";
import { showToast } from "vant"; const router = useRouter();
const keyword = ref(""); const keyword = ref("");
const refreshing = ref(false); const refreshing = ref(false);
...@@ -15,6 +18,14 @@ const currentPage = ref(1); ...@@ -15,6 +18,14 @@ const currentPage = ref(1);
const displayList = ref<ReportItem[]>([]); const displayList = ref<ReportItem[]>([]);
const scroller = ref<Element | undefined>(undefined); const scroller = ref<Element | undefined>(undefined);
const listEmpty = computed(
() =>
!refreshing.value &&
!loading.value &&
displayList.value.length === 0 &&
finished.value,
);
function resetList() { function resetList() {
currentPage.value = 1; currentPage.value = 1;
finished.value = false; finished.value = false;
...@@ -89,7 +100,7 @@ async function onRefresh() { ...@@ -89,7 +100,7 @@ async function onRefresh() {
} }
function onViewReport(item: ReportItem) { function onViewReport(item: ReportItem) {
showToast(`查看报告:${item.reportNo}`); void router.push({ name: "CarDetail", params: { id: String(item.id) } });
} }
watch([keyword], () => { watch([keyword], () => {
...@@ -116,9 +127,14 @@ void onRefresh(); ...@@ -116,9 +127,14 @@ void onRefresh();
<div ref="scroller" class="list-wrap"> <div ref="scroller" class="list-wrap">
<van-pull-refresh v-model="refreshing" @refresh="onRefresh"> <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list v-model:loading="loading" <div v-if="listEmpty"
class="list-empty">
<van-empty description="暂无数据" />
</div>
<van-list v-else
v-model:loading="loading"
:finished="finished" :finished="finished"
finished-text="没有更多了" finished-text="到底了"
:scroller="scroller" :scroller="scroller"
@load="onLoad"> @load="onLoad">
<div v-for="item in displayList" <div v-for="item in displayList"
...@@ -197,6 +213,14 @@ void onRefresh(); ...@@ -197,6 +213,14 @@ void onRefresh();
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
.list-empty {
display: flex;
align-items: center;
justify-content: center;
min-height: 220px;
padding: 32px 0;
}
.report-card { .report-card {
padding: 12px; padding: 12px;
margin-bottom: 12px; margin-bottom: 12px;
......
...@@ -28,11 +28,20 @@ const tabCounts = ref({ ...@@ -28,11 +28,20 @@ const tabCounts = ref({
}); });
const statusTabs = computed(() => [ const statusTabs = computed(() => [
{ status: 1 as const, label: "待检测", count: tabCounts.value.dispatchedCount }, { status: 1 as const, label: "待检测 ·", count: tabCounts.value.dispatchedCount },
{ status: 2 as const, label: "检测中", count: tabCounts.value.inProgressCount }, { status: 2 as const, label: "检测中 ·", count: tabCounts.value.inProgressCount },
{ status: 3 as const, label: "检测完成", count: tabCounts.value.completedCount }, { status: 3 as const, label: "检测完成 ·", count: tabCounts.value.completedCount },
]); ]);
/** 首屏/刷新结束后仍无数据 */
const listEmpty = computed(
() =>
!refreshing.value &&
!loading.value &&
displayList.value.length === 0 &&
finished.value,
);
// tag 样式与映射由 WorkOrderStatusTags 统一处理 // tag 样式与映射由 WorkOrderStatusTags 统一处理
function resetList() { function resetList() {
...@@ -257,9 +266,14 @@ void onRefresh(); ...@@ -257,9 +266,14 @@ void onRefresh();
<!-- 列表(独立滚动区域) --> <!-- 列表(独立滚动区域) -->
<div ref="scroller" class="list-wrap"> <div ref="scroller" class="list-wrap">
<van-pull-refresh v-model="refreshing" @refresh="onRefresh"> <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list v-model:loading="loading" <div v-if="listEmpty"
class="list-empty">
<van-empty description="暂无数据" />
</div>
<van-list v-else
v-model:loading="loading"
:finished="finished" :finished="finished"
finished-text="没有更多了" finished-text="到底了"
:scroller="scroller" :scroller="scroller"
@load="onLoad"> @load="onLoad">
<div v-for="item in displayList" <div v-for="item in displayList"
...@@ -303,7 +317,7 @@ void onRefresh(); ...@@ -303,7 +317,7 @@ void onRefresh();
<div class="card-footer"> <div class="card-footer">
<div class="card-bottom"> <div class="card-bottom">
派单于 {{ item.dispatchTime }} <span class="k">派单于</span> <span class="v">{{ item.dispatchTime }}</span>
</div> </div>
<div class="card-actions" <div class="card-actions"
@click.stop="stopCardFooterBubbling"> @click.stop="stopCardFooterBubbling">
...@@ -405,6 +419,14 @@ void onRefresh(); ...@@ -405,6 +419,14 @@ void onRefresh();
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
.list-empty {
display: flex;
align-items: center;
justify-content: center;
min-height: 220px;
padding: 32px 0;
}
.order-card { .order-card {
padding: 12px; padding: 12px;
margin-bottom: 12px; margin-bottom: 12px;
...@@ -476,8 +498,15 @@ void onRefresh(); ...@@ -476,8 +498,15 @@ void onRefresh();
.card-bottom { .card-bottom {
min-width: 0; min-width: 0;
font-size: $font-size-xs; font-size: 12px;
color: $color-text-disabled; .k {
margin-right: 6px;
color: #999ea8;
}
.v {
color: #666666;
}
} }
.card-actions { .card-actions {
...@@ -499,7 +528,7 @@ void onRefresh(); ...@@ -499,7 +528,7 @@ void onRefresh();
:deep(.wo-btn) { :deep(.wo-btn) {
height: auto; height: auto;
padding: 6px 12px; padding: 10px 12px;
font-size: 13px; font-size: 13px;
font-weight: 400; font-weight: 400;
line-height: 1; line-height: 1;
......
...@@ -32,18 +32,20 @@ const { ...@@ -32,18 +32,20 @@ const {
<van-field v-model="phone" <van-field v-model="phone"
class="rounded-full login-input" class="rounded-full login-input"
clearable clearable
inputmode="numeric"
label="手机号" label="手机号"
maxlength="11" maxlength="11"
placeholder="请输入手机号" placeholder="请输入手机号"
type="tel" /> type="digit" />
<van-field v-model="code" <van-field v-model="code"
class="rounded-full login-input" class="rounded-full login-input"
clearable clearable
inputmode="numeric"
label="验证码" label="验证码"
maxlength="6" maxlength="6"
placeholder="请输入验证码" placeholder="请输入验证码"
type="tel"> type="digit">
<template #button> <template #button>
<van-button class="login-send-code-btn p-0 text-[13px] leading-[1.25]" <van-button class="login-send-code-btn p-0 text-[13px] leading-[1.25]"
:class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'" :class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'"
......
...@@ -28,18 +28,20 @@ const { ...@@ -28,18 +28,20 @@ const {
<van-field v-model="phone" <van-field v-model="phone"
class="rounded-full login-input" class="rounded-full login-input"
clearable clearable
inputmode="numeric"
label="手机号" label="手机号"
maxlength="11" maxlength="11"
placeholder="请输入手机号" placeholder="请输入手机号"
type="tel" /> type="digit" />
<van-field v-model="code" <van-field v-model="code"
class="rounded-full login-input" class="rounded-full login-input"
clearable clearable
inputmode="numeric"
label="验证码" label="验证码"
maxlength="6" maxlength="6"
placeholder="请输入验证码" placeholder="请输入验证码"
type="tel"> type="digit">
<template #button> <template #button>
<van-button class="p-0 text-[13px]" <van-button class="p-0 text-[13px]"
:class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'" :class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'"
......
import { ref } from "vue"; import { ref, watch } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { showFailToast, showSuccessToast } from "vant"; import { showFailToast, showSuccessToast } from "vant";
...@@ -17,6 +17,16 @@ export function useLogin() { ...@@ -17,6 +17,16 @@ export function useLogin() {
const code = ref(""); const code = ref("");
const agreed = ref(false); const agreed = ref(false);
/** 仅数字 + 长度上限;配合 Field type=digit,并兜底粘贴等非数字字符 */
watch(phone, (v) => {
const n = v.replace(/\D/g, "").slice(0, 11);
if (n !== v) phone.value = n;
});
watch(code, (v) => {
const n = v.replace(/\D/g, "").slice(0, 6);
if (n !== v) code.value = n;
});
const sending = ref(false); const sending = ref(false);
const countdown = ref(0); const countdown = ref(0);
const hasSent = ref(false); const hasSent = ref(false);
......
<script setup lang="ts"> <script setup lang="ts">
import type { InspectDetailAccount } from "@/api/modules/user";
import { computed, onActivated, onMounted, ref, watch } from "vue"; import { computed, onActivated, onMounted, ref, watch } from "vue";
import type { InspectDetailAccount } from "@/api/modules/user";
import { getInspectDetail } from "@/api/modules/user"; import { getInspectDetail } from "@/api/modules/user";
import LogoutConfirmModal from "@/components/LogoutConfirmModal.vue";
import PageTop from "@/components/PageTop.vue"; import PageTop from "@/components/PageTop.vue";
import { useUserStore } from "@/stores"; import { useUserStore } from "@/stores";
import { showToast } from "vant"; import { showToast } from "vant";
const userStore = useUserStore(); const userStore = useUserStore();
const showLogoutConfirm = ref(false);
const avgInspectCost = ref<number>(0); const avgInspectCost = ref<number>(0);
const inspectAccount = ref<InspectDetailAccount | null>(null); const inspectAccount = ref<InspectDetailAccount | null>(null);
const avgInspectCostText = computed(() => `${avgInspectCost.value || 0}秒`); /** 接口 `avgInspectCost` 为秒,展示为「X小时Y分」;不足 1 分钟且大于 0 时显示「不足1分」 */
function formatAvgInspectCostSeconds(totalSeconds: number): string {
const s = Math.max(0, Math.floor(Number(totalSeconds) || 0));
const h = Math.floor(s / 3600);
const m = Math.floor((s % 3600) / 60);
if (h > 0 && m > 0) return `${h}小时${m}分`;
if (h > 0) return `${h}小时`;
if (m > 0) return `${m}分`;
if (s > 0) return "不足1分";
return "0分";
}
const avgInspectCostText = computed(() => formatAvgInspectCostSeconds(avgInspectCost.value));
const displayName = computed(() => const displayName = computed(() =>
userStore.isLoggedIn ? inspectAccount.value?.name || userStore.username : "" userStore.isLoggedIn ? inspectAccount.value?.name || userStore.username : ""
...@@ -50,8 +65,14 @@ function onLogin() { ...@@ -50,8 +65,14 @@ function onLogin() {
showToast("登录功能开发中"); showToast("登录功能开发中");
} }
async function onLogout() { function onLogoutTap() {
userStore.logout(); if (!userStore.isLoggedIn) return;
showLogoutConfirm.value = true;
}
async function onLogoutConfirm() {
showLogoutConfirm.value = false;
await userStore.logout();
avgInspectCost.value = 0; avgInspectCost.value = 0;
inspectAccount.value = null; inspectAccount.value = null;
showToast("已退出登录"); showToast("已退出登录");
...@@ -119,23 +140,19 @@ watch( ...@@ -119,23 +140,19 @@ watch(
<div class="logout-wrap"> <div class="logout-wrap">
<van-button block <van-button block
class="logout-btn" class="logout-btn"
round @click="onLogoutTap">
@click="onLogout">
退出登录 退出登录
</van-button> </van-button>
</div> </div>
<!-- 版本号 -->
<div class="app-version">
当前版本 v{{ __APP_VERSION__ ?? '1.0.0' }}
</div>
</div> </div>
<LogoutConfirmModal :show="showLogoutConfirm"
@confirm="onLogoutConfirm"
@update:show="showLogoutConfirm = $event" />
</div> </div>
</template> </template>
<script lang="ts">
const __APP_VERSION__ = "1.0.0";
</script>
<style lang="scss" scoped> <style lang="scss" scoped>
@use "@assets/styles/variables" as *; @use "@assets/styles/variables" as *;
...@@ -217,16 +234,23 @@ const __APP_VERSION__ = "1.0.0"; ...@@ -217,16 +234,23 @@ const __APP_VERSION__ = "1.0.0";
} }
.logout-wrap { .logout-wrap {
padding: 0 12px; padding: 0 12px 40px;
margin-top: auto; margin-top: auto;
} }
.logout-btn { .logout-btn {
height: 44px; height: 44px;
color: $color-text-primary; font-size: 16px;
background: #fff; font-weight: 400;
border: 0; color: #222222;
box-shadow: 0 1px 0 rgb(0 0 0 / 4%); background: #ffffff;
border-radius: 8px;
opacity: 1;
box-shadow: none;
&:active::before {
opacity: 0;
}
} }
.app-version { .app-version {
......
<script setup lang="ts">
import { ref } from "vue";
import PageTop from "@/components/PageTop.vue";
import { OSS_CONFIG } from "@/config/oss";
import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant";
const fileInputRef = ref<HTMLInputElement | null>(null);
const uploading = ref(false);
const lastResult = ref<Record<string, unknown> | null>(null);
const lastError = ref<string>("");
function pickFile() {
lastError.value = "";
lastResult.value = null;
fileInputRef.value?.click();
}
async function onFileChange(ev: Event) {
const input = ev.target as HTMLInputElement;
const file = input.files?.[0];
input.value = "";
if (!file) return;
uploading.value = true;
lastError.value = "";
lastResult.value = null;
try {
const res = (await uploadFile(file)) as Record<string, unknown>;
lastResult.value = res;
const url =
(typeof res.aliyunAddress === "string" && res.aliyunAddress) ||
(typeof res.url === "string" && res.url) ||
"";
showToast(url ? "上传成功" : "上传完成(无 URL 字段)");
} catch (e: unknown) {
const msg = e instanceof Error ? e.message : String(e);
lastError.value = msg;
showToast(`上传失败:${msg}`);
} finally {
uploading.value = false;
}
}
</script>
<template>
<div class="upload-demo">
<PageTop title="OSS 上传 Demo" />
<div class="card">
<p class="hint">
使用 <code>utils/upload.js</code> 的 <code>uploadFile</code>,桶 <code>{{ OSS_CONFIG.BUCKET_NAME }}</code>,目录
<code>{{ OSS_CONFIG.FOLDER }}</code>
</p>
<input ref="fileInputRef"
accept="image/*"
class="hidden-input"
type="file"
@change="onFileChange">
<van-button :loading="uploading"
block
type="primary"
@click="pickFile">
{{ uploading ? "上传中…" : "选择图片并上传" }}
</van-button>
<div v-if="lastError" class="block error">
<div class="label">错误</div>
<pre>{{ lastError }}</pre>
</div>
<div v-if="lastResult" class="block ok">
<div class="label">返回(JSON)</div>
<pre>{{ JSON.stringify(lastResult, null, 2) }}</pre>
</div>
</div>
</div>
</template>
<style scoped lang="scss">
.upload-demo {
min-height: 100vh;
background: #f5f6f7;
}
.card {
margin: 12px;
padding: 16px;
background: #fff;
border-radius: 8px;
}
.hint {
margin: 0 0 16px;
font-size: 12px;
color: #646566;
line-height: 1.5;
code {
padding: 0 4px;
font-size: 11px;
background: #f2f3f5;
border-radius: 2px;
}
}
.hidden-input {
position: absolute;
width: 0;
height: 0;
opacity: 0;
pointer-events: none;
}
.block {
margin-top: 16px;
padding: 12px;
border-radius: 6px;
font-size: 12px;
.label {
margin-bottom: 8px;
font-weight: 600;
color: #323233;
}
pre {
margin: 0;
white-space: pre-wrap;
word-break: break-all;
font-size: 11px;
line-height: 1.4;
}
}
.block.error {
background: #fff1f0;
color: #cf1322;
}
.block.ok {
background: #f6ffed;
color: #389e0d;
}
</style>
...@@ -63,7 +63,7 @@ function fmtTime(v?: string) { ...@@ -63,7 +63,7 @@ function fmtTime(v?: string) {
} }
function continueCheck():void { function continueCheck():void {
const id = route.params.id as string; const id = route.params.id as string;
router.push({ name: "CarDetail", params: { taskId: id } }); router.push({ name: "CarDetail", params: { id } });
} }
const onBack=()=>{ const onBack=()=>{
router.back(); router.back();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!