Commit 5468ed5b by 前端

Merge branch 'release/venus-usedcar-h5/1.2.0' into 'master'

上线合并

See merge request !22
2 parents 4edfd455 345ec455
Pipeline #241 for 5468ed5b failed in 0 seconds
import { gscPost } from "@/utils/gscRequest";
import { boutiquePost, carlifePost } from "@utils/ropRequest";
// 获取车辆品牌数据
export function getCarBrandList(params: { sessionId: string, }) {
return carlifePost<unknown>("scrm.api.carlife.common.getOnlyCarBrandList", params);
}
// 获取车系数据
export function getCarSeriesList(params: { brandId: string; childBrandId: string }) {
return carlifePost<unknown>("scrm.api.carlife.common.getCarSeriesList", params);
}
// 获取车型数据
export function getCarTypeList(params: { carSeriesId: string }) {
return carlifePost<unknown>("scrm.api.carlife.common.getCarTypeList", params);
}
// 获取门店销售顾问列表
export function getStoreConsultants(merchantId: number | string) {
return boutiquePost<unknown>("dj.api.smartcarlife.employee.onTheJob.getByMerchantId", { merchantId });
}
// 新增线索
export function addClueApi(data: any) {
return gscPost<unknown>("/gsc-vcp-pad-facade/clues/add", data);
}
// 线索详情
export function getClueDetailApi(data: any) {
return gscPost<unknown>("/gsc-vcp-pad-facade/clues/detail", data);
}
// 线索详情跟进记录列表
export function getClueFollowUpListApi(data: any) {
return gscPost<unknown>("/gsc-vcp-pad-facade/clues/followRecord/list", data);
}
// 根据商户号反查园区店下的所有驻店员工
export function getStoreEmployeesByMerchantId(params: { merchantId: number | string }) {
return gscPost<unknown>("/gsc-vcp-pad-facade/staff/listSceneMerchantStaff", params);
}
......@@ -24,6 +24,7 @@ declare module 'vue' {
SelectDropdown: typeof import('./components/CustomizeForm/selectDropdown.vue')['default']
VanActionSheet: typeof import('vant/es')['ActionSheet']
VanButton: typeof import('vant/es')['Button']
VanCell: typeof import('vant/es')['Cell']
VanDatePicker: typeof import('vant/es')['DatePicker']
VanDialog: typeof import('vant/es')['Dialog']
VanEmpty: typeof import('vant/es')['Empty']
......
/*
* @Author: cen
* @Date: 2026-04-02 15:37:28
* @Description:
* @Description:
* @FilePath: /venus-usedcar-h5/apps/web/venus-usedcar-quality/src/router/index.ts
* @LastEditTime: 2026-04-03 14:18:49
* @LastEditors: cenchengwei@foreverht.com
......@@ -31,7 +31,7 @@ const router = createRouter({
});
// 不需要登录的白名单路由
const WHITE_LIST = new Set(["/ai-purchase", "/inspect-detail", "/inspect-report", "/login", "/scan-livecode", "/vehicle-brief", "/vehicle-detail", "/vehicle-list"]);
const WHITE_LIST = new Set(["/add-clue", "/add-clue/brand", "/add-clue/series", "/ai-purchase", "/clue-detail", "/inspect-detail", "/inspect-report", "/login", "/scan-livecode", "/vehicle-brief", "/vehicle-detail", "/vehicle-list"]);
router.beforeEach(async (to, from, next) => {
const userStore = useUserStore();
......
......@@ -67,6 +67,42 @@ const routes: RouteRecordRaw[] = [
},
},
{
path: "/add-clue",
name: "AddClue",
component: () => import("@views/add-clue/index.vue"),
meta: {
title: "新增线索",
showTabBar: false,
},
},
{
path: "/clue-detail",
name: "ClueDetail",
component: () => import("@views/clue-detail/index.vue"),
meta: {
title: "线索详情",
showTabBar: false,
},
},
{
path: "/add-clue/brand",
name: "AddClueBrand",
component: () => import("@views/add-clue/brand/index.vue"),
meta: {
title: "选择品牌",
showTabBar: false,
},
},
{
path: "/add-clue/series",
name: "AddClueSeries",
component: () => import("@views/add-clue/series/index.vue"),
meta: {
title: "选择车系",
showTabBar: false,
},
},
{
path: "/",
component: () => import("@/layouts/index.vue"),
children: [
......
......@@ -43,6 +43,10 @@ function getSecretKey(service?: string): string {
env = cfg.boutiqueApiEnv as undefined | { secret?: string };
break;
}
case "carlife": {
env = cfg.scrmCarlifeApiEnv as undefined | {secret?: string};
break;
}
case "sso": {
env = cfg.ssoApiEnv as undefined | { secret?: string };
break;
......@@ -68,6 +72,10 @@ function getAppKey(service?: string): string {
env = cfg.boutiqueApiEnv as undefined | { appKey?: string };
break;
}
case "carlife": {
env = cfg.scrmCarlifeApiEnv as undefined | { appKey?: string };
break;
}
case "sso": {
env = cfg.ssoApiEnv as undefined | { appKey?: string };
break;
......@@ -205,9 +213,9 @@ type RopService = {
resolveBaseURL: () => string;
};
type ServiceName = "boutique" | "clue" | "sso" | "stoassistant" | (string & {});
type ServiceName = "boutique" | "carlife" | "clue" | "sso" | "stoassistant" | (string & {});
const DEFAULT_SERVICES: Record<"boutique" | "clue" | "sso" | "stoassistant", RopService> = {
const DEFAULT_SERVICES: Record<"boutique" | "carlife" | "clue" | "sso" | "stoassistant", RopService> = {
stoassistant: {
resolveBaseURL: () => {
const cfg = getConfig() as Record<string, unknown>;
......@@ -238,6 +246,16 @@ const DEFAULT_SERVICES: Record<"boutique" | "clue" | "sso" | "stoassistant", Rop
return apiBaseUrl || "/";
},
},
carlife: {
resolveBaseURL: () => {
const cfg = getConfig() as Record<string, unknown>;
const apiBaseUrl =
((cfg.scrmCarlifeApiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseURL ??
(cfg.scrmCarlifeApiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseUrl ??
"") as string | undefined;
return apiBaseUrl || "/";
},
},
clue: {
resolveBaseURL: () => {
const cfg = getConfig() as Record<string, unknown>;
......@@ -326,6 +344,17 @@ export function boutiquePost<T = unknown>(method: string, data?: unknown, config
return ropPost<T>("boutique", method, data, config);
}
export function carlifePost<T = unknown>(method: string, data?: unknown, config?: RequestConfig) {
return ropPost<T>("carlife", method, data, config).then((res) => {
// 当接口返回 data 为 null 时,ropPost 会回退返回整个响应包装对象
// 这里只对 carlife 服务做二次解包,避免影响其他服务
if (res && typeof res === "object" && ("code" in res || "success" in res) && "data" in res) {
return (res as ApiResponse<T>).data as T;
}
return res;
});
}
export function cluePost<T = unknown>(method: string, data?: unknown, config?: RequestConfig) {
return ropPost<T>("clue", method, data, config);
}
......@@ -88,6 +88,12 @@ export function notifyHostLogout() {
postToWeChatMiniProgram(payload);
}
export function callPhone(phone: string): void {
const number = phone.replaceAll(/\s/g, "");
if (!number) return;
window.location.href = `tel:${number}`;
}
export function initTokenBridge() {
const userStore = useUserStore();
......
<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { getCarBrandList } from "@/api/modules/clueManage/index";
import { showToast } from "vant";
export interface BrandItem {
childs?: SeriesGroupItem[];
id: string;
letter: string;
logoUrl?: string;
name: string;
}
export interface SeriesGroupItem {
childs?: SeriesItem[];
id: string;
name: string;
}
export interface SeriesItem {
id: string;
name: string;
}
const router = useRouter();
const searchValue = ref("");
const brandList = ref<{ letter: string; list: BrandItem[] }[]>([]);
const filteredBrandList = computed(() => {
const kw = searchValue.value.trim();
if (!kw) return brandList.value;
return brandList.value
.map((group) => ({
...group,
list: group.list.filter((item) => item.name.includes(kw)),
}))
.filter((group) => group.list.length > 0);
});
const activeLetter = ref("");
const showLetterTip = ref(false);
const letterTip = ref("");
const letterArr = computed(() => brandList.value.map((i) => i.letter));
const loading = ref(false);
onMounted(() => {
loadBrands();
});
async function loadBrands() {
loading.value = true;
try {
const res = (await getCarBrandList()) as BrandItem[] | null | undefined;
brandList.value = formatBrandData(res || []);
} catch (error) {
console.error("loadBrands error", error);
brandList.value = [];
} finally {
loading.value = false;
}
}
function formatBrandData(data: BrandItem[]) {
const letterSet = new Set(data.map((e) => e.letter));
const letters = Array.from(letterSet).sort();
return letters.map((letter) => ({
letter,
list: data.filter((i) => i.letter === letter),
}));
}
function onSearch() {
const kw = searchValue.value.trim();
if (!kw) return;
for (const group of filteredBrandList.value) {
const hit = group.list.find((i) => i.name.includes(kw));
if (hit) {
activeLetter.value = `brand-${hit.id}`;
break;
}
}
}
function onLetterTouchStart(letter: string) {
showLetterTip.value = true;
letterTip.value = letter;
activeLetter.value = letter;
}
function onLetterTouchMove(event: TouchEvent) {
if (!showLetterTip.value) return;
const wrap = document.querySelector(".brand-page__sidebar");
if (!wrap) return;
const rect = wrap.getBoundingClientRect();
const y = event.touches[0].clientY - rect.top;
const itemHeight = rect.height / letterArr.value.length;
let index = Math.floor(y / itemHeight);
if (index < 0) index = 0;
if (index >= letterArr.value.length) index = letterArr.value.length - 1;
const letter = letterArr.value[index];
if (letter && letterTip.value !== letter) {
letterTip.value = letter;
activeLetter.value = letter;
}
}
function onLetterTouchEnd() {
showLetterTip.value = false;
}
function onBrandClick(item: BrandItem) {
if (item.childs && item.childs.length > 0) {
router.push({
name: "AddClueSeries",
query: {
brandId: item.id,
brandName: item.name,
list: encodeURIComponent(JSON.stringify(item.childs)),
},
});
} else {
showToast("暂无该品牌车系");
}
}
</script>
<template>
<div v-if="loading" class="brand-loading">
<div class="page-loading">
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
</div>
<span class="page-loading__text">加载中...</span>
</div>
<div v-else class="brand-page">
<div class="brand-page__search">
<van-search v-model="searchValue"
placeholder="搜索品牌"
@search="onSearch" />
</div>
<div class="brand-page__body">
<div class="brand-page__scroll">
<div v-for="group in filteredBrandList"
:key="group.letter"
class="brand-group"
:data-letter="group.letter">
<div class="brand-group__title">
{{ group.letter }}
</div>
<div v-for="item in group.list"
:id="`brand-${item.id}`"
:key="item.id"
class="brand-item"
@click="onBrandClick(item)">
<img v-if="item.logoUrl"
class="brand-item__logo"
:src="item.logoUrl" />
<span class="brand-item__name">{{ item.name }}</span>
</div>
</div>
<div v-if="filteredBrandList.length === 0" class="brand-empty">
暂无数据
</div>
</div>
<div class="brand-page__sidebar"
@touchend.prevent
@touchmove.prevent
@touchstart.prevent>
<div v-for="letter in letterArr"
:key="letter"
class="sidebar-item"
:class="{ active: activeLetter === letter }"
@touchend="onLetterTouchEnd"
@touchmove="onLetterTouchMove"
@touchstart="onLetterTouchStart(letter)">
{{ letter }}
</div>
</div>
<div v-if="showLetterTip" class="brand-page__letter-tip">
{{ letterTip }}
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.brand-loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
}
.page-loading {
display: flex;
gap: 6px;
align-items: center;
height: 24px;
margin-bottom: 8px;
}
.page-loading__bar {
width: 6px;
height: 100%;
border-radius: 2px;
animation: stretchdelay 1.2s infinite ease-in-out;
}
.page-loading__bar:nth-child(2) {
animation-delay: -1.1s;
}
.page-loading__bar:nth-child(3) {
animation-delay: -1s;
}
.page-loading__bar:nth-child(4) {
animation-delay: -0.9s;
}
.page-loading__text {
font-size: 14px;
color: #282829;
}
@keyframes stretchdelay {
0%,
40%,
100% {
transform: scaleY(0.33);
}
20% {
transform: scaleY(1);
}
}
.brand-page {
display: flex;
flex-direction: column;
width: 100%;
height: 100vh;
background: #f7f8fa;
}
.brand-page__search {
flex-shrink: 0;
padding: 0 12px;
background: #fff;
}
.brand-page__body {
position: relative;
flex: 1;
min-height: 0;
overflow: hidden;
}
.brand-page__scroll {
height: 100%;
padding-right: 32px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.brand-group__title {
position: sticky;
top: 0;
z-index: 2;
padding: 0 16px;
font-size: 14px;
line-height: 32px;
color: #646566;
background: #f7f8fa;
}
.brand-item {
display: flex;
gap: 10px;
align-items: center;
padding: 12px 16px;
background: #fff;
border-bottom: 1px solid #ebedf0;
}
.brand-item__logo {
width: 34px;
height: 34px;
object-fit: contain;
}
.brand-item__name {
font-size: 14px;
color: #323233;
}
.brand-empty {
padding: 60px 16px;
color: #969799;
text-align: center;
}
.brand-page__sidebar {
position: absolute;
top: 50%;
right: 0;
z-index: 10;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 8px 4px;
transform: translateY(-50%);
}
.sidebar-item {
padding: 2px 6px;
font-size: 11px;
color: #646566;
text-align: center;
}
.sidebar-item.active {
color: #347BFF;
}
.brand-page__letter-tip {
position: fixed;
top: 50%;
left: 50%;
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
width: 70px;
height: 70px;
font-size: 28px;
font-weight: 600;
color: #fff;
background: rgb(0 0 0 / 50%);
border-radius: 50%;
transform: translate(-50%, -50%);
}
</style>
<script setup lang="ts">
import { computed, ref, watch } from "vue";
export interface ConversionOption {
staffUuid: string;
staffName: string;
subMerchantId: number;
subMerchantName: string;
}
const props = withDefaults(
defineProps<{
conversionUserId: string;
modelValue: string;
options: ConversionOption[];
show: boolean;
title?: string;
}>(),
{
conversionUserId: "",
title: "选择指派人员",
}
);
const emit = defineEmits<{
(e: "update:modelValue", v: string): void;
(e: "update:conversionUserId", v: string): void;
(e: "update:show", v: boolean): void;
(e: "update:conversionMerchantId", v: number): void;
(e: "update:conversionMerchantName", v: string): void;
}>();
const searchValue = ref("");
const tempSelectedUuid = ref("");
const tempSelectedName = ref("");
const tempMerchantId = ref<number | undefined>();
const tempMerchantName = ref("");
const showProxy = computed({
get: () => props.show,
set: (v: boolean) => emit("update:show", v),
});
watch(
() => props.show,
(v) => {
if (v) {
searchValue.value = "";
const byId = (props.options || []).find((o) => o.staffUuid === props.conversionUserId);
if (byId) {
tempSelectedUuid.value = byId.staffUuid;
tempSelectedName.value = byId.staffName;
tempMerchantId.value = byId.subMerchantId;
tempMerchantName.value = byId.subMerchantName;
return;
}
const byName = (props.options || []).find((o) => o.staffName === props.modelValue);
tempSelectedUuid.value = byName?.staffUuid || "";
tempSelectedName.value = byName?.staffName || "";
tempMerchantId.value = byName?.subMerchantId;
tempMerchantName.value = byName?.subMerchantName || "";
}
}
);
const filteredOptions = computed(() => {
const kw = searchValue.value.trim();
if (!kw) return props.options || [];
return (props.options || []).filter((item) =>
item.staffName.includes(kw) || item.subMerchantName.includes(kw),
);
});
const isEmpty = computed(() => (filteredOptions.value?.length || 0) === 0);
function onCancel() {
showProxy.value = false;
}
function onSelect(item: ConversionOption) {
tempSelectedUuid.value = item.staffUuid;
tempSelectedName.value = item.staffName;
tempMerchantId.value = item.subMerchantId;
tempMerchantName.value = item.subMerchantName;
}
function onConfirm() {
emit("update:modelValue", tempSelectedName.value);
emit("update:conversionUserId", tempSelectedUuid.value);
if (tempMerchantId.value !== undefined) {
emit("update:conversionMerchantId", tempMerchantId.value);
}
emit("update:conversionMerchantName", tempMerchantName.value);
showProxy.value = false;
}
</script>
<template>
<van-popup v-model:show="showProxy"
position="bottom"
round
teleport="#vant-portal-host">
<div class="conversion-picker">
<div class="conversion-picker__header">
<span class="conversion-picker__title">{{ title || "选择指派人员" }}</span>
</div>
<!-- <div class="conversion-picker__search">
<van-search v-model="searchValue"
placeholder="搜索人员姓名或门店" />
</div> -->
<div class="conversion-picker__body">
<div v-for="item in filteredOptions"
:key="item.staffUuid"
class="conversion-option"
:class="{ active: tempSelectedUuid === item.staffUuid }"
@click="onSelect(item)">
<div class="conversion-option__name">
{{ item.staffName }}
</div>
<van-icon v-if="tempSelectedUuid === item.staffUuid"
class="conversion-option__check"
name="success" />
</div>
<div v-if="isEmpty" class="conversion-empty">
暂无数据
</div>
</div>
<div class="conversion-picker__footer">
<div class="btn cancel" @click="onCancel">
取消
</div>
<div class="btn confirm" @click="onConfirm">
确定
</div>
</div>
</div>
</van-popup>
</template>
<style lang="scss" scoped>
.conversion-picker {
display: flex;
flex-direction: column;
min-height: 60vh;
max-height: 80vh;
}
.conversion-picker__header {
position: relative;
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
}
.conversion-picker__title {
font-size: 16px;
font-weight: 600;
color: #323233;
}
.conversion-picker__close {
position: absolute;
top: 50%;
right: 16px;
font-size: 18px;
color: #969799;
transform: translateY(-50%);
}
.conversion-picker__search {
flex-shrink: 0;
padding: 0 12px;
background: #fff;
}
.conversion-picker__body {
flex: 1;
min-height: 0;
padding: 0 16px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.conversion-option {
position: relative;
display: flex;
flex-direction: column;
gap: 4px;
padding: 14px 28px 14px 0;
cursor: pointer;
border-bottom: 1px solid #f2f3f5;
}
.conversion-option__name {
font-size: 15px;
font-weight: 600;
color: #323233;
}
.conversion-option__merchant {
font-size: 13px;
color: #646566;
}
.conversion-option__check {
position: absolute;
top: 50%;
right: 0;
font-size: 18px;
color: #347BFF;
transform: translateY(-50%);
}
.conversion-empty {
padding: 60px 16px;
font-size: 14px;
color: #969799;
text-align: center;
}
.conversion-picker__footer {
display: flex;
flex-shrink: 0;
gap: 8px;
align-items: center;
padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
.btn {
flex: 1;
height: 40px;
font-size: 16px;
line-height: 40px;
text-align: center;
border-radius: 6px;
}
.cancel {
height: 38px;
line-height: 38px;
color: #347BFF;
border: 1px solid #347BFF;
}
.confirm {
color: #fff;
background: #347BFF;
}
}
</style>
<script setup lang="ts">
import { computed, ref, watch } from "vue";
export interface LevelItem {
code: string;
color: string;
desc: string;
followDays: number;
name: string;
}
const props = defineProps<{
modelValue: string;
options: LevelItem[];
show: boolean;
}>();
const emit = defineEmits<{
(e: "update:show", v: boolean): void;
(e: "update:modelValue", v: string): void;
}>();
const showProxy = computed({
get: () => props.show,
set: (v) => emit("update:show", v),
});
const tempCode = ref(props.modelValue);
watch(() => props.show, (v) => {
if (v) tempCode.value = props.modelValue;
});
function onConfirm() {
emit("update:modelValue", tempCode.value);
showProxy.value = false;
}
function onCancel() {
showProxy.value = false;
}
</script>
<template>
<van-popup v-model:show="showProxy"
position="bottom"
round
teleport="#vant-portal-host">
<div class="level-picker">
<div class="level-picker__header">
<span class="level-picker__title">选择意向等级</span>
</div>
<div class="level-picker__body">
<div v-for="item in options"
:key="item.code"
class="level-option"
:class="{ active: tempCode === item.code }"
@click="tempCode = item.code">
<div class="level-option__badge" :style="{ background: item.color }">
{{ item.code }}
</div>
<div class="level-option__content">
<div class="level-option__name" :style="{ color: item.color }">
{{ item.name }}
</div>
<div class="level-option__desc">
{{ item.desc }}
</div>
</div>
<van-icon v-if="tempCode === item.code"
class="level-option__check"
name="success" />
</div>
</div>
<div class="level-picker__footer">
<div class="btn cancel" @click="onCancel">
取消
</div>
<div class="btn confirm" @click="onConfirm">
确定
</div>
</div>
</div>
</van-popup>
</template>
<style lang="scss" scoped>
.level-picker {
display: flex;
flex-direction: column;
max-height: 78vh;
}
.level-picker__header {
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
}
.level-picker__title {
font-size: 16px;
font-weight: 600;
color: #323233;
}
.level-picker__close {
font-size: 18px;
color: #969799;
}
.level-picker__body {
flex: 1;
min-height: 0;
padding: 0 16px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.level-option {
position: relative;
display: flex;
gap: 12px;
align-items: center;
padding: 14px 28px 14px 0;
border-bottom: 1px solid #f2f3f5;
}
.level-option__badge {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 26px;
height: 26px;
font-size: 12px;
font-weight: 600;
color: #fff;
border-radius: 50%;
}
.level-option__content {
flex: 1;
min-width: 0;
}
.level-option__name {
margin-bottom: 4px;
font-size: 15px;
font-weight: 600;
color: #323233;
}
.level-option__desc {
font-size: 13px;
line-height: 1.5;
color: #000000E5;
}
.level-option__check {
position: absolute;
top: 50%;
right: 0;
flex-shrink: 0;
width: 18px;
font-size: 18px;
color: #347BFF;
transform: translateY(-50%);
}
.level-picker__footer {
display: flex;
flex-shrink: 0;
gap: 8px;
align-items: center;
padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
.btn {
flex: 1;
height: 40px;
font-size: 16px;
line-height: 40px;
text-align: center;
border-radius: 6px;
}
.cancel {
height: 38px;
line-height: 38px;
color: #347BFF;
border: 1px solid #347BFF;
}
.confirm {
color: #fff;
background: #347BFF;
}
}
</style>
<script setup lang="ts">
import { computed, nextTick, ref, watch } from "vue";
import { showToast } from "vant";
export type ConsultantOption = {
sellerName: string;
sellerUserId: string;
staffPhone: string;
};
const props = withDefaults(
defineProps<{
modelValue: string;
options: ConsultantOption[];
sellerUserId: string;
show: boolean;
title?: string;
}>(),
{
sellerUserId: "",
title: "选择销售顾问",
}
);
const emit = defineEmits<{
(e: "update:show", v: boolean): void;
(e: "update:modelValue", v: string): void;
(e: "update:sellerUserId", v: string): void;
(e: "update:staffPhone", v: string): void;
}>();
const showProxy = computed({
get: () => props.show,
set: (v: boolean) => emit("update:show", v),
});
const keywordInput = ref("");
const keywordApplied = ref("");
const tempSelected = ref<ConsultantOption>({ sellerName: "", sellerUserId: "", staffPhone: "" });
watch(
() => props.show,
(v) => {
if (v) {
keywordInput.value = "";
keywordApplied.value = "";
nextTick(() => {
const input = document.querySelector(".scp-search input") as HTMLInputElement | null;
input?.blur();
});
const byId = (props.options || []).find((o) => o.sellerUserId === props.sellerUserId);
if (byId) {
tempSelected.value = {
sellerName: byId.sellerName,
sellerUserId: byId.sellerUserId,
staffPhone: byId.staffPhone,
};
return;
}
const byName = (props.options || []).find((o) => o.sellerName === props.modelValue);
tempSelected.value = byName
? { sellerName: byName.sellerName, sellerUserId: byName.sellerUserId, staffPhone: byName.staffPhone }
: { sellerName: "", sellerUserId: "", staffPhone: "" };
}
}
);
const filteredOptions = computed(() => {
const kw = keywordApplied.value.trim();
if (!kw) return props.options || [];
return (props.options || []).filter((o) => String(o.sellerName || "").includes(kw));
});
const isEmpty = computed(() => (filteredOptions.value?.length || 0) === 0);
function onSearch() {
keywordApplied.value = keywordInput.value.trim();
}
function onClear() {
keywordInput.value = "";
keywordApplied.value = "";
}
function onCancel() {
showProxy.value = false;
}
function onConfirm() {
if (!tempSelected.value.sellerUserId) {
showToast("请选择销售顾问");
return;
}
emit("update:modelValue", tempSelected.value.sellerName);
emit("update:sellerUserId", tempSelected.value.sellerUserId);
emit("update:staffPhone", tempSelected.value.staffPhone);
showProxy.value = false;
}
function toggleSelect(o: ConsultantOption) {
if (tempSelected.value.sellerUserId === o.sellerUserId) {
tempSelected.value = { sellerName: "", sellerUserId: "", staffPhone: "" };
return;
}
tempSelected.value = {
sellerName: o.sellerName,
sellerUserId: o.sellerUserId,
staffPhone: o.staffPhone,
};
}
</script>
<template>
<van-popup v-model:show="showProxy"
class="scp-popup"
position="bottom"
round
teleport="#vant-portal-host"
@close="onCancel">
<div class="scp">
<div class="scp-header">
<span class="scp-header__title">{{ title }}</span>
<!-- <van-icon class="scp-header__close"
name="cross"
@click="onCancel" /> -->
</div>
<!-- <div class="scp-search">
<van-search
v-model="keywordInput"
clearable
placeholder="搜索"
@clear="onClear"
@search="onSearch"
/>
</div> -->
<div class="scp-body">
<div class="scp-list">
<template v-if="!isEmpty">
<div v-for="o in filteredOptions"
:key="o.sellerUserId"
class="scp-item"
:class="{ 'is-active': tempSelected.sellerUserId === o.sellerUserId }"
@click="toggleSelect(o)">
<div class="scp-item-text">
{{ o.sellerName }}
</div>
<van-icon v-if="tempSelected.sellerUserId === o.sellerUserId"
class="scp-item-check"
name="success" />
</div>
</template>
<template v-else>
<van-empty description="暂无数据"
image="https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/empty_data.png" />
</template>
</div>
</div>
<div class="scp-footer">
<div class="btn cancel" @click="onCancel">
取消
</div>
<div class="btn confirm" @click="onConfirm">
确定
</div>
</div>
</div>
</van-popup>
</template>
<style scoped lang="scss">
.scp-popup {
width: 100%;
height: 78vh;
border-top-left-radius: 16px;
border-top-right-radius: 16px;
}
.scp {
display: flex;
flex-direction: column;
height: 100%;
}
.scp-header {
position: relative;
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
}
.scp-header__title {
font-size: 16px;
font-weight: 600;
color: #323233;
text-align: center;
}
.scp-header__close {
position: absolute;
top: 16px;
right: 16px;
font-size: 18px;
color: #969799;
}
.scp-search {
padding: 0 16px 8px;
:deep(.van-search) {
padding: 8px 0;
}
}
.scp-body {
flex: 1;
min-height: 0;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.scp-list {
padding: 6px 0;
}
.scp-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 16px;
font-size: 14px;
color: #1b233d;
border-bottom: 1px solid #f2f3f5;
}
.scp-item.is-active {
color: #2c66f7;
}
.scp-item-check {
font-size: 18px;
color: #2c66f7;
}
.scp-footer {
display: flex;
flex-shrink: 0;
gap: 8px;
align-items: center;
padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
.btn {
flex: 1;
height: 40px;
font-size: 16px;
line-height: 40px;
text-align: center;
border-radius: 6px;
}
.cancel {
height: 38px;
line-height: 38px;
color: #347BFF;
border: 1px solid #347BFF;
}
.confirm {
color: #fff;
background: #347BFF;
}
}
</style>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import { getCarSeriesList, getCarTypeList } from "@/api/modules/clueManage/index";
export interface SeriesGroupItem {
childs?: SeriesItem[];
id: string;
name: string;
}
export interface SeriesItem {
id: string;
name: string;
}
export interface CarTypeItem {
id: string;
name: string;
}
const route = useRoute();
const router = useRouter();
const brandId = ref((route.query.brandId as string) || "");
const brandName = ref((route.query.brandName as string) || "");
const seriesList = ref<SeriesGroupItem[]>([]);
const loading = ref(false);
const showType = ref(false);
const typeLoading = ref(false);
const carTypeList = ref<CarTypeItem[]>([]);
const selectedGroup = ref<null | SeriesGroupItem>(null);
const selectedSeries = ref<null | SeriesItem>(null);
onMounted(() => {
loadSeries();
});
async function loadSeries() {
const listStr = route.query.list as string;
let groups: SeriesGroupItem[] = [];
try {
groups = JSON.parse(decodeURIComponent(listStr || "[]"));
} catch {
groups = [];
}
if (groups.length === 0 || !brandId.value) {
seriesList.value = [];
return;
}
loading.value = true;
try {
const result = await Promise.all(
groups.map(async (group) => {
const childs = (await getCarSeriesList({
brandId: brandId.value,
childBrandId: group.id,
})) as SeriesItem[];
return { ...group, childs: childs || [] };
})
);
seriesList.value = result;
} catch (error) {
console.error("loadSeries error", error);
} finally {
loading.value = false;
}
}
async function onSeriesClick(group: SeriesGroupItem, series: SeriesItem) {
selectedGroup.value = group;
selectedSeries.value = series;
showType.value = true;
typeLoading.value = true;
try {
const res = (await getCarTypeList({ carSeriesId: series.id })) as CarTypeItem[];
carTypeList.value = res || [];
} catch (error) {
console.error("onSeriesClick error", error);
} finally {
typeLoading.value = false;
}
}
function onTypeClick(type: CarTypeItem) {
const result = {
carBrandId: brandId.value,
carBrand: brandName.value,
carChildsBrandId: selectedGroup.value?.id || "",
carChildsBrandName: selectedGroup.value?.name || "",
carSeriesId: selectedSeries.value?.id || "",
carSeriesName: selectedSeries.value?.name || "",
carTypeId: type.id,
carTypeName: type.name,
};
sessionStorage.setItem("addClueVehicle", JSON.stringify(result));
showType.value = false;
// 返回两级,直接回到新增线索页面
router.go(-2);
}
function onCancelType() {
showType.value = false;
}
</script>
<template>
<div v-if="loading" class="series-loading">
<div class="page-loading">
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
</div>
<span class="page-loading__text">加载中...</span>
</div>
<div v-else class="series-page">
<div class="series-page__scroll">
<div v-for="group in seriesList"
:key="group.id"
class="series-group">
<div class="series-group__title">
{{ group.name }}
</div>
<div v-for="series in group.childs"
:key="series.id"
class="series-item"
@click="onSeriesClick(group, series)">
{{ series.name }}
</div>
<div v-if="!group.childs || group.childs.length === 0" class="series-empty-small">
暂无车系
</div>
</div>
<div v-if="seriesList.length === 0" class="series-empty">
暂无数据
</div>
</div>
<div v-if="showType"
class="type-popup"
@click.self="onCancelType">
<div class="type-popup__mask" @click="onCancelType"></div>
<div class="type-popup__panel">
<div v-if="typeLoading" class="type-popup__loading">
<div class="page-loading">
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
<div class="page-loading__bar" style="background-color: #347BFF;"></div>
</div>
<span class="page-loading__text">加载中...</span>
</div>
<div v-else class="type-popup__list">
<div v-for="type in carTypeList"
:key="type.id"
class="type-popup__item"
@click="onTypeClick(type)">
{{ type.name }}
</div>
<div v-if="carTypeList.length === 0" class="type-popup__empty">
暂无数据
</div>
</div>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.series-page {
display: flex;
flex-direction: column;
width: 100%;
height: 100vh;
background: #f7f8fa;
}
.series-page__scroll {
flex: 1;
min-height: 0;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.series-group__title {
position: sticky;
top: 0;
z-index: 2;
padding: 0 16px;
font-size: 14px;
line-height: 32px;
color: #646566;
background: #f7f8fa;
}
.series-item {
padding: 14px 16px;
font-size: 14px;
color: #323233;
background: #fff;
border-bottom: 1px solid #ebedf0;
}
.series-empty {
padding: 60px 16px;
color: #969799;
text-align: center;
}
.series-empty-small {
padding: 20px 16px;
color: #969799;
text-align: center;
background: #fff;
}
.series-loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
color: #969799;
}
.page-loading {
display: flex;
gap: 6px;
align-items: center;
height: 24px;
margin-bottom: 8px;
}
.page-loading__bar {
width: 6px;
height: 100%;
border-radius: 2px;
animation: stretchdelay 1.2s infinite ease-in-out;
}
.page-loading__bar:nth-child(2) {
animation-delay: -1.1s;
}
.page-loading__bar:nth-child(3) {
animation-delay: -1s;
}
.page-loading__bar:nth-child(4) {
animation-delay: -0.9s;
}
.page-loading__text {
font-size: 14px;
color: #282829;
}
@keyframes stretchdelay {
0%,
40%,
100% {
transform: scaleY(0.33);
}
20% {
transform: scaleY(1);
}
}
.type-popup {
position: fixed;
inset: 0;
z-index: 9999;
}
.type-popup__mask {
position: absolute;
inset: 0;
background: rgb(0 0 0 / 50%);
}
.type-popup__panel {
position: absolute;
top: 0;
right: 0;
width: 75vw;
height: 100vh;
padding-bottom: env(safe-area-inset-bottom);
overflow-y: auto;
background: #fff;
-webkit-overflow-scrolling: touch;
animation: slide-in 0.4s ease;
}
@keyframes slide-in {
from {
transform: translateX(100%);
}
to {
transform: translateX(0);
}
}
.type-popup__item {
padding: 16px;
font-size: 14px;
color: #323233;
border-bottom: 1px solid #ebedf0;
}
.type-popup__loading,
.type-popup__empty {
padding: 60px 16px;
color: #969799;
text-align: center;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!