Commit bbc0cddc by liimin

refactor(components): 重构汽车品牌和员工选择组件样式及结构

- 调整 CarBrands 组件模板结构和属性命名格式
- 优化 CarBrands 组件导入顺序和代码布局
- 更新 Employee 组件模板结构和属性命名格式
- 调整 FinishStep 组件弹窗结构和按钮组件
- 优化选择项样式为居中对齐的弹性布局
- 统一组件属性绑定的命名规范
- 调整 FinishStep 组件表单输入和选择控件样式
1 parent 6267daab
<template> <template>
<view> <view>
<MessageBox <MessageBox ref="carBrandListVisible"
ref="carBrandListVisible" :is-footer="false"
position="bottom" position="bottom"
:isFooter="false"
title="请选择车品牌" title="请选择车品牌"
@close="$emit('close')" @close="$emit('close')">
> <view :key="updateView" class="select-box">
<view class="select-box" :key="updateView">
<template v-for="(item, index) in carBrandList" <template v-for="(item, index) in carBrandList"
:key="index"> :key="index">
<view <view class="select-item"
:class="['select-item',{ checked: carBrand == (item as UTSJSONObject).name }]" :class="[{ checked: carBrand == (item as UTSJSONObject).name }]"
@click="selectCar(item, false ,'')" @click="selectCar(item, false ,'')">
>
{{ (item as UTSJSONObject).name }} {{ (item as UTSJSONObject).name }}
</view> </view>
</template> </template>
</view> </view>
</MessageBox> </MessageBox>
<MessageBox <MessageBox ref="carBoxVisible"
ref="carBoxVisible" back
:is-footer="false"
:max-height="1000"
position="bottom" position="bottom"
:isFooter="false"
title="请选择车系" title="请选择车系"
:maxHeight="1000" @close="closeCarBoxVisible">
back
@close="closeCarBoxVisible"
>
<view class="select-box"> <view class="select-box">
<template v-for="(item, index) in carlist" <template v-for="(item, index) in carlist"
:key="index"> :key="index">
<view <view class="select-item"
:class="['select-item',{ checked: carModel == (item as UTSJSONObject).name }]" :class="[{ checked: carModel == (item as UTSJSONObject).name }]"
@click="handleSelect(item)" @click="handleSelect(item)">
>
{{ (item as UTSJSONObject).name }} {{ (item as UTSJSONObject).name }}
</view> </view>
</template> </template>
...@@ -46,12 +39,14 @@ ...@@ -46,12 +39,14 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import MessageBox from './MessageBox.uvue' import { ComponentPublicInstance } from "vue";
import { storage } from '@/utils/storage.uts'
import { getMerchantCarBrandList,getCarBrandsListApi } from '@/api/common-api.uts' import { getCarBrandsListApi, getMerchantCarBrandList } from "@/api/common-api.uts";
import { state, dispatch } from "@/store/index.uts" import { recordService } from "@/services/recorder/index.uts";
import { ComponentPublicInstance } from 'vue' import { dispatch, state } from "@/store/index.uts";
import { recordService } from '@/services/recorder/index.uts' import { storage } from "@/utils/storage.uts";
import MessageBox from "./MessageBox.uvue";
...@@ -59,14 +54,14 @@ ...@@ -59,14 +54,14 @@
type UserInfo = UTSJSONObject type UserInfo = UTSJSONObject
const props = defineProps({ const props = defineProps({
carBrandKey: { carBrandKey: {
type: String, type: String,
default: 'carBrand' default: "carBrand"
}, },
carModelKey: { carModelKey: {
type: String, type: String,
default: 'carModel' default: "carModel"
}, },
echoData: { echoData: {
type: Object, type: Object,
...@@ -80,77 +75,77 @@ ...@@ -80,77 +75,77 @@
type: Boolean, type: Boolean,
default: true default: true
} }
}) });
const emit = defineEmits(['close', 'select']) const emit = defineEmits(["close", "select"]);
const carlist = ref<Array<any>>([]) const carlist = ref<Array<any>>([]);
const selectItem = ref<UTSJSONObject>({}) const selectItem = ref<UTSJSONObject>({});
const clickFlga = ref<boolean>(false) const clickFlga = ref<boolean>(false);
const carBrandListOff = ref<boolean>(false) const carBrandListOff = ref<boolean>(false);
const carBrandListVisible = ref(null) const carBrandListVisible = ref(null);
const carBoxVisible = ref(null) const carBoxVisible = ref(null);
const updateView = ref<number>(Date.now()) const updateView = ref<number>(Date.now());
const carBrandList = ref<Array<any>>([]) const carBrandList = ref<Array<any>>([]);
const watchStatus = computed<boolean>(() => { const watchStatus = computed<boolean>(() => {
const status = state.user?.historyStatus const status = state.user?.historyStatus;
if (status == null) { if (status == null) {
return false return false;
} else if (status == 1) { } else if (status == 1) {
return true return true;
} else { } else {
return false return false;
} }
}) });
const carModel = computed<string|null>(() => { const carModel = computed<null|string>(() => {
const car_key = props.carModelKey const car_key = props.carModelKey;
if (props.customBoolean) { if (props.customBoolean) {
const echoObj = props.echoData as UTSJSONObject const echoObj = props.echoData as UTSJSONObject;
const value = echoObj[car_key] const value = echoObj[car_key];
return value != null ? `${value}` : null return value != null ? `${value}` : null;
} else { } else {
return `${state.user.customerInfo.carModel}` return `${state.user.customerInfo.carModel}`;
} }
}) });
const carBrand = computed<string|null>(() => { const carBrand = computed<null|string>(() => {
const car_key = props.carModelKey const car_key = props.carModelKey;
if (props.customBoolean) { if (props.customBoolean) {
const echoObj = props.echoData as UTSJSONObject const echoObj = props.echoData as UTSJSONObject;
const value = echoObj[car_key] const value = echoObj[car_key];
return value != null ? `${value}` : null return value != null ? `${value}` : null;
} else { } else {
return `${state.user.customerInfo.carBrand}` return `${state.user.customerInfo.carBrand}`;
} }
}) });
const boutiqueDefaultCarBrandId = computed<any>(() => { const boutiqueDefaultCarBrandId = computed<any>(() => {
return state.user.boutiqueDefaultCarBrandId return state.user.boutiqueDefaultCarBrandId;
}) });
const defaultCarId = computed<any>(() => { const defaultCarId = computed<any>(() => {
const val = state.user.defaultCarId const val = state.user.defaultCarId;
return val != null && val != 0 ? val : '' return val != null && val != 0 ? val : "";
}) });
function close(): void { function close(): void {
if (carBoxVisible.value != null) { if (carBoxVisible.value != null) {
(carBoxVisible.value as ComponentPublicInstance).$callMethod('close') (carBoxVisible.value as ComponentPublicInstance).$callMethod("close");
} }
if (carBrandListVisible.value != null) { if (carBrandListVisible.value != null) {
(carBrandListVisible.value as ComponentPublicInstance).$callMethod('close') (carBrandListVisible.value as ComponentPublicInstance).$callMethod("close");
} }
carBrandListOff.value = false carBrandListOff.value = false;
} }
function closeCarBoxVisible(): void { function closeCarBoxVisible(): void {
if (carBrandListOff.value) return if (carBrandListOff.value) return;
else emit('close') else emit("close");
} }
function handleSelect(item: any): void { function handleSelect(item: any): void {
const selectItemVal = selectItem.value const selectItemVal = selectItem.value;
const stateCustomerInfo = state.user.customerInfo const stateCustomerInfo = state.user.customerInfo;
// const customerInfo: UTSJSONObject = { // const customerInfo: UTSJSONObject = {
// ...state.user.customerInfo, // ...state.user.customerInfo,
// carBrand: selectItemVal.carChildsBrandName, // carBrand: selectItemVal.carChildsBrandName,
...@@ -160,12 +155,12 @@ ...@@ -160,12 +155,12 @@
// carModel: item.name, // carModel: item.name,
// carModelId: item.id // carModelId: item.id
// } // }
stateCustomerInfo.carBrand = selectItemVal.carChildsBrandName stateCustomerInfo.carBrand = selectItemVal.carChildsBrandName;
stateCustomerInfo.carBrandId = selectItemVal.carChildsBrandId stateCustomerInfo.carBrandId = selectItemVal.carChildsBrandId;
stateCustomerInfo.oneCarBrand = selectItemVal.carBrand stateCustomerInfo.oneCarBrand = selectItemVal.carBrand;
stateCustomerInfo.oneCarBrandId = selectItemVal.carBrandId stateCustomerInfo.oneCarBrandId = selectItemVal.carBrandId;
stateCustomerInfo.carModel = (item as UTSJSONObject).name stateCustomerInfo.carModel = (item as UTSJSONObject).name;
stateCustomerInfo.carModelId = (item as UTSJSONObject).id stateCustomerInfo.carModelId = (item as UTSJSONObject).id;
if (props.linkage) { if (props.linkage) {
const businessData: UTSJSONObject = { const businessData: UTSJSONObject = {
carBrand: selectItemVal.carChildsBrandName, carBrand: selectItemVal.carChildsBrandName,
...@@ -174,136 +169,136 @@ ...@@ -174,136 +169,136 @@
oneCarBrandId: selectItemVal.carBrandId, oneCarBrandId: selectItemVal.carBrandId,
carModel: (item as UTSJSONObject).name, carModel: (item as UTSJSONObject).name,
carModelId: (item as UTSJSONObject).id carModelId: (item as UTSJSONObject).id
} as UTSJSONObject } as UTSJSONObject;
recordService.updateBusinessData(businessData) recordService.updateBusinessData(businessData);
// dispatch('setCustomerInfo', stateCustomerInfo) // dispatch('setCustomerInfo', stateCustomerInfo)
dispatch('updateViewKey') dispatch("updateViewKey");
dispatch('setCurrentCarInfo', selectItemVal) dispatch("setCurrentCarInfo", selectItemVal);
} }
(carBoxVisible.value as ComponentPublicInstance).$callMethod('close') (carBoxVisible.value as ComponentPublicInstance).$callMethod("close");
emit('select', { ...item, ...selectItemVal }) emit("select", { ...item, ...selectItemVal });
} }
function selectCar(e: any, auto: boolean = false, carId?: string): void { function selectCar(e: any, auto: boolean = false, carId?: string): void {
const _brandId = (e as UTSJSONObject).brandId const _brandId = (e as UTSJSONObject).brandId;
const _carId = (e as UTSJSONObject).id const _carId = (e as UTSJSONObject).id;
if (_brandId == null || _carId == null) { if (_brandId == null || _carId == null) {
return uni.showToast({ return uni.showToast({
title: "车型 ID 或品牌 ID 为空", title: "车型 ID 或品牌 ID 为空",
icon: "none" icon: "none"
}) });
} }
let index = 0 let index = 0;
if (clickFlga.value) return if (clickFlga.value) return;
clickFlga.value = true clickFlga.value = true;
const _brandName = (e as UTSJSONObject).brandName const _brandName = (e as UTSJSONObject).brandName;
const _carName = (e as UTSJSONObject).name const _carName = (e as UTSJSONObject).name;
const selectData = { const selectData = {
carBrand: _brandName, carBrand: _brandName,
carBrandId: _brandId, carBrandId: _brandId,
carChildsBrandName: _carName, carChildsBrandName: _carName,
carChildsBrandId: _carId carChildsBrandId: _carId
} as UTSJSONObject } as UTSJSONObject;
selectItem.value = selectData selectItem.value = selectData;
const cacheKey = `${_carId}_${_brandId}_carlist` const cacheKey = `${_carId}_${_brandId}_carlist`;
let _carList = uni.getStorageSync(cacheKey) let _carList = uni.getStorageSync(cacheKey);
if (_carList != null && _carList != '' && _carList != 'null') { if (_carList != null && _carList != "" && _carList != "null") {
_carList = typeof _carList == 'string' ? JSON.parse(_carList) as Array<any> : _carList as Array<any> _carList = typeof _carList === "string" ? JSON.parse(_carList) as Array<any> : _carList as Array<any>;
clickFlga.value = false clickFlga.value = false;
carlist.value = _carList carlist.value = _carList;
if (auto) { if (auto) {
if (carId != null) index = _carList.findIndex((i :any) => (i as UTSJSONObject).id == carId) if (carId != null) index = _carList.findIndex((i :any) => (i as UTSJSONObject).id == carId);
if (index < 0) index = 0 if (index < 0) index = 0;
handleSelect(_carList[index]) handleSelect(_carList[index]);
} else { } else {
(carBoxVisible.value as ComponentPublicInstance).$callMethod('open') (carBoxVisible.value as ComponentPublicInstance).$callMethod("open");
} }
} else { } else {
if (!auto) uni.showLoading({ if (!auto) uni.showLoading({
title: '', title: "",
mask: true mask: true
}) });
} }
getCarBrandsListApi({ brandId: _brandId, childBrandId: _carId }).then(res => { getCarBrandsListApi({ brandId: _brandId, childBrandId: _carId }).then(res => {
uni.hideLoading() uni.hideLoading();
const typedRes = res as UTSArray<any> const typedRes = res as UTSArray<any>;
carlist.value = typedRes carlist.value = typedRes;
if (typedRes.length > 0) uni.setStorageSync(cacheKey, typedRes) if (typedRes.length > 0) uni.setStorageSync(cacheKey, typedRes);
if (carlist.value != null) { if (carlist.value != null) {
if (auto && typedRes.length > 0) { if (auto && typedRes.length > 0) {
if (carId != null) index = typedRes.findIndex((i: any) => (i as UTSJSONObject).id == carId) if (carId != null) index = typedRes.findIndex((i: any) => (i as UTSJSONObject).id == carId);
if (index < 0) index = 0 if (index < 0) index = 0;
handleSelect(typedRes[index]) handleSelect(typedRes[index]);
} else { } else {
(carBoxVisible.value as ComponentPublicInstance).$callMethod('open') (carBoxVisible.value as ComponentPublicInstance).$callMethod("open");
}
} }
clickFlga.value = false
}).catch(err => {
clickFlga.value = false
uni.hideLoading()
})
} }
clickFlga.value = false;
}).catch(error => {
clickFlga.value = false;
uni.hideLoading();
});
}
watch(watchStatus.value, () => { watch(watchStatus.value, () => {
close() close();
}, { immediate: true }) }, { immediate: true });
watch(updateView.value ,()=>{ watch(updateView.value, ()=>{
const carBrandListData = storage.get("carBrandList") const carBrandListData = storage.get("carBrandList");
carBrandList.value = carBrandListData != null ? (carBrandListData as Array<any>) : [] carBrandList.value = carBrandListData != null ? (carBrandListData as Array<any>) : [];
}, { immediate: true, deep: true }) }, { immediate: true, deep: true });
function autoSelect(): void { function autoSelect(): void {
const boutiqueDefaultCarBrandIdVal = boutiqueDefaultCarBrandId.value const boutiqueDefaultCarBrandIdVal = boutiqueDefaultCarBrandId.value;
const defaultCarIdVal = defaultCarId.value as String const defaultCarIdVal = defaultCarId.value as String;
let carIndex = 0 let carIndex = 0;
if (boutiqueDefaultCarBrandIdVal != null) { if (boutiqueDefaultCarBrandIdVal != null) {
carIndex = carBrandList.value.findIndex((e: any) => (e as UTSJSONObject).id == boutiqueDefaultCarBrandIdVal) carIndex = carBrandList.value.findIndex((e: any) => (e as UTSJSONObject).id == boutiqueDefaultCarBrandIdVal);
} }
if (carIndex < 0) carIndex = 0 if (carIndex < 0) carIndex = 0;
if (carBrandList.value.length > 0) { if (carBrandList.value.length > 0) {
selectCar(carBrandList.value[carIndex], true, defaultCarIdVal) selectCar(carBrandList.value[carIndex], true, defaultCarIdVal);
}
} }
}
function open(): void { function open(): void {
const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null const userInfo: null | UserInfo = storage.get("userInfo") as null | UTSJSONObject;
if (userInfo == null) return if (userInfo == null) return;
const shopMerchantId = userInfo.shopMerchantId const shopMerchantId = userInfo.shopMerchantId;
getMerchantCarBrandList([shopMerchantId] as UTSArray<Any>) getMerchantCarBrandList([shopMerchantId] as UTSArray<Any>)
.then((res: Any) => { .then((res: Any) => {
const resObj = res as UTSJSONObject const resObj = res as UTSJSONObject;
const data = resObj.data as UTSArray<Any> const data = resObj.data as UTSArray<Any>;
if(data.length > 0){ if (data.length > 0){
let list = (data[0] as UTSJSONObject).carBrandList as UTSArray<Any> const list = (data[0] as UTSJSONObject).carBrandList as UTSArray<Any>;
const carBrandListData: Array<any> = [] const carBrandListData: Array<any> = [];
if(list.length > 0) { if (list.length > 0) {
list?.forEach((e: any) => { list?.forEach((e: any) => {
if(e != null) { if (e != null) {
const childs = (e as UTSJSONObject).childs as UTSArray<Any> const childs = (e as UTSJSONObject).childs as UTSArray<Any>;
const _brandName = (e as UTSJSONObject).name as string const _brandName = (e as UTSJSONObject).name as string;
const _brandId = (e as UTSJSONObject).id as number const _brandId = (e as UTSJSONObject).id as number;
console.log(childs) console.log(childs);
if(childs.length > 0){ if (childs.length > 0){
for(let i = 0; i < childs.length; i++){ for (const child_ of childs){
const child = childs[i] as UTSJSONObject const child = child_ as UTSJSONObject;
child.brandName = _brandName child.brandName = _brandName;
child.brandId = _brandId child.brandId = _brandId;
carBrandListData.push(child) carBrandListData.push(child);
} }
// childs.forEach((i: any) => { // childs.forEach((i: any) => {
// i.brandName = _brandName // i.brandName = _brandName
...@@ -313,50 +308,48 @@ ...@@ -313,50 +308,48 @@
} }
} }
}) });
dispatch("setCarBrandsList", carBrandListData) dispatch("setCarBrandsList", carBrandListData);
storage.set("carBrandList", carBrandListData, 0) storage.set("carBrandList", carBrandListData, 0);
} }
} }
updateView.value = Date.now() updateView.value = Date.now();
}) });
const carBrandVal = carBrand.value const carBrandVal = carBrand.value;
if (carBrandVal != null) { if (carBrandVal != null) {
const carBrandListVal = carBrandList.value const carBrandListVal = carBrandList.value;
let foundIndex = -1 let foundIndex = -1;
for (let i = 0; i < carBrandListVal.length; i++) { carBrandListVal.forEach((element: any, index: number) => {
const element = carBrandListVal[i]
if ((element as UTSJSONObject).name == carBrandVal) { if ((element as UTSJSONObject).name == carBrandVal) {
foundIndex = i foundIndex = index;
break
}
} }
});
if (foundIndex != -1 && carBrandListVal.length == 1) { if (foundIndex != -1 && carBrandListVal.length == 1) {
selectCar(carBrandListVal[foundIndex], false, '') selectCar(carBrandListVal[foundIndex], false, "");
} else { } else {
if (carBrandListVisible.value != null) { if (carBrandListVisible.value != null) {
(carBrandListVisible.value as ComponentPublicInstance).$callMethod('open') (carBrandListVisible.value as ComponentPublicInstance).$callMethod("open");
} }
carBrandListOff.value = true carBrandListOff.value = true;
} }
return return;
} }
if (carBrandListVisible.value != null) { if (carBrandListVisible.value != null) {
(carBrandListVisible.value as ComponentPublicInstance).$callMethod('open') (carBrandListVisible.value as ComponentPublicInstance).$callMethod("open");
}
carBrandListOff.value = true
} }
carBrandListOff.value = true;
}
defineExpose({ open, close, autoSelect }) defineExpose({ open, close, autoSelect });
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
...@@ -373,14 +366,20 @@ ...@@ -373,14 +366,20 @@
/* width: 23.5%; */ /* width: 23.5%; */
margin-right: 2%; margin-right: 2%;
margin-bottom: 16px; margin-bottom: 16px;
text-align: center;
height: 34px; height: 34px;
line-height: 22px;
opacity: 1; opacity: 1;
border: 1px solid #dce0e6; border: 1px solid #dce0e6;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
text {
text-align: center;
color: #333; color: #333;
font-size: 16px; font-size: 16px;
border-radius: 4px; line-height: 22px;
}
&:nth-child(4n) { &:nth-child(4n) {
margin-right: 0; margin-right: 0;
......
<template> <template>
<MessageBox <MessageBox ref="employeeBoxVisible"
ref="employeeBoxVisible" :is-footer="false"
:max-height="1000"
position="bottom" position="bottom"
:isFooter="false"
:title="`请选择${title}`" :title="`请选择${title}`"
:maxHeight="1000" @close="handleClose">
@close="handleClose"
>
<view class="select-box"> <view class="select-box">
<template v-for="(item, index) in employeeList" :key="index" > <template v-for="(item, index) in employeeList" :key="index">
<view <view class="select-item"
:class="['select-item',{ checked: (salesUuid as string) == (item as UTSJSONObject).uuid }]" :class="[{ checked: (salesUuid as string) == (item as UTSJSONObject).uuid }]"
@click="handleSelect(item)" @click="handleSelect(item)">
>
{{ (item as UTSJSONObject).staffName }} {{ (item as UTSJSONObject).staffName }}
</view> </view>
</template> </template>
...@@ -21,96 +18,97 @@ ...@@ -21,96 +18,97 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, computed, watch } from 'vue' import { ComponentPublicInstance, computed, ref, watch } from "vue";
import MessageBox from './MessageBox.uvue'
import { state, dispatch } from '@/store/index.uts' import { getEmployeeListApi } from "@/api/common-api.uts";
import { storage } from '@/utils/storage.uts' import { dispatch, state } from "@/store/index.uts";
import { getEmployeeListApi } from '@/api/common-api.uts' import { storage } from "@/utils/storage.uts";
import { ComponentPublicInstance } from 'vue'
import MessageBox from "./MessageBox.uvue";
type Props = { type Props = {
title?: string
salesPropsUuid?: string salesPropsUuid?: string
title?: string
} }
type UserInfo = UTSJSONObject type UserInfo = UTSJSONObject
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
title: '销售', title: "销售",
salesPropsUuid: '' salesPropsUuid: ""
}) });
const emit = defineEmits(['close', 'select']) const emit = defineEmits(["close", "select"]);
const employeeBoxVisible = ref(null) const employeeBoxVisible = ref(null);
const watchStatus = computed(() => { const watchStatus = computed(() => {
const status = state.user?.historyStatus const status = state.user?.historyStatus;
if (status == null) { if (status == null) {
return false return false;
} else if (status == 1) { } else if (status == 1) {
return true return true;
} else { } else {
return false return false;
} }
}) });
const updateView = ref<number>(Date.now()) const updateView = ref<number>(Date.now());
const salesUuid = computed(() => { const salesUuid = computed(() => {
const val1 = state.user.customerInfo.salesUuid const val1 = state.user.customerInfo.salesUuid;
const val2 = props.salesPropsUuid const val2 = props.salesPropsUuid;
return val1 !== null && val1 !== '' ? val1 : val2 return val1 !== null && val1 !== "" ? val1 : val2;
}) });
// const employeeList = computed(() => { // const employeeList = computed(() => {
// return state.user.employeeList // return state.user.employeeList
// }) // })
const employeeList = ref<Array<any>>([]) const employeeList = ref<Array<any>>([]);
watch(updateView.value,()=>{ watch(updateView.value, ()=>{
const list = storage.get("employeeList") as UTSArray<Any> const list = storage.get("employeeList") as UTSArray<Any>;
employeeList.value = list != null ? list : [] employeeList.value = list != null ? list : [];
}, { immediate: true, deep: true }) }, { immediate: true, deep: true });
function close(): void { function close(): void {
if (employeeBoxVisible.value != null) { if (employeeBoxVisible.value != null) {
(employeeBoxVisible.value as ComponentPublicInstance).$callMethod('close') (employeeBoxVisible.value as ComponentPublicInstance).$callMethod("close");
}
} }
}
watch(watchStatus.value, () => { watch(watchStatus.value, () => {
close() close();
}, { immediate: true }) }, { immediate: true });
function handleClose(): void { function handleClose(): void {
emit('close') emit("close");
} }
function open(): void { function open(): void {
if (employeeBoxVisible.value != null) { if (employeeBoxVisible.value != null) {
(employeeBoxVisible.value as ComponentPublicInstance).$callMethod('open') (employeeBoxVisible.value as ComponentPublicInstance).$callMethod("open");
} }
const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null const userInfo: null | UserInfo = storage.get("userInfo") as null | UTSJSONObject;
if (userInfo == null) return if (userInfo == null) return;
const shopMerchantId = userInfo.shopMerchantId const shopMerchantId = userInfo.shopMerchantId;
// 获取销售人员列表 // 获取销售人员列表
getEmployeeListApi({ merchantId: shopMerchantId }).then((res: any) => { getEmployeeListApi({ merchantId: shopMerchantId }).then((res: any) => {
const employeeList = res as Array<any> const employeeList = res as Array<any>;
dispatch('setEmployeeList', employeeList) dispatch("setEmployeeList", employeeList);
const listToStore = employeeList != null ? employeeList : [] const listToStore = employeeList != null ? employeeList : [];
storage.set('employeeList', listToStore, 0) storage.set("employeeList", listToStore, 0);
updateView.value = Date.now() updateView.value = Date.now();
}) });
} }
function handleSelect(item: any): void { function handleSelect(item: any): void {
close() close();
emit('select', item) emit("select", item);
} }
defineExpose({ open, close }) defineExpose({ open, close });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -127,14 +125,20 @@ ...@@ -127,14 +125,20 @@
/* width: 23.5%; */ /* width: 23.5%; */
margin-right: 2%; margin-right: 2%;
margin-bottom: 16px; margin-bottom: 16px;
text-align: center;
height: 34px; height: 34px;
line-height: 22px;
opacity: 1; opacity: 1;
border: 1px solid #dce0e6; border: 1px solid #dce0e6;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
text {
text-align: center;
color: #333; color: #333;
font-size: 16px; font-size: 16px;
border-radius: 4px; line-height: 22px;
}
&:nth-child(4n) { &:nth-child(4n) {
margin-right: 0; margin-right: 0;
......
<template> <template>
<view class="step"> <view class="step">
<MessageBox ref="formRef" <MessageBox ref="successRef"
:cancel-btn-text="`${step == 1 ? '取消' : '上一步'}`" :is-footer="false"
class="step-box" position="center"
:confirm-btn-text="`${sceneType == 0 ? (step == 1 ? '下一步' : '完成接待') : '完成接待'}`" :title="step == 1 ? '客户信息完善' : '结果反馈'"
:is-auto-close="false" @close="close">
:max-height="500" <view class="popup-content">
:popup-w="330" <!-- 内容区域 -->
:title="`${step == 1 ? '客户信息完善' : '结果反馈'}`" <scroll-view class="popup-body" scroll-y>
@cancel="cancel" <view :key="updateViewKey" class="content">
@confirm="submit">
<view :key="updateViewKey"
class="content"
name="content">
<template v-if="step == 1"> <template v-if="step == 1">
<template v-if="!check(true)"> <template v-if="!check(true)">
<view v-if="errorTip" <view v-if="errorTip" class="error-tip">
class="error-tip"> <text>以下信息不能为空,请完善信息后保存</text>
以下信息不能为空,请完善信息后保存 </view>
<view v-else class="pop-tips-wrapper">
<view class="pop-tips">
<uni-icons :size="16" type="info-circle"></uni-icons>
<text>{{ tipsText }}</text>
</view> </view>
<view v-else
class="pop-tips">
{{ tips }}
</view> </view>
</template> </template>
<view class="form"> <view class="form">
<template v-for="(i, index) in formObject" :key="index"> <template v-for="(i, index) in formObject" :key="index">
<view class="form-item"> <view class="form-item">
<view class="label flex"> <view class="label">
<view v-if="i.required == true" class="required"> <view v-if="i.required == true" class="required">
* <text>*</text>
</view> </view>
{{ i.label }} <text>{{ i.label }}</text>
</view> </view>
<view class="value" :class="[{ error: showError(i.key) && i.required == true }, { disabled: customerType == 0 || i.disabled == true }]"> <view class="value" :class="[{ error: showError(i.key) && i.required == true }, { disabled: customerType == 0 || i.disabled == true }]">
<template v-if="i.type == 'input'"> <template v-if="i.type == 'input'">
<input v-model="formData[i.key]" <un-input v-model="formData[i.key]"
class="input"
:disabled="customerType == 0" :disabled="customerType == 0"
:maxlength="i.maxlength" :maxlength="i.maxlength"
:placeholder="i.placeholder" :placeholder="i.placeholder"
placeholder-style="color:#c9c9c9;" style="flex: 1;"
:type="i.inputType" :type="i.inputType" />
@input="inputCustomer(i.key)" />
</template> </template>
<template v-else> <template v-else>
<view :key="selectKey" <view :key="selectKey"
class="select" class="select"
:class="[{'placeholder': (formData as UTSJSONObject)[i.key] == ''}]" :class="[{'placeholder': (formData as UTSJSONObject)[i.key] == ''}]"
@click="showPopup(i)"> @click="showSelectPopup(i)">
{{ (formData as UTSJSONObject)[i.key] != '' ? (formData as UTSJSONObject)[i.key] : i.placeholder }} <view class="select-content">
<text>{{ (formData as UTSJSONObject)[i.key] != '' ? (formData as UTSJSONObject)[i.key] : i.placeholder }}</text>
<uni-icons class="arrow" <uni-icons class="arrow"
:size="16" :size="16"
type="down"> type="down">
</uni-icons> </uni-icons>
</view> </view>
</view>
</template> </template>
</view> </view>
</view> </view>
...@@ -62,22 +59,40 @@ ...@@ -62,22 +59,40 @@
</view> </view>
</template> </template>
<template v-else> <template v-else>
<view class="pop-tips-wrapper">
<view class="pop-tips"> <view class="pop-tips">
请完善本次接待结果 <uni-icons :size="16" type="info-circle"></uni-icons>
<text>请完善本次接待结果</text>
</view>
</view> </view>
<view class="choose-box"> <view class="choose-box">
<template v-for="(i, index) in resultList" :key="index"> <template v-for="(item, index) in resultList" :key="index">
<view class="choose-item" <view class="choose-item"
:class="[`${i.status == receptionStatus ? (i.status == '1' ? 'success' : 'error') : ''}`]" :class="[`${item.status == receptionStatus ? (item.status == '1' ? 'success' : 'error') : ''}`]"
@click="chooseResult(i.status)"> @click="chooseResult(item.status)">
<view class="sprite-icon" :class="[`icon-face-${i.status == receptionStatus ? `${i.icon}-active` : i.icon}`]"> <view class="sprite-icon" :class="[`icon-face-${item.status == receptionStatus ? `${item.icon}-active` : item.icon}`]">
</view> </view>
{{ i.text }} <text>{{ item.text }}</text>
</view> </view>
</template> </template>
</view> </view>
</template> </template>
</view> </view>
</scroll-view>
<!-- 底部按钮 -->
<view class="popup-footer">
<un-button round="4px"
size="normal"
:text="step == 1 ? '取消' : '上一步'"
@click="cancel" />
<un-button round="4px"
size="normal"
:text="sceneType == 0 ? (step == 1 ? '下一步' : '完成接待') : '完成接待'"
type="primary"
@click="submit" />
</view>
</view>
</MessageBox> </MessageBox>
<CarBrands ref="carBrandListVisible" <CarBrands ref="carBrandListVisible"
@select="handleSelect($event as IUTSObject, 'carBrandListVisible')" /> @select="handleSelect($event as IUTSObject, 'carBrandListVisible')" />
...@@ -103,12 +118,13 @@ import { ComponentPublicInstance, computed, ref, watch } from "vue"; ...@@ -103,12 +118,13 @@ import { ComponentPublicInstance, computed, ref, watch } from "vue";
import CarBrands from "@/components/CarBrands.uvue"; import CarBrands from "@/components/CarBrands.uvue";
import Employee from "@/components/Employee.uvue"; import Employee from "@/components/Employee.uvue";
import MessageBox from "@/components/MessageBox.uvue";
import { recordService } from "@/services/recorder/index.uts"; import { recordService } from "@/services/recorder/index.uts";
import { state } from "@/store/index.uts"; import { state } from "@/store/index.uts";
import MessageBox from "./MessageBox.uvue";
type FormObjectItem = { // ============ 类型定义 ============
type FormObjectItem = {
disabled?: boolean disabled?: boolean
inputType?: string inputType?: string
key: string key: string
...@@ -118,15 +134,21 @@ import MessageBox from "./MessageBox.uvue"; ...@@ -118,15 +134,21 @@ import MessageBox from "./MessageBox.uvue";
popKey?: string popKey?: string
required?: boolean required?: boolean
type: string type: string
} }
type ResultListItem = { type ResultListItem = {
icon: string icon: string
status: string status: string
text: string text: string
} }
type Props = {
customerType?: number
sceneType?: number
titleTips?: string
}
// ============ Props & Emits ============
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
sceneType: 0, sceneType: 0,
customerType: 1, customerType: 1,
...@@ -135,13 +157,15 @@ const props = withDefaults(defineProps<Props>(), { ...@@ -135,13 +157,15 @@ const props = withDefaults(defineProps<Props>(), {
const emit = defineEmits(["submit", "back"]); const emit = defineEmits(["submit", "back"]);
// ============ 响应式数据 ============
const showPopup = ref<boolean>(false); // 控制弹窗显示(现在由 MessageBox 管理)
const formData = ref<UTSJSONObject>({ const formData = ref<UTSJSONObject>({
customerName: "", customerName: "",
carModel: "", carModel: "",
phoneNumber: "", phoneNumber: "",
salesUuid: "", salesUuid: "",
staffName: "", staffName: "",
carModelId:"" carModelId: ""
} as UTSJSONObject); } as UTSJSONObject);
const resultList = ref<Array<ResultListItem>>([ const resultList = ref<Array<ResultListItem>>([
...@@ -192,13 +216,7 @@ const formObject_boutique: Array<FormObjectItem> = [{ ...@@ -192,13 +216,7 @@ const formObject_boutique: Array<FormObjectItem> = [{
required: true required: true
}]; }];
type Props = { // 主表单配置
customerType?: number
sceneType?: number
titleTips?: string
}
const step = ref<number>(1);
const formObject = ref<Array<FormObjectItem>>([ const formObject = ref<Array<FormObjectItem>>([
{ {
label: "车主姓名", label: "车主姓名",
...@@ -236,23 +254,48 @@ const formObject = ref<Array<FormObjectItem>>([ ...@@ -236,23 +254,48 @@ const formObject = ref<Array<FormObjectItem>>([
} }
]); ]);
// UI 状态
const step = ref<number>(1);
const errorTip = ref<boolean>(false); const errorTip = ref<boolean>(false);
const receptionStatus = ref<string>(""); const receptionStatus = ref<string>("");
const updateViewKey = ref<number>(Date.now()); const updateViewKey = ref<number>(Date.now());
const selectKey = ref<number>(Date.now()); const selectKey = ref<number>(Date.now());
const formRef = ref(null); const isLoading = ref<boolean>(false); // 加载状态
const carBrandListVisible = ref(null);
const employeeBoxVisible = ref(null); // Refs
const phoneRex = /^1([3-9])\d{9}$/; const successRef = ref<ComponentPublicInstance | null>(null);
const carBrandListVisible = ref<ComponentPublicInstance | null>(null);
const employeeBoxVisible = ref<ComponentPublicInstance | null>(null);
// 获取动态ref 的值 // 正则
const getRefValue = (key: string): any | null => { const phoneRex = /^1[3-9]\d{9}$/;
// ============ 工具函数 ============
// 获取动态 ref 值
const getRefValue = (key: string): ComponentPublicInstance | null => {
if (key === "carBrandListVisible") return carBrandListVisible.value; if (key === "carBrandListVisible") return carBrandListVisible.value;
if (key === "employeeBoxVisible") return employeeBoxVisible.value; if (key === "employeeBoxVisible") return employeeBoxVisible.value;
return null; return null;
}; };
const successRef = ref(null);
// 关闭弹窗
const close = (): void => {
showPopup.value = false;
errorTip.value = false;
receptionStatus.value = "";
if (successRef.value != null) {
(successRef.value as ComponentPublicInstance).$callMethod("close");
}
};
// 显示成功提示
const showSuccess = (): void => {
if (successRef.value != null) {
successRef.value.$callMethod("open");
}
};
// ============ 计算属性 ============
const watchStatus = computed(() => { const watchStatus = computed(() => {
const status = state.user?.historyStatus; const status = state.user?.historyStatus;
if (status == null) { if (status == null) {
...@@ -264,7 +307,7 @@ const watchStatus = computed(() => { ...@@ -264,7 +307,7 @@ const watchStatus = computed(() => {
} }
}); });
const tips = computed(() => { const tipsText = computed(() => {
const _sceneType = props.sceneType; const _sceneType = props.sceneType;
const _titleTips = props.titleTips; const _titleTips = props.titleTips;
let text = _titleTips !== null && _titleTips !== "" ? _titleTips : '检测到"交车告知书"中未填写客户档案,请填写后再完成接待。'; let text = _titleTips !== null && _titleTips !== "" ? _titleTips : '检测到"交车告知书"中未填写客户档案,请填写后再完成接待。';
...@@ -272,11 +315,12 @@ const tips = computed(() => { ...@@ -272,11 +315,12 @@ const tips = computed(() => {
return text; return text;
}); });
watch(watchStatus.value, () => { // ============ 监听器 ============
watch(watchStatus, (newVal: boolean) => {
receptionStatus.value = ""; receptionStatus.value = "";
errorTip.value = false; errorTip.value = false;
if (formRef.value != null) { if (successRef.value != null) {
(formRef.value as ComponentPublicInstance).$callMethod("close"); (successRef.value as ComponentPublicInstance).$callMethod("close");
} }
}, { immediate: true }); }, { immediate: true });
function showError(key: string): boolean { function showError(key: string): boolean {
...@@ -291,7 +335,7 @@ function showError(key: string): boolean { ...@@ -291,7 +335,7 @@ function showError(key: string): boolean {
return errorTip.value && flag; return errorTip.value && flag;
} }
function showPopup(item: FormObjectItem): void { function showSelectPopup(item: FormObjectItem): void {
if (props.customerType == 0 || (item.disabled === true)) return; if (props.customerType == 0 || (item.disabled === true)) return;
const popKey = item.popKey !== null ? item.popKey : ""; const popKey = item.popKey !== null ? item.popKey : "";
const refValue = getRefValue(popKey); const refValue = getRefValue(popKey);
...@@ -299,21 +343,11 @@ function showPopup(item: FormObjectItem): void { ...@@ -299,21 +343,11 @@ function showPopup(item: FormObjectItem): void {
(refValue as ComponentPublicInstance).$callMethod("open"); (refValue as ComponentPublicInstance).$callMethod("open");
} }
} }
function close(): void {
if (formRef.value != null) {
(formRef.value as ComponentPublicInstance).$callMethod("hide");
}
errorTip.value = false;
receptionStatus.value = "";
}
// 取消 // 取消
function cancel(): void { function cancel(): void {
if (step.value == 1) close(); if (step.value == 1) close();
else step.value = 1; else step.value = 1;
} }
function check(all: boolean = false): boolean { function check(all: boolean = false): boolean {
let flag = true; let flag = true;
...@@ -341,22 +375,24 @@ function check(all: boolean = false): boolean { ...@@ -341,22 +375,24 @@ function check(all: boolean = false): boolean {
return flag; return flag;
} }
function success(): void { // 显示成功
if (successRef.value != null) { const showSuccessMessage = (): void => {
(successRef.value as ComponentPublicInstance).$callMethod("open"); showSuccess();
}
emit("submit", receptionStatus.value); emit("submit", receptionStatus.value);
} };
// 保存
function submit(): void { // 提交表单
const submit = (): void => {
if (step.value == 1) { if (step.value == 1) {
errorTip.value = true; errorTip.value = true;
if (check()) { if (check()) {
const sceneType = props.sceneType; const sceneType = props.sceneType;
if (sceneType == 0) step.value = 2; if (sceneType == 0) {
else { step.value = 2;
} else {
receptionStatus.value = "1"; receptionStatus.value = "1";
success(); showSuccessMessage();
} }
} }
} else { } else {
...@@ -367,44 +403,51 @@ function submit(): void { ...@@ -367,44 +403,51 @@ function submit(): void {
}); });
return; return;
} }
success(); showSuccessMessage();
} }
} };
function inputCustomer(key: string): void { // 输入更新
const onInputChange = (key: string): void => {
const value = (formData.value as UTSJSONObject)[key] as string; const value = (formData.value as UTSJSONObject)[key] as string;
recordService.updateBusinessData({ recordService.updateBusinessData({
[key]: value [key]: value
}); });
};
} // 选择处理
const handleSelect = (item: IUTSObject, popkey: string): void => {
function handleSelect(item: IUTSObject, popkey: string): void {
const value = formData.value as UTSJSONObject; const value = formData.value as UTSJSONObject;
const itemObj = item as UTSJSONObject; const itemObj = item as UTSJSONObject;
if (popkey === "employeeBoxVisible") { if (popkey === "employeeBoxVisible") {
(value as UTSJSONObject).salesUuid = itemObj.uuid as string; value.salesUuid = itemObj.uuid as string;
(value as UTSJSONObject).staffName = itemObj.staffName as string; value.staffName = itemObj.staffName as string;
recordService.updateBusinessData({ recordService.updateBusinessData({
salesUuid: itemObj.uuid as string, salesUuid: itemObj.uuid as string,
salesName: itemObj.staffName as string salesName: itemObj.staffName as string
}); });
} else { } else {
if (carBrandListVisible.value !== null) { if (carBrandListVisible.value !== null) {
(carBrandListVisible.value as ComponentPublicInstance).$callMethod("close"); carBrandListVisible.value.$callMethod("close");
} }
(value as UTSJSONObject).carModel = itemObj.name as string; value.carModel = itemObj.name as string;
(value as UTSJSONObject).carModelId = itemObj.id as number; value.carModelId = itemObj.id as number;
} }
formData.value = value; formData.value = value;
selectKey.value = Date.now(); selectKey.value = Date.now();
} };
function open(): void { // 打开弹窗
recordService.getBusinessData().then((data: any) =>{ const open = (): void => {
isLoading.value = true;
recordService.getBusinessData().then((data: any) => {
const customerInfo = (data != null ? data as UTSJSONObject : null); const customerInfo = (data != null ? data as UTSJSONObject : null);
if (customerInfo != null) { if (customerInfo != null) {
// 填充表单数据
formData.value = { formData.value = {
customerName: customerInfo.customerName != null && customerInfo.customerName != "null" ? customerInfo.customerName : "", customerName: customerInfo.customerName != null && customerInfo.customerName != "null" ? customerInfo.customerName : "",
carModel: customerInfo.carModel != null && customerInfo.carModel != "null" ? customerInfo.carModel : "", carModel: customerInfo.carModel != null && customerInfo.carModel != "null" ? customerInfo.carModel : "",
...@@ -413,11 +456,13 @@ function open(): void { ...@@ -413,11 +456,13 @@ function open(): void {
staffName: customerInfo.staffName != null && customerInfo.staffName != "null" ? customerInfo.staffName : "", staffName: customerInfo.staffName != null && customerInfo.staffName != "null" ? customerInfo.staffName : "",
salesUuid: customerInfo.salesUuid != null && customerInfo.salesUuid != "null" ? customerInfo.salesUuid : "", salesUuid: customerInfo.salesUuid != null && customerInfo.salesUuid != "null" ? customerInfo.salesUuid : "",
}; };
const _sceneType = props.sceneType; const _sceneType = props.sceneType;
const _customerType = props.customerType; const _customerType = props.customerType;
let stepValue = 1; let stepValue = 1;
const keys = ["customerName", "carModel", "phoneNumber"];
// 检查必填字段
const keys = ["customerName", "carModel", "phoneNumber"];
for (const key of keys) { for (const key of keys) {
const value = formData.value[key] as null | string; const value = formData.value[key] as null | string;
if (value == null || value == "") { if (value == null || value == "") {
...@@ -428,15 +473,18 @@ function open(): void { ...@@ -428,15 +473,18 @@ function open(): void {
} }
errorTip.value = false; errorTip.value = false;
if (_sceneType == 1) { if (_sceneType == 1) {
stepValue = 1; stepValue = 1;
formObject.value = formObject_boutique; formObject.value = formObject_boutique;
const checkResult = check(); const checkResult = check();
if (_customerType == 0 && !checkResult) { if (_customerType == 0 && !checkResult) {
emit("back"); emit("back");
isLoading.value = false;
return; return;
} }
} }
if (stepValue == 2) { if (stepValue == 2) {
const checkResult = check(); const checkResult = check();
if (!checkResult) { if (!checkResult) {
...@@ -444,46 +492,112 @@ function open(): void { ...@@ -444,46 +492,112 @@ function open(): void {
stepValue = 1; stepValue = 1;
} }
} }
step.value = stepValue; step.value = stepValue;
if (formRef.value != null) {
(formRef.value as ComponentPublicInstance).$callMethod("open"); // 打开弹窗
if (successRef.value != null) {
(successRef.value as ComponentPublicInstance).$callMethod("open");
} }
updateViewKey.value = Date.now(); updateViewKey.value = Date.now();
} }
isLoading.value = false;
}).catch(() => {
isLoading.value = false;
}); });
} };
function chooseResult(val: string): void { // 选择接待结果
const chooseResult = (val: string): void => {
receptionStatus.value = val; receptionStatus.value = val;
recordService.updateBusinessData({ receptionStatus: val }); recordService.updateBusinessData({ receptionStatus: val });
} };
// 暴露方法
defineExpose({ open, close }); defineExpose({ open, close });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.content{ .step {
width: 100%;
height: 100%;
}
.popup-content {
width: 375px;
background: #ffffff;
border-radius: 16px;
overflow: hidden;
display: flex;
flex-direction: column;
.popup-body {
padding: 0 20px;
max-height: 500px;
flex: 1;
overflow-y: auto;
}
.popup-footer {
display: flex;
padding: 12px 20px;
border-top: 1px solid #f0f0f0;
gap: 10px;
flex-shrink: 0;
align-items: center;
justify-content: space-between;
}
}
.content{
width: 100%; width: 100%;
flex-direction: column; flex-direction: column;
} }
.pop-tips { .pop-tips {
width: 100%; width: 100%;
background: rgba(44, 102, 247, 0.1); background: rgba(44, 102, 247, 0.1);
color: #2c66f7;
font-size: 14px;
padding: 12px 5px 12px; padding: 12px 5px 12px;
/* padding: 12px 40px 12px; */ /* padding: 12px 40px 12px; */
margin-top: 15px; margin-top: 15px;
text {
color: #2c66f7;
font-size: 14px;
text-align: center; text-align: center;
} }
}
.error-tip { .error-tip {
font-size: 14px;
padding: 16px 30px 12px; padding: 16px 30px 12px;
margin-top: 15px; margin-top: 15px;
text-align: center; text-align: center;
background-color: rgb(254, 237, 234); background-color: rgb(254, 237, 234);
text {
color: #f45c3d; color: #f45c3d;
font-size: 14px;
}
}
.pop-tips-wrapper {
margin-top: 8px;
.pop-tips {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
padding: 10px 14px;
background: rgba(44, 102, 247, 0.08);
border-radius: 6px;
text {
color: #2c66f7;
font-size: 13px;
}
}
} }
.form { .form {
...@@ -494,74 +608,92 @@ defineExpose({ open, close }); ...@@ -494,74 +608,92 @@ defineExpose({ open, close });
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
color: #6c6c70;
font-size: 15px;
box-sizing: border-box; box-sizing: border-box;
margin: 0 auto 12px; margin: 0 auto 12px;
flex-direction: row; flex-direction: row;
.label { .label {
position: relative; position: relative;
margin-left: auto;
flex-shrink: 0; flex-shrink: 0;
width: 72px; width: 80px;
display: flex;
align-items: center;
text {
color: #6c6c70;
font-size: 15px; font-size: 15px;
}
.required{ .required{
text {
color: #ff0000; color: #ff0000;
margin-right: 2px;
}
} }
} }
.value { .value {
/* width: 260px; */ flex: 1;
/* width: calc(100% - 88px); */ min-height: 40px;
flex:1;
height: 40px;
border: 1px solid #e8e8ea;
background: #ffffff; background: #ffffff;
margin-left: 16px; margin-left: 12px;
box-sizing: border-box; box-sizing: border-box;
padding: 0 20px;
border-radius: 4px; border-radius: 4px;
display: flex;
align-items: center;
&.error { &.error {
border: 1px solid #f24724; // un-input 错误状态由组件自己控制
border-radius: 4px; }
&.disabled {
background: #f4f4f4;
} }
.input,
.select { .select {
width: 100%; width: 100%;
height: 100%; height: 40px;
border: none !important; display: flex;
outline: none; align-items: center;
padding: 0 !important; justify-content: space-between;
padding: 0 12px;
border: 1px solid #e8e8ea;
border-radius: 4px;
box-sizing: border-box;
text {
font-size: 15px; font-size: 15px;
flex-direction: row; color: #333333;
&::placeholder { }
&.placeholder {
text {
color: #c9c9c9; color: #c9c9c9;
} }
} }
.select {
display: flex;
align-items: center;
justify-content: space-between;
.arrow { .arrow {
flex-shrink: 0;
margin-left: auto; margin-left: auto;
} }
} }
.placeholder { .select-content {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 100%;
text {
flex: 1;
font-size: 15px; font-size: 15px;
color: #c9c9c9 !important; color: #333333;
}
} }
.disabled {
background: #f4f4f4;
.select {
.arrow { .arrow {
display: none; flex-shrink: 0;
margin-left: auto;
} }
} }
} }
...@@ -583,6 +715,10 @@ defineExpose({ open, close }); ...@@ -583,6 +715,10 @@ defineExpose({ open, close });
justify-content: center; justify-content: center;
margin-top: 12px; margin-top: 12px;
text {
/* 选择按钮内的文字样式 */
}
.sprite-icon { .sprite-icon {
margin-right: 8px; margin-right: 8px;
} }
......
<template> <template>
<un-popup :show="visible" @close="onClose" @open="open" :mode="position"> <un-popup :mode="position"
<view :show="visible">
:class="['tips-wrapper',{'radius': position === 'center'}]" <view class="tips-wrapper"
:style="popupStyle" :class="[{'radius': position === 'center'}]"
> :style="popupStyle">
<view class="tips-content"> <view class="tips-content">
<view <view class="icon-close-box flex"
class="icon-close-box flex" @click="hide">
@click="hide" <uni-icons class="icon-close"
>
<uni-icons
class="icon-close"
type="closeempty"
:size="18"
color="#1A1A1A" color="#1A1A1A"
> :size="18"
type="closeempty">
</uni-icons> </uni-icons>
</view> </view>
<view class="tips-title"> <view class="tips-title">
<template v-if="back"> <template v-if="back">
<view <view class="sprite-icon icon-back"
class="sprite-icon icon-back" @click="hide">
@click="hide"
>
</view> </view>
</template> </template>
{{ title }} {{ title }}
</view> </view>
<text <text v-if="content"
class="tips-text" class="tips-text">
v-if="content" {{ content }}
>{{ content }}</text> </text>
<slot> <slot>
</slot> </slot>
</view> </view>
<view <view v-if="isFooter"
class="tips-footer" class="tips-footer">
v-if="isFooter" <view v-if="showCancelBtn"
>
<view
v-if="showCancelBtn"
class="tips-btn close" class="tips-btn close"
@click="cancel" @click="cancel">
>{{ {{
cancelBtnText cancelBtnText
}}</view> }}
<view </view>
class="tips-btn preview" <view class="tips-btn preview"
@click="confirm" @click="confirm">
>{{ {{
confirmBtnText confirmBtnText
}}</view> }}
</view>
</view> </view>
<template v-else> <template v-else>
<slot name="footer"> <slot name="footer">
</slot> </slot>
</template> </template>
</view> </view>
</un-popup> </un-popup>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ComponentPublicInstance } from 'vue' import { ComponentPublicInstance } from "vue";
const props = defineProps({ const props = defineProps({
isAutoClose: { isAutoClose: {
type: Boolean, type: Boolean,
default: true default: true
...@@ -103,57 +95,57 @@ ...@@ -103,57 +95,57 @@
type: Boolean, type: Boolean,
default: true default: true
} }
}) });
const emit = defineEmits(['close', const emit = defineEmits(["close",
'cancel', "cancel",
'confirm']) "confirm"]);
const visible = ref<boolean>(false) const visible = ref<boolean>(false);
const popupRef= ref(null) const popupRef= ref(null);
const popupStyle = computed(() => { const popupStyle = computed(() => {
return { return {
width: props.popupW != null && props.popupW > 0 ? (props.popupW ?? 0) + 'px' : '100%', width: props.popupW != null && props.popupW > 0 ? `${props.popupW ?? 0 }px` : "100%",
minHeight: props.popupH != null && props.popupH > 0 ? (props.popupH ?? 0) + 'px' : '100%', minHeight: props.popupH != null && props.popupH > 0 ? `${props.popupH ?? 0 }px` : "100%",
maxHeight: props.maxHeight != null && props.maxHeight > 0 ? (props.maxHeight ?? 0) + 'px' : '100%' maxHeight: props.maxHeight != null && props.maxHeight > 0 ? `${props.maxHeight ?? 0 }px` : "100%"
} };
}) });
function onClose(): void { function onClose(): void {
emit('close') emit("close");
} }
function close(): void { function close(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false;
} else { } else {
if (popupRef.value != null) { if (popupRef.value != null) {
(popupRef.value as ComponentPublicInstance).$callMethod('close') (popupRef.value as ComponentPublicInstance).$callMethod("close");
}
}
emit('close')
} }
function hide(): void {
visible.value = false
}
function open(): void {
visible.value = true
} }
emit("close");
}
function hide(): void {
visible.value = false;
}
function open(): void {
visible.value = true;
}
function cancel(): void { function cancel(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false;
}
emit('cancel')
} }
emit("cancel");
}
function confirm(): void { function confirm(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false;
}
emit('confirm')
} }
emit("confirm");
}
defineExpose({ open, close ,hide }) defineExpose({ open, close, hide });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -184,10 +176,16 @@ ...@@ -184,10 +176,16 @@
.tips-title { .tips-title {
position: relative; position: relative;
width: 100%; width: 100%;
display: flex;
align-items: center;
justify-content: center;
text {
font-weight: 500; font-weight: 500;
font-size: 18px; font-size: 18px;
color: #292d33; color: #292d33;
text-align: center; text-align: center;
}
.icon-back { .icon-back {
position: absolute; position: absolute;
...@@ -200,12 +198,16 @@ ...@@ -200,12 +198,16 @@
.tips-text { .tips-text {
display: block; display: block;
text-align: center;
margin-top: 24px;
text {
font-size: 15px; font-size: 15px;
color: #5a5e66; color: #5a5e66;
letter-spacing: 0.5px; letter-spacing: 0.5px;
text-align: center;
line-height: 20px; line-height: 20px;
margin-top: 24px; text-align: center;
}
} }
.tips-footer { .tips-footer {
...@@ -215,23 +217,32 @@ ...@@ -215,23 +217,32 @@
height: 50px; height: 50px;
border-top: 1px solid #e8e8e8; border-top: 1px solid #e8e8e8;
flex-direction: row; flex-direction: row;
.close { .close {
text {
color: #6c6c70; color: #6c6c70;
} }
}
.preview { .preview {
text {
color: #2c66f7; color: #2c66f7;
} }
} }
}
.tips-btn { .tips-btn {
width: 50%; width: 50%;
display: flex;
align-items: center;
justify-content: center;
text {
text-align: center; text-align: center;
font-size: 16px; font-size: 16px;
text-align: center;
line-height: 22px; line-height: 22px;
font-weight: 500; font-weight: 500;
justify-content: center; }
} }
} }
.radius{ .radius{
......
<template> <template>
<view class="tool-box" :style="(toolStyle ?? '') as string"> <view class="tool-box">
<view :class="['btn', { hideIcon: !show }]" @click="show = false"> <!-- 使用 uview-plus 的 FAB 组件 -->
<view class="icon sprite-icon icon-tool-file"> <un-fab v-model:active="show"
</view> active-icon="folder"
direction="bottom"
:expandable="true"
inactive-icon="folder"
:offset-right="20"
:offset-top="120"
position="top-right"
:size="56"
type="primary"
@click="handleFabClick">
<!-- <template #trigger>
<view class="custom-trigger">
文件夹 文件夹
</view> </view>
<view :class="['list', { showList: !show }]"> </template> -->
<view class="title" @click="show = true"> <template #default>
文件夹 <view class="list-wrapper">
<!-- 动态数据项 -->
<template v-for="(item, index) in displayData" :key="index">
<view class="fab-item"
@click="selectItem(item)">
<view class="icon-box">
<image class="btn-icon"
mode="aspectFill"
:src="item.shortTitleUrl" />
<text class="item-text">{{ item.shortTitle }}</text>
</view> </view>
<view class="list-body">
<template v-for="(item, index) in (displayData as Array<ToolItem>)" :key="index">
<view :class="['item', { active: item.id == props.id }]" @click="jump(item)">
<image class="icon" :src="item.shortTitleUrl" mode="scaleToFill" />
{{ item.shortTitle }}
</view> </view>
</template> </template>
</view>
<!-- 付款方式 -->
<template v-if="props.showPayBtn"> <template v-if="props.showPayBtn">
<view class="item" @click="toPay"> <view class="fab-item"
<view class="icon"> @click="toPay">
<view class="sprite-icon icon-tool-pay"> <view class="icon-box">
<view class="sprite-icon icon-tool-pay"></view>
<text class="item-text">付款方式</text>
</view> </view>
</view> </view>
付款方式
</view>
</template> </template>
<!-- 完成接待 -->
<template v-if="props.type != 'preview'"> <template v-if="props.type != 'preview'">
<view class="item" @click="finish"> <view class="fab-item"
<view class="icon"> @click="finish">
<view class="sprite-icon icon-tool-finish"> <view class="icon-box">
<view class="sprite-icon icon-tool-finish"></view>
<text class="item-text">完成接待</text>
</view> </view>
</view> </view>
完成接待
</view>
</template> </template>
</view> </view>
</template>
</un-fab>
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { state } from "@/store/index.uts";
const emit = defineEmits(['choose', 'finish', 'toPay']) const props = defineProps({
type: {
type ToolItem = {
id?: string | number
shortTitleUrl?: string
shortTitle?: string
}
const props = defineProps({
type: String, type: String,
default: ""
},
data:{ data:{
type: Array, type: Array,
default: () => [] default: () => []
}, },
id: [String, Number], id: {
showPayBtn: Boolean, type: [String, Number],
default: null
},
showPayBtn: {
type: Boolean,
default: false
},
idKey: { idKey: {
type: String, type: String,
default: 'id' default: "id"
}, },
toolStyle: String toolStyle: {
}) type: String,
default: ""
}
});
const show = ref<boolean>(true) const emit = defineEmits(["choose", "finish", "toPay"]);
type ToolItem = {
id?: number | string
shortTitle?: string
shortTitleUrl?: string
}
const displayData = computed(() => { const show = ref<boolean>(false); // 初始收起
const displayData = computed(() => {
if (props.data == null) { if (props.data == null) {
return [] as Array<ToolItem> console.log("[ToolBox] data is null");
return [] as Array<ToolItem>;
} }
console.log("[ToolBox] data:", props.data);
return (props.data as Array<UTSJSONObject>).map(element => { return (props.data as Array<UTSJSONObject>).map(element => {
return { return {
id: element.id, id: element.id,
shortTitleUrl: element.shortTitleUrl as string, shortTitleUrl: element.shortTitleUrl as string,
shortTitle: element.shortTitle as string shortTitle: element.shortTitle as string
} as ToolItem } as ToolItem;
}) });
}) });
const watchStatus = computed(() => {
const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
watch(watchStatus.value, () => { const isActive = (item: ToolItem): boolean => {
show.value = true return props.id != null && item.id === props.id;
}, { immediate: true }) };
function hide(): void { // 切换展开/收起
show.value = true const toggle = (): void => {
} show.value = !show.value;
};
function getItemTitle(item: ToolItem): string { // 处理 FAB 点击
if (item.shortTitle == null) { const handleFabClick = (): void => {
return '' toggle();
} };
return item.shortTitle
}
function getItemImageUrl(item: ToolItem): string { // 选择项目
if (item.shortTitleUrl == null) { const selectItem = (item: ToolItem): void => {
return '' show.value = false; // 自动收起
} emit("choose", item);
return item.shortTitleUrl };
}
function jump(item: ToolItem): void { function finish(): void {
show.value = true emit("finish");
emit('choose', item) }
}
function finish(): void { function toPay(): void {
emit('finish') emit("toPay");
} }
function toPay(): void { function hide(): void {
emit('toPay') show.value = false;
} }
defineExpose({ hide }) defineExpose({ hide });
</script> </script>
<style lang="scss"> <style lang="scss">
.tool-box { .tool-box {
position: fixed; position: relative;
right: 20px;
top: calc(5% + 70px);
z-index: 998;
width: 60px;
display:flex;
flex-direction: column;
.btn {
width: 100%; width: 100%;
height: 60px; height: 100%;
background-image: linear-gradient(180deg, #ffffff 0%, #f8f9fb 100%);
border: 1px solid #ffffff; .list-wrapper {
box-shadow: 0 4px 12px 0 #00000033;
border-radius: 8px;
font-size: 12px;
color: #292d33;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 16px;
padding: 16px 12px;
margin-bottom: 8px;
align-items: center; align-items: center;
.fab-item {
display: flex;
justify-content: center; justify-content: center;
padding:0; cursor: pointer;
.icon { margin-bottom:16px;
width: 30px; .icon-box {
height: 30px; position: relative;
margin-bottom: 4px; width: 56px;
transition: all 0.05s; height: 56px;
} border-radius: 50%;
} box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
.hideIcon { background: #ffffff;
height: 0; display: flex;
overflow: hidden;
opacity: 0;
.icon {
height: 0;
margin-bottom: 0;
}
}
.list {
width: 100%;
border: 1px solid #ffffff;
box-shadow: 0 4px 11px 0 #0000001a;
border-radius: 8px;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center;
overflow: hidden; overflow: hidden;
position: relative;
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
max-height: 0; .btn-icon,
opacity: 0; .sprite-icon {
transform: translateY(-10px) scale(0.95);
transform-origin: top center;
transition:
max-height 0.3s cubic-bezier(0.215, 0.61, 0.355, 1),
opacity 0.2s linear,
transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
&::after {
position: absolute; position: absolute;
content: '';
background: inherit;
top: 0; top: 0;
left: 0; left: 0;
right: 0; width: 100%;
bottom: 0; height: 100%;
z-index: -1; border-radius: 50%;
}
.title {
font-size: 12px;
width: 60px;
height: 28px;
background: #f4f4f5;
border: 1px solid #ffffff;
border-radius: 8px 8px 0 0;
display: flex;
align-items: center;
justify-content: center;
}
.list-body {
display:flex;
flex-direction:column;
max-height: 350px;
overflow-y: auto;
}
.item {
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-size: 10px; z-index: 1;
color: #666666;
width: 100%;
padding-top: 8px;
.icon {
width: 30px;
height: 30px;
margin-bottom: 4px;
}
} }
.active {
color: #2c66f7; .item-text {
position: relative;
font-size: 11px;
color: #333;
text-align: center;
white-space: nowrap;
z-index: 2;
font-weight: 500;
} }
} }
.showList {
display: flex;
max-height: 578px;
opacity: 1;
transform: translateY(0) scale(1);
padding-bottom: 8px;
} }
} }
}
</style> </style>
...@@ -196,9 +196,6 @@ const chooseMerchant = (userInfo: any): void => { ...@@ -196,9 +196,6 @@ const chooseMerchant = (userInfo: any): void => {
width: 100%; width: 100%;
height: 100%; height: 100%;
padding-top: 72px; padding-top: 72px;
font-size: 14px;
color: #333;
letter-spacing: 0;
box-sizing: border-box; box-sizing: border-box;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
...@@ -310,9 +307,7 @@ const chooseMerchant = (userInfo: any): void => { ...@@ -310,9 +307,7 @@ const chooseMerchant = (userInfo: any): void => {
border: 1.5px solid #a8c1ff; border: 1.5px solid #a8c1ff;
border-radius: 8px; border-radius: 8px;
box-sizing: border-box; box-sizing: border-box;
color: #333;
padding: 0 6px; padding: 0 6px;
font-size: 14px;
position: relative; position: relative;
.input { .input {
...@@ -320,9 +315,11 @@ const chooseMerchant = (userInfo: any): void => { ...@@ -320,9 +315,11 @@ const chooseMerchant = (userInfo: any): void => {
align-items: center; align-items: center;
height: 100%; height: 100%;
width: 100%; width: 100%;
justify-content: center;
text-align: center; text {
font-size: 14px; font-size: 14px;
text-align: center;
}
} }
.icon-search { .icon-search {
...@@ -330,8 +327,11 @@ const chooseMerchant = (userInfo: any): void => { ...@@ -330,8 +327,11 @@ const chooseMerchant = (userInfo: any): void => {
} }
.placeholder { .placeholder {
text {
font-size: 14px; font-size: 14px;
color: #999999; color: #999999;
text-align: center;
}
} }
} }
......
...@@ -2,19 +2,23 @@ ...@@ -2,19 +2,23 @@
<!-- 保持单根节点,确保父组件 v-show 生效 --> <!-- 保持单根节点,确保父组件 v-show 生效 -->
<view> <view>
<view v-if="!flag" class="skeleton-wrap"> <view v-if="!flag" class="skeleton-wrap">
<un-skeleton :loading="true" :animate="true" title avatar rows="6"></un-skeleton> <un-skeleton :animate="true"
avatar
:loading="true"
rows="6"
title>
</un-skeleton>
</view> </view>
<view v-else class="box"> <view v-else class="box">
<template v-if="loginUserInfoList.length > 0"> <template v-if="loginUserInfoList.length > 0">
<view <view v-for="(item, index) in loginUserInfoList"
v-for="(item, index) in loginUserInfoList"
:key="index" :key="index"
:class="['items', item.active ? 'active' : '']" class="items"
@click="chooseAccount(item)" :class="[item.active ? 'active' : '']"
> @click="chooseAccount(item)">
<view class="right"> <view class="right">
<view :class="['midle', getMidleClass(item)]"> <view class="midle" :class="[getMidleClass(item)]">
<text :class="['midle-text', getMidleClass(item)]">{{ getRoleText(item) }}</text> <text class="midle-text" :class="[getMidleClass(item)]">{{ getRoleText(item) }}</text>
</view> </view>
</view> </view>
<view class="left"> <view class="left">
...@@ -32,70 +36,71 @@ ...@@ -32,70 +36,71 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, defineExpose, onMounted } from 'vue' import { defineExpose, onMounted, ref } from "vue";
import { apiGetListSelectAccount, apiSelectAccountLogin, apiGetSceneMerchantRefStoreList } from '@/api/user-api.uts'
import { storage } from '@/utils/storage.uts' import { apiGetListSelectAccount, apiGetSceneMerchantRefStoreList, apiSelectAccountLogin } from "@/api/user-api.uts";
import { storage } from "@/utils/storage.uts";
type AccountItem = { type AccountItem = {
uuid: string active: boolean
merchantName: string
merchantId: string
isSuper: boolean isSuper: boolean
userType: number
loginRole: number loginRole: number
active: boolean merchantId: string
merchantName: string
userType: number
uuid: string
} }
const emit = defineEmits(['chooseAccount']) const emit = defineEmits(["chooseAccount"]);
const loginUserInfoList = ref<AccountItem[]>([]) const loginUserInfoList = ref<AccountItem[]>([]);
const copyLoginUserInfoList = ref<AccountItem[]>([]) const copyLoginUserInfoList = ref<AccountItem[]>([]);
const selectedUuid = ref<string>('') const selectedUuid = ref<string>("");
const flag = ref<boolean>(false) const flag = ref<boolean>(false);
function getRoleText(item: AccountItem): string { function getRoleText(item: AccountItem): string {
if (item.isSuper == true) return '超管' if (item.isSuper == true) return "超管";
if (item.userType == 1) return '商户' if (item.userType == 1) return "商户";
if (item.loginRole == 3) return '督导' if (item.loginRole == 3) return "督导";
if (item.loginRole == 4) return '驻店' if (item.loginRole == 4) return "驻店";
return '员工' return "员工";
} }
function getMidleClass(item: AccountItem): string { function getMidleClass(item: AccountItem): string {
if (item.isSuper == true) return 'midle_1' if (item.isSuper == true) return "midle_1";
if (item.userType == 1) return 'midle_2' if (item.userType == 1) return "midle_2";
if (item.loginRole == 3) return 'midle_3' if (item.loginRole == 3) return "midle_3";
if (item.loginRole == 4) return 'midle_4' if (item.loginRole == 4) return "midle_4";
return 'midle_5' return "midle_5";
} }
function get4SStoreList(loginUserObj: UTSJSONObject): void { function get4SStoreList(loginUserObj: UTSJSONObject): void {
console.log('get4SStoreList:', loginUserObj) console.log("get4SStoreList:", loginUserObj);
if (loginUserObj.isSuper == true) { if (loginUserObj.isSuper == true) {
emit('chooseAccount', loginUserObj) emit("chooseAccount", loginUserObj);
return return;
} }
const params: UTSJSONObject = { const params: UTSJSONObject = {
merchantId: loginUserObj.merchantId, merchantId: loginUserObj.merchantId,
staffUUID: loginUserObj.uuid staffUUID: loginUserObj.uuid
} };
apiGetSceneMerchantRefStoreList(params).then((res: any | null): void => { apiGetSceneMerchantRefStoreList(params).then((res: any | null): void => {
console.log('getSceneMerchantRefStoreList 返回数据:', res) console.log("getSceneMerchantRefStoreList 返回数据:", res);
if (res != null) { if (res != null) {
const code = (res as UTSJSONObject)['code'] as string | null const code = (res as UTSJSONObject).code as null | string;
if (code == '0') { if (code == "0") {
const data = (res as UTSJSONObject)['data'] as any[] | null const data = (res as UTSJSONObject).data as any[] | null;
if (data != null) { if (data != null) {
console.log('4S店列表数量:', data.length) console.log("4S店列表数量:", data.length);
if (data.length == 1) { if (data.length == 1) {
const store = data[0] as UTSJSONObject | null const store = data[0] as null | UTSJSONObject;
if (store != null) { if (store != null) {
const storeMerchantName = store['merchantName'] as string | null const storeMerchantName = store.merchantName as null | string;
const storeMerchantId = store['merchantId'] as string | null const storeMerchantId = store.merchantId as null | string;
const userInfoWithStore: UTSJSONObject = { const userInfoWithStore: UTSJSONObject = {
...loginUserObj, ...loginUserObj,
...@@ -114,271 +119,272 @@ function get4SStoreList(loginUserObj: UTSJSONObject): void { ...@@ -114,271 +119,272 @@ function get4SStoreList(loginUserObj: UTSJSONObject): void {
merchantId: storeMerchantId, merchantId: storeMerchantId,
merchantName: storeMerchantName merchantName: storeMerchantName
} }
};
emit("chooseAccount", userInfoWithStore);
} }
emit('chooseAccount', userInfoWithStore) } else if (data.length === 0) {
}
} else if (data.length == 0) {
uni.showToast({ uni.showToast({
title: '园区店关联的4s店商户账号无效,请联系总部管理员', title: "园区店关联的4s店商户账号无效,请联系总部管理员",
icon: 'none' icon: "none"
}) });
} else { } else {
emit('chooseAccount', loginUserObj) emit("chooseAccount", loginUserObj);
} }
} }
} else { } else {
const message = (res as UTSJSONObject)['message'] as string | null const message = (res as UTSJSONObject).message as null | string;
uni.showToast({ uni.showToast({
title: message ?? '获取4S店列表失败', title: message ?? "获取4S店列表失败",
icon: 'none' icon: "none"
}) });
} }
} }
}).catch((err: any | null): void => { }).catch((error: any | null): void => {
console.error('get4SStoreList 失败:', err) console.error("get4SStoreList 失败:", error);
uni.showToast({ uni.showToast({
title: '网络异常,请稍后重试', title: "网络异常,请稍后重试",
icon: 'none' icon: "none"
}) });
}) });
} }
function selectAccountLogin(id: string, merchantName: string, userInfo: AccountItem | null): void { function selectAccountLogin(id: string, merchantName: string, userInfo: AccountItem | null): void {
console.log(`选择账号${merchantName}登录!`) console.log(`选择账号${merchantName}登录!`);
uni.showLoading({ uni.showLoading({
title: '加载中', title: "加载中",
mask: false mask: false
}) });
const params: UTSJSONObject = { const params: UTSJSONObject = {
id: id id
} };
apiSelectAccountLogin(params).then((res: UTSJSONObject): void => { apiSelectAccountLogin(params).then((res: UTSJSONObject): void => {
uni.hideLoading() uni.hideLoading();
console.log('selectAccountLogin 返回数据:', res) console.log("selectAccountLogin 返回数据:", res);
const code = res['code'] as string | null const code = res.code as null | string;
if (code == '0') { if (code == "0") {
const data = res['data'] as UTSJSONObject | null const data = res.data as null | UTSJSONObject;
if (data != null) { if (data != null) {
const loginUserInfoListData = data['loginUserInfoList'] as any[] | null const loginUserInfoListData = data.loginUserInfoList as any[] | null;
if (loginUserInfoListData != null && loginUserInfoListData.length > 0 && userInfo != null) { if (loginUserInfoListData != null && loginUserInfoListData.length > 0 && userInfo != null) {
console.log('开始获取4S店列表') console.log("开始获取4S店列表");
console.log(loginUserInfoListData) console.log(loginUserInfoListData);
let info = loginUserInfoListData[0] as UTSJSONObject const info = loginUserInfoListData[0] as UTSJSONObject;
get4SStoreList(info) get4SStoreList(info);
} else { } else {
uni.showToast({ uni.showToast({
title: '获取4S店列表失败', title: "获取4S店列表失败",
icon: 'none' icon: "none"
}) });
} }
} }
} else { } else {
const message = res['message'] as string | null const message = res.message as null | string;
uni.showToast({ uni.showToast({
title: message ?? '选择账号失败', title: message ?? "选择账号失败",
icon: 'none' icon: "none"
}) });
} }
}).catch((err: any | null): void => { }).catch((error: any | null): void => {
uni.hideLoading() uni.hideLoading();
console.error('selectAccountLogin 失败:', err) console.error("selectAccountLogin 失败:", error);
uni.showToast({ uni.showToast({
title: '网络异常,请稍后重试', title: "网络异常,请稍后重试",
icon: 'none' icon: "none"
}) });
}) });
} }
function choiceAccountLogin(): void { function choiceAccountLogin(): void {
const list = loginUserInfoList.value const list = loginUserInfoList.value;
let id: string | null = null let id: null | string = null;
let merchantName: string | null = null let merchantName: null | string = null;
let selectedItem: AccountItem | null = null let selectedItem: AccountItem | null = null;
let i = 0 let i = 0;
while (i < list.length) { while (i < list.length) {
if (list[i].active) { if (list[i].active) {
id = list[i].uuid id = list[i].uuid;
merchantName = list[i].merchantName merchantName = list[i].merchantName;
selectedItem = list[i] selectedItem = list[i];
break break;
} }
i++ i++;
} }
if (id == null || id == '') { if (id == null || id == "") {
uni.showToast({ uni.showToast({
title: '请选择账号', title: "请选择账号",
icon: 'none' icon: "none"
}) });
return return;
} }
selectAccountLogin(id, merchantName ?? '', selectedItem) selectAccountLogin(id, merchantName ?? "", selectedItem);
} }
function chooseAccount(item: AccountItem): void { function chooseAccount(item: AccountItem): void {
const list = loginUserInfoList.value const list = loginUserInfoList.value;
let i = 0 let i = 0;
while (i < list.length) { while (i < list.length) {
list[i].active = false list[i].active = false;
if (list[i].uuid == item.uuid) { if (list[i].uuid == item.uuid) {
list[i].active = true list[i].active = true;
} }
i++ i++;
} }
loginUserInfoList.value = list loginUserInfoList.value = list;
selectedUuid.value = item.uuid selectedUuid.value = item.uuid;
choiceAccountLogin() choiceAccountLogin();
} }
function searchEvent(searchValue: string): void { function searchEvent(searchValue: string): void {
const copyList = copyLoginUserInfoList.value const copyList = copyLoginUserInfoList.value;
const uuid = selectedUuid.value const uuid = selectedUuid.value;
let i = 0 let i = 0;
while (i < copyList.length) { while (i < copyList.length) {
copyList[i].active = false copyList[i].active = false;
if (copyList[i].uuid == uuid) { if (copyList[i].uuid == uuid) {
copyList[i].active = true copyList[i].active = true;
} }
i++ i++;
} }
if (searchValue == '' || searchValue == null) { if (searchValue == "" || searchValue == null) {
loginUserInfoList.value = copyList loginUserInfoList.value = copyList;
return return;
} }
const filterArr: AccountItem[] = [] const filterArr: AccountItem[] = [];
let j = 0 let j = 0;
while (j < copyList.length) { while (j < copyList.length) {
const item = copyList[j] const item = copyList[j];
const nameMatch = item.merchantName.includes(searchValue) const nameMatch = item.merchantName.includes(searchValue);
const idMatch = item.merchantId == searchValue const idMatch = item.merchantId == searchValue;
if (nameMatch || idMatch) { if (nameMatch || idMatch) {
filterArr.push(item) filterArr.push(item);
} }
j++ j++;
} }
loginUserInfoList.value = filterArr loginUserInfoList.value = filterArr;
} }
function getListSelectAccount(autoLogin: boolean): void { function getListSelectAccount(autoLogin: boolean): void {
console.log('进入选择账号页面!autoLogin:', autoLogin) console.log("进入选择账号页面!autoLogin:", autoLogin);
flag.value = false flag.value = false;
uni.showLoading({ uni.showLoading({
title: '加载中', title: "加载中",
mask: false mask: false
}) });
const params: UTSJSONObject = {} const params: UTSJSONObject = {};
apiGetListSelectAccount(params).then((res: UTSJSONObject): void => { apiGetListSelectAccount(params).then((res: UTSJSONObject): void => {
uni.hideLoading() uni.hideLoading();
console.log('getListSelectAccount 返回数据:', res) console.log("getListSelectAccount 返回数据:", res);
const code = res['code'] as string | null const code = res.code as null | string;
if (code == '21') { if (code == "21") {
uni.reLaunch({ uni.reLaunch({
url: '/pages/common/login/index' url: "/pages/common/login/index"
}) });
return return;
} }
if (code == '0') { if (code == "0") {
const data = res['data'] as UTSJSONObject | null const data = res.data as null | UTSJSONObject;
if (data != null) { if (data != null) {
const sessionId = data['sessionId'] as string | null const sessionId = data.sessionId as null | string;
if (sessionId != null) { if (sessionId != null) {
storage.set('sessionId', sessionId, 0) storage.set("sessionId", sessionId, 0);
console.log('保存 sessionId:', sessionId) console.log("保存 sessionId:", sessionId);
} }
const list = data['loginUserInfoList'] as any[] | null const list = data.loginUserInfoList as any[] | null;
console.log('loginUserInfoList:', list) console.log("loginUserInfoList:", list);
if (list != null) { if (list != null) {
const accountList: AccountItem[] = [] const accountList: AccountItem[] = [];
let i = 0 let i = 0;
while (i < list.length) { while (i < list.length) {
const item = list[i] as UTSJSONObject | null const item = list[i] as null | UTSJSONObject;
if (item != null) { if (item != null) {
console.log('账号项数据:', item) console.log("账号项数据:", item);
const merchantIdValue = item['merchantId'] const merchantIdValue = item.merchantId;
let merchantIdStr = '' let merchantIdStr = "";
if (merchantIdValue != null) { if (merchantIdValue != null) {
merchantIdStr = `${merchantIdValue}` merchantIdStr = `${merchantIdValue}`;
} }
accountList.push({ accountList.push({
uuid: (item['uuid'] as string | null) ?? (item['id'] as string | null) ?? '', uuid: (item.uuid as null | string) ?? (item.id as null | string) ?? "",
merchantName: (item['merchantName'] as string | null) ?? (item['accountName'] as string | null) ?? '', merchantName: (item.merchantName as null | string) ?? (item.accountName as null | string) ?? "",
merchantId: merchantIdStr, merchantId: merchantIdStr,
isSuper: (item['isSuper'] as boolean | null) ?? (item['accountLevel'] as number | null) == 1, isSuper: (item.isSuper as boolean | null) ?? (item.accountLevel as null | number) == 1,
userType: (item['userType'] as number | null) ?? 0, userType: (item.userType as null | number) ?? 0,
loginRole: (item['loginRole'] as number | null) ?? (item['accountLevel'] as number | null) ?? 0, loginRole: (item.loginRole as null | number) ?? (item.accountLevel as null | number) ?? 0,
active: false active: false
}) });
} }
i++ i++;
} }
console.log('解析后的账号列表,数量:', accountList.length) console.log("解析后的账号列表,数量:", accountList.length);
loginUserInfoList.value = accountList loginUserInfoList.value = accountList;
copyLoginUserInfoList.value = accountList copyLoginUserInfoList.value = accountList;
flag.value = true flag.value = true;
console.log('设置 flag = true') console.log("设置 flag = true");
if (autoLogin && accountList.length > 0) { if (autoLogin && accountList.length > 0) {
console.log('自动选择第一个账号') console.log("自动选择第一个账号");
chooseAccount(accountList[0]) chooseAccount(accountList[0]);
} }
} else { } else {
console.log('loginUserInfoList 为空') console.log("loginUserInfoList 为空");
flag.value = true flag.value = true;
} }
} }
} else { } else {
const message = res['message'] as string | null const message = res.message as null | string;
uni.showToast({ uni.showToast({
title: message ?? '获取账号列表失败', title: message ?? "获取账号列表失败",
icon: 'none' icon: "none"
}) });
flag.value = true flag.value = true;
} }
}).catch((err: any | null): void => { }).catch((error: any | null): void => {
uni.hideLoading() uni.hideLoading();
flag.value = true flag.value = true;
console.error('getListSelectAccount 失败:', err) console.error("getListSelectAccount 失败:", error);
uni.showToast({ uni.showToast({
title: '网络异常,请稍后重试', title: "网络异常,请稍后重试",
icon: 'none' icon: "none"
}) });
}) });
} }
defineExpose({ defineExpose({
getListSelectAccount, getListSelectAccount,
searchEvent searchEvent
}) });
onMounted(() => { onMounted(() => {
console.log('AccountList 组件已挂载,开始加载数据') console.log("AccountList 组件已挂载,开始加载数据");
getListSelectAccount(false) getListSelectAccount(false);
}) });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.skeleton-wrap { .skeleton-wrap {
padding: 24px; padding: 24px;
width: 100%;
} }
.box { .box {
...@@ -447,28 +453,43 @@ onMounted(() => { ...@@ -447,28 +453,43 @@ onMounted(() => {
} }
.midle_1 { .midle_1 {
color: #f24724;
background-color: #f247241a; background-color: #f247241a;
.midle-text {
color: #f24724;
}
} }
.midle_2 { .midle_2 {
color: #ff9d0a;
background-color: #ff9d0a1a; background-color: #ff9d0a1a;
.midle-text {
color: #ff9d0a;
}
} }
.midle_3 { .midle_3 {
color: #347bff;
background-color: #347bff1a; background-color: #347bff1a;
.midle-text {
color: #347bff;
}
} }
.midle_4 { .midle_4 {
color: #35c376;
background-color: #35c3761a; background-color: #35c3761a;
.midle-text {
color: #35c376;
}
} }
.midle_5 { .midle_5 {
color: #35c376;
background-color: #35c3761a; background-color: #35c3761a;
.midle-text {
color: #35c376;
}
} }
} }
} }
......
<template> <template>
<view v-if="!flag" class="skeleton-wrap"> <view v-if="!flag" class="skeleton-wrap">
<un-skeleton :loading="true" :animate="true" title avatar rows="6"></un-skeleton> <un-skeleton :animate="true"
avatar
:loading="true"
rows="6"
title>
</un-skeleton>
</view> </view>
<view v-if="flag" class="box"> <view v-if="flag" class="box">
<template v-if="loginUserInfoList.length > 0"> <template v-if="loginUserInfoList.length > 0">
<view <view v-for="(item, index) in loginUserInfoList"
v-for="(item, index) in loginUserInfoList"
:key="index" :key="index"
:class="['items', item.active ? 'active' : '']" class="items"
@click="chooseMerchantItem(item)" :class="[item.active ? 'active' : '']"
> @click="chooseMerchantItem(item)">
<view class="right"> <view class="right">
<view class="sprite-icon icon-store"></view> <view class="sprite-icon icon-store"></view>
</view> </view>
...@@ -24,69 +28,70 @@ ...@@ -24,69 +28,70 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, defineExpose } from 'vue' import { defineExpose, ref } from "vue";
import { apiGetSceneMerchantRefStoreList, apiGetYqMerchantSceneConfigAPI, apiSelectMerchantScene } from '@/api/user-api.uts'
import { storage } from '@/utils/storage.uts' import { apiGetSceneMerchantRefStoreList, apiGetYqMerchantSceneConfigAPI, apiSelectMerchantScene } from "@/api/user-api.uts";
import { storage } from "@/utils/storage.uts";
type MerchantItem = { type MerchantItem = {
active: boolean
merchantId: string merchantId: string
merchantName: string merchantName: string
active: boolean
} }
const emit = defineEmits(['chooseMerchant']) const emit = defineEmits(["chooseMerchant"]);
const loginUserInfoList = ref<MerchantItem[]>([]) const loginUserInfoList = ref<MerchantItem[]>([]);
const copyLoginUserInfoList = ref<MerchantItem[]>([]) const copyLoginUserInfoList = ref<MerchantItem[]>([]);
const flag = ref<boolean>(false) const flag = ref<boolean>(false);
const selectMerchantId = ref<string>('') const selectMerchantId = ref<string>("");
let userInfo: UTSJSONObject | null = null let userInfo: null | UTSJSONObject = null;
function jumpPage(item: MerchantItem, openSceneArr: number[]): void { function jumpPage(item: MerchantItem, openSceneArr: number[]): void {
const shopMerchantName = item.merchantName const shopMerchantName = item.merchantName;
const shopMerchantId = item.merchantId const shopMerchantId = item.merchantId;
const usedCarSceneType = 7 const usedCarSceneType = 7;
const currentUserInfo = userInfo const currentUserInfo = userInfo;
if (currentUserInfo == null) { if (currentUserInfo == null) {
uni.hideLoading() uni.hideLoading();
return return;
} }
if (openSceneArr.length == 0) { if (openSceneArr.length === 0) {
const isSuper = currentUserInfo['isSuper'] as boolean | null const isSuper = currentUserInfo.isSuper as boolean | null;
if (isSuper != true) { if (isSuper != true) {
uni.hideLoading() uni.hideLoading();
uni.showToast({ title: '暂无开通业务,请联系总部管理员', icon: 'none' }) uni.showToast({ title: "暂无开通业务,请联系总部管理员", icon: "none" });
return return;
} }
} }
let finalOpenSceneArr = openSceneArr let finalOpenSceneArr = openSceneArr;
const isSuperVal = currentUserInfo['isSuper'] as boolean | null const isSuperVal = currentUserInfo.isSuper as boolean | null;
if (isSuperVal == true) { if (isSuperVal == true) {
finalOpenSceneArr = [1, 0, usedCarSceneType] finalOpenSceneArr = [1, 0, usedCarSceneType];
} }
const newUserInfo: UTSJSONObject = {} const newUserInfo: UTSJSONObject = {};
for (const k in currentUserInfo) { for (const k in currentUserInfo) {
newUserInfo[k] = currentUserInfo[k] newUserInfo[k] = currentUserInfo[k];
} }
newUserInfo['openSceneArr'] = finalOpenSceneArr newUserInfo.openSceneArr = finalOpenSceneArr;
newUserInfo['shopMerchantName'] = shopMerchantName newUserInfo.shopMerchantName = shopMerchantName;
newUserInfo['shopMerchantId'] = shopMerchantId newUserInfo.shopMerchantId = shopMerchantId;
newUserInfo['default4SStoreInfo'] = { newUserInfo.default4SStoreInfo = {
merchantId: shopMerchantId, merchantId: shopMerchantId,
merchantName: shopMerchantName merchantName: shopMerchantName
} };
newUserInfo['default4SStoreInfo_crowdFunding'] = { newUserInfo.default4SStoreInfo_crowdFunding = {
merchantId: shopMerchantId, merchantId: shopMerchantId,
merchantName: shopMerchantName merchantName: shopMerchantName
} };
newUserInfo['default4SStoreInfo_newCarConversion'] = { newUserInfo.default4SStoreInfo_newCarConversion = {
merchantId: shopMerchantId, merchantId: shopMerchantId,
merchantName: shopMerchantName merchantName: shopMerchantName
} };
if (finalOpenSceneArr.length == 1 && finalOpenSceneArr[0] == usedCarSceneType) { if (finalOpenSceneArr.length == 1 && finalOpenSceneArr[0] == usedCarSceneType) {
apiSelectMerchantScene({ apiSelectMerchantScene({
...@@ -95,201 +100,202 @@ function jumpPage(item: MerchantItem, openSceneArr: number[]): void { ...@@ -95,201 +100,202 @@ function jumpPage(item: MerchantItem, openSceneArr: number[]): void {
sceneType: usedCarSceneType sceneType: usedCarSceneType
}).then((data: any): void => { }).then((data: any): void => {
if (data != null) { if (data != null) {
const loginRole = (data as UTSJSONObject)['loginRoleOnSelectMerchant'] const loginRole = (data as UTSJSONObject).loginRoleOnSelectMerchant;
if (loginRole != null) { if (loginRole != null) {
newUserInfo['loginRoleOnSelectMerchant'] = loginRole newUserInfo.loginRoleOnSelectMerchant = loginRole;
} }
} }
newUserInfo['sceneType'] = usedCarSceneType newUserInfo.sceneType = usedCarSceneType;
storage.set('userInfo', newUserInfo, 0) storage.set("userInfo", newUserInfo, 0);
uni.hideLoading() uni.hideLoading();
uni.reLaunch({ url: '/pages/usedCar/index' }) uni.reLaunch({ url: "/pages/usedCar/index" });
}).catch((err): void => { }).catch((error): void => {
uni.hideLoading() uni.hideLoading();
uni.showToast({ title: '网络异常', icon: 'none' }) uni.showToast({ title: "网络异常", icon: "none" });
}) });
return return;
} }
emit('chooseMerchant', newUserInfo) emit("chooseMerchant", newUserInfo);
uni.hideLoading() uni.hideLoading();
} }
function getSceneArr(shopMerchantId: string): Promise<number[]> { function getSceneArr(shopMerchantId: string): Promise<number[]> {
return new Promise((resolve) => { return new Promise((resolve) => {
const currentUserInfo = userInfo const currentUserInfo = userInfo;
if (currentUserInfo == null) { if (currentUserInfo == null) {
resolve([]) resolve([]);
return return;
} }
const yqMerchantId = (currentUserInfo['subLoginUser'] as UTSJSONObject | null)?.['merchantId'] ?? currentUserInfo['merchantId'] const yqMerchantId = (currentUserInfo.subLoginUser as null | UTSJSONObject)?.merchantId ?? currentUserInfo.merchantId;
const yqId = yqMerchantId != null ? `${yqMerchantId}` : '' const yqId = yqMerchantId != null ? `${yqMerchantId}` : "";
const params: UTSJSONObject = { const params: UTSJSONObject = {
yqMerchantId: yqId, yqMerchantId: yqId,
merchantId: shopMerchantId merchantId: shopMerchantId
} };
apiGetYqMerchantSceneConfigAPI(params).then((res: any): void => { apiGetYqMerchantSceneConfigAPI(params).then((res: any): void => {
const code = (res as UTSJSONObject)['code'] as string | null const code = (res as UTSJSONObject).code as null | string;
if (code == '0') { if (code == "0") {
const data = (res as UTSJSONObject)['data'] as any[] | null const data = (res as UTSJSONObject).data as any[] | null;
const openSceneArr: number[] = [] const openSceneArr: number[] = [];
if (data != null) { if (data != null) {
let i = 0 let i = 0;
while (i < data.length) { while (i < data.length) {
const val = data[i] as UTSJSONObject | null const val = data[i] as null | UTSJSONObject;
if (val != null) { if (val != null) {
const sceneOpenFlag = val['sceneOpenFlag'] as number | null const sceneOpenFlag = val.sceneOpenFlag as null | number;
if (sceneOpenFlag == 0) { if (sceneOpenFlag == 0) {
const scene = val['scene'] as number | null const scene = val.scene as null | number;
if (scene != null) { if (scene != null) {
openSceneArr.push(scene) openSceneArr.push(scene);
} }
} }
} }
i++ i++;
} }
} }
resolve(openSceneArr) resolve(openSceneArr);
} else { } else {
resolve([]) resolve([]);
} }
}).catch((err) => { }).catch((error) => {
console.error('getSceneArr 失败:', err) console.error("getSceneArr 失败:", error);
resolve([]) resolve([]);
}) });
}) });
} }
function chooseMerchantItem(item: MerchantItem): void { function chooseMerchantItem(item: MerchantItem): void {
console.log('选择4s店' + item.merchantName + '!') console.log(`选择4s店${ item.merchantName }!`);
uni.showLoading({ title: '加载中', mask: false }) uni.showLoading({ title: "加载中", mask: false });
const list = loginUserInfoList.value const list = loginUserInfoList.value;
let i = 0 let i = 0;
while (i < list.length) { while (i < list.length) {
list[i].active = list[i].merchantId == item.merchantId list[i].active = list[i].merchantId == item.merchantId;
i++ i++;
} }
loginUserInfoList.value = list loginUserInfoList.value = list;
selectMerchantId.value = item.merchantId selectMerchantId.value = item.merchantId;
getSceneArr(item.merchantId).then((openSceneArr: number[]): void => { getSceneArr(item.merchantId).then((openSceneArr: number[]): void => {
jumpPage(item, openSceneArr) jumpPage(item, openSceneArr);
}) });
} }
function getMerchantList(): void { function getMerchantList(): void {
loginUserInfoList.value = [] loginUserInfoList.value = [];
copyLoginUserInfoList.value = [] copyLoginUserInfoList.value = [];
flag.value = false flag.value = false;
const currentUserInfo = userInfo const currentUserInfo = userInfo;
if (currentUserInfo == null) { if (currentUserInfo == null) {
return return;
} }
uni.showLoading({ title: '加载中', mask: false }) uni.showLoading({ title: "加载中", mask: false });
const isSuper = currentUserInfo['isSuper'] as boolean | null const isSuper = currentUserInfo.isSuper as boolean | null;
const params: UTSJSONObject = { const params: UTSJSONObject = {
merchantId: isSuper == true ? '' : `${currentUserInfo['merchantId'] ?? ''}`, merchantId: isSuper == true ? "" : `${currentUserInfo.merchantId ?? ""}`,
staffUUID: isSuper == true ? '' : `${currentUserInfo['uuid'] ?? ''}` staffUUID: isSuper == true ? "" : `${currentUserInfo.uuid ?? ""}`
} };
apiGetSceneMerchantRefStoreList(params).then((res: any): void => { apiGetSceneMerchantRefStoreList(params).then((res: any): void => {
uni.hideLoading() uni.hideLoading();
const code = (res as UTSJSONObject)['code'] as string | null const code = (res as UTSJSONObject).code as null | string;
if (code == '0') { if (code == "0") {
const data = (res as UTSJSONObject)['data'] as any[] | null const data = (res as UTSJSONObject).data as any[] | null;
if (data != null) { if (data != null) {
const list: MerchantItem[] = [] const list: MerchantItem[] = [];
let i = 0 let i = 0;
while (i < data.length) { while (i < data.length) {
const item = data[i] as UTSJSONObject | null const item = data[i] as null | UTSJSONObject;
if (item != null) { if (item != null) {
const mid = item['merchantId'] const mid = item.merchantId;
list.push({ list.push({
merchantId: mid != null ? `${mid}` : '', merchantId: mid != null ? `${mid}` : "",
merchantName: (item['merchantName'] as string | null) ?? '', merchantName: (item.merchantName as null | string) ?? "",
active: false active: false
}) });
} }
i++ i++;
} }
loginUserInfoList.value = list loginUserInfoList.value = list;
copyLoginUserInfoList.value = list copyLoginUserInfoList.value = list;
flag.value = true flag.value = true;
if (list.length == 1) { if (list.length == 1) {
chooseMerchantItem(list[0]) chooseMerchantItem(list[0]);
} }
} else { } else {
flag.value = true flag.value = true;
} }
} else { } else {
flag.value = true flag.value = true;
const msg = (res as UTSJSONObject)['message'] as string | null const msg = (res as UTSJSONObject).message as null | string;
uni.showToast({ title: msg ?? '获取4S店列表失败', icon: 'none' }) uni.showToast({ title: msg ?? "获取4S店列表失败", icon: "none" });
} }
}).catch((err) => { }).catch((error) => {
uni.hideLoading() uni.hideLoading();
flag.value = true flag.value = true;
console.error('getMerchantList 失败:', err) console.error("getMerchantList 失败:", error);
uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' }) uni.showToast({ title: "网络异常,请稍后重试", icon: "none" });
}) });
} }
function init(info: any): void { function init(info: any): void {
console.log('进入选择4s店页面!') console.log("进入选择4s店页面!");
// 将 any 转换为 UTSJSONObject // 将 any 转换为 UTSJSONObject
userInfo = info as UTSJSONObject userInfo = info as UTSJSONObject;
getMerchantList() getMerchantList();
} }
function searchEvent(searchValue: string): void { function searchEvent(searchValue: string): void {
const copyList = copyLoginUserInfoList.value const copyList = copyLoginUserInfoList.value;
const uuid = selectMerchantId.value const uuid = selectMerchantId.value;
const list = loginUserInfoList.value const list = loginUserInfoList.value;
let i = 0 let i = 0;
while (i < copyList.length) { while (i < copyList.length) {
copyList[i].active = copyList[i].merchantId == uuid copyList[i].active = copyList[i].merchantId == uuid;
i++ i++;
} }
if (searchValue == '' || searchValue == null) { if (searchValue == "" || searchValue == null) {
loginUserInfoList.value = copyList loginUserInfoList.value = copyList;
return return;
} }
const filterArr: MerchantItem[] = [] const filterArr: MerchantItem[] = [];
let j = 0 let j = 0;
while (j < copyList.length) { while (j < copyList.length) {
const val = copyList[j] const val = copyList[j];
const nameMatch = val.merchantName.includes(searchValue) const nameMatch = val.merchantName.includes(searchValue);
const idMatch = val.merchantId == searchValue const idMatch = val.merchantId == searchValue;
if (nameMatch || idMatch) { if (nameMatch || idMatch) {
filterArr.push(val) filterArr.push(val);
} }
j++ j++;
} }
loginUserInfoList.value = filterArr loginUserInfoList.value = filterArr;
} }
defineExpose({ defineExpose({
init, init,
searchEvent searchEvent
}) });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.skeleton-wrap { .skeleton-wrap {
padding: 24px; padding: 24px;
width: 100%;
} }
.box { .box {
......
<template> <template>
<view v-if="loading" class="skeleton-wrap"> <view v-if="loading" class="skeleton-wrap">
<un-skeleton :loading="true" :animate="true" title avatar rows="3"></un-skeleton> <un-skeleton :animate="true"
avatar
:loading="true"
rows="3"
title>
</un-skeleton>
</view> </view>
<view v-else class="box"> <view v-else class="box">
<view v-for="(item, index) in sceneList" <view v-for="(item, index) in sceneList"
...@@ -83,7 +88,7 @@ function jump(info: UTSJSONObject, data: any | null): void { ...@@ -83,7 +88,7 @@ function jump(info: UTSJSONObject, data: any | null): void {
} else { } else {
info.channelType = 1; info.channelType = 1;
} }
info.staffUuid = info.uuid info.staffUuid = info.uuid;
storage.set("userInfo", info, 0); storage.set("userInfo", info, 0);
const sceneType = info.sceneType as null | number; const sceneType = info.sceneType as null | number;
...@@ -229,6 +234,7 @@ defineExpose({ ...@@ -229,6 +234,7 @@ defineExpose({
<style scoped lang="scss"> <style scoped lang="scss">
.skeleton-wrap { .skeleton-wrap {
padding: 24px; padding: 24px;
width: 100%;
} }
.box { .box {
......
...@@ -32,10 +32,10 @@ ...@@ -32,10 +32,10 @@
<view v-if="code != ''" <view v-if="code != ''"
class="icon" class="icon"
@click="clearCode"> @click="clearCode">
<icon color="#000" <uni-icons color="#000"
size="16" size="16"
type="clear"> type="clear">
</icon> </uni-icons>
</view> </view>
<view class="code-btn" <view class="code-btn"
:class="[count > 0 ? 'code-disabled' : '']" :class="[count > 0 ? 'code-disabled' : '']"
......
...@@ -65,10 +65,13 @@ ...@@ -65,10 +65,13 @@
.code-btn { .code-btn {
flex-shrink: 0; flex-shrink: 0;
margin-right: 20px; margin-right: 20px;
border: none;
text {
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
color: #2c66f7; color: #2c66f7;
border: none; }
} }
.code-disabled { .code-disabled {
...@@ -122,10 +125,13 @@ ...@@ -122,10 +125,13 @@
position: fixed; position: fixed;
bottom: 10px; bottom: 10px;
left: 50%; left: 50%;
transform: translate(-50%);
text {
font-size: 12px; font-size: 12px;
line-height: 20px; line-height: 20px;
color: #999; color: #999;
transform: translate(-50%); }
.icon-clone { .icon-clone {
width: 12px; width: 12px;
......
<template> <template>
<layout-root> <layout-root>
<view <view :key="dateilKey"
class="detail-box" class="detail-box">
:key="dateilKey" <view class="nav-bar"
> :style="{ 'z-index': backZindex }">
<view <view class="back"
class="nav-bar" @click="back">
:style="{ 'z-index': backZindex }" <uni-icons color="#000"
>
<view
class="back"
@click="back"
>
<uni-icons
type="left"
:size="20" :size="20"
color="#000" type="left">
>
</uni-icons> </uni-icons>
</view> </view>
</view> </view>
<template v-for="(item, index) in moduleList" :key="index"> <template v-for="(item, index) in moduleList" :key="index">
<!-- <template v-for="(item, index) in (useCarConfig ? moduleList : media)" :key="index"> --> <!-- <template v-for="(item, index) in (useCarConfig ? moduleList : media)" :key="index"> -->
<view <view class="view" :class="[{ showView: id == (item as UTSJSONObject).id }, modeName]">
:class="['view', { showView: id == (item as UTSJSONObject).id }, modeName]"
>
<!-- 不支持动态组件 --> <!-- 不支持动态组件 -->
<!-- <component <!-- <component
:is="item.componentName" :is="item.componentName"
...@@ -44,11 +34,9 @@ ...@@ -44,11 +34,9 @@
:hasCarBrand="item.hasCarBrand" :hasCarBrand="item.hasCarBrand"
/> --> /> -->
<template v-if="(item as UTSJSONObject).componentName == 'reception'"> <template v-if="(item as UTSJSONObject).componentName == 'reception'">
<reception <Reception :show="id == (item as UTSJSONObject).id"
:views="(item as UTSJSONObject).receptionSourceDetailList"
:show="id == (item as UTSJSONObject).id"
:title="title" :title="title"
/> :views="(item as UTSJSONObject).receptionSourceDetailList" />
</template> </template>
<!-- <template v-else-if="(item as UTSJSONObject).componentName == 'history'"> <!-- <template v-else-if="(item as UTSJSONObject).componentName == 'history'">
...@@ -104,16 +92,14 @@ ...@@ -104,16 +92,14 @@
</template> </template>
<template v-if="type != 'preview'"> <template v-if="type != 'preview'">
<template v-if="backZindex"> <template v-if="backZindex">
<tool-box <ToolBox :id="id"
ref="toolRef" ref="toolRef"
:data="pageToolList" :data="pageToolList"
:show-pay-btn="paymentTypeList.length > 0"
:type="type" :type="type"
@choose="choose" @choose="choose"
@finish="open" @finish="open"
:id="id" @to-pay="toPay" />
@toPay="toPay"
:showPayBtn="paymentTypeList.length > 0"
/>
<!-- <view <!-- <view
class="pen-box" class="pen-box"
@click="drawStatus = !drawStatus" @click="drawStatus = !drawStatus"
...@@ -137,203 +123,200 @@ ...@@ -137,203 +123,200 @@
<!-- <BackPress ref="backpressRef" @openStep="openStep" @backHome="backHome" /> --> <!-- <BackPress ref="backpressRef" @openStep="openStep" @backHome="backHome" /> -->
<finish-step <FinishStep ref="stepRef"
ref="stepRef" :title-tips="finishTips"
@submit="done" @submit="done" />
:titleTips="finishTips" </layout-root>
/>
</layout-root>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { storage } from '@/utils/storage.uts' // import { receptionTrackMixin } from '@/mixin/index.js'
import { ComponentPublicInstance, ref } from "vue";
import ToolBox from '@/components/ToolBox.uvue' import { findPayInfo as findPayInfoApi } from "@/api/common-api.uts";
import Reception from './components/Reception.uvue' // import informationEntry from './components/informationEntry.uvue'
// import insurance from './components/Insurance/index.uvue'
// import CaseCenter from './components/CaseCenter.uvue' // import CaseCenter from './components/CaseCenter.uvue'
// import MediaComponent from './components/MediaComponent.uvue' // import MediaComponent from './components/MediaComponent.uvue'
// import History from './components/History.uvue' // import History from './components/History.uvue'
// import ThreeGuarantees from './components/ThreeGuarantees.uvue' // import ThreeGuarantees from './components/ThreeGuarantees.uvue'
// import payPop from './components/payPop.uvue' // import payPop from './components/payPop.uvue'
import FinishStep from '@/components/FinishStep.uvue' import FinishStep from "@/components/FinishStep.uvue";
// import informationEntry from './components/informationEntry.uvue' import ToolBox from "@/components/ToolBox.uvue";
// import insurance from './components/Insurance/index.uvue' import { recordService } from "@/services/recorder/index.uts";
import BackPress from '@/components/BackPress.uvue' import { dispatch, state } from "@/store/index.uts";
// import { receptionTrackMixin } from '@/mixin/index.js' import { storage } from "@/utils/storage.uts";
import { ref, getCurrentInstance, ComponentPublicInstance } from 'vue'
import { state , dispatch} from "@/store/index.uts" import Reception from "./components/Reception.uvue";
import { getSoureData } from '@/api/system-api.uts'
import { findPayInfo as findPayInfoApi } from '@/api/common-api.uts'
import { recordService } from '@/services/recorder/index.uts'
type BackPressEvent = { type BackPressEvent = {
from: string from: string
} }
const backZindex = ref<number>(9) const backZindex = ref<number>(9);
const drawStatus = ref<boolean>(false) const drawStatus = ref<boolean>(false);
const startX = ref<number>(0) const startX = ref<number>(0);
const startY = ref<number>(0) const startY = ref<number>(0);
const screenWidth = ref<number>(0) const screenWidth = ref<number>(0);
const scaleValueObject = ref<UTSJSONObject>({}) const scaleValueObject = ref<UTSJSONObject>({});
const showPayPage = ref<boolean>(false) const showPayPage = ref<boolean>(false);
const productModelStatus = ref<boolean>(false) const productModelStatus = ref<boolean>(false);
const modeName = ref<string>('') const modeName = ref<string>("");
const pageToolList = ref<Array<any>>([]) const pageToolList = ref<Array<any>>([]);
const moduleList = ref<Array<any>>([]) const moduleList = ref<Array<any>>([]);
const useCarConfig = ref<boolean>(false) const useCarConfig = ref<boolean>(false);
const dateilKey = ref<number>(Date.now()) const dateilKey = ref<number>(Date.now());
const currentMediaId = ref<string>('') const currentMediaId = ref<string>("");
const id = ref<string>('') const id = ref<string>("");
const type = ref<string>('') const type = ref<string>("");
const media = ref<Array<any>>([]) const media = ref<Array<any>>([]);
const toolList = ref<Array<any>>([]) const toolList = ref<Array<any>>([]);
const paymentTypeList = ref<Array<any>>([]) const paymentTypeList = ref<Array<any>>([]);
const toolRef = ref(null) const toolRef = ref(null);
const payRef = ref(null) const payRef = ref(null);
const stepRef = ref(null) const stepRef = ref(null);
const backpressRef = ref(null) const backpressRef = ref(null);
// 用于存储动态ref 的对象 // 用于存储动态ref 的对象
const mediaRefs = ref<UTSJSONObject>({}) const mediaRefs = ref<UTSJSONObject>({});
// 设置动态 ref 的函数 // 设置动态 ref 的函数
const setMediaRef = (id: string | number, component: any): void => { const setMediaRef = (id: number | string, component: any): void => {
if (component != null) { if (component != null) {
mediaRefs.value[`media${id}`] = component mediaRefs.value[`media${id}`] = component;
}
} }
};
type UserInfo = UTSJSONObject type UserInfo = UTSJSONObject
const channelType = computed<number>(() => { const channelType = computed<number>(() => {
const userInfo = storage.get('userInfo') as UTSJSONObject const userInfo = storage.get("userInfo") as UTSJSONObject;
if (userInfo == null) return 0 if (userInfo == null) return 0;
return (userInfo.channelType as number) ?? 0 return (userInfo.channelType as number) ?? 0;
}) });
const shopMerchantId = computed<string | null>(() => { const shopMerchantId = computed<null | string>(() => {
const userInfo = storage.get('userInfo') as UTSJSONObject const userInfo = storage.get("userInfo") as UTSJSONObject;
return (userInfo?.shopMerchantId as string) ?? null return (userInfo?.shopMerchantId as string) ?? null;
}) });
const sceneType = computed<any>(() => { const sceneType = computed<any>(() => {
const userInfo = storage.get('userInfo') as UTSJSONObject const userInfo = storage.get("userInfo") as UTSJSONObject;
return (userInfo?.sceneType) ?? 0 return (userInfo?.sceneType) ?? 0;
}) });
const currentCarInfo = computed(() => { const currentCarInfo = computed(() => {
const data = state.user.currentCarInfo const data = state.user.currentCarInfo;
return data as UTSJSONObject return data as UTSJSONObject;
}) });
const watchStatus = computed(() => { const watchStatus = computed(() => {
const status = state.user?.historyStatus const status = state.user?.historyStatus;
if (status == null) { if (status == null) {
return false return false;
} else if (status == 1) { } else if (status == 1) {
return true return true;
} else { } else {
return false return false;
} }
}) });
const isPreview = computed<boolean>(() => { const isPreview = computed<boolean>(() => {
return type.value == 'preview' return type.value == "preview";
}) });
const penSwitch = computed<boolean>(() => { const penSwitch = computed<boolean>(() => {
return isPreview.value == false && drawStatus.value == true return isPreview.value == false && drawStatus.value == true;
}) });
const title = computed(() => { const title = computed(() => {
let mediaItem: UTSJSONObject | null = null let mediaItem: null | UTSJSONObject = null;
for (const e of media.value) { for (const e of media.value) {
if ((e as UTSJSONObject).id == id.value) { if ((e as UTSJSONObject).id == id.value) {
mediaItem = e as UTSJSONObject mediaItem = e as UTSJSONObject;
break break;
} }
} }
const titleValue = mediaItem?.detailTitle; const titleValue = mediaItem?.detailTitle;
return titleValue != null ? titleValue as string : ''; return titleValue != null ? titleValue as string : "";
}) });
const finishTips = computed(() => { const finishTips = computed(() => {
let text = '' let text = "";
if (channelType.value == 3) text = '检测到"汽车保险告知书"中未填写客户档案,请填写后再完成接待。' if (channelType.value == 3) text = '检测到"汽车保险告知书"中未填写客户档案,请填写后再完成接待。';
return text return text;
}) });
function setViewInfo(data: any): void { function setViewInfo(data: any): void {
if (data == null) return if (data == null) return;
const pageId = id.value const pageId = id.value;
const useCarConfigVal = useCarConfig.value const useCarConfigVal = useCarConfig.value;
const pageModuleListVal = moduleList.value const pageModuleListVal = moduleList.value;
const pageMediaVal = media.value const pageMediaVal = media.value;
const array = useCarConfigVal === true ? pageModuleListVal : pageMediaVal const array = useCarConfigVal === true ? pageModuleListVal : pageMediaVal;
let findItem: UTSJSONObject = {} as UTSJSONObject let findItem: UTSJSONObject = {} as UTSJSONObject;
for (const item of array) { for (const item of array) {
if ((item as UTSJSONObject).id == pageId) { if ((item as UTSJSONObject).id == pageId) {
findItem = item as UTSJSONObject findItem = item as UTSJSONObject;
break break;
} }
} }
const detailTitle = findItem != null ? (findItem.detailTitle != null ? findItem.detailTitle : '') : '' const detailTitle = findItem != null ? (findItem.detailTitle != null ? findItem.detailTitle : "") : "";
// receptionTrackLeave() // receptionTrackLeave()
console.log(data) console.log(data);
let dataObj: UTSJSONObject = {} as UTSJSONObject let dataObj: UTSJSONObject = {} as UTSJSONObject;
if (typeof data === 'string') { if (typeof data === "string") {
try { try {
if (data != null && data !== '') { if (data != null && data !== "") {
dataObj = JSON.parse(data) as UTSJSONObject dataObj = JSON.parse(data) as UTSJSONObject;
} else { } else {
console.warn('data 为空字符串或 null') console.warn("data 为空字符串或 null");
dataObj = {} as UTSJSONObject dataObj = {} as UTSJSONObject;
} }
} catch (e) { } catch (error) {
console.error('解析 data 失败:', e) console.error("解析 data 失败:", error);
dataObj = {} as UTSJSONObject dataObj = {} as UTSJSONObject;
} }
} else { } else {
dataObj = data as UTSJSONObject dataObj = data as UTSJSONObject;
} }
// 处理 moduleList 的空值情况 // 处理 moduleList 的空值情况
const moduleListData: Array<any> = dataObj.moduleList != null ? dataObj.moduleList as Array<any> : [] const moduleListData: Array<any> = dataObj.moduleList != null ? dataObj.moduleList as Array<any> : [];
moduleList.value = moduleListData moduleList.value = moduleListData;
// 处理 toolList 的空值情况 // 处理 toolList 的空值情况
const toolListData: Array<any> = dataObj.toolList != null ? dataObj.toolList as Array<any> : [] const toolListData: Array<any> = dataObj.toolList != null ? dataObj.toolList as Array<any> : [];
pageToolList.value = toolListData pageToolList.value = toolListData;
useCarConfig.value = true useCarConfig.value = true;
if (id.value != currentMediaId.value) { if (id.value != currentMediaId.value) {
let jumpItem: UTSJSONObject = {} as UTSJSONObject let jumpItem: UTSJSONObject = {} as UTSJSONObject;
for (const e of moduleListData) { for (const e of moduleListData) {
if ((e as UTSJSONObject).detailTitle == detailTitle) { if ((e as UTSJSONObject).detailTitle == detailTitle) {
jumpItem = e as UTSJSONObject jumpItem = e as UTSJSONObject;
break break;
} }
} }
const firstItem = moduleListData.length > 0 ? moduleListData[0] as UTSJSONObject : null const firstItem = moduleListData.length > 0 ? moduleListData[0] as UTSJSONObject : null;
id.value = jumpItem != null ? ((jumpItem?.id ?? '') as string) : ((firstItem?.id ?? '') as string) id.value = jumpItem != null ? ((jumpItem?.id ?? "") as string) : ((firstItem?.id ?? "") as string);
} }
currentMediaId.value = ((dataObj?.id ?? '') as string) currentMediaId.value = ((dataObj?.id ?? "") as string);
} }
const viewKey = computed(() => { const viewKey = computed(() => {
return state.user.viewKey return state.user.viewKey;
}) });
async function setPageData() { async function setPageData() {
const carBrandId= currentCarInfo.value.carBrandId, const carBrandId= currentCarInfo.value.carBrandId;
carChildsBrandId = currentCarInfo.value.carChildsBrandId, const carChildsBrandId = currentCarInfo.value.carChildsBrandId;
params = { const params = {
brandId: carBrandId, brandId: carBrandId,
subBrandId: carChildsBrandId subBrandId: carChildsBrandId
} };
let storageName = `source_${sceneType.value}_${shopMerchantId.value}_${carBrandId}_${carChildsBrandId}` const storageName = `source_${sceneType.value}_${shopMerchantId.value}_${carBrandId}_${carChildsBrandId}`;
let data = uni.getStorageSync(storageName) const data = uni.getStorageSync(storageName);
console.log(data) console.log(data);
// try { // try {
// console.log('try',currentCarInfo.value) // console.log('try',currentCarInfo.value)
// let requestData = await getSoureData(shopMerchantId.value ?? '', sceneType.value ?? 0, params) // let requestData = await getSoureData(shopMerchantId.value ?? '', sceneType.value ?? 0, params)
...@@ -342,157 +325,162 @@ const currentCarInfo = computed(() => { ...@@ -342,157 +325,162 @@ const currentCarInfo = computed(() => {
// console.log(error) // console.log(error)
// if (data != null) setViewInfo(data) // if (data != null) setViewInfo(data)
// } // }
} }
watch(viewKey, () => { watch(viewKey, () => {
if(id.value != null && id.value !== '') setPageData() if (id.value != null && id.value !== "") setPageData();
}, { immediate: true }) }, { immediate: true });
watch(watchStatus, () => { watch(watchStatus, () => {
useCarConfig.value = false useCarConfig.value = false;
dateilKey.value = Date.now() dateilKey.value = Date.now();
pageToolList.value = toolList.value pageToolList.value = toolList.value;
currentMediaId.value = id.value currentMediaId.value = id.value;
drawStatus.value = false drawStatus.value = false;
}, { immediate: true }) }, { immediate: true });
watch(id, () => { watch(id, () => {
if (pageToolList.value.length == 0) pageToolList.value = toolList.value if (pageToolList.value.length === 0) pageToolList.value = toolList.value;
}, { immediate: true }) }, { immediate: true });
onMounted(() => { onMounted(() => {
const systemInfo = uni.getSystemInfoSync() const systemInfo = uni.getSystemInfoSync();
screenWidth.value = systemInfo.screenWidth screenWidth.value = systemInfo.screenWidth;
}) });
// 查询门店支付配置 // 查询门店支付配置
async function findPayInfo(): Promise<void> { async function findPayInfo(): Promise<void> {
const data = await findPayInfoApi({ const data = await findPayInfoApi({
merchantId: shopMerchantId.value merchantId: shopMerchantId.value
}) });
let paymentType: Array<any> = [] const paymentType: Array<any> = [];
const dataArray = data as Array<any> const dataArray = data as Array<any>;
for (const item of dataArray) { for (const item of dataArray) {
const itemObj = item as UTSJSONObject const itemObj = item as UTSJSONObject;
if (itemObj.paymentType == 1) { if (itemObj.paymentType == 1) {
paymentType.push({ paymentType.push({
name: '扫码支付', name: "扫码支付",
type: 1, type: 1,
title: '付款二维码', title: "付款二维码",
...itemObj ...itemObj
}) });
} }
if (itemObj.paymentType == 2) { if (itemObj.paymentType == 2) {
paymentType.push({ paymentType.push({
name: '对公账户', name: "对公账户",
type: 2, type: 2,
title: '付款方式', title: "付款方式",
...itemObj ...itemObj
}) });
}
} }
paymentTypeList.value = paymentType
} }
onLoad((options) => { paymentTypeList.value = paymentType;
recordService.startAudio() }
dispatch('setCustomerInfo', {}) onLoad((options) => {
recordService.startAudio();
dispatch("setCustomerInfo", {});
moduleList.value = [ moduleList.value = [
{ {
componentName: "reception", componentName: "reception",
id:'1', id:"1",
detailTitle: '交车告知书', detailTitle: "交车告知书",
receptionSourceDetailList:{ receptionSourceDetailList:{
detailUrl:'https://img02.glsx.com.cn/weapp/resource/app-tape/media/reception/aito-1.png' detailUrl:"https://img02.glsx.com.cn/weapp/resource/app-tape/media/reception/aito-1.png"
} }
} }
] ];
id.value = '1' id.value = "1";
// const storageKey = `source_${sceneType.value}_${shopMerchantId.value}` const storageKey = `source_${sceneType.value}_${shopMerchantId.value}`;
// const data = uni.getStorageSync(storageKey) as UTSJSONObject const storageData = uni.getStorageSync(storageKey);
let data: null | UTSJSONObject = null;
if (storageData != null && storageData != "" && storageData != "null") {
data = typeof storageData === "string" ? JSON.parse(storageData) as UTSJSONObject : storageData as UTSJSONObject;
}
// id.value = options.id ?? '' // id.value = options.id ?? ''
// type.value = options.type ?? '' // type.value = options.type ?? ''
// console.log(data) console.log("[Storage Data]", data);
// if (data != null) { if (data != null) {
// toolList.value = data.toolList as Array<any> toolList.value = data.toolList as Array<any>;
// media.value = data.moduleList as Array<any> media.value = data.moduleList as Array<any>;
// } }
// setPageData() setPageData();
// findPayInfo() findPayInfo();
}) });
const open = (): void => { const open = (): void => {
if (stepRef.value != null) { if (stepRef.value != null) {
(stepRef.value as ComponentPublicInstance).$callMethod('open') (stepRef.value as ComponentPublicInstance).$callMethod("open");
}
} }
const openStep = (): void => { };
const openStep = (): void => {
if (backpressRef.value != null) { if (backpressRef.value != null) {
(backpressRef.value as ComponentPublicInstance).$callMethod('hide') (backpressRef.value as ComponentPublicInstance).$callMethod("hide");
}
open()
} }
open();
};
function handleFull(val: boolean) { function handleFull(val: boolean) {
backZindex.value = val === true ? 0 : 9 backZindex.value = val === true ? 0 : 9;
} }
function closeAllChildPopups(): void { function closeAllChildPopups(): void {
// 获取所有动态生成的组件 ref(通过 'media' + id 命名) // 获取所有动态生成的组件 ref(通过 'media' + id 命名)
const refsToClose: Array<any> = [] const refsToClose: Array<any> = [];
// 收集所有 media 开头的 ref // 收集所有 media 开头的 ref
const currentList = useCarConfig.value === true ? moduleList.value : media.value const currentList = useCarConfig.value === true ? moduleList.value : media.value;
for (const item of currentList) { for (const item of currentList) {
const itemObj = item as UTSJSONObject const itemObj = item as UTSJSONObject;
const refName = `media${itemObj.id}` const refName = `media${itemObj.id}`;
const refValue = mediaRefs.value[refName] const refValue = mediaRefs.value[refName];
if (refValue != null) { if (refValue != null) {
// 处理可能是数组的情况(v-for 生成的 ref 通常是数组) // 处理可能是数组的情况(v-for 生成的 ref 通常是数组)
const componentInstance = Array.isArray(refValue) ? refValue[0] : refValue const componentInstance = Array.isArray(refValue) ? refValue[0] : refValue;
if (componentInstance != null) { if (componentInstance != null) {
(componentInstance as ComponentPublicInstance).$callMethod('closeAllPopup') (componentInstance as ComponentPublicInstance).$callMethod("closeAllPopup");
} }
} }
} }
// 同时关闭固定的几个 ref // 同时关闭固定的几个 ref
if (toolRef.value != null) { if (toolRef.value != null) {
(toolRef.value as ComponentPublicInstance).$callMethod('closeAllPopup') (toolRef.value as ComponentPublicInstance).$callMethod("closeAllPopup");
} }
if (payRef.value != null) { if (payRef.value != null) {
(payRef.value as ComponentPublicInstance).$callMethod('closeAllPopup') (payRef.value as ComponentPublicInstance).$callMethod("closeAllPopup");
}
} }
}
type ToolItem = { type ToolItem = {
id?: string | number id?: number | string
shortTitleUrl?: string
shortTitle?: string shortTitle?: string
shortTitleUrl?: string
} }
function choose(e: ToolItem): void { function choose(e: ToolItem): void {
// 关闭所有子组件的 popup // 关闭所有子组件的 popup
closeAllChildPopups() closeAllChildPopups();
// receptionTrackLeave() // receptionTrackLeave()
const itemId = e.id ?? '' const itemId = e.id ?? "";
id.value = (itemId ?? '') as string id.value = (itemId ?? "") as string;
// uni.$logger.local.info(`预览${e.title}`) // uni.$logger.local.info(`预览${e.title}`)
} }
function clearHistory():void{ function clearHistory():void{
dispatch('clearCustomerInfo') dispatch("clearCustomerInfo");
dispatch('clearHistory') dispatch("clearHistory");
dispatch('clearReceptionTrack') dispatch("clearReceptionTrack");
} }
function backHome():void{ function backHome():void{
uni.navigateBack() uni.navigateBack();
} }
function back(): void { function back(): void {
// if(showPayPage.value === true) { // if(showPayPage.value === true) {
// showPayPage.value = false // showPayPage.value = false
// return // return
...@@ -503,116 +491,116 @@ const currentCarInfo = computed(() => { ...@@ -503,116 +491,116 @@ const currentCarInfo = computed(() => {
// } // }
// return // return
// } // }
backHome() backHome();
} }
function done(val: string) { function done(val: string) {
showPayPage.value = false showPayPage.value = false;
if (toolRef.value != null) { if (toolRef.value != null) {
(toolRef.value as ComponentPublicInstance).$callMethod('hide') (toolRef.value as ComponentPublicInstance).$callMethod("hide");
} }
if (stepRef.value != null) { if (stepRef.value != null) {
(stepRef.value as ComponentPublicInstance).$callMethod('close') (stepRef.value as ComponentPublicInstance).$callMethod("close");
} }
const customerInfo = state.user.customerInfo as UTSJSONObject const customerInfo = state.user.customerInfo as UTSJSONObject;
recordService.stopAudio() recordService.stopAudio();
uni.navigateBack() uni.navigateBack();
// receptionTrackLeave() // receptionTrackLeave()
} }
function toPay(): void { function toPay(): void {
if (payRef.value != null) { if (payRef.value != null) {
(payRef.value as ComponentPublicInstance).$callMethod('show') (payRef.value as ComponentPublicInstance).$callMethod("show");
}
} }
}
function touchStart(e: any) { function touchStart(e: any) {
if (drawStatus.value === false && (e as UTSJSONObject).changedTouches != null && ((e as UTSJSONObject).changedTouches as Array<any>).length > 0) { if (drawStatus.value === false && (e as UTSJSONObject).changedTouches != null && ((e as UTSJSONObject).changedTouches as Array<any>).length > 0) {
const touches = (e as UTSJSONObject).changedTouches as Array<any> const touches = (e as UTSJSONObject).changedTouches as Array<any>;
startX.value = ((touches[0] as UTSJSONObject).pageX as number) ?? 0 startX.value = ((touches[0] as UTSJSONObject).pageX as number) ?? 0;
startY.value = ((touches[0] as UTSJSONObject).pageY as number) ?? 0 startY.value = ((touches[0] as UTSJSONObject).pageY as number) ?? 0;
} }
} }
function getNextId(index: number, pageToolList: Array<any>, startX: number, halfScreenWidth: number) { function getNextId(index: number, pageToolList: Array<any>, startX: number, halfScreenWidth: number) {
let nextItem: UTSJSONObject = {} as UTSJSONObject, let modeName = "";
modeName = '' let nextItem: UTSJSONObject = {} as UTSJSONObject;
if (startX > halfScreenWidth) { if (startX > halfScreenWidth) {
nextItem = index === pageToolList.length - 1 ? pageToolList[0] as UTSJSONObject : pageToolList[index + 1] as UTSJSONObject nextItem = index === pageToolList.length - 1 ? pageToolList[0] as UTSJSONObject : pageToolList[index + 1] as UTSJSONObject;
modeName = 'to-right' modeName = "to-right";
} else { } else {
nextItem = index === 0 ? pageToolList[pageToolList.length - 1] as UTSJSONObject : pageToolList[index - 1] as UTSJSONObject nextItem = index === 0 ? pageToolList[pageToolList.length - 1] as UTSJSONObject : pageToolList[index - 1] as UTSJSONObject;
modeName = 'to-left' modeName = "to-left";
} }
return { return {
nextId: (nextItem.id as string) ?? '', nextId: (nextItem.id as string) ?? "",
modeName, modeName,
title: (nextItem.title as string) ?? '' title: (nextItem.title as string) ?? ""
} };
} }
function touchEnd(e: any) { function touchEnd(e: any) {
if (modeName.value != null && modeName.value !== '') return if (modeName.value != null && modeName.value !== "") return;
try { try {
const eObj = e as UTSJSONObject const eObj = e as UTSJSONObject;
if (eObj == null || eObj.changedTouches == null || drawStatus.value === true || pageToolList.value.length == 0 || ((eObj.changedTouches as Array<any>).length == 0)) return if (eObj == null || eObj.changedTouches == null || drawStatus.value === true || pageToolList.value.length === 0 || ((eObj.changedTouches as Array<any>).length === 0)) return;
let halfScreenWidth = screenWidth.value / 2 const halfScreenWidth = screenWidth.value / 2;
let touches = eObj.changedTouches as Array<any> const touches = eObj.changedTouches as Array<any>;
const touch = touches[0] as UTSJSONObject const touch = touches[0] as UTSJSONObject;
let isDistanceSignificant = Math.abs((touch.pageX as number) - startX.value) > screenWidth.value / 6 const isDistanceSignificant = Math.abs((touch.pageX as number) - startX.value) > screenWidth.value / 6;
let index = -1 let index = -1;
for (let i = 0; i < pageToolList.value.length; i++) { for (let i = 0; i < pageToolList.value.length; i++) {
const item = pageToolList.value[i] as UTSJSONObject const item = pageToolList.value[i] as UTSJSONObject;
if (item.id == id.value) { if (item.id == id.value) {
index = i index = i;
break break;
} }
} }
if (Math.abs(startY.value - (touch.pageY as number)) > 150) return if (Math.abs(startY.value - (touch.pageY as number)) > 150) return;
if (scaleValueObject.value[id.value] == null) scaleValueObject.value[id.value] = 1 if (scaleValueObject.value[id.value] == null) scaleValueObject.value[id.value] = 1;
if (isDistanceSignificant === true && index != -1 && scaleValueObject.value[id.value] == 1 && productModelStatus.value === false) { if (isDistanceSignificant === true && index != -1 && scaleValueObject.value[id.value] == 1 && productModelStatus.value === false) {
const result = getNextId(index, pageToolList.value, startX.value, halfScreenWidth) const result = getNextId(index, pageToolList.value, startX.value, halfScreenWidth);
modeName.value = (result.modeName as string) ?? '' modeName.value = (result.modeName as string) ?? "";
// receptionTrackLeave() // receptionTrackLeave()
id.value = (result.nextId as string) ?? '' id.value = (result.nextId as string) ?? "";
// uni.$logger.local.info(`预览${(result.title as string) ?? ''}`) // uni.$logger.local.info(`预览${(result.title as string) ?? ''}`)
setTimeout(() => { setTimeout(() => {
modeName.value = '' modeName.value = "";
}, 500) }, 500);
} }
} catch (error) { } catch (error) {
console.log(error) console.log(error);
}
} }
}
function scale(e: number) { function scale(e: number) {
scaleValueObject.value[id.value] = e scaleValueObject.value[id.value] = e;
} }
onBackPress((options: OnBackPressOptions) => { onBackPress((options: OnBackPressOptions) => {
console.log('返回键触发', options.from) console.log("返回键触发", options.from);
if (options.from === 'backbutton') { if (options.from === "backbutton") {
// 如果是预览模式,直接返回 // 如果是预览模式,直接返回
if (type.value === 'preview') { if (type.value === "preview") {
uni.navigateBack() uni.navigateBack();
} else { } else {
// 非预览模式,执行自定义返回逻辑 // 非预览模式,执行自定义返回逻辑
back() back();
} }
// 返回 true 阻止默认的返回行为 // 返回 true 阻止默认的返回行为
return true return true;
} }
// 其他情况允许正常返回 // 其他情况允许正常返回
return false return false;
}) });
</script> </script>
......
...@@ -54,7 +54,7 @@ function setViewInfo(data: any): void { ...@@ -54,7 +54,7 @@ function setViewInfo(data: any): void {
moduleList.value = dataObj.moduleList as Array<any>; moduleList.value = dataObj.moduleList as Array<any>;
toolList.value = dataObj.toolList as Array<any>; toolList.value = dataObj.toolList as Array<any>;
const idValue = dataObj.id; const idValue = dataObj.id;
mediaId.value = typeof idValue === 'number' ? idValue.toString() : (idValue as string) ?? ''; mediaId.value = typeof idValue === "number" ? idValue.toString() : (idValue as string) ?? "";
loadComplete.value = true; loadComplete.value = true;
// 直接将数据属性设置到 state.user 上 // 直接将数据属性设置到 state.user 上
...@@ -87,15 +87,15 @@ async function getSoure(brandIdList: number[], subBrandIdList: number[]): Promis ...@@ -87,15 +87,15 @@ async function getSoure(brandIdList: number[], subBrandIdList: number[]): Promis
const storageKey = `source_${sceneType}_${shopMerchantId}`; const storageKey = `source_${sceneType}_${shopMerchantId}`;
const cachedData = uni.getStorageSync(storageKey); const cachedData = uni.getStorageSync(storageKey);
let data: UTSJSONObject | null = null; let data: null | UTSJSONObject = null;
if (cachedData != null && cachedData !== '') { if (cachedData != null && cachedData !== "") {
try { try {
data = JSON.parse(cachedData as string) as UTSJSONObject; data = JSON.parse(cachedData as string) as UTSJSONObject;
} catch (e) { } catch (error) {
console.error('解析缓存数据失败:', e); console.error("解析缓存数据失败:", error);
} }
} }
console.log(data) console.log(data);
if (data != null) { if (data != null) {
setViewInfo(data); setViewInfo(data);
} }
......
...@@ -30,8 +30,7 @@ ...@@ -30,8 +30,7 @@
*/ */
import { Logger } from "./logger/LoggerCore"; import { Logger } from "./logger/LoggerCore";
import { DBRecord } from "./recorder/DBRecord.uts"; import DBRecord from "./recorder/DBRecord.uts";
import { RecordSave } from "./recorder/RecordSave.uts";
import { RecordService } from "./recorder/RecordService.uts"; import { RecordService } from "./recorder/RecordService.uts";
import { TimeoutService } from "./recorder/TimeoutService.uts"; import { TimeoutService } from "./recorder/TimeoutService.uts";
import { FileUploadService } from "./uploader/FileUploadService.uts"; import { FileUploadService } from "./uploader/FileUploadService.uts";
...@@ -85,21 +84,6 @@ class Services { ...@@ -85,21 +84,6 @@ class Services {
return this._loggerInstance as Logger; return this._loggerInstance as Logger;
} }
/** /**
* 获取记录保存服务
*
* 使用方式:
* ```typescript
* const recordSave = services.recordSave;
* await recordSave.save(record);
* ```
*/
get recordSave(): RecordSave {
if (this._recordSaveInstance === null) {
this._recordSaveInstance = RecordSave.getInstance();
}
return this._recordSaveInstance as RecordSave;
}
/**
* 获取录音服务(已是单例,直接返回) * 获取录音服务(已是单例,直接返回)
* *
* 使用方式: * 使用方式:
...@@ -137,7 +121,6 @@ class Services { ...@@ -137,7 +121,6 @@ class Services {
private _dbRecordInstance: DBRecord | null = null; private _dbRecordInstance: DBRecord | null = null;
private _fileUploadInstance: FileUploadService | null = null; private _fileUploadInstance: FileUploadService | null = null;
private _loggerInstance: Logger | null = null; private _loggerInstance: Logger | null = null;
private _recordSaveInstance: null | RecordSave = null;
private _recordServiceInstance: null | RecordService = null; private _recordServiceInstance: null | RecordService = null;
private _timeoutServiceInstance: null | TimeoutService = null; private _timeoutServiceInstance: null | TimeoutService = null;
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
......
...@@ -29,7 +29,7 @@ export async function consumeAll(recordId: string, cacheConfig: string[]): Promi ...@@ -29,7 +29,7 @@ export async function consumeAll(recordId: string, cacheConfig: string[]): Promi
uni.removeStorage({ uni.removeStorage({
key: storageKey, key: storageKey,
fail: (res) => { fail: (res) => {
services.logger?.warn(`RecordCacheManager: Remove ${storageKey} failed: ${res.errMsg}`, "RecordCache"); services.logger.warn(`RecordCacheManager: Remove ${storageKey} failed: ${res.errMsg}`, "RecordCache");
} }
}); });
} }
......
...@@ -82,12 +82,10 @@ $uni-font-size-paragraph: 15px; ...@@ -82,12 +82,10 @@ $uni-font-size-paragraph: 15px;
} }
.text-two-line { .text-two-line {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
/* 定义文本的行数 */
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-flex;
max-height: 48px; /* 根据 font-size * line-height * 2 计算 */
} }
.select-box { .select-box {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!