Commit bbc0cddc by liimin

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

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