Commit f1259e46 by 李伟康

refactor(uniappX): 重构组件实现并优化API调用

- 将getEmployeeList函数重命名为getEmployeeListApi
- 更新BackPress组件中的组件实例调用方式为$callMethod
- 重构CarBrands组件的数据类型定义和状态管理逻辑
- 优化CustomPopup组件中的位置映射计算方法
- 调整CustomerAutocomplete组件的模板结构和样式
- 修复组件中多处类型安全问题并改进响应式数据处理
1 parent d901015c
Showing 25 changed files with 3615 additions and 3828 deletions
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import http from "@/api/request/http.uts"; import http from "@/api/request/http.uts";
/** 获取交付人员列表 */ /** 获取交付人员列表 */
export function getEmployeeList(data: UTSJSONObject): Promise<any> { export function getEmployeeListApi(data: UTSJSONObject): Promise<any> {
return http.post({ return http.post({
'method': 'dj.api.smartcarlife.employee.getByMerchantId.new', 'method': 'dj.api.smartcarlife.employee.getByMerchantId.new',
'projectName': 'boutique', 'projectName': 'boutique',
......
<!-- 退出弹框 --> <!-- 退出弹框 -->
<template> <template>
<MessageBox :popupW="704" ref="finishRef" :content="finishContene" :isFooter="false"> <MessageBox :popupW="704" ref="finishRef" :content="finishContene" :isFooter="false">
<view class="footer"> <view class="footer">
<view class="footer-btn confirm flex" @click="$emit('openStep')"> <view class="footer-btn confirm flex" @click="$emit('openStep')">
<template v-if="finishDoneText"> <template v-if="finishDoneText">
{{ finishDoneText }} {{ finishDoneText }}
</template> </template>
<template v-else> <template v-else>
完成接待 完成接待
<text>(推荐)</text> <text>
</template> (推荐)
</view> </text>
<view class="footer-btn cancel flex" @click="$emit('backHome')"> </template>
仍要退出
<text>(不推荐)</text>
</view>
</view> </view>
</MessageBox> <view class="footer-btn cancel flex" @click="$emit('backHome')">
仍要退出
<text>
(不推荐)
</text>
</view>
</view>
</MessageBox>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import MessageBox from './MessageBox.uvue' import MessageBox from './MessageBox.uvue'
import { ComponentPublicInstance } from 'vue'
const props = defineProps({
finishDoneText: String, const props = defineProps({
finishContene: { finishDoneText: String,
type: String, finishContene: {
default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」' type: String,
} default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」'
}) }
function open(): void {
finishRef.value.open()
}
function hide(): void {
finishRef.value.close()
}
const finishRef = ref<any>(null)
const emit = defineEmits(['openStep', 'backHome'])
defineExpose({
open,
hide
}) })
const finishRef = ref(null)
function open(): void {
(finishRef.value as ComponentPublicInstance).$callMethod('open')
}
function hide(): void {
(finishRef.value as ComponentPublicInstance).$callMethod('close')
}
const emit = defineEmits(['openStep', 'backHome'])
defineExpose({ open, hide })
</script> </script>
<style lang="scss"> <style lang="scss">
.footer { .footer {
border-top: 2rpx solid #eff0f2; border-top: 2rpx solid #eff0f2;
font-weight: 600; font-weight: 600;
font-size: 32rpx; font-size: 32rpx;
margin-top: 48rpx; margin-top: 48rpx;
.footer-btn { .footer-btn {
justify-content: center; justify-content: center;
margin: 16rpx auto 0; margin: 16rpx auto 0;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
} }
.confirm { .confirm {
width: 608rpx; width: 608rpx;
height: 80rpx; height: 80rpx;
background: #2c66f7; background: #2c66f7;
border-radius: 40rpx; border-radius: 40rpx;
color: #fff; color: #fff;
} }
.cancel { .cancel {
width: 608rpx; width: 608rpx;
height: 80rpx; height: 80rpx;
background: #ffffff00; background: #ffffff00;
border-radius: 40rpx; border-radius: 40rpx;
color: #2c66f7; color: #2c66f7;
} }
text { text {
font-size: 24rpx; font-size: 24rpx;
}
} }
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
<view> <view>
<MessageBox <MessageBox
ref="carBrandListVisible" ref="carBrandListVisible"
position="bottom" position="bottom"
:isFooter="false" :isFooter="false"
title="请选择车品牌" title="请选择车品牌"
@close="$emit('close')" @close="$emit('close')"
> >
<view class="select-box"> <view class="select-box" :key="updateView">
<view <view
class="select-item" class="select-item"
:class="{ checked: carBrand == item.name }" :class="{ checked: carBrand == item.name }"
@click="selectCar(item)" @click="selectCar(item, false ,'')"
v-for="(item, index) in carBrandList" v-for="(item, index) in carBrandList"
:key="index" :key="index"
> >
{{ item.name }} {{ item.name }}
</view> </view>
...@@ -21,20 +21,20 @@ ...@@ -21,20 +21,20 @@
</MessageBox> </MessageBox>
<MessageBox <MessageBox
ref="carBoxVisible" ref="carBoxVisible"
position="bottom" position="bottom"
:isFooter="false" :isFooter="false"
title="请选择车系" title="请选择车系"
:maxHeight="1000" :maxHeight="1000"
back back
@close="closeCarBoxVisible" @close="closeCarBoxVisible"
> >
<view class="select-box"> <view class="select-box">
<view <view
class="select-item" class="select-item"
:class="{ checked: carModel == item.name }" :class="{ checked: carModel == item.name }"
@click="handleSelect(item)" @click="handleSelect(item)"
v-for="(item, index) in carlist" v-for="(item, index) in carlist"
:key="index" :key="index"
> >
{{ item.name }} {{ item.name }}
</view> </view>
...@@ -45,293 +45,322 @@ ...@@ -45,293 +45,322 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import MessageBox from './MessageBox.uvue' import MessageBox from './MessageBox.uvue'
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { getMerchantCarBrandList,getCarBrandsListApi } from '@/api/common-api.uts' import { getMerchantCarBrandList,getCarBrandsListApi } from '@/api/common-api.uts'
import { state, dispatch } from "@/store/index.uts" import { state, dispatch } from "@/store/index.uts"
import { ComponentPublicInstance } from 'vue'
interface CarBrandItem {
id: string type CarBrandItem = {
name: string id: string
brandId?: string name: string
brandName?: string brandId?: string
childs?: Array<CarBrandItem> brandName?: string
} childs?: Array<CarBrandItem>
interface CustomerInfo {
carModel?: string
carBrand?: string
carBrandId?: string
oneCarBrand?: string
oneCarBrandId?: string
}
interface SelectItem {
carBrand: string
carBrandId: string
carChildsBrandName: string
carChildsBrandId: string
}
interface UserInfo {
shopMerchantId: string
[key: string]: any
}
interface CarBrandListResponse {
carBrandList?: Array<CarBrandItem>
}
const props = defineProps({
carBrandKey: {
type: String,
default: 'carBrand'
},
carModelKey: {
type: String,
default: 'carModel'
},
echoData: {
type: Object,
default: () => ({})
},
customBoolean: Boolean,
linkage: {
type: Boolean,
default: true
} }
})
const emit = defineEmits(['close', 'select']) type SelectItem = {
carBrand: string
const carlist = ref<Array<CarBrandItem>>([]) carBrandId: string
const selectItem = ref<SelectItem>({} as SelectItem) carChildsBrandName: string
const clickFlga = ref<boolean>(false) carChildsBrandId: string
const carBrandListOff = ref<boolean>(false)
const carBrandListVisible = ref<any>(null)
const carBoxVisible = ref<any>(null)
const watchStatus = computed(() => {
return state.user.historyStatus
})
const carModel = computed<string | undefined>(() => {
return props.customBoolean ? props.echoData[props.carModelKey] : state.user.customerInfo.carModel
})
const carBrandList = computed<Array<CarBrandItem>>(() => {
return storage.get("carBrandList") || []
})
const carBrand = computed<string | undefined>(() => {
return props.customBoolean ? props.echoData[props.carBrandKey] : state.user.customerInfo.carBrand
})
const boutiqueDefaultCarBrandId = computed<string | undefined>(() => {
return state.user.boutiqueDefaultCarBrandId
})
const defaultCarId = computed<string>(() => {
return state.user.defaultCarId || ''
})
watch(() => watchStatus.value, (newval) => {
close()
}, { immediate: true })
function autoSelect(): void {
const boutiqueDefaultCarBrandIdVal = boutiqueDefaultCarBrandId.value
const defaultCarIdVal = defaultCarId.value
let carIndex = 0
if (boutiqueDefaultCarBrandIdVal) {
carIndex = carBrandList.value.findIndex(e => e.id == boutiqueDefaultCarBrandIdVal)
} }
if (carIndex < 0) carIndex = 0 type UserInfo = UTSJSONObject
if (carBrandList.value.length) { interface CarBrandListResponse {
selectCar(carBrandList.value[carIndex], true, defaultCarIdVal) carBrandList?: Array<CarBrandItem>
} }
}
const props = defineProps({
function open(): void { carBrandKey: {
const userInfo: UserInfo = storage.get("userInfo") type: String,
const { shopMerchantId } = userInfo default: 'carBrand'
},
getMerchantCarBrandList([shopMerchantId]) carModelKey: {
.then(({ data }) => { type: String,
let list = (data[0] as CarBrandListResponse).carBrandList default: 'carModel'
const carBrandListData: Array<CarBrandItem> = [] },
echoData: {
list?.forEach((e: CarBrandItem) => { type: Object,
e.childs?.forEach((i: CarBrandItem) => { default: () => ({})
i.brandName = e.name },
i.brandId = e.id customBoolean: {
carBrandListData.push(i) type:Boolean,
}) default:false
}) },
linkage: {
dispatch("setCarBrandsList", carBrandListData) type: Boolean,
storage.set("carBrandList", carBrandListData) default: true
}) }
})
const { carBrand: carBrandVal } = props
if (carBrandVal) { const emit = defineEmits(['close', 'select'])
const carBrandListVal = carBrandList.value
const item = carBrandListVal.find(e => e.name == carBrandVal) const carlist = ref<Array<CarBrandItem>>([])
const selectItem = ref<SelectItem>({
if (item && carBrandListVal.length == 1) { carBrand: '',
selectCar(item) carBrandId: '',
} else { carChildsBrandName: '',
carBrandListVisible.value?.open() carChildsBrandId: ''
carBrandListOff.value = true })
} const clickFlga = ref<boolean>(false)
return const carBrandListOff = ref<boolean>(false)
const carBrandListVisible = ref(null)
const carBoxVisible = ref(null)
const updateView = ref<number>(Date.now())
const carBrandList = ref<Array<CarBrandItem>>([])
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 === true) {
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 === true) {
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 !== '' ? 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
} }
carBrandListVisible.value?.open() function closeCarBoxVisible(): void {
carBrandListOff.value = true if (carBrandListOff.value) return
} else emit('close')
function selectCar(e: CarBrandItem, auto: boolean = false, carId?: string): void {
if (!e.brandId || !e.id) {
return uni.showToast({
title: "车型 ID 或品牌 ID 为空",
icon: "none"
})
} }
function handleSelect(item: CarBrandItem): void {
let index = 0 const selectItemVal = selectItem.value
if (clickFlga.value) return const customerInfo: UTSJSONObject = {
clickFlga.value = true ...state.user.customerInfo,
carBrand: selectItemVal.carChildsBrandName,
selectItem.value = { carBrandId: selectItemVal.carChildsBrandId,
carBrand: e.brandName!, oneCarBrand: selectItemVal.carBrand,
carBrandId: e.brandId!, oneCarBrandId: selectItemVal.carBrandId,
carChildsBrandName: e.name, carModel: item.name,
carChildsBrandId: e.id carModelId: item.id
}
if (props.linkage) {
dispatch('setCustomerInfo', customerInfo)
dispatch('updateViewKey')
dispatch('setCurrentCarInfo', selectItemVal)
}
(carBoxVisible.value as ComponentPublicInstance).$callMethod('close')
emit('select', { ...item, ...selectItemVal })
} }
function selectCar(e: CarBrandItem, auto: boolean = false, carId?: string): void {
const cacheKey = `${e.id}_${e.brandId}_carlist` if (e.brandId == null || e.id == null) {
const carList = uni.getStorageSync(cacheKey) return uni.showToast({
title: "车型 ID 或品牌 ID 为空",
if (carList) { icon: "none"
clickFlga.value = false })
carlist.value = carList }
if (auto && carList.length) { let index = 0
if (carId) index = carList.findIndex(i => i.id == carId)
if (index < 0) index = 0 if (clickFlga.value) return
handleSelect(carList[index]) clickFlga.value = true
} else {
carBoxVisible.value?.open() const selectData: SelectItem = {
} carBrand: e.brandName!,
} else { carBrandId: e.brandId!,
if (!auto) uni.showLoading({ carChildsBrandName: e.name,
mask: true carChildsBrandId: e.id
}) }
selectItem.value = selectData
const cacheKey = `${e.id}_${e.brandId}_carlist`
let _carList = uni.getStorageSync(cacheKey) as Array<CarBrandItem> | null
if (_carList != null) {
clickFlga.value = false
carlist.value = _carList
if (auto) {
if (carId != null) index = _carList.findIndex(i => i.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: e.brandId, childBrandId: e.id }).then(res => {
uni.hideLoading()
const typedRes = res as UTSArray<CarBrandItem>
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 => i.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()
})
} }
getCarBrandsListApi({ watch(watchStatus.value, () => {
brandId: e.brandId, close()
childBrandId: e.id }, { immediate: true })
}).then(res => { watch(updateView.value ,()=>{
uni.hideLoading() const carBrandListData = storage.get("carBrandList")
carlist.value = res carBrandList.value = carBrandListData != null ? (carBrandListData as Array<CarBrandItem>) : []
}, { immediate: true, deep: true })
if (res) uni.setStorageSync(cacheKey, res)
function autoSelect(): void {
if (!carList) { const boutiqueDefaultCarBrandIdVal = boutiqueDefaultCarBrandId.value
if (auto && res.length) { const defaultCarIdVal = defaultCarId.value as String
if (carId) index = res.findIndex(i => i.id == carId) let carIndex = 0
if (index < 0) index = 0
handleSelect(res[index]) if (boutiqueDefaultCarBrandIdVal != null) {
} else { carIndex = carBrandList.value.findIndex(e => e.id == boutiqueDefaultCarBrandIdVal)
carBoxVisible.value?.open() }
}
} if (carIndex < 0) carIndex = 0
clickFlga.value = false
}).catch(err => { if (carBrandList.value.length > 0) {
clickFlga.value = false selectCar(carBrandList.value[carIndex], true, defaultCarIdVal)
uni.hideLoading() }
})
}
function handleSelect(item: CarBrandItem): void {
const selectItemVal = selectItem.value
const customerInfo: CustomerInfo = {
...state.user.customerInfo,
carBrand: selectItemVal.carChildsBrandName,
carBrandId: selectItemVal.carChildsBrandId,
oneCarBrand: selectItemVal.carBrand,
oneCarBrandId: selectItemVal.carBrandId,
carModel:item.name,
carModelId:item.id
} }
if (props.linkage) { function open(): void {
dispatch('setCustomerInfo', customerInfo) const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null
dispatch('updateViewKey')
dispatch('setCurrentCarInfo', selectItemVal) 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>
let list = (data[0] as CarBrandListResponse).carBrandList
const carBrandListData: Array<CarBrandItem> = []
list?.forEach((e: CarBrandItem) => {
e.childs?.forEach((i: CarBrandItem) => {
i.brandName = e.name
i.brandId = e.id
carBrandListData.push(i)
})
})
dispatch("setCarBrandsList", carBrandListData)
storage.set("carBrandList", carBrandListData, 0)
updateView.value = Date.now()
})
const carBrandVal = carBrand.value
if (carBrandVal != null) {
const carBrandListVal: Array<CarBrandItem> = carBrandList.value
const item = carBrandListVal.find((e) => e.name == carBrandVal)
if (item != null && carBrandListVal.length == 1) {
selectCar(item as CarBrandItem, 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
} }
carBoxVisible.value?.close()
emit('select', {
...item,
...selectItemVal defineExpose({ open, close, autoSelect })
})
}
function close(): void {
carBoxVisible.value?.close()
carBrandListVisible.value?.close()
carBrandListOff.value = false
}
function closeCarBoxVisible(): void {
if (carBrandListOff.value) return
else emit('close')
}
defineExpose({
open,
close,
autoSelect
})
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.select-box { .select-box {
margin: 40rpx 0; margin: 40rpx 0;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
overflow-y: scroll; overflow-y: scroll;
max-height: 800rpx; max-height: 800rpx;
padding-bottom: 60rpx; padding-bottom: 60rpx;
flex-direction: row; flex-direction: row;
.select-item { .select-item {
width: 23.5%; width: 23.5%;
margin-right: 2%; margin-right: 2%;
margin-bottom: 32rpx; margin-bottom: 32rpx;
text-align: center; text-align: center;
height: 68rpx; height: 68rpx;
line-height: 44rpx; line-height: 44rpx;
opacity: 1; opacity: 1;
border: 2rpx solid #dce0e6; border: 2rpx solid #dce0e6;
color: #333; color: #333;
font-size: 32rpx; font-size: 32rpx;
border-radius: 8rpx; border-radius: 8rpx;
&:nth-child(4n) { &:nth-child(4n) {
margin-right: 0; margin-right: 0;
} }
&.checked { &.checked {
border: 2rpx solid #292d33; border: 2rpx solid #292d33;
}
} }
} }
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -2,216 +2,221 @@ ...@@ -2,216 +2,221 @@
<view <view
v-if="showMask" v-if="showMask"
class="custom-popup-mask" class="custom-popup-mask"
:class="{ 'mask-visible': isAnimated }" :class="{ 'mask-visible': isAnimated }"
@click="handleMaskClick" @click="handleMaskClick"
> >
<view <view
class="custom-popup-content" class="custom-popup-content"
:class="[`popup-${positionClass}`, { 'content-visible': isAnimated }]" :class="[`popup-${positionClass}`, { 'content-visible': isAnimated }]"
@click.stop @click.stop
> >
<slot></slot> <slot>
</slot>
</view> </view>
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
const props = defineProps({ const props = defineProps({
visible: { visible: {
type: Boolean, type: Boolean,
default: false default: false
}, },
position: { position: {
type: String, type: String,
default: "center" default: "center"
}, },
maskClosable: { maskClosable: {
type: Boolean, type: Boolean,
default: true default: true
}, },
duration: { duration: {
type: Number, type: Number,
default: 300 default: 300
}
})
const emit = defineEmits(['update:visible', 'close', 'mask-click', 'opened', 'closed'])
function close(): void {
emit('update:visible', false)
emit('close')
} }
})
function open(): void {
const emit = defineEmits(['update:visible', 'close', 'mask-click', 'opened', 'closed']) emit('update:visible', true)
const showMask = ref<boolean>(props.visible)
const isAnimated = ref<boolean>(false)
let closeTimer: any = null
let openTimer: any = null
const positionClass = computed(() => {
const positionMap: Record<string, string> = {
'top': 'top',
'center': 'center',
'bottom': 'bottom',
'left': 'left',
'right': 'right'
} }
return positionMap[props.position] || 'center' function handleMaskClick(): void {
}) emit('mask-click')
if (props.maskClosable) {
watch(() => props.visible, (newVal) => { close()
if (newVal) {
// 打开流程
if (closeTimer) {
clearTimeout(closeTimer)
closeTimer = null
} }
if (openTimer) {
clearTimeout(openTimer)
openTimer= null
}
showMask.value = true
isAnimated.value = false
// 等待 DOM 渲染后添加动画类
openTimer = setTimeout(() => {
isAnimated.value = true
}, 50)
// 动画完成后触发事件
setTimeout(() => {
emit('opened')
}, props.duration + 50)
} else {
// 关闭流程
if (openTimer) {
clearTimeout(openTimer)
openTimer = null
}
isAnimated.value = false
closeTimer= setTimeout(() => {
showMask.value = false
emit('closed')
}, props.duration)
} }
}, { immediate: true }) const showMask = ref<boolean>(props.visible)
const isAnimated = ref<boolean>(false)
let closeTimer: any | null = null
let openTimer: any | null = null
function handleMaskClick(): void { const positionClass = computed<string>(() => {
emit('mask-click') const positionMap: UTSJSONObject = {
if (props.maskClosable) { 'top': 'top',
close() 'center': 'center',
} 'bottom': 'bottom',
} 'left': 'left',
'right': 'right'
} as UTSJSONObject
const mappedValue = positionMap[props.position] as string | null
if (mappedValue == null) {
return 'center'
}
return mappedValue
})
watch(props.visible, (newVal: boolean) => {
if (newVal == true) {
// 打开流程
if (closeTimer != null) {
clearTimeout(closeTimer as number)
closeTimer = null
}
if (openTimer != null) {
clearTimeout(openTimer as number)
openTimer= null
}
showMask.value = true
isAnimated.value = false
// 等待 DOM 渲染后添加动画类
openTimer = setTimeout(() => {
isAnimated.value = true
}, 50)
// 动画完成后触发事件
setTimeout(() => {
emit('opened')
}, props.duration + 50)
} else {
// 关闭流程
if (openTimer != null) {
clearTimeout(openTimer as number)
openTimer = null
}
function close(): void { isAnimated.value = false
emit('update:visible', false)
emit('close')
}
function open(): void { closeTimer= setTimeout(() => {
emit('update:visible', true) showMask.value = false
} emit('closed')
}, props.duration)
}
}, { immediate: true })
defineExpose({
open,
close defineExpose({ open, close })
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.custom-popup-mask { .custom-popup-mask {
position: fixed; position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.3);
z-index: 1000;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s ease;
&.mask-visible {
opacity: 1;
}
}
.custom-popup-content {
position: absolute;
max-height: 90%;
opacity: 0;
transform: scale(0.95);
transition: opacity 0.3s ease, transform 0.3s ease;
&.content-visible {
opacity: 1;
transform: scale(1);
}
&.popup-top {
top: 0; top: 0;
left: 50%; left: 0;
transform: translateY(-100%) translateX(-50%); right: 0;
width: 100%; bottom: 0;
border-bottom-left-radius: 20rpx; background-color: rgba(0, 0, 0, 0.3);
border-bottom-right-radius: 20rpx; z-index: 1000;
display: flex;
&.content-visible { justify-content: center;
transform: translateY(0) translateX(-50%); align-items: center;
opacity: 0;
transition: opacity 0.3s ease;
&.mask-visible {
opacity: 1;
} }
} }
&.popup-center { .custom-popup-content {
top: 50%; position: absolute;
left: 50%; max-height: 90%;
transform: translate(-50%, -50%) scale(0.95); opacity: 0;
min-width: 600rpx; transform: scale(0.95);
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.15); transition: opacity 0.3s ease, transform 0.3s ease;
&.content-visible { &.content-visible {
transform: translate(-50%, -50%) scale(1); opacity: 1;
transform: scale(1);
} }
}
&.popup-top {
&.popup-bottom { top: 0;
bottom: 0; left: 50%;
left: 50%; transform: translateY(-100%) translateX(-50%);
transform: translateY(100%) translateX(-50%); width: 100%;
width: 100%; border-bottom-left-radius: 20rpx;
border-top-left-radius: 20rpx; border-bottom-right-radius: 20rpx;
border-top-right-radius: 20rpx;
&.content-visible {
&.content-visible { transform: translateY(0) translateX(-50%);
transform: translateY(0) translateX(-50%); }
} }
}
&.popup-center {
&.popup-left { top: 50%;
top: 50%; left: 50%;
left: 0; transform: translate(-50%, -50%) scale(0.95);
transform: translateX(-100%) translateY(-50%); min-width: 600rpx;
height: 100%; box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.15);
max-width: 80%;
border-top-right-radius: 20rpx; &.content-visible {
border-bottom-right-radius: 20rpx; transform: translate(-50%, -50%) scale(1);
}
&.content-visible {
transform: translateX(0) translateY(-50%);
} }
}
&.popup-bottom {
&.popup-right { bottom: 0;
top: 50%; left: 50%;
right: 0; transform: translateY(100%) translateX(-50%);
transform: translateX(100%) translateY(-50%); width: 100%;
height: 100%; border-top-left-radius: 20rpx;
max-width: 80%; border-top-right-radius: 20rpx;
border-top-left-radius: 20rpx;
border-bottom-left-radius: 20rpx; &.content-visible {
transform: translateY(0) translateX(-50%);
&.content-visible { }
transform: translateX(0) translateY(-50%); }
&.popup-left {
top: 50%;
left: 0;
transform: translateX(-100%) translateY(-50%);
height: 100%;
max-width: 80%;
border-top-right-radius: 20rpx;
border-bottom-right-radius: 20rpx;
&.content-visible {
transform: translateX(0) translateY(-50%);
}
}
&.popup-right {
top: 50%;
right: 0;
transform: translateX(100%) translateY(-50%);
height: 100%;
max-width: 80%;
border-top-left-radius: 20rpx;
border-bottom-left-radius: 20rpx;
&.content-visible {
transform: translateX(0) translateY(-50%);
}
} }
} }
}
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<view :class="['customer-box',{'is-show':showCustomerBox}]"> <view :class="['customer-box',{'is-show':showCustomerBox}]">
<view class="customer-title">客户档案的记录</view> <view class="customer-title">
客户档案的记录
</view>
<scroll-view <scroll-view
scroll-y scroll-y
class="scroll-box" class="scroll-box"
> >
<template v-if="loading"> <template v-if="loading">
<view class="loading flex"> <view class="loading flex">
<uni-icons <uni-icons
type="refreshempty" type="refreshempty"
:size="46" :size="46"
color="#3773F8" color="#3773F8"
class="icon" class="icon"
></uni-icons> >
</uni-icons>
</view> </view>
</template> </template>
<template v-else> <template v-else>
...@@ -20,18 +23,19 @@ ...@@ -20,18 +23,19 @@
<template v-for="(i,index) in searchList" :key="index"> <template v-for="(i,index) in searchList" :key="index">
<view <view
class="item flex" class="item flex"
hover-class="active" hover-class="active"
@click="chooseItem(i)" @click="chooseItem(i)"
> >
{{ `${showType == 'tel'?i.ownerPhone:i.ownerName}`}} {{ `${showType == 'tel'?i.ownerPhone:i.ownerName}`}}
</view> </view>
</template> </template>
</template> </template>
<template v-else> <template v-else>
<view class="nothing flex"> <view class="nothing flex">
<view class="icon"></view> <view class="icon">
未匹配到客户信息 </view>
未匹配到客户信息
</view> </view>
</template> </template>
</template> </template>
...@@ -40,153 +44,147 @@ ...@@ -40,153 +44,147 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { state } from '@/store/index.uts' import { state } from '@/store/index.uts'
import { getCustomerInfoListApi } from '@/api/customer-api.uts' import { getCustomerInfoListApi } from '@/api/customer-api.uts'
interface CustomerInfo { type CustomerInfo = UTSJSONObject
ownerPhone?: string
ownerName?: string
[key: string]: any
}
interface UserInfo { type UserInfo = UTSJSONObject
shopMerchantId: string
sceneType: number
[key: string]: any
}
interface SearchParams { type SearchParams = {
merchantId: string merchantId: string
bussinessScene: number bussinessScene: number
ownerPhone?: string ownerPhone?: string
ownerName?: string ownerName?: string
} }
const props = defineProps({ const props = defineProps({
searchValue: String, searchValue: String,
showType: String, showType: String,
show: Boolean show: Boolean
}) })
const emit = defineEmits(['choose']) const emit = defineEmits(['choose'])
const loading = ref<boolean>(true) const loading = ref<boolean>(true)
const searchList = ref<Array<CustomerInfo>>([]) const searchList = ref<Array<CustomerInfo>>([])
const showCustomerBox = computed<boolean>(() => { const showCustomerBox = computed<boolean>(() => {
return props.show && state.user?.haveCustomerAccess && props.searchValue const searchValue = props.searchValue ?? ''
}) return props.show == true && (state.user?.haveCustomerAccess ?? false) && (searchValue !== '' && searchValue !== null)
})
async function getCustomerInfoList(val: string, type: string): Promise<void> {
try {
loading.value = true
const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null
const userInfoObj = userInfo ?? { shopMerchantId: '', sceneType: 0 }
const shopMerchantId = userInfoObj.shopMerchantId
const params: SearchParams = {
merchantId: shopMerchantId as String,
bussinessScene: userInfoObj.sceneType == 0 ? 1 : 2
}
watch(() => showCustomerBox.value, (newval) => { if (type == 'tel') {
if (newval) { params.ownerPhone= val
getCustomerInfoList(props.searchValue || '', props.showType || '') } else {
} params.ownerName = val
}, { immediate: true }) }
async function getCustomerInfoList(val: string, type: string): Promise<void> { const result = await getCustomerInfoListApi(params as UTSJSONObject)
try { searchList.value = result as UTSArray<UTSJSONObject>
loading.value = true loading.value = false
const userInfo: UserInfo = storage.get("userInfo") || { shopMerchantId: '', sceneType: 0 } } catch (error) {
const params: SearchParams = { loading.value = false
merchantId: userInfo.shopMerchantId, }
bussinessScene: userInfo.sceneType == 0 ? 1 : 2
}
if (type == 'tel') {
params.ownerPhone= val
} else {
params.ownerName = val
}
const result = await getCustomerInfoListApi(params)
searchList.value = result || []
loading.value = false
} catch (error) {
loading.value = false
console.error('获取客户信息失败:', error)
} }
} watch(showCustomerBox.value , (newVal: boolean) => {
if (newVal == true) {
getCustomerInfoList(props.searchValue ?? '', props.showType ?? '')
}
}, { immediate: true })
function chooseItem(item: CustomerInfo): void {
emit('choose', item)
} function chooseItem(item: CustomerInfo): void {
emit('choose', item)
}
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.customer-box { .customer-box {
position: absolute; position: absolute;
left: 0; left: 0;
top: 88rpx; top: 88rpx;
width: 100%; width: 100%;
height: 352rpx; height: 352rpx;
background: #ffffff; background: #ffffff;
border-radius: 16rpx; border-radius: 16rpx;
z-index: -1; z-index: -1;
opacity: 0; opacity: 0;
.customer-title { .customer-title {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
line-height: 40rpx; line-height: 40rpx;
padding: 16rpx 24rpx 8rpx; padding: 16rpx 24rpx 8rpx;
} }
.scroll-box { .scroll-box {
height: calc(100% - 64rpx); height: calc(100% - 64rpx);
.loading { .loading {
width: 100%; width: 100%;
height: 100%; height: 100%;
justify-content: center; justify-content: center;
.icon { .icon {
animation: rotate-loading 1s linear infinite; animation: rotate-loading 1s linear infinite;
} }
} }
.nothing { .nothing {
width: 100%; width: 100%;
height: 100%; height: 100%;
font-size: 24rpx; font-size: 24rpx;
color: #c7ccd7; color: #c7ccd7;
flex-direction: column; flex-direction: column;
.icon { .icon {
margin-top: 52rpx; margin-top: 52rpx;
width: 96rpx; width: 96rpx;
height: 96rpx; height: 96rpx;
/* background-image: url('@/assets/images/common/nothing.webp'); */ /* background-image: url('@/assets/images/common/nothing.webp'); */
background-size: 100%; background-size: 100%;
} }
} }
.item { .item {
width: 100%; width: 100%;
height: 48rpx; height: 48rpx;
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
line-height: 40rpx; line-height: 40rpx;
padding-left: 24rpx; padding-left: 24rpx;
margin-bottom: 8rpx; margin-bottom: 8rpx;
} }
.active { .active {
background: #ecf1ff; background: #ecf1ff;
} }
@keyframes rotate-loading { @keyframes rotate-loading {
0% { 0% {
transform: rotate(0); transform: rotate(0);
} }
100% { 100% {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
}
} }
}
.is-show { .is-show {
z-index: 1; z-index: 1;
opacity: 1; opacity: 1;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<MessageBox <MessageBox
ref="employeeBoxVisible" ref="employeeBoxVisible"
position="bottom" position="bottom"
:isFooter="false" :isFooter="false"
:title="`请选择${title}`" :title="`请选择${title}`"
:maxHeight="1000" :maxHeight="1000"
@close="handleClose" @close="handleClose"
> >
<view class="select-box"> <view class="select-box">
<view <view
class="select-item" class="select-item"
:class="{ checked: salesUuid == item.uuid }" :class="{ checked: salesUuid == item.uuid }"
@click="handleSelect(item)" @click="handleSelect(item)"
v-for="(item, index) in employeeList" v-for="(item, index) in employeeList"
:key="index" :key="index"
> >
{{ item.staffName }} {{ item.staffName }}
</view> </view>
...@@ -26,63 +26,88 @@ ...@@ -26,63 +26,88 @@
import MessageBox from './MessageBox.uvue' import MessageBox from './MessageBox.uvue'
import { state, dispatch } from '@/store/index.uts' import { state, dispatch } from '@/store/index.uts'
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { getEmployeeList as getEmployeeListApi } from '@/api/common-api.uts' import { getEmployeeListApi } from '@/api/common-api.uts'
import { ComponentPublicInstance } from 'vue'
interface EmployeeItem { interface EmployeeItem {
staffName: string staffName: string
uuid: string uuid: string
[key: string]: any
} }
interface Props { interface Props {
title?: string title?: string
salesPropsUuid?: string salesPropsUuid?: string
} }
type UserInfo = UTSJSONObject
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
title: '销售', title: '销售',
salesPropsUuid: '' salesPropsUuid: ''
}) })
const emit = defineEmits(['close', 'select']) const emit = defineEmits(['close', 'select'])
const employeeBoxVisible = ref<any>(null) const employeeBoxVisible = ref(null)
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus 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 salesUuid = computed(() => {
return state.user.customerInfo.salesUuid || props.salesPropsUuid const val1 = state.user.customerInfo.salesUuid
}) const val2 = props.salesPropsUuid
return val1 !== null && val1 !== '' ? val1 : val2
})
const employeeList = computed(() => { // const employeeList = computed(() => {
return state.user.employeeList // return state.user.employeeList
}) // })
const employeeList = ref<Array<EmployeeItem>>([])
watch(updateView.value,()=>{
const list = storage.get("employeeList") as UTSArray<EmployeeItem>
employeeList.value = list !== null ? list : []
watch(() => watchStatus.value, (newval: number) => { }, { immediate: true, deep: true })
close() function close(): void {
}, { immediate: true }) if (employeeBoxVisible.value != null) {
(employeeBoxVisible.value as ComponentPublicInstance).$callMethod('close')
}
}
watch(watchStatus.value, (newval: number) => {
close()
}, { immediate: true })
function handleClose(): void { function handleClose(): void {
emit('close') emit('close')
} }
function open(): void { function open(): void {
employeeBoxVisible.value?.open() if (employeeBoxVisible.value != null) {
const userInfo = storage.get('userInfo') (employeeBoxVisible.value as ComponentPublicInstance).$callMethod('open')
const userInfoObj = userInfo as any }
const shopMerchantId = userInfoObj?.shopMerchantId const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null
if (userInfo == null) return
const shopMerchantId = userInfo.shopMerchantId
// 获取销售人员列表 // 获取销售人员列表
getEmployeeListApi({ getEmployeeListApi({ merchantId: shopMerchantId }).then((res: any) => {
merchantId: shopMerchantId const employeeList = res as Array<EmployeeItem>
}).then((res: EmployeeItem[]) => { dispatch('setEmployeeList', employeeList)
dispatch('setEmployeeList', res) const listToStore = employeeList != null ? employeeList : []
storage.set('employeeList', res || []) storage.set('employeeList', listToStore, 0)
}).catch((error: any) => { updateView.value = Date.now()
console.error('获取员工列表失败:', error)
}) })
} }
function handleSelect(item: EmployeeItem): void { function handleSelect(item: EmployeeItem): void {
...@@ -90,39 +115,33 @@ ...@@ -90,39 +115,33 @@
emit('select', item) emit('select', item)
} }
function close(): void {
employeeBoxVisible.value?.close()
}
defineExpose({ defineExpose({ open, close })
open,
close
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.select-box { .select-box {
margin: 40rpx 0; margin: 40rpx 0;
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
gap: 32rpx; gap: 32rpx;
overflow-y: scroll; overflow-y: scroll;
max-height: 50vh; max-height: 50vh;
padding-bottom: 60rpx; padding-bottom: 60rpx;
.select-item { .select-item {
text-align: center; text-align: center;
height: 68rpx; height: 68rpx;
line-height: 44rpx; line-height: 44rpx;
opacity: 1; opacity: 1;
border: 2rpx solid #dce0e6; border: 2rpx solid #dce0e6;
color: #333; color: #333;
font-size: 32rpx; font-size: 32rpx;
border-radius: 8rpx; border-radius: 8rpx;
&.checked { &.checked {
border: 2rpx solid #292d33; border: 2rpx solid #292d33;
}
} }
} }
}
</style> </style>
...@@ -2,105 +2,111 @@ ...@@ -2,105 +2,111 @@
<view class="step"> <view class="step">
<MessageBox <MessageBox
class="step-box" class="step-box"
ref="formRef" ref="formRef"
@cancel="cancel" @cancel="cancel"
@confirm="submit" @confirm="submit"
:cancelBtnText="`${step == 1 ? '取消' : '上一步'}`" :cancelBtnText="`${step == 1 ? '取消' : '上一步'}`"
:confirmBtnText="`${sceneType == 0 ? (step == 1 ? '下一步' : '完成接待') : '完成接待'}`" :confirmBtnText="`${sceneType == 0 ? (step == 1 ? '下一步' : '完成接待') : '完成接待'}`"
:title="`${step == 1 ? '客户信息完善' : '结果反馈'}`" :title="`${step == 1 ? '客户信息完善' : '结果反馈'}`"
:popupW="820" :popupW="820"
:maxHeight="820" :maxHeight="820"
:isAutoClose="false" :isAutoClose="false"
> >
<view <view
name="content" name="content"
:key="updateViewKey" :key="updateViewKey"
> >
<template v-if="step == 1"> <template v-if="step == 1">
<template v-if="!check(true)"> <template v-if="!check(true)">
<view <view
class="error-tip" class="error-tip"
v-if="errorTip" v-if="errorTip"
>以下信息不能为空,请完善信息后保存</view> >以下信息不能为空,请完善信息后保存</view>
<view <view
class="pop-tips" class="pop-tips"
v-else v-else
>{{ tips }}</view> >{{ tips }}</view>
</template> </template>
<view class="form"> <view class="form">
<template v-for="(i, index) in formObject" :key="index"> <template v-for="(i, index) in formObject" :key="index">
<view <view
class="form-item" class="form-item"
>
> <view :class="['label', { required: i.required == true}]">
<view :class="['label', { required: i.required }]">{{ i.label }}</view> {{ i.label }}
<view :class="['value', { error: showError(i.key) && i.required }, { disabled: customerType == 0 || i.disabled }]">
<template v-if="i.type == 'input'">
<input
:type="i.inputType"
:maxlength="i.maxlength"
v-model="formData[i.key]"
class="input"
:placeholder="i.placeholder"
:disabled="customerType == 0"
@input="inputCustomer"
placeholder-style="color:#c9c9c9;"
/>
</template>
<template v-else>
<view
:class="['select', `${formData[i.key] ? '' : 'placeholder'}`]"
@click="showPopup(i)"
:key="selectKey"
>
{{ formData[i.key] || i.placeholder }}
<uni-icons
class="arrow"
type="down"
:size="16"
></uni-icons>
</view> </view>
</template> <view :class="['value', { error: showError(i.key) && i.required == true }, { disabled: customerType == 0 || i.disabled == true }]">
</view> <template v-if="i.type == 'input'">
<input
:type="i.inputType"
:maxlength="i.maxlength"
v-model="formData[i.key]"
class="input"
:placeholder="i.placeholder"
:disabled="customerType == 0"
@input="inputCustomer"
placeholder-style="color:#c9c9c9;"
/>
</template>
<template v-else>
<view
:class="['select', `${formData[i.key] !== null && formData[i.key] !== '' ? '' : 'placeholder'}`]"
@click="showPopup(i)"
:key="selectKey"
>
{{ formData[i.key] !== null && formData[i.key] !== '' ? formData[i.key] : i.placeholder }}
<uni-icons
class="arrow"
type="down"
:size="16"
>
</uni-icons>
</view>
</template>
</view>
</view>
</template>
</view> </view>
</template> </template>
</view> <template v-else>
</template> <view class="pop-tips">
<template v-else> 请完善本次接待结果
<view class="pop-tips">请完善本次接待结果</view> </view>
<view class="choose-box"> <view class="choose-box">
<template v-for="(i, index) in resultList" :key="index"> <template v-for="(i, index) in resultList" :key="index">
<view <view
:class="['choose-item', `${i.status == receptionStatus ? (i.status == 1 ? 'success' : 'error') : ''}`]" :class="['choose-item', `${i.status == receptionStatus ? (i.status == 1 ? 'success' : 'error') : ''}`]"
@click="chooseResult(i.status)" @click="chooseResult(i.status)"
> >
<view :class="['sprite-icon', `icon-face-${i.status == receptionStatus ? `${i.icon}-active` : i.icon}`]"></view> <view :class="['sprite-icon', `icon-face-${i.status == receptionStatus ? `${i.icon}-active` : i.icon}`]">
{{ i.text }} </view>
{{ i.text }}
</view>
</template>
</view> </view>
</template> </template>
</view> </view>
</template> </MessageBox>
</view> <car-brands
</MessageBox> ref="carBrandListVisible"
<car-brands @select="handleSelect($event as IUTSObject, 'carBrandListVisible')"
ref="carBrandListVisible" />
@select="handleSelect($event, 'carBrandListVisible')" <employee
/> ref="employeeBoxVisible"
<employee @select="handleSelect($event as IUTSObject, 'employeeBoxVisible')"
ref="employeeBoxVisible" />
@select="handleSelect($event, 'employeeBoxVisible')" <!-- <uni-popup
/> ref="successRef"
<!-- <uni-popup type="message"
ref="successRef" >
type="message" <uni-popup-message
> type="success"
<uni-popup-message message="数据保存成功"
type="success" :duration="1500"
message="数据保存成功" >
:duration="1500" </uni-popup-message>
></uni-popup-message> </uni-popup> -->
</uni-popup> --> </view>
</view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
...@@ -109,8 +115,9 @@ ...@@ -109,8 +115,9 @@
import CarBrands from '@/components/CarBrands.uvue' import CarBrands from '@/components/CarBrands.uvue'
import { state, dispatch } from '@/store/index.uts' import { state, dispatch } from '@/store/index.uts'
import MessageBox from './MessageBox.uvue' import MessageBox from './MessageBox.uvue'
import { ComponentPublicInstance } from 'vue'
interface FormObjectItem {
type FormObjectItem = {
label: string label: string
key: string key: string
type: string type: string
...@@ -121,85 +128,62 @@ ...@@ -121,85 +128,62 @@
popKey?: string popKey?: string
disabled?: boolean disabled?: boolean
} }
interface FormData { type FormData = {
customerName: string customerName: string
carModel: string carModel: string
phoneNumber: string phoneNumber: string
salesUuid: string salesUuid: string
staffName: string staffName: string
[key: string]: string carModelId: string
} }
interface ResultListItem { type ResultListItem = {
icon: string icon: string
text: string text: string
status: number status: number
} }
const phoneRex = /^[1]([3-9])[0-9]{9}$/ const formData = ref<FormData>({
customerName: "",
const formObject_boutique: FormObjectItem[] = [{ carModel: "",
label: "车主姓名", phoneNumber: "",
key: "customerName", salesUuid: "",
type: "input", staffName: "",
inputType: "text", carModelId:""
maxlength: 20, })
placeholder: '请输入车主姓名',
required: true
},
{
label: "品牌车型",
key: "carModel",
type: "select",
popKey: "carBrandListVisible",
placeholder: '请选择品牌车型',
disabled: true
},
{
label: "车主电话",
key: "phoneNumber",
type: "input",
inputType: "tel",
maxlength: 11,
placeholder: '请输入车主电话',
required: true
},
{
label: "交付专员",
key: "staffName",
type: "select",
popKey: "employeeBoxVisible",
placeholder: '请选择交付专员',
required: true
}]
interface Props {
sceneType?: number
customerType?: number
titleTips?: string
}
const props = withDefaults(defineProps<Props>(), {
sceneType: 0,
customerType: 1,
titleTips: ''
})
const emit = defineEmits(['submit', 'back']) const resultList = ref<Array<ResultListItem>>([
{
icon: 'success',
text: '结果完美,成交了',
status: 1
},
{
icon: 'error',
text: '仍需努力,战败了',
status: 0
}
])
const step = ref<number>(1) const formObject_boutique: Array<FormObjectItem> = [{
const formObject = ref<FormObjectItem[]>([
{
label: "车主姓名", label: "车主姓名",
key: "customerName", key: "customerName",
type: "input", type: "input",
inputType: "text", inputType: "text",
maxlength: 50, maxlength: 20,
placeholder: '请输入车主姓名', placeholder: '请输入车主姓名',
required: true required: true
}, },
{ {
label: "品牌车型",
key: "carModel",
type: "select",
popKey: "carBrandListVisible",
placeholder: '请选择品牌车型',
disabled: true
},
{
label: "车主电话", label: "车主电话",
key: "phoneNumber", key: "phoneNumber",
type: "input", type: "input",
...@@ -209,197 +193,267 @@ ...@@ -209,197 +193,267 @@
required: true required: true
}, },
{ {
label: "品牌车型", label: "交付专员",
key: "carModel",
type: "select",
popKey: "carBrandListVisible",
placeholder: '请选择品牌车型',
required: true
},
{
label: "销售姓名",
key: "staffName", key: "staffName",
type: "select", type: "select",
popKey: "employeeBoxVisible", popKey: "employeeBoxVisible",
placeholder: '请选择销售', placeholder: '请选择交付专员',
required: true required: true
} }]
])
interface Props {
const formData = ref<FormData>({ sceneType?: number
customerName: "", customerType?: number
carModel: "", titleTips?: string
phoneNumber: "", }
salesUuid: "",
staffName: "" const props = withDefaults(defineProps<Props>(), {
}) sceneType: 0,
customerType: 1,
const resultList = ref<ResultListItem[]>([ titleTips: ''
{ })
icon: 'success',
text: '结果完美,成交了', const emit = defineEmits(['submit', 'back'])
status: 1
}, const step = ref<number>(1)
{ const formObject = ref<Array<FormObjectItem>>([
icon: 'error', {
text: '仍需努力,战败了', label: "车主姓名",
status: 0 key: "customerName",
} type: "input",
]) inputType: "text",
maxlength: 50,
placeholder: '请输入车主姓名',
required: true
},
{
label: "车主电话",
key: "phoneNumber",
type: "input",
inputType: "tel",
maxlength: 11,
placeholder: '请输入车主电话',
required: true
},
{
label: "品牌车型",
key: "carModel",
type: "select",
popKey: "carBrandListVisible",
placeholder: '请选择品牌车型',
required: true
},
{
label: "销售姓名",
key: "staffName",
type: "select",
popKey: "employeeBoxVisible",
placeholder: '请选择销售',
required: true
}
])
const errorTip = ref<boolean>(false) const errorTip = ref<boolean>(false)
const receptionStatus = ref<number>(-1) const receptionStatus = ref<number>(-1)
const updateViewKey = ref<number>(Date.now()) const updateViewKey = ref<number>(Date.now())
const selectKey = ref<number>(Date.now()) const selectKey = ref<number>(Date.now())
const formRef = ref<any>(null) const formRef = ref(null)
const carBrandListVisible = ref<any>(null) const carBrandListVisible = ref(null)
const employeeBoxVisible = ref<any>(null) const employeeBoxVisible = ref(null)
const phoneRex = /^[1]([3-9])[0-9]{9}$/
// 获取动态 ref 的值
const getRefValue = (key: string): any => { // 获取动态ref 的值
const getRefValue = (key: string): any | null => {
if (key === 'carBrandListVisible') return carBrandListVisible.value if (key === 'carBrandListVisible') return carBrandListVisible.value
if (key === 'employeeBoxVisible') return employeeBoxVisible.value if (key === 'employeeBoxVisible') return employeeBoxVisible.value
return null return null
} }
const successRef = ref<any>(null) const successRef = ref(null)
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
}) if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
const tips = computed(() => { const tips = computed(() => {
let { sceneType, titleTips } = props let { sceneType, titleTips } = props
let text = titleTips || '检测到"交车告知书"中未填写客户档案,请填写后再完成接待。' let text = titleTips !== null && titleTips !== '' ? titleTips : '检测到"交车告知书"中未填写客户档案,请填写后再完成接待。'
if (sceneType == 1) text = '请确认"车型加装选购页"中的客户信息,并点击「完成接待」结束客户接待。' if (sceneType == 1) text = '请确认"车型加装选购页"中的客户信息,并点击「完成接待」结束客户接待。'
return text return text
}) })
watch(() => watchStatus.value, (newval: number) => { watch(watchStatus.value, () => {
receptionStatus.value = -1 receptionStatus.value = -1
errorTip.value = false errorTip.value = false
formRef.value?.close() if (formRef.value != null) {
}, { immediate: true }) (formRef.value as ComponentPublicInstance).$callMethod('close')
}
}, { immediate: true })
function showError(key: string): boolean { function showError(key: string): boolean {
let flag = !formData.value[key] const value = formData.value[key]
if (key == 'phoneNumber' && formData.value[key]) flag = !phoneRex.test(formData.value[key]) let flag = value === null || value === ''
if (key == 'phoneNumber') {
const phoneValue = formData.value[key] as string
if (phoneValue !== null && phoneValue !== '') {
flag = phoneRex.test(phoneValue) == false
}
}
return errorTip.value && flag return errorTip.value && flag
} }
function showPopup(item: FormObjectItem): void { function showPopup(item: FormObjectItem): void {
let { customerType } = props let { customerType } = props
if (customerType == 0 || item.disabled) return if (customerType == 0 || (item.disabled === true)) return
const popKey = item.popKey || '' const popKey = item.popKey !== null ? item.popKey : ''
const refValue = getRefValue(popKey) const refValue = getRefValue(popKey)
refValue?.open() if (refValue != null) {
(refValue as ComponentPublicInstance).$callMethod('open')
}
}
function close(): void {
errorTip.value = false
receptionStatus.value = -1
if (formRef.value != null) {
(formRef.value as ComponentPublicInstance).$callMethod('close')
}
} }
// 取消 // 取消
function cancel(): void { function cancel(): void {
if (step.value == 1) close() if (step.value == 1) close()
else step.value = 1 else step.value = 1
} }
function close(): void {
errorTip.value = false
receptionStatus.value = -1
formRef.value?.close()
}
function check(all: boolean = false): boolean { function check(all: boolean = false): boolean {
let flag = true let flag = true
try {
formObject.value.forEach(e => { formObject.value.forEach(e => {
if (e.required) { if (e.required == true) {
if (!formData.value[e.key]) throw false const value = formData.value[e.key]
if (!all && e.key == 'phoneNumber' && !phoneRex.test(formData.value[e.key])) { if (value === null || value === '') {
uni.showToast({ flag = false
title: "请输入正确的车主电话", return
icon: "none" }
}) if (!all && e.key == 'phoneNumber') {
throw false const phoneValue = formData.value[e.key] as string
if (phoneValue !== null && phoneValue !== '' && phoneRex.test(phoneValue) == false) {
uni.showToast({
title: "请输入正确的车主电话",
icon: "none"
})
flag = false
return
}
} }
} }
}) })
} catch (error) {
flag = error as boolean
}
return flag return flag
} }
function success(receptionStatus: number): void {
if (successRef.value != null) {
(successRef.value as ComponentPublicInstance).$callMethod('open')
}
emit('submit', receptionStatus)
}
// 保存 // 保存
function submit(): void { function submit(): void {
let { receptionStatus: status } = { receptionStatus: receptionStatus.value }
if (step.value == 1) { if (step.value == 1) {
errorTip.value = true errorTip.value = true
if (check()) { if (check()) {
const { sceneType } = props const sceneType = props.sceneType
if (sceneType == 0) step.value = 2 if (sceneType == 0) step.value = 2
else { else {
status = 1 receptionStatus.value = 1
success(status) success(receptionStatus.value)
} }
} }
} else { } else {
if (receptionStatus.value == -1) { if (receptionStatus.value == -1) {
uni.showToast({ uni.showToast({
title: '请完善本次接待结果', title: '请完善本次接待结果',
icon: 'none' icon: 'none'
}) })
return return
} }
success(receptionStatus.value) success(receptionStatus.value)
} }
} }
function success(receptionStatus: number): void {
successRef.value?.open()
emit('submit', receptionStatus)
}
function inputCustomer(): void { function inputCustomer(): void {
dispatch('setCustomerInfo', formData.value) dispatch('setCustomerInfo', formData.value)
} }
function handleSelect(item: any, popkey: string): void { function handleSelect(item: IUTSObject, popkey: string): void {
const customerInfo = dispatch('getCustomerInfo') const customerInfo = dispatch('getCustomerInfo') as IUTSObject
if (popkey == "employeeBoxVisible") { if (popkey == "employeeBoxVisible") {
formData.value.salesUuid = item.uuid formData.value.salesUuid = item['uuid'] as string
formData.value.staffName = item.staffName formData.value.staffName = item['staffName'] as string
dispatch("setCustomerInfo", { dispatch("setCustomerInfo", { ...customerInfo, ...formData.value })
...customerInfo,
...formData.value
})
} else { } else {
carBrandListVisible.value?.close() if (carBrandListVisible.value != null) {
formData.value.carModel = item.name (carBrandListVisible.value as ComponentPublicInstance).$callMethod('close')
formData.value.carModelId = item.id }
formData.value.carModel = item['name'] as string
formData.value.carModelId = item['id'] as string
} }
selectKey.value = Date.now() selectKey.value = Date.now()
} }
function open(): void { function open(): void {
const customerInfo = dispatch('getCustomerInfo') const customerInfo = dispatch('getCustomerInfo')
formData.value = customerInfo
if (customerInfo != null) {
formData.value = customerInfo as FormData
let { sceneType, customerType } = props let { sceneType, customerType } = props
let stepValue = Object.values(customerInfo).every((value) => !!value) ? 2 : 1
let stepValue = 1
const keys = ['customerName', 'carModel', 'phoneNumber']
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
const value = customerInfo[key] as string | null
if (value == null || value === '') {
stepValue = 1
break
}
stepValue = 2
}
errorTip.value = false errorTip.value = false
if (sceneType == 1) { if (sceneType == 1) {
stepValue = 1 stepValue = 1
formObject.value = formObject_boutique formObject.value = formObject_boutique
if (customerType == 0 && !check()) { const checkResult = check()
if (customerType == 0 && !checkResult) {
emit('back') emit('back')
return return
} }
} }
if (stepValue == 2 && !check()) { if (stepValue == 2) {
errorTip.value = true const checkResult = check()
stepValue = 1 if (!checkResult) {
errorTip.value = true
stepValue = 1
}
} }
step.value = stepValue step.value = stepValue
formRef.value?.open() if (formRef.value != null) {
(formRef.value as ComponentPublicInstance).$callMethod('open')
}
updateViewKey.value = Date.now() updateViewKey.value = Date.now()
}
} }
function chooseResult(val: number): void { function chooseResult(val: number): void {
...@@ -407,150 +461,166 @@ ...@@ -407,150 +461,166 @@
dispatch('setReceptionStatus', val) dispatch('setReceptionStatus', val)
} }
defineExpose({ function updateStep(): void {
open, const customerInfo = dispatch('getCustomerInfo') as IUTSObject
close
}) let stepValue = 1
const keys = ['customerName', 'carModel', 'phoneNumber']
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
const value = customerInfo[key]
if (value == null || value === '') {
stepValue = 1
break
}
stepValue = 2
}
step.value = stepValue
}
defineExpose({ open, close })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.pop-tips { .pop-tips {
background: rgba(44, 102, 247, 0.1); background: rgba(44, 102, 247, 0.1);
color: #2c66f7; color: #2c66f7;
font-size: 28rpx; font-size: 28rpx;
padding: 24rpx 80rpx 24rpx; padding: 24rpx 80rpx 24rpx;
margin-top: 30rpx; margin-top: 30rpx;
text-align: center; text-align: center;
} }
.error-tip { .error-tip {
font-size: 28rpx; font-size: 28rpx;
padding: 32rpx 60rpx 24rpx; padding: 32rpx 60rpx 24rpx;
margin-top: 30rpx; margin-top: 30rpx;
text-align: center; text-align: center;
background-color: rgb(254, 237, 234); background-color: rgb(254, 237, 234);
color: #f45c3d; color: #f45c3d;
} }
.form { .form {
display: flex;
flex-wrap: wrap;
gap: 24rpx 0;
padding-top: 30rpx;
&-item {
display: flex; display: flex;
align-items: center; flex-wrap: wrap;
color: #6c6c70; gap: 24rpx 0;
font-size: 30rpx; padding-top: 30rpx;
box-sizing: border-box;
margin: 0 auto; &-item {
flex-direction: row; display: flex;
.label { align-items: center;
position: relative; color: #6c6c70;
margin-left: auto;
flex-shrink: 0;
width: 144rpx;
font-size: 30rpx; font-size: 30rpx;
box-sizing: border-box;
&.required { margin: 0 auto;
padding-left: 20rpx; flex-direction: row;
.label {
&::before { position: relative;
content: '*'; margin-left: auto;
color: #ff0000; flex-shrink: 0;
position: absolute; width: 144rpx;
left: 0; font-size: 30rpx;
top: 50%;
transform: translateY(-50%); &.required {
padding-left: 20rpx;
&::before {
content: '*';
color: #ff0000;
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
}
} }
} }
}
.value {
.value { width: 520rpx;
width: 520rpx; height: 80rpx;
height: 80rpx; border: 2rpx solid #e8e8ea;
border: 2rpx solid #e8e8ea; background: #ffffff;
background: #ffffff; margin-left: 32rpx;
margin-left: 32rpx; box-sizing: border-box;
box-sizing: border-box; padding: 0 40rpx;
padding: 0 40rpx;
border-radius: 8rpx;
&.error {
border: 2rpx solid #f24724;
border-radius: 8rpx; border-radius: 8rpx;
}
&.error {
.input, border: 2rpx solid #f24724;
.select { border-radius: 8rpx;
width: 100%; }
height: 100%;
border: none !important; .input,
outline: none; .select {
padding: 0 !important; width: 100%;
font-size: 30rpx; height: 100%;
border: none !important;
outline: none;
padding: 0 !important;
font-size: 30rpx;
flex-direction: row; flex-direction: row;
&::placeholder { &::placeholder {
color: #c9c9c9; color: #c9c9c9;
}
} }
}
.select {
.select { display: flex;
display: flex; align-items: center;
align-items: center;
.arrow {
.arrow { margin-left: auto;
margin-left: auto; }
}
.placeholder {
font-size: 30rpx;
color: #c9c9c9;
} }
} }
.placeholder { .disabled {
font-size: 30rpx; background: #f4f4f4;
color: #c9c9c9;
} .select {
} .arrow {
display: none;
.disabled { }
background: #f4f4f4;
.select {
.arrow {
display: none;
} }
} }
} }
} }
}
.choose-box {
.choose-box {
display: flex;
flex-direction: column;
align-items: center;
.choose-item {
width: 100%;
height: 128rpx;
border: 2rpx solid #e8e8e8;
border-radius: 16rpx;
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center;
margin-top: 24rpx; .choose-item {
width: 100%;
.sprite-icon { height: 128rpx;
margin-right: 16rpx; border: 2rpx solid #e8e8e8;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
margin-top: 24rpx;
.sprite-icon {
margin-right: 16rpx;
}
}
.success {
background: #14cc681a;
border-color: #14cc681a;
}
.error {
background: #f247241a;
border-color: #f247241a;
} }
} }
.success {
background: #14cc681a;
border-color: #14cc681a;
}
.error {
background: #f247241a;
border-color: #f247241a;
}
}
</style> </style>
<template> <template>
<CustomPopup <CustomPopup
ref="popupRef" ref="popupRef"
:visible="visible" :visible="visible"
:position="position" :position="position"
:mask-closable="false" :mask-closable="false"
:duration="300" :duration="300"
@update:visible="visible = $event" @update:visible="visible = $event as Boolean"
@close="onClose" @close="onClose"
> >
<view <view
:class="['tips-wrapper',{'radius': position === 'center'}]" :class="['tips-wrapper',{'radius': position === 'center'}]"
:style="{ width: popupW + 'rpx', minHeight: popupH + 'rpx', maxHeight: maxHeight + 'rpx' }" :style="{ width: (popupW ?? 0) + 'rpx', minHeight: (popupH ?? 0) + 'rpx', maxHeight: (maxHeight ?? 0) + 'rpx' }"
> >
<view class="tips-content"> <view class="tips-content">
<view <view
class="icon-close-box flex" class="icon-close-box flex"
@click="close" @click="close"
> >
<uni-icons <uni-icons
class="icon-close" class="icon-close"
type="closeempty" type="closeempty"
:size="18" :size="18"
color="#1A1A1A" color="#1A1A1A"
></uni-icons> >
</uni-icons>
</view> </view>
<view class="tips-title"> <view class="tips-title">
<template v-if="back"> <template v-if="back">
<view <view
class="sprite-icon icon-back" class="sprite-icon icon-back"
@click="close" @click="close"
></view> >
</view>
</template> </template>
{{ title }} {{ title }}
</view> </view>
<text <text
class="tips-text" class="tips-text"
v-if="content" v-if="content"
>{{ content }}</text> >{{ content }}</text>
<slot></slot> <slot>
</view> </slot>
<view </view>
class="tips-footer"
v-if="isFooter"
>
<view <view
v-if="showCancelBtn" class="tips-footer"
class="tips-btn close" v-if="isFooter"
>
<view
v-if="showCancelBtn"
class="tips-btn close"
@click="cancel" @click="cancel"
>{{ >{{
cancelBtnText cancelBtnText
}}</view> }}</view>
<view <view
class="tips-btn preview" class="tips-btn preview"
@click="confirm" @click="confirm"
>{{ >{{
confirmBtnText confirmBtnText
}}</view> }}</view>
</view> </view>
<template v-else> <template v-else>
<slot name="footer"></slot> <slot name="footer">
</template> </slot>
</view> </template>
</CustomPopup> </view>
</CustomPopup>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import CustomPopup from './CustomPopup.uvue' import CustomPopup from './CustomPopup.uvue'
import { ComponentPublicInstance } from 'vue'
const props = defineProps({
isAutoClose: { const props = defineProps({
type: Boolean, isAutoClose: {
default: true type: Boolean,
}, default: true
position: { },
type: String, position: {
default: "center" type: String,
}, default: "center"
popupW: Number, },
popupH: { popupW: Number,
type: Number, popupH: {
default: 372 type: Number,
}, default: 372
isFooter: { },
type: Boolean, isFooter: {
default: true type: Boolean,
}, default: true
title: { },
type: String, title: {
default: "提示" type: String,
}, default: "提示"
content: { },
type: String, content: {
default: "" type: String,
}, default: ""
confirmBtnText: { },
type: String, confirmBtnText: {
default: "确定" type: String,
}, default: "确定"
cancelBtnText: { },
type: String, cancelBtnText: {
default: "取消" type: String,
}, default: "取消"
maxHeight: Number, },
back: Boolean, maxHeight: Number,
showCancelBtn: { back: Boolean,
type: Boolean, showCancelBtn: {
default: true type: Boolean,
} default: true
}) }
})
const emit = defineEmits(['close', 'cancel', 'confirm']) const emit = defineEmits(['close',
'cancel',
'confirm'])
const visible = ref<boolean>(false) const visible = ref<boolean>(false)
const popupRef= ref<any>(null) const popupRef= ref(null)
function onClose(): void { function onClose(): void {
emit('close') emit('close')
} }
function close(): void { function close(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false
} else { } else {
popupRef.value?.close() if (popupRef.value != null) {
(popupRef.value as ComponentPublicInstance).$callMethod('close')
}
}
emit('close')
} }
emit('close')
}
function open(): void { function open(): void {
visible.value = true visible.value = true
} }
function cancel(): void { function cancel(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false
}
emit('cancel')
} }
emit('cancel')
}
function confirm(): void { function confirm(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false
}
emit('confirm')
} }
emit('confirm')
}
defineExpose({ defineExpose({ open, close })
open,
close
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.tips-wrapper { .tips-wrapper {
background: #ffffff; background: #ffffff;
border-radius: 20rpx 20rpx 0 0; border-radius: 20rpx 20rpx 0 0;
height: 100%; height: 100%;
.tips-content { .tips-content {
padding: 48rpx; padding: 48rpx;
box-sizing: border-box; box-sizing: border-box;
height: calc(100% - 100rpx); height: calc(100% - 100rpx);
position: relative;
.icon-close-box {
position: absolute;
right: 0;
top: 0;
width: 120rpx;
height: 120rpx;
justify-content: center;
z-index: 2;
align-items: center;
}
.tips-title {
position: relative; position: relative;
width: 100%;
font-weight: 500; .icon-close-box {
font-size: 36rpx;
color: #292d33;
text-align: center;
.icon-back {
position: absolute; position: absolute;
left: 0; right: 0;
top: 50%; top: 0;
transform: translateY(-50%); width: 120rpx;
height: 120rpx;
justify-content: center;
z-index: 2;
align-items: center;
}
.tips-title {
position: relative;
width: 100%;
font-weight: 500;
font-size: 36rpx;
color: #292d33;
text-align: center;
.icon-back {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
}
} }
} }
}
.tips-text {
.tips-text { display: block;
display: block; font-size: 30rpx;
font-size: 30rpx; color: #5a5e66;
color: #5a5e66; letter-spacing: 1rpx;
letter-spacing: 1rpx; text-align: center;
text-align: center; line-height: 40rpx;
line-height: 40rpx; margin-top: 48rpx;
margin-top: 48rpx;
}
.tips-footer {
display: flex;
align-items: center;
justify-content: center;
height: 100rpx;
border-top: 1px solid #e8e8e8;
flex-direction: row;
.close {
color: #6c6c70;
} }
.preview { .tips-footer {
color: #2c66f7; display: flex;
align-items: center;
justify-content: center;
height: 100rpx;
border-top: 1px solid #e8e8e8;
flex-direction: row;
.close {
color: #6c6c70;
}
.preview {
color: #2c66f7;
}
}
.tips-btn {
width: 50%;
text-align: center;
font-size: 32rpx;
text-align: center;
line-height: 44rpx;
font-weight: 500;
} }
} }
.radius{
.tips-btn { border-radius: 20rpx;
width: 50%;
text-align: center;
font-size: 32rpx;
text-align: center;
line-height: 44rpx;
font-weight: 500;
}
}
.radius{
border-radius: 20rpx;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
<view class="wn-canvas"> <view class="wn-canvas">
<zoom-pan <zoom-pan
:class="['canvas-box', { fill: custom }]" :class="['canvas-box', { fill: custom }]"
:disabled="drawStatus || !scaleSwitch" :disabled="(drawStatus == true || scaleSwitch == false)"
:scale-max="3" :scale-max="3"
:scale-min="1" :scale-min="1"
@scale="onScale" @scale="onScale"
> >
<template #content> <template #content>
<canvas <!-- <canvas
:class="['board-canvas', { 'draw-canvas': drawStatus }]" :class="['board-canvas', { 'draw-canvas': drawStatus }]"
:canvas-id="canvasId" :canvas-id="canvasId"
:disable-scroll="drawStatus" :disable-scroll="drawStatus"
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
@touchmove="onTouchMove" @touchmove="onTouchMove"
@touchend="onTouchEnd" @touchend="onTouchEnd"
> >
</canvas> </canvas> -->
<template v-if="custom"> <template v-if="custom">
<slot name="customContent"> <slot name="customContent">
</slot> </slot>
...@@ -43,24 +43,28 @@ ...@@ -43,24 +43,28 @@
import zoomPan from './zoom-pan.uvue' import zoomPan from './zoom-pan.uvue'
import { state } from "@/store/index.uts" import { state } from "@/store/index.uts"
interface HistoryItem { type HistoryItemStyle = {
style: { color: string
color: string width: number
width: number }
}
coordinates: Array<{ type HistoryItemCoordinate = {
type: string type: string
mode: string mode: string
x: number x: number
y: number y: number
}> }
type HistoryItem = {
style: HistoryItemStyle
coordinates: Array<HistoryItemCoordinate>
}
type ColorPickObj = {
color: string
} }
const props = defineProps({ const props = defineProps({
showSave: {
type: Boolean,
default: false
},
drawImage: { drawImage: {
type: String, type: String,
default: '' default: ''
...@@ -81,13 +85,12 @@ ...@@ -81,13 +85,12 @@
} }
}) })
const emit = defineEmits(['scale', const emit = defineEmits(['scale',])
'dowmloadSuc',
'dowmloadErr',
'saveImage'])
const colorShow = ref<boolean>(false) const colorShow = ref<boolean>(false)
const drawContext = ref<any>(null) // Canvas 相关 - 已注释
// let canvasContext: CanvasContext | null = null
// let renderingContext: CanvasRenderingContext2D | null = null
const historyList = ref<Array<HistoryItem>>([]) const historyList = ref<Array<HistoryItem>>([])
const startX = ref<number>(0) const startX = ref<number>(0)
const startY = ref<number>(0) const startY = ref<number>(0)
...@@ -97,8 +100,8 @@ ...@@ -97,8 +100,8 @@
const currentColor = ref<string>('red') const currentColor = ref<string>('red')
const bgColor = ref<string>('#fff') const bgColor = ref<string>('#fff')
const lineWidth = ref<number>(2) const lineWidth = ref<number>(2)
const lastRect = ref<UJSObject>({}) const lastRect = ref<UTSObject>({})
const lastCircle = ref<UJSObject>({}) const lastCircle = ref<UTSObject>({})
const isLandScape = ref<boolean>(false) const isLandScape = ref<boolean>(false)
const aspectRatio = ref<number | null>(null) const aspectRatio = ref<number | null>(null)
const height = ref<number | string | null>(null) const height = ref<number | string | null>(null)
...@@ -112,522 +115,42 @@ ...@@ -112,522 +115,42 @@
const isUnderBkg = ref<boolean>(false) const isUnderBkg = ref<boolean>(false)
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
}) if (status == null) {
return false
watch(() => watchStatus.value, (newval) => { } else if (status == 1) {
if (newval) { return true
clearBoard()
}
}, { immediate: true })
watch(() => props.drawImage, (n) => {
if (n) {
initBoard()
}
})
onMounted(() => {
drawContext.value = uni.createCanvasContext(props.canvasId)
initBoard()
})
function penBegin(x: number, y: number): void {
x = x / scaleValue.value
y = y / scaleValue.value
begin.value = true
drawContext.value.beginPath()
drawContext.value.setStrokeStyle(currentColor.value)
startX.value = x
startY.value = y
drawContext.value.moveTo(startX.value / scaleValue.value, startY.value / scaleValue.value)
drawPen(x, y)
}
function drawPen(x: number, y: number): void {
drawContext.value.moveTo(startX.value, startY.value)
drawContext.value.lineTo(x, y)
drawContext.value.stroke()
startX.value = x
startY.value = y
}
function lineBegin(x: number, y: number): void {
begin.value = true
startX.value = x
startY.value = y
}
function lineDraw(x: number, y: number): void {
drawContext.value.beginPath()
drawContext.value.moveTo(startX.value, startY.value)
drawContext.value.lineTo(x, y)
drawContext.value.stroke()
drawContext.value.draw(true)
}
function lineEnd(x: number, y: number): void {
if (startX.value == x && startY.value == y && !lastX.value && !lastY.value) {
drawContext.value.beginPath()
drawContext.value.moveTo(startX.value - 1, startY.value - 1)
drawContext.value.lineTo(x + 1, y + 1)
drawContext.value.stroke()
drawContext.value.draw(true)
}
lastX.value = 0
lastY.value = 0
drawContext.value.closePath()
begin.value = false
}
function rectFillBegin(x: number, y: number): void {
begin.value = true
drawContext.value.beginPath()
startX.value = x
startY.value = y
}
function rectBegin(x: number, y: number): void {
begin.value = true
drawContext.value.beginPath()
startX.value = x
startY.value = y
}
function circleFillBegin(x: number, y: number): void {
begin.value = true
drawContext.value.beginPath()
startX.value = x
startY.value = y
}
function circleBegin(x: number, y: number): void {
begin.value = true
drawContext.value.beginPath()
startX.value = x
startY.value = y
}
function drawRectFill(x: number, y: number, isReverse: boolean = true): void {
const width = x !== startX.value ? x - startX.value : startX.value - x
const height = y !== startY.value ? y - startY.value : startY.value - y
drawContext.value.rect(startX.value, startY.value, width, height)
drawContext.value.setFillStyle(currentColor.value)
drawContext.value.fill()
draw(isReverse)
}
function drawRect(x: number, y: number, isReverse: boolean = true): void {
const pointLT = {} as UTSJSONObject
const pointRB = {} as UTSJSONObject
const pointRT = {} as UTSJSONObject
const pointLB = {} as UTSJSONObject
pointLT.X = startX.value <= x ? startX.value : x
pointLT.Y = startY.value <= y ? startY.value : y
pointRB.X = startX.value >= x ? startX.value : x
pointRB.Y = startY.value >= y ? startY.value : y
pointRT.X = pointRB.X
pointRT.Y = pointLT.Y
pointLB.X = pointLT.X
pointLB.Y = pointRB.Y
const width = x !== startX.value ? x - startX.value : startX.value - x
const height = y !== startY.value ? y - startY.value : startY.value - y
drawContext.value.rect(startX.value, startY.value, width, height)
drawContext.value.setStrokeStyle(currentColor.value)
drawContext.value.stroke()
draw(isReverse)
lastRect.value = {
x: startX.value,
y: startY.value,
width: Math.abs(width),
height: Math.abs(height),
pointLT: pointLT
}
clearLastRect()
}
function clearLastRect(): void {
drawContext.value.clearRect(
lastRect.value.pointLT.X + lineWidth.value / 2,
lastRect.value.pointLT.Y + lineWidth.value / 2,
lastRect.value.width - lineWidth.value,
lastRect.value.height - lineWidth.value
)
}
function drawCircleFill(x: number, y: number, isReverse: boolean = true): void {
const pointLT = {} as UTSJSONObject
const pointRB = {} as UTSJSONObject
pointLT.X = startX.value <= x ? startX.value : x
pointLT.Y = startY.value <= y ? startY.value : y
pointRB.X = startX.value >= x ? startX.value : x
pointRB.Y = startY.value >= y ? startY.value : y
const centerX = (pointRB.X + pointLT.X) / 2
const centerY = (pointRB.Y + pointLT.Y) / 2
const dx = pointRB.X - pointLT.X
const dy = pointRB.Y - pointLT.Y
const r = Math.sqrt(dx * dx + dy * dy) / 2
drawContext.value.arc(centerX, centerY, r, 0, 2 * Math.PI)
drawContext.value.setFillStyle(currentColor.value)
drawContext.value.fill()
draw(isReverse)
}
function drawCircle(x: number, y: number, isReverse: boolean = true): void {
const pointLT = {} as UTSJSONObject
const pointRB = {} as UTSJSONObject
pointLT.X = startX.value <= x ? startX.value : x
pointLT.Y = startY.value <= y ? startY.value : y
pointRB.X = startX.value >= x ? startX.value : x
pointRB.Y = startY.value >= y ? startY.value : y
const centerX = (pointRB.X + pointLT.X) / 2
const centerY = (pointRB.Y + pointLT.Y) / 2
const dx = pointRB.X - pointLT.X
const dy = pointRB.Y - pointLT.Y
const r = Math.sqrt(dx * dx + dy * dy) / 2
drawContext.value.arc(centerX, centerY, r, 0, 2 * Math.PI)
drawContext.value.stroke()
drawContext.value.beginPath()
drawContext.value.arc(centerX, centerY, r - lineWidth.value / 2, 0, 2 * Math.PI)
drawContext.value.setFillStyle(bgColor.value)
drawContext.value.fill()
draw(isReverse)
}
function onTouchStart(e: any): void {
if (!props.drawStatus) return
drawContext.value.setLineWidth(lineWidth.value)
const { x, y } = e.touches[0]
switch (mode.value) {
case 'pen':
penBegin(x, y)
break
case 'eraser':
penBegin(x, y)
break
case 'rect':
rectBegin(x, y)
break
case 'circle':
circleBegin(x, y)
break
case 'rect-fill':
rectFillBegin(x, y)
break
case 'circle-fill':
circleFillBegin(x, y)
break
}
historyList.value.push({
style: {
color: currentColor.value,
width: lineWidth.value
},
coordinates: [{
type: e.type,
mode: mode.value,
x: e.touches[0].x,
y: e.touches[0].y
}]
})
}
function onTouchMove(e: any): void {
if (!props.drawStatus) return
drawContext.value.setLineWidth(lineWidth.value)
const { x, y } = e.touches[0]
const scaledX = x / scaleValue.value
const scaledY = y / scaleValue.value
lastX.value = scaledX
lastY.value = scaledY
switch (mode.value) {
case 'pen':
drawPen(scaledX, scaledY)
draw(true)
break
case 'eraser':
drawPen(scaledX, scaledY)
draw(true)
break
case 'rect':
drawRect(scaledX, scaledY)
break
case 'circle':
drawCircle(scaledX, scaledY)
break
case 'rect-fill':
drawRectFill(scaledX, scaledY)
break
case 'circle-fill':
drawCircleFill(scaledX, scaledY)
break
}
historyList.value[historyList.value.length - 1].coordinates.push({
type: e.type,
mode: mode.value,
x: scaledX,
y: scaledY
})
}
function onTouchEnd(e: any): void {
if (!props.drawStatus) return
drawContext.value.setLineWidth(lineWidth.value)
const { x, y } = e.changedTouches[0]
switch (mode.value) {
case 'pen':
lineEnd(x, y)
break
case 'eraser':
drawContext.value.setFillStyle(currentColor.value)
lineEnd(x, y)
break
case 'rect':
drawRect(x, y, true)
break
case 'circle':
drawCircle(x, y)
break
case 'rect-fill':
drawRectFill(x, y)
break
case 'circle-fill':
drawCircleFill(x, y)
break
}
}
function backHandle(): void {
drawContext.value.draw()
historyList.value.pop()
drawHistory()
}
function drawHistory(): void {
historyList.value.forEach((item) => {
drawContext.value.beginPath()
drawContext.value.setLineCap('round')
drawContext.value.setStrokeStyle(item.style.color)
drawContext.value.setLineWidth(item.style.width)
item.coordinates.forEach(it => {
if (it.type == 'touchstart') {
switchModeToLine(it.mode, 1, it.x, it.y)
} else {
switchModeToLine(it.mode, 2, it.x, it.y)
}
})
drawContext.value.stroke()
})
drawContext.value.draw(true)
}
function switchModeToLine(modeName: string, type: number, x: number, y: number): void {
drawContext.value.setFillStyle(currentColor.value)
if (modeName == 'pen') {
if (type == 1) {
drawContext.value.moveTo(x, y)
} else {
drawContext.value.lineTo(x, y)
}
} else if (modeName == 'eraser') {
drawContext.value.setFillStyle(bgColor.value)
if (type == 1) {
startX.value = x
startY.value = y
} else {
lineDraw(x, y)
}
} else if (modeName == 'rect') {
if (type == 1) {
startX.value = x
startY.value = y
} else {
drawRect(x, y, true)
}
} else if (modeName == 'circle') {
if (type == 1) {
startX.value = x
startY.value = y
} else {
drawCircle(x, y, true)
}
} else if (modeName == 'rect-fill') {
if (type == 1) {
startX.value = x
startY.value = y
} else {
drawRectFill(x, y, true)
}
} else if (modeName == 'circle-fill') {
if (type == 1) {
startX.value = x
startY.value = y
} else {
drawCircleFill(x, y, true)
}
}
}
function colorPickTapHandler(obj: { color: string }): void {
colorShow.value = false
currentColor.value = obj.color
drawContext.value.strokeStyle = obj.color
}
function downloadHandle(): void {
if (props.saveImageType == '1' || props.saveImageType == '3') {
saveImage()
}
if (props.saveImageType == '2' || props.saveImageType == '3') {
uni.canvasToTempFilePath({
canvasId: props.canvasId,
success: function(res: any) {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function(res: any) {
emit('dowmloadSuc', JSON.stringify(res))
},
fail: function(res: any) {
emit('dowmloadErr', JSON.stringify(res))
}
})
}
})
}
}
function saveImage(): void {
if (isUnderBkg.value) {
saveImageUrl()
} else {
uni.canvasToTempFilePath({
canvasId: props.canvasId,
success: function(res: any) {
emit('saveImage', res.tempFilePath)
}
})
}
}
function saveImageUrl(): void {
const query = uni.createSelectorQuery()
query.select('.canvas-box').boundingClientRect(data => {
drawContext.value.setFillStyle(bgColor.value)
drawContext.value.fillRect(0, 0, data.width, data.height)
drawContext.value.fill()
drawContext.value.drawImage(props.drawImage, 0, 0, data.width, data.height)
drawContext.value.draw()
drawHistory()
uni.canvasToTempFilePath({
canvasId: props.canvasId,
success: function(res: any) {
emit('saveImage', res.tempFilePath)
}
})
}).exec()
}
function fillBackground(): void {
const query = uni.createSelectorQuery()
query.select('.canvas-box').boundingClientRect(data => {
drawContext.value.setFillStyle(bgColor.value)
drawContext.value.fillRect(0, 0, data.width, data.height)
drawContext.value.fill()
if (props.drawImage && !isUnderBkg.value) {
drawContext.value.drawImage(props.drawImage, 0, 0, data.width, data.height)
}
drawContext.value.draw()
}).exec()
}
function draw(isReverse: boolean = false, cb?: Function): void {
drawContext.value.draw(isReverse, () => {
if (cb && typeof cb == 'function') {
cb()
}
})
}
function setBoardMode(key: string): void {
mode.value = key
}
function clearBoard(): void {
historyList.value = []
drawContext.value?.draw()
}
async function initBoard(): Promise<void> {
try {
const systemInfo = uni.getSystemInfoSync()
if (systemInfo.screenWidth > systemInfo.screenHeight) {
isLandScape.value = true
} else { } else {
isLandScape.value = false return false
} }
})
if (props.drawImage) {
const imageInfo = await uni.getImageInfo({
src: props.drawImage
})
if (imageInfo) {
const imageInfoObj = imageInfo[1] || {} as any
aspectRatio.value = imageInfoObj.width / imageInfoObj.height
height.value = `${imageInfoObj.height * (systemInfo.windowWidth / imageInfoObj.width)}px`
}
}
if (isUnderBkg.value) {
bgColor.value = 'rgba(0,0,0,0)'
} else {
bgColor.value = 'rgba(255,255,255,0)'
}
drawContext.value.setLineCap('round')
drawContext.value.strokeStyle = currentColor.value
drawContext.value.setLineWidth(lineWidth.value)
nextTick(() => {
drawContext.value.setLineWidth(lineWidth.value)
})
} catch (error) {
console.error(error)
}
}
function onScale(e: number): void { function onScale(e: number): void {
scaleValue.value = e scaleValue.value = e
emit('scale', e) emit('scale', e)
} }
onMounted(() => {
// initBoard()
// uni.createCanvasContextAsync({
// id: props.canvasId as string,
// component: getCurrentInstance()?.proxy,
// success: (context : CanvasContext) => {
// canvasContext = context
// renderingContext = context.getContext('2d')!
// }
// })
})
watch(watchStatus, (newval: boolean) => {
if (newval != null) {
// clearBoard()
}
}, { immediate: true })
defineExpose({ colorPickTapHandler, downloadHandle, saveImage, fillBackground, draw, setBoardMode, clearBoard, initBoard }) watch(props.drawImage, (n: string) => {
if (n != null) {
// initBoard()
}
})
</script> </script>
<style lang="scss"> <style lang="scss">
......
<template> <template>
<view <view
class="zoom-pan-container" class="zoom-pan-container"
:style="{ 'overflow': 'hidden', 'position': 'relative', 'touch-action': 'none' }" :style="{ 'overflow': 'hidden', 'position': 'relative', 'touch-action': 'none' }"
@touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd"
> >
<!-- @touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd" -->
<view <view
class="content" class="content"
:style="contentStyle" :style="contentStyle"
> >
<slot name="content"> <slot name="content">
</slot> </slot>
...@@ -17,145 +18,171 @@ ...@@ -17,145 +18,171 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { throttle } from '@/utils/common.uts' import { throttle } from '@/utils/common.uts'
import { state } from "@/store/index.uts" import { state } from "@/store/index.uts"
const props = defineProps({
disabled: Boolean,
scaleMax: {
type: Number,
default: 10
},
scaleMin: {
type: Number,
default: 1
}
})
const scale = ref<number>(1)
const isScaling = ref<boolean>(false)
const initialDistance = ref<number>(0)
const initialScale = ref<number>(1)
const translateX = ref<number>(0)
const translateY = ref<number>(0)
const lastTouchCenter = ref<{ x: number; y: number }>({ x: 0, y: 0 })
const currentTouchCenter = ref<{ x: number; y: number }>({ x: 0, y: 0 })
const contentStyle = computed(() => {
return {
'transform': `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`,
'transform-origin': 'center center',
'transition': isScaling.value ? 'none' : 'transform 0.3s ease-out',
'will-change': 'transform',
'position': 'absolute',
'left': '0',
'top': '0',
'width': '100%',
'height': '100%'
}
})
const watchStatus = computed(() => { type Point = {
return state.user.historyStatus x: number
}) y: number
}
watch(() => watchStatus.value, (newval) => { type TouchPoint = {
if (scale.value != 1) { pageX: number
scale.value = 1 pageY: number
translateX.value = 0 clientX: number
translateY.value = 0 clientY: number
} x: number
}, { immediate: true }) y: number
}
function handleTouchStart(e: any): void { type TouchEvent = {
if (props.disabled) return touches: Array<TouchPoint>
changedTouches: Array<TouchPoint>
if (e.touches.length === 2) {
isScaling.value = true
initialDistance.value = getTouchDistance(e.touches)
initialScale.value = scale.value
const center = getTouchCenter(e.touches)
lastTouchCenter.value = center
currentTouchCenter.value = center
}
} }
const handleTouchMove = throttle(function(e: any): void { const props = defineProps({
if (props.disabled) return disabled: Boolean,
scaleMax: {
if (isScaling.value && e.touches.length === 2) { type: Number,
const currentDistance = getTouchDistance(e.touches) default: 10
const newScale = Math.max( },
props.scaleMin, scaleMin: {
Math.min( type: Number,
props.scaleMax, default: 1
initialScale.value * (currentDistance / initialDistance.value) }
) })
)
const scale = ref<number>(1)
scale.value = newScale const isScaling = ref<boolean>(false)
const initialDistance = ref<number>(0)
const center = getTouchCenter(e.touches) const initialScale = ref<number>(1)
currentTouchCenter.value = center const translateX = ref<number>(0)
const translateY = ref<number>(0)
if (scale.value > 1) { const lastTouchCenter = ref<Point>({ x: 0, y: 0 })
const deltaX = center.x - lastTouchCenter.value.x const currentTouchCenter = ref<Point>({ x: 0, y: 0 })
const deltaY = center.y - lastTouchCenter.value.y
translateX.value += deltaX const contentStyle = computed(() => {
translateY.value += deltaY return {
'transform': `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`,
'transform-origin': 'center center',
'transition': isScaling.value ? 'none' : 'transform 0.3s ease-out',
'will-change': 'transform',
'position': 'absolute',
'left': '0',
'top': '0',
'width': '100%',
'height': '100%'
}
})
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 , () => {
if (scale.value != 1) {
scale.value = 1
translateX.value = 0
translateY.value = 0
}
}, { immediate: true })
// function handleTouchStart(e: TouchEvent): void {
// if (props.disabled == true) return
// if (e.touches.length === 2) {
// isScaling.value = true
// initialDistance.value = getTouchDistance(e.touches)
// initialScale.value = scale.value
// const center = getTouchCenter(e.touches)
// lastTouchCenter.value = center
// currentTouchCenter.value = center
// }
// }
// const handleTouchMove = throttle(function(e: TouchEvent): void {
// if (props.disabled == true) return
// if (isScaling.value && e.touches.length === 2) {
// const currentDistance = getTouchDistance(e.touches)
// const newScale = Math.max(
// props.scaleMin,
// Math.min(
// props.scaleMax,
// initialScale.value * (currentDistance / initialDistance.value)
// )
// )
// scale.value = newScale
// const center = getTouchCenter(e.touches)
// currentTouchCenter.value = center
// if (scale.value > 1) {
// const deltaX = center.x - lastTouchCenter.value.x
// const deltaY = center.y - lastTouchCenter.value.y
// translateX.value += deltaX
// translateY.value += deltaY
// }
// lastTouchCenter.value = center
// emit('scale', scale.value)
// }
// }, 16)
// function handleTouchEnd(): void {
// if (isScaling.value) {
// isScaling.value = false
// adjustPosition()
// }
// }
function adjustPosition(): void {
if (scale.value <= 1) {
translateX.value = 0
translateY.value = 0
scale.value = 1
} }
lastTouchCenter.value = center
emit('scale', scale.value)
} }
}, 16)
function handleTouchEnd(): void { function getTouchDistance(touches: Array<TouchPoint>): number {
if (isScaling.value) { const dx = touches[0].pageX - touches[1].pageX
isScaling.value = false const dy = touches[0].pageY - touches[1].pageY
adjustPosition() return Math.sqrt(dx * dx + dy * dy)
} }
}
function adjustPosition(): void { function getTouchCenter(touches: Array<TouchPoint>): Point {
if (scale.value <= 1) { const centerX = (touches[0].pageX + touches[1].pageX) / 2
translateX.value = 0 const centerY = (touches[0].pageY + touches[1].pageY) / 2
translateY.value = 0 return { x: centerX, y: centerY }
scale.value = 1
} }
}
function getTouchDistance(touches: Array<any>): number { const emit = defineEmits(['scale'])
const dx = touches[0].pageX - touches[1].pageX
const dy = touches[0].pageY - touches[1].pageY
return Math.sqrt(dx * dx + dy * dy)
}
function getTouchCenter(touches: Array<any>): { x: number; y: number } {
const centerX = (touches[0].pageX + touches[1].pageX) / 2
const centerY = (touches[0].pageY + touches[1].pageY) / 2
return { x: centerX, y: centerY }
}
const emit = defineEmits(['scale'])
</script> </script>
<style lang="scss"> <style lang="scss">
.zoom-pan-container { .zoom-pan-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
touch-action: none; touch-action: none;
} }
.content { .content {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
transform-origin: center center; transform-origin: center center;
will-change: transform; will-change: transform;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<view class="tool-box" :style="toolStyle"> <view class="tool-box" :style="toolStyle as string">
<view :class="['btn', { hideIcon: !show }]" @click="show = false"> <view :class="['btn', { hideIcon: !show }]" @click="show = false">
<view class="icon sprite-icon icon-tool-file"> <view class="icon sprite-icon icon-tool-file">
</view> </view>
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
文件夹 文件夹
</view> </view>
<view class="list-body"> <view class="list-body">
<template v-for="(i, index) in data" :key="index"> <template v-for="(item, index) in displayData" :key="index">
<view :class="['item', { active: i[idKey] == id }]" @click="jump(i)"> <view :class="['item', { active: item.id == props.id }]" @click="jump(item)">
<image class="icon" :src="i.shortTitleUrl" mode="scaleToFill" /> <image class="icon" :src="item.shortTitleUrl" mode="scaleToFill" />
{{ i.shortTitle }} {{ item.shortTitle }}
</view> </view>
</template> </template>
</view> </view>
<template v-if="showPayBtn"> <template v-if="props.showPayBtn">
<view class="item" @click="toPay"> <view class="item" @click="toPay">
<view class="icon"> <view class="icon">
<view class="sprite-icon icon-tool-pay"> <view class="sprite-icon icon-tool-pay">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
付款方式 付款方式
</view> </view>
</template> </template>
<template v-if="type != 'preview'"> <template v-if="props.type != 'preview'">
<view class="item" @click="finish"> <view class="item" @click="finish">
<view class="icon"> <view class="icon">
<view class="sprite-icon icon-tool-finish"> <view class="sprite-icon icon-tool-finish">
...@@ -42,11 +42,18 @@ ...@@ -42,11 +42,18 @@
<script setup lang="uts"> <script setup lang="uts">
import { state } from "@/store/index.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({ const props = defineProps({
type: String, type: String,
data: Array, data: Array as () => Array<ToolItem>,
id: [String, id: [String, Number],
Number],
showPayBtn: Boolean, showPayBtn: Boolean,
idKey: { idKey: {
type: String, type: String,
...@@ -57,11 +64,25 @@ ...@@ -57,11 +64,25 @@
const show = ref<boolean>(true) const show = ref<boolean>(true)
const displayData = computed<Array<ToolItem>>(() => {
if (props.data == null) {
return []
}
return props.data as Array<ToolItem>
})
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
}) })
watch(() => watchStatus.value, (newval) => { watch(watchStatus.value, () => {
show.value = true show.value = true
}, { immediate: true }) }, { immediate: true })
...@@ -69,7 +90,21 @@ ...@@ -69,7 +90,21 @@
show.value = true show.value = true
} }
function jump(item: any): void { 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 show.value = true
emit('choose', item) emit('choose', item)
} }
...@@ -82,13 +117,9 @@ ...@@ -82,13 +117,9 @@
emit('toPay') emit('toPay')
} }
const emit = defineEmits(['choose',
'finish', defineExpose({ hide })
'toPay'])
defineExpose({
hide
})
</script> </script>
<style lang="scss"> <style lang="scss">
......
...@@ -227,31 +227,27 @@ ...@@ -227,31 +227,27 @@
<script setup lang="uts"> <script setup lang="uts">
import { ref, computed, watch } from 'vue' import { ref, computed, watch } from 'vue'
interface ReceptionpriproCusCaseStageDetail { type ReceptionpriproCusCaseStageDetail = {
stageName: string stageName: string
imageUrl: string imageUrl: string
imageTag: string imageTag: string
[key: string]: any
} }
interface ReceptionpriproCusCaseStage { type ReceptionpriproCusCaseStage = {
receptionpriproCusCaseStageDetailList: Array<ReceptionpriproCusCaseStageDetail> receptionpriproCusCaseStageDetailList: Array<ReceptionpriproCusCaseStageDetail>
[key: string]: any
} }
interface ReceptionpriproCusCase { type ReceptionpriproCusCase = {
customerName: string customerName: string
licPlateNumber: string licPlateNumber: string
comAmount: string | number comAmount: string | number
receptionpriproCusCaseStageList: Array<ReceptionpriproCusCaseStage> receptionpriproCusCaseStageList: Array<ReceptionpriproCusCaseStage>
[key: string]: any
} }
interface DetailData { type DetailData = {
title: string title: string
productPoster: string productPoster: string
receptionpriproCusCaseList: Array<ReceptionpriproCusCase> receptionpriproCusCaseList: Array<ReceptionpriproCusCase>
[key: string]: any
} }
interface Thumbnail { interface Thumbnail {
......
<template> <template>
<view class="layout"> <view class="layout">
<view class="layout-content"> <view class="layout-content">
<view class="title flex">{{ title }}</view> <view class="title flex">
{{ title }}
</view>
<view class="form-box" :key="watchStatus"> <view class="form-box" :key="watchStatus">
<view class="form"> <view class="form">
<template v-for="(i, index) in formObject" :key="index"> <template v-for="(i, index) in formObject" :key="index">
...@@ -9,683 +11,725 @@ ...@@ -9,683 +11,725 @@
<view class="form-item-box" v-if="i.key == 'goodsCtegory'"> <view class="form-item-box" v-if="i.key == 'goodsCtegory'">
<view :class="['select flex', { placeholderStyle: !customerInfo[i.key] }]" @click="showPopup(i.popKey, index)"> <view :class="['select flex', { placeholderStyle: !customerInfo[i.key] }]" @click="showPopup(i.popKey, index)">
<view class="value text-hide" v-if="chooseContent.length > 0"> <view class="value text-hide" v-if="chooseContent.length > 0">
<text class="category-name" v-for="(item, index) in chooseContent.slice(0, 2)" :key="index">{{ item.categoryName }}</text> <text class="category-name" v-for="(item, index) in chooseContent.slice(0, 2)" :key="index">
<text class="category-name" v-if="chooseContent.length > 2">+ {{ chooseContent.length - 2 }}</text> {{ item.categoryName }}
</text>
<text class="category-name" v-if="chooseContent.length >
2">+ {{ chooseContent.length - 2 }}
</text>
</view>
<view class="value text-hide" v-else>
请选择
</view>
<uni-icons class="arrow" type="right" :size="16">
</uni-icons>
</view> </view>
<view class="value text-hide" v-else>请选择</view>
<uni-icons class="arrow" type="right" :size="16"></uni-icons>
</view> </view>
</view> <view class="form-item-box" v-else>
<view class="form-item-box" v-else> <view :class="['select flex', { placeholderStyle: !customerInfo[i.key] }]" @click="showPopup(i.popKey, index)">
<view :class="['select flex', { placeholderStyle: !customerInfo[i.key] }]" @click="showPopup(i.popKey, index)"> <view class="value text-hide">
<view class="value text-hide">{{ customerInfo[i.key] || i.placeholder }}</view> {{ customerInfo[i.key] ? customerInfo[i.key] : i.placeholder }}
<uni-icons class="arrow" type="right" :size="16"></uni-icons> </view>
<uni-icons class="arrow" type="right" :size="16">
</uni-icons>
</view>
</view> </view>
</view> </view>
</view> </template>
</template>
<view class="form-check flex" @click="showphoto = !showphoto"> <view class="form-check flex" @click="showphoto = !showphoto">
<view :class="['check-box flex', { checked: showphoto }]"> <view :class="['check-box flex', { checked: showphoto }]">
<uni-icons type="checkmarkempty" :size="14" color="#fff"></uni-icons> <uni-icons type="checkmarkempty" :size="14" color="#fff">
</uni-icons>
</view>
显示凭证
</view> </view>
显示凭证 <view class="form-check flex" @click="merchantOrder = !merchantOrder" v-if="!subLoginUserChannelType">
</view> <view :class="['check-box flex', { checked: merchantOrder }]">
<view class="form-check flex" @click="merchantOrder = !merchantOrder" v-if="!subLoginUserChannelType"> <uni-icons type="checkmarkempty" :size="14" color="#fff">
<view :class="['check-box flex', { checked: merchantOrder }]"> </uni-icons>
<uni-icons type="checkmarkempty" :size="14" color="#fff"></uni-icons> </view>
门店订单
</view> </view>
门店订单
</view> </view>
</view> </view>
</view> <template v-if="list.length > 0">
<template v-if="list.length > 0"> <scroll-view :class="['record-box']" scroll-y :scroll-top="scrollTop" @scrolltolower="pageonReachBottom">
<scroll-view :class="['record-box']" scroll-y :scroll-top="scrollTop" @scrolltolower="pageonReachBottom"> <view class="card-list">
<view class="card-list"> <view class="card-item" v-for="item in list" :key="item.id">
<view class="card-item" v-for="item in list" :key="item.id"> <template v-if="showphoto">
<template v-if="showphoto"> <image v-if="item.paymentDocUrl" class="image-box" :src="item.paymentDocUrl" />
<image v-if="item.paymentDocUrl" class="image-box" :src="item.paymentDocUrl" /> <image v-else class="image-box photo" src="https://img02.glsx.com.cn/weapp/resource/app-tape/media/common/pay.webp" />
<image v-else class="image-box photo" src="https://img02.glsx.com.cn/weapp/resource/app-tape/media/common/pay.webp" /> <view class="gradient-overlay">
<view class="gradient-overlay"></view> </view>
</template> </template>
<template v-else> <template v-else>
<div :class="['payType sprite-icon', `icon-payType-${item.payType}`]"></div> <div :class="['payType sprite-icon', `icon-payType-${item.payType}`]">
</template> </div>
<view> </template>
<view class="name">{{ nameHide(item.customerName) }}</view> <view>
<view class="goods-name">{{ item.goodsName }}</view> <view class="name">
<view class="card-info"> {{ nameHide(item.customerName) }}
<view class="label">车架号</view> </view>
<view class="value">{{ item.carVin || '-' }}</view> <view class="goods-name">
</view> {{ item.goodsName }}
<view class="card-info"> </view>
<view class="label">工单号</view> <view class="card-info">
<view class="value">{{ item.payId }}</view> <view class="label">
</view> 车架号
<view class="card-info"> </view>
<view class="label">交易流水号</view> <view class="value">
<view class="value">{{ item.transactionNo }}</view> {{ item.carVin || '-' }}
</view> </view>
<view class="card-info"> </view>
<view class="label">实收金额</view> <view class="card-info">
<view class="price"> <view class="label">
<view class="flag">¥</view> 工单号
{{ item.equityPrice }} </view>
<view class="value">
{{ item.payId }}
</view>
</view>
<view class="card-info">
<view class="label">
交易流水号
</view>
<view class="value">
{{ item.transactionNo }}
</view>
</view>
<view class="card-info">
<view class="label">
实收金额
</view>
<view class="price">
<view class="flag">
¥
</view>
{{ item.equityPrice }}
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> <view class="end-text" v-if="list.length >
<view class="end-text" v-if="list.length > 0 && isEnd">我是一个有底线的人</view> 0 && isEnd">我是一个有底线的人
</scroll-view> </view>
</template> </scroll-view>
<template v-else> </template>
<view class="no-data"> <template v-else>
<glsx-image class="no-data-img" src="media/no-data.png" mode="scaleToFill" /> <view class="no-data">
<view class="no-data-text">暂无数据</view> <glsx-image class="no-data-img" src="media/no-data.png" mode="scaleToFill" />
<view class="no-data-text">
暂无数据
</view>
</view>
</template>
</view> </view>
</template> <CarBrands ref="carBrandListVisible" @select="handleSelect($event, 'carBrandListVisible')" @close="resetFocusIndex" />
</view> <!-- <OrderPopup ref="goodsCtegoryVisible" :data="chooseContent" @onConfirm="onConfirm" :externalData="[]" :popupType="15" /> -->
<CarBrands ref="carBrandListVisible" @select="handleSelect($event, 'carBrandListVisible')" @close="resetFocusIndex" /> </view>
<!-- <OrderPopup ref="goodsCtegoryVisible" :data="chooseContent" @onConfirm="onConfirm" :externalData="[]" :popupType="15" /> -->
</view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import CarBrands from '@/components/CarBrands.uvue' import CarBrands from '@/components/CarBrands.uvue'
// import OrderPopup from '@/components/OrderPopup/index.uvue' // import OrderPopup from '@/components/OrderPopup/index.uvue'
import { state, dispatch } from "@/store/index.uts" import { state, dispatch } from "@/store/index.uts"
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { getOrderListPage } from '@/api/boutique-api.uts' import { getOrderListPage } from '@/api/boutique-api.uts'
interface FormItem { type FormItem = {
placeholder: string placeholder: string
key: string key: string
type: string type: string
popKey: string popKey: string
} }
interface CustomerInfo { type CustomerInfo = {
carModel?: string carModel?: string
carModelId?: string carModelId?: string
[key: string]: any }
}
type SubLoginUser = {
interface UserInfo { channelType: number
shopMerchantId: string
sceneType: number
subLoginUser: {
channelType: number
} }
channelType: number
[key: string]: any type UserInfo = {
} shopMerchantId: string
sceneType: number
interface QuotationListItem { subLoginUser: SubLoginUser
id: string channelType: number
customerName: string
goodsName: string
carVin?: string
payId: string
transactionNo?: string
equityPrice: number
paymentDocUrl?: string
payType: number
createdTime: string
[key: string]: any
}
const props = defineProps({
title: String,
madiaId: Number,
show: Boolean,
})
const carBrandListVisible = ref<any>(null)
const goodsCtegoryVisible = ref<any>(null)
const scrollTop = ref<number>(0)
const formObject = ref<Array<FormItem>>([
{
placeholder: '品牌车型',
key: 'carModel',
type: 'select',
popKey: 'carBrandListVisible'
},
{
placeholder: '商品类目',
key: 'goodsCtegory',
type: 'select',
popKey: 'goodsCtegoryVisible'
} }
])
const customerInfo = ref<CustomerInfo>({}) type QuotationListItem = {
const focusIndex = ref<number>(-1) id: string
const showphoto = ref<boolean>(false) customerName: string
const merchantOrder = ref<boolean>(false) goodsName: string
const historyOrderGoodsTypes = ref<Array<any>>([]) carVin?: string
const chooseContent = ref<Array<any>>([]) payId: string
const list = ref<Array<QuotationListItem>>([]) transactionNo?: string
const formatList = ref<Array<any>>([]) equityPrice: number
const pageNum = ref<number>(1) paymentDocUrl?: string
const pageSize = ref<number>(10) payType: number
const total = ref<number>(0) createdTime: string
const isEnd = ref<boolean>(false)
const flag = ref<boolean>(true)
const watchStatus = computed(() => {
return state.user.historyStatus
})
const watchCustomerInfo = computed<CustomerInfo>(() => {
return state.user.customerInfo || {}
})
const shopMerchantId = computed<string>(() => {
const userInfo: UserInfo = storage.get('userInfo') || {}
return userInfo.shopMerchantId || ''
})
const subLoginUserChannelType = computed<boolean>(() => {
const userInfo: UserInfo = storage.get('userInfo') || {}
return userInfo.subLoginUser?.channelType == 9
})
const channelType = computed<number>(() => {
const userInfo: UserInfo = storage.get('userInfo') || {}
return userInfo.channelType || 0
})
watch(() => props.show, (n) => {
if (n) {
init()
} else {
scrollTop.value = 0
} }
})
const props = defineProps({
watch(() => watchStatus.value, (newval) => { title: String,
pageNum.value = 1 madiaId: Number,
scrollTop.value = 1000 show: Boolean,
list.value = [] })
customerInfo.value = {}
if (channelType.value == 1) merchantOrder.value = true const carBrandListVisible = ref(null)
setTimeout(() => { const goodsCtegoryVisible = ref(null)
scrollTop.value = 0
}, 100) const scrollTop = ref<number>(0)
}, { immediate: true }) const formObject = ref<Array<FormItem>>([{
placeholder: '品牌车型',
watch(() => merchantOrder.value, (newval) => { key: 'carModel',
pageNum.value = 1 type: 'select',
scrollTop.value = 1000 popKey: 'carBrandListVisible'
list.value = [] }, {
setTimeout(() => { placeholder: '商品类目',
scrollTop.value = 0 key: 'goodsCtegory',
getQuotationList() type: 'select',
}, 100) popKey: 'goodsCtegoryVisible'
}, { immediate: true }) }] as Array<FormItem>)
const customerInfo = ref<CustomerInfo>({} as CustomerInfo)
watch(() => watchCustomerInfo.value, (newval) => { const focusIndex = ref<number>(-1)
if (newval) { const showphoto = ref<boolean>(false)
customerInfo.value = { ...newval } const merchantOrder = ref<boolean>(false)
const historyOrderGoodsTypes = ref<Array<any>>([] as Array<any>)
const chooseContent = ref<Array<any>>([] as Array<any>)
const list = ref<Array<QuotationListItem>>([] as Array<QuotationListItem>)
const formatList = ref<Array<any>>([] as Array<any>)
const pageNum = ref<number>(1)
const pageSize = ref<number>(10)
const total = ref<number>(0)
const isEnd = ref<boolean>(false)
const flag = ref<boolean>(true)
const watchStatus = computed(() => {
const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
const watchCustomerInfo = computed<CustomerInfo>(() => {
return state.user.customerInfo != null ? state.user.customerInfo : {} as CustomerInfo
})
const shopMerchantId = computed<string>(() => {
const userInfo: UserInfo = storage.get('userInfo') != null ? storage.get('userInfo') : {} as UserInfo
return userInfo.shopMerchantId != null && userInfo.shopMerchantId !== '' ? userInfo.shopMerchantId : ''
})
const subLoginUserChannelType = computed<boolean>(() => {
const userInfo: UserInfo = storage.get('userInfo') != null ? storage.get('userInfo') : {} as UserInfo
return userInfo.subLoginUser?.channelType == 9
})
const channelType = computed<number>(() => {
const userInfo: UserInfo = storage.get('userInfo') != null ? storage.get('userInfo') : {} as UserInfo
return userInfo.channelType != null ? userInfo.channelType : 0
})
watch(() => props.show, (n) => {
if (n === true) {
init()
} else {
scrollTop.value = 0
}
})
watch(watchStatus.value, (newval) => {
pageNum.value = 1
scrollTop.value = 1000
list.value = []
customerInfo.value = {} as CustomerInfo
if (channelType.value == 1) merchantOrder.value = true
setTimeout(() => {
scrollTop.value = 0
}, 100)
}, { immediate: true })
watch(() => merchantOrder.value, (newval) => {
pageNum.value = 1
scrollTop.value = 1000
list.value = []
setTimeout(() => {
scrollTop.value = 0
getQuotationList()
}, 100)
}, { immediate: true })
watch(() => watchCustomerInfo.value, (newval) => {
if (newval != null) {
customerInfo.value = { ...newval }
}
}, { immediate: true })
function init(): void {
customerInfo.value = watchCustomerInfo.value
if (subLoginUserChannelType.value === true) {
merchantOrder.value = true
}
search()
} }
}, { immediate: true })
function init(): void { function search(): void {
customerInfo.value = watchCustomerInfo.value if (pageNum.value == 1) {
if (subLoginUserChannelType.value) { getQuotationList()
merchantOrder.value = true }
} }
search()
}
function search(): void { async function getQuotationList(): Promise<void> {
if (pageNum.value == 1) { try {
getQuotationList() uni.showLoading({
title: '',
mask: true
})
const carBrandList: Array<any> = storage.get('carBrandList') != null ? storage.get('carBrandList') : []
const carChildsBrandIds: Array<string> = carBrandList.map((i: any) => i.id)
const userInfo: UserInfo = storage.get('userInfo') != null ? storage.get('userInfo') : {} as UserInfo
let params: any = {
merchantId: shopMerchantId.value,
pageNum: pageNum.value,
pageSize: pageSize.value,
carModel: customerInfo.value.carModel != null ? customerInfo.value.carModel : '',
orderStatus: 3,
merchantOrder: merchantOrder.value,
sceneType: userInfo.sceneType,
historyOrderGoodsTypes: historyOrderGoodsTypes.value
}
if (params.merchantOrder === false) {
// delete params.merchantId
params.merchantId = null
params.maxCreateTime = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss')
params.minCreateTime = dayjs(Date.now() - 90 * 24 * 60 * 60 * 1000).format('YYYY-MM-DD HH:mm:ss')
params.carChildsBrandIds = carChildsBrandIds
}
const result = await getOrderListPage(params)
uni.hideLoading()
list.value = [...(pageNum.value == 1 ? [] : list.value), ...result.list]
let previousCreatedTime: string | null = null
let _list: Array<any> = []
list.value.forEach((e: QuotationListItem) => {
let createdTime = dayjs(e.createdTime).format('YYYY 年 MM 月 DD 日')
if (createdTime !== previousCreatedTime) {
_list.push({
title: createdTime,
list: []
})
previousCreatedTime = createdTime
}
})
_list.forEach((e: any) => {
list.value.forEach((i: QuotationListItem) => {
let createdTime = dayjs(i.createdTime).format('YYYY 年 MM 月 DD 日')
if (e.title === createdTime) e.list.push(i)
})
})
formatList.value = result.list
flag.value = true
total.value = result.total
if (customerInfo.value.carModel == null && pageNum.value == 1 && list.value.length > 0) {
uni.setStorageSync(`${shopMerchantId.value}-historyList`, list.value)
}
} catch (error) {
uni.hideLoading()
flag.value = true
isEnd.value = true
if (customerInfo.value.carModel == null && pageNum.value == 1) {
const cachedList = uni.getStorageSync(`${shopMerchantId.value}-historyList`)
list.value = cachedList != null ? cachedList : []
}
}
} }
}
function pageonReachBottom(): void {
async function getQuotationList(): Promise<void> { isEnd.value = false
try { if (Math.ceil(total.value / pageSize.value) > pageNum.value) {
uni.showLoading({ pageNum.value += 1
mask: true getQuotationList()
}) } else {
isEnd.value = true
const carBrandList: Array<any> = storage.get('carBrandList') || [] }
const carChildsBrandIds: Array<string> = carBrandList.map((i: any) => i.id)
const userInfo: UserInfo = storage.get('userInfo') || {}
let params: any = {
merchantId: shopMerchantId.value,
pageNum: pageNum.value,
pageSize: pageSize.value,
carModel: customerInfo.value.carModel || '',
orderStatus: 3,
merchantOrder: merchantOrder.value,
sceneType: userInfo.sceneType,
historyOrderGoodsTypes: historyOrderGoodsTypes.value
}
if (!params.merchantOrder) {
delete params.merchantId
params.maxCreateTime = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss')
params.minCreateTime = dayjs(Date.now() - 90 * 24 * 60 * 60 * 1000).format('YYYY-MM-DD HH:mm:ss')
params.carChildsBrandIds = carChildsBrandIds
}
const result = await getOrderListPage(params)
uni.hideLoading()
list.value = [...(pageNum.value == 1 ? [] : list.value), ...result.list]
let previousCreatedTime: string | null = null
let _list: Array<any> = []
list.value.forEach((e: QuotationListItem) => {
let createdTime = dayjs(e.createdTime).format('YYYY 年 MM 月 DD 日')
if (createdTime !== previousCreatedTime) {
_list.push({
title: createdTime,
list: []
})
previousCreatedTime = createdTime
}
})
_list.forEach((e: any) => {
list.value.forEach((i: QuotationListItem) => {
let createdTime = dayjs(i.createdTime).format('YYYY 年 MM 月 DD 日')
if (e.title === createdTime) e.list.push(i)
})
})
formatList.value = result.list
flag.value = true
total.value = result.total
if (!customerInfo.value.carModel && pageNum.value == 1 && list.value.length) {
uni.setStorageSync(`${shopMerchantId.value}-historyList`, list.value)
}
} catch (error) {
uni.hideLoading()
flag.value = true
isEnd.value = true
if (!customerInfo.value.carModel && pageNum.value == 1) {
list.value = uni.getStorageSync(`${shopMerchantId.value}-historyList`) || []
}
} }
}
function nameHide(name: string): string {
function pageonReachBottom(): void { if (name == null || name === '') return ''
isEnd.value = false return name.substring(0, 1) + '*'
if (Math.ceil(total.value / pageSize.value) > pageNum.value) {
pageNum.value += 1
getQuotationList()
} else {
isEnd.value = true
} }
}
function nameHide(name: string): string { function handleSelect(item: any, popkey: string): void {
if (!name) return '' if (popkey === 'carBrandListVisible') {
return name.substring(0, 1) + '*' carBrandListVisible.value?.close()
} }
customerInfo.value.carModel = item.name
customerInfo.value.carModelId = item.id
resetFocusIndex()
dispatch('setCustomerInfo', customerInfo.value)
list.value = []
pageNum.value = 1
getQuotationList()
}
function handleSelect(item: any, popkey: string): void { function showPopup(e: string, index: number): void {
if (popkey === 'carBrandListVisible') { focusIndex.value = index
carBrandListVisible.value?.close() if (e === 'carBrandListVisible') {
carBrandListVisible.value?.open()
} else if (e === 'goodsCtegoryVisible') {
goodsCtegoryVisible.value?.open()
}
} }
customerInfo.value.carModel = item.name
customerInfo.value.carModelId = item.id function closeAllPopup(): void {
resetFocusIndex() carBrandListVisible.value?.close()
dispatch('setCustomerInfo', customerInfo.value) resetFocusIndex()
list.value = []
pageNum.value = 1
getQuotationList()
}
function showPopup(e: string, index: number): void {
focusIndex.value = index
if (e === 'carBrandListVisible') {
carBrandListVisible.value?.open()
} else if (e === 'goodsCtegoryVisible') {
goodsCtegoryVisible.value?.open()
} }
}
function resetFocusIndex(): void {
function closeAllPopup(): void { focusIndex.value = -1
carBrandListVisible.value?.close()
resetFocusIndex()
}
function resetFocusIndex(): void {
focusIndex.value = -1
}
function onConfirm(chooseList: any): void {
chooseContent.value = chooseList.chooseContent || []
historyOrderGoodsTypes.value = []
if (chooseList && chooseList.chooseContent && chooseList.chooseContent.length > 0) {
const level3Map = new Map<string, Array<any>>()
chooseList.chooseContent.forEach((item: any) => {
if (item.level === 2) {
historyOrderGoodsTypes.value.push({
secondaryGoodsType: item.categoryType,
thirdLevelGoodsTypes: null
})
} else if (item.level === 3) {
const parentCategoryType = item.parentCategoryType
if (level3Map.has(parentCategoryType)) {
level3Map.get(parentCategoryType)?.push(item.categoryType)
} else {
level3Map.set(parentCategoryType, [item.categoryType])
}
}
})
level3Map.forEach((categoryTypes, parentCategoryType) => {
historyOrderGoodsTypes.value.push({
secondaryGoodsType: parentCategoryType,
thirdLevelGoodsTypes: categoryTypes
})
})
} }
list.value = [] function onConfirm(chooseList: any): void {
pageNum.value = 1 chooseContent.value = chooseList.chooseContent != null ? chooseList.chooseContent : []
// uni.$track?.add({ eventCode: 'app_goodsGategory_change', eventType: 0 }) historyOrderGoodsTypes.value = []
getQuotationList()
} if (chooseList != null && chooseList.chooseContent != null && chooseList.chooseContent.length > 0) {
const level3Map = new Map<string, Array<any>>()
chooseList.chooseContent.forEach((item: any) => {
if (item.level === 2) {
historyOrderGoodsTypes.value.push({
secondaryGoodsType: item.categoryType,
thirdLevelGoodsTypes: null
})
} else if (item.level === 3) {
const parentCategoryType = item.parentCategoryType
if (level3Map.has(parentCategoryType)) {
level3Map.get(parentCategoryType)?.push(item.categoryType)
} else {
level3Map.set(parentCategoryType, [item.categoryType])
}
}
})
level3Map.forEach((categoryTypes, parentCategoryType) => {
historyOrderGoodsTypes.value.push({
secondaryGoodsType: parentCategoryType,
thirdLevelGoodsTypes: categoryTypes
})
})
}
list.value = []
pageNum.value = 1
// uni.$track?.add({ eventCode: 'app_goodsGategory_change', eventType: 0 })
getQuotationList()
}
defineExpose({ defineExpose({ closeAllPopup })
closeAllPopup
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.layout { .layout {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
background-size: 100%; background-size: 100%;
&-content { &-content {
height: 100%; height: 100%;
position: relative; position: relative;
// margin: 40rpx; // margin: 40rpx;
.form-box { .form-box {
height: 80rpx; height: 80rpx;
padding: 0 110rpx; padding: 0 110rpx;
z-index: 2; z-index: 2;
position: absolute; position: absolute;
left: 64rpx; left: 64rpx;
top: 168rpx; top: 168rpx;
padding: 0; padding: 0;
.form { .form {
display: flex; display: flex;
gap: 0 28rpx; gap: 0 28rpx;
height: 100%; height: 100%;
flex-direction: row; flex-direction: row;
.flex{ .flex{
flex-direction: row;
align-items: center;
}
&-item {
width: 742rpx;
height: 100%;
position: relative;
&-box {
position: relative;
width: 100%;
height: 100%;
background: #ffffff;
border: 3rpx solid #a8c1ff;
border-radius: 16rpx;
box-sizing: border-box;
padding: 0 24rpx;
z-index: 2;
.category-name {
width: 160rpx;
height: 48rpx;
border-radius: 8rpx;
background: #f5f6f7;
color: #333333;
font-size: 26rpx;
padding: 6rpx 16rpx;
margin-right: 12rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.input,
.select {
width: 100%;
height: 100%;
border: none !important;
outline: none;
font-size: 28rpx;
color: #333333;
border-radius: 16rpx;
box-sizing: border-box;
line-height: 80rpx;
padding: 0 !important;
&::placeholder {
color: #999999;
}
}
.placeholderStyle {
color: #999999;
}
.arrow {
color: #999 !important;
margin-left: auto;
flex-shrink: 0;
}
}
.active {
&::after {
position: absolute;
left: -2rpx;
top: -2rpx;
width: calc(100% + 4rpx);
height: calc(100% + 4rpx);
content: '';
background-image: linear-gradient(#2f6af7, #75bcff);
box-shadow: 0 0 0 8rpx #2c66f71a;
border-radius: 16rpx;
}
}
}
.check-box {
width: 32rpx;
height: 32rpx;
background: #ffffff;
border: 3rpx solid #a8c1ff;
border-radius: 4rpx;
box-sizing: border-box;
margin-right: 12rpx;
justify-content: center;
overflow: hidden;
font-weight: 700;
transition: all 0.25s;
flex-shrink: 0;
}
.checked {
background: #2c66f7;
border-color: #2c66f7;
}
}
.title {
justify-content: center;
position: absolute;
height: 96rpx;
left: 0;
top: 48rpx;
font-weight: 500;
font-size: 36rpx;
color: #333;
text-align: center;
width: 100%;
z-index: 2;
}
.record-box {
height: 100%;
padding-top: 284rpx;
}
.has-tabs {
padding-top: 360rpx;
}
.card-list {
display: flex;
flex-wrap: wrap;
gap: 24rpx 48rpx;
padding: 0 64rpx;
flex-direction: row; flex-direction: row;
align-items: center; .card-item {
} background-color: #f7f9ff;
&-item { border-radius: 32rpx;
width: 742rpx; height: 372rpx;
height: 100%; box-sizing: border-box;
position: relative; border: 4rpx solid hsl(0, 80%, 100%);
position: relative;
&-box { box-shadow: inset 0 0 16rpx 0 #ffffff;
position: relative; z-index: 11;
width: 100%; padding: 32rpx;
height: 100%; width: 706rpx;
background: #ffffff; flex-shrink: 0;
border: 3rpx solid #a8c1ff;
border-radius: 16rpx; .image-box {
box-sizing: border-box; display: block;
padding: 0 24rpx; position: absolute;
z-index: 2; right: 0;
top: 0;
.category-name { width: 252rpx;
width: 160rpx; height: 364rpx;
height: 48rpx; border-radius: 0 32rpx 32rpx 0;
border-radius: 8rpx; z-index: -1;
background: #f5f6f7; }
color: #333333;
font-size: 26rpx; .payType {
padding: 6rpx 16rpx; position: absolute;
margin-right: 12rpx; width: 160rpx;
overflow: hidden; height: 160rpx;
text-overflow: ellipsis; right: 16rpx;
white-space: nowrap; bottom: 16rpx;
} }
}
.name {
.input, font-weight: 500;
.select { font-size: 32rpx;
width: 100%; color: #292d33;
height: 100%; line-height: 44rpx;
border: none !important; }
outline: none;
font-size: 28rpx; .goods-name {
color: #333333; margin-top: 12rpx;
border-radius: 16rpx; margin-bottom: 16rpx;
box-sizing: border-box; font-weight: 500;
line-height: 80rpx; font-size: 32rpx;
padding: 0 !important; color: #2c66f7;
width: 644rpx;
&::placeholder { overflow: hidden;
color: #999999; white-space: nowrap;
} text-overflow: ellipsis;
} line-height: 44rpx;
}
.placeholderStyle {
color: #999999; .card-info {
} display: flex;
align-items: center;
.arrow { margin-top: 12rpx;
color: #999 !important; line-height: 36rpx;
margin-left: auto; font-size: 24rpx;
flex-shrink: 0; flex-direction: row;
} &:last-child {
} margin-bottom: 0;
}
.active {
&::after { .label {
position: absolute; font-size: 24rpx;
left: -2rpx; color: #999ea8;
top: -2rpx; width: 136rpx;
width: calc(100% + 4rpx); }
height: calc(100% + 4rpx);
content: ''; .value {
background-image: linear-gradient(#2f6af7, #75bcff); font-size: 24rpx;
box-shadow: 0 0 0 8rpx #2c66f71a; color: #666666;
border-radius: 16rpx; margin-left: 0;
} }
}
} .price {
margin-left: 0;
.check-box { display: flex;
width: 32rpx; align-items: baseline;
height: 32rpx; font-weight: 500;
background: #ffffff; font-size: 32rpx;
border: 3rpx solid #a8c1ff; color: #22ac38;
border-radius: 4rpx; flex-direction: row;
box-sizing: border-box; .flag {
margin-right: 12rpx; font-size: 24rpx;
justify-content: center; }
overflow: hidden; }
font-weight: 700; }
transition: all 0.25s;
flex-shrink: 0; .gradient-overlay {
} z-index: -1;
position: absolute;
.checked { top: 0;
background: #2c66f7; right: 0;
border-color: #2c66f7; width: 252rpx;
} height: 364rpx;
} background: linear-gradient(to left, rgba(247, 249, 255, 0) 0%, rgba(247, 249, 255, 1) 100%);
}
.title { }
justify-content: center; }
position: absolute; }
height: 96rpx;
left: 0;
top: 48rpx;
font-weight: 500;
font-size: 36rpx;
color: #333;
text-align: center;
width: 100%;
z-index: 2;
}
.record-box {
height: 100%;
padding-top: 284rpx;
}
.has-tabs {
padding-top: 360rpx;
}
.card-list {
display: flex;
flex-wrap: wrap;
gap: 24rpx 48rpx;
padding: 0 64rpx;
flex-direction: row;
.card-item {
background-color: #f7f9ff;
border-radius: 32rpx;
height: 372rpx;
box-sizing: border-box;
border: 4rpx solid hsl(0, 80%, 100%);
position: relative;
box-shadow: inset 0 0 16rpx 0 #ffffff;
z-index: 11;
padding: 32rpx;
width: 706rpx;
flex-shrink: 0;
.image-box {
display: block;
position: absolute;
right: 0;
top: 0;
width: 252rpx;
height: 364rpx;
border-radius: 0 32rpx 32rpx 0;
z-index: -1;
}
.payType {
position: absolute;
width: 160rpx;
height: 160rpx;
right: 16rpx;
bottom: 16rpx;
}
.name {
font-weight: 500;
font-size: 32rpx;
color: #292d33;
line-height: 44rpx;
}
.goods-name {
margin-top: 12rpx;
margin-bottom: 16rpx;
font-weight: 500;
font-size: 32rpx;
color: #2c66f7;
width: 644rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
line-height: 44rpx;
}
.card-info {
display: flex;
align-items: center;
margin-top: 12rpx;
line-height: 36rpx;
font-size: 24rpx;
flex-direction: row;
&:last-child {
margin-bottom: 0;
}
.label {
font-size: 24rpx;
color: #999ea8;
width: 136rpx;
}
.value {
font-size: 24rpx;
color: #666666;
margin-left: 0;
}
.price {
margin-left: 0;
display: flex;
align-items: baseline;
font-weight: 500;
font-size: 32rpx;
color: #22ac38;
flex-direction: row;
.flag {
font-size: 24rpx;
}
}
}
.gradient-overlay {
z-index: -1;
position: absolute;
top: 0;
right: 0;
width: 252rpx;
height: 364rpx;
background: linear-gradient(to left, rgba(247, 249, 255, 0) 0%, rgba(247, 249, 255, 1) 100%);
}
}
}
} }
}
.end-text {
.end-text { width: 100%;
width: 100%; color: #999;
color: #999; text-align: center;
text-align: center; padding: 50rpx 0;
padding: 50rpx 0;
}
.no-data {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
&-img {
width: 640rpx;
height: 272rpx;
} }
&-text { .no-data {
font-size: 32rpx; position: absolute;
color: #999999; left: 50%;
text-align: center; top: 50%;
margin-top: 24rpx; transform: translate(-50%, -50%);
&-img {
width: 640rpx;
height: 272rpx;
}
&-text {
font-size: 32rpx;
color: #999999;
text-align: center;
margin-top: 24rpx;
}
} }
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -35,14 +35,13 @@ import CustomPopup from '@/components/CustomPopup.uvue' ...@@ -35,14 +35,13 @@ import CustomPopup from '@/components/CustomPopup.uvue'
itemName: string itemName: string
main: string main: string
itemDesc: string itemDesc: string
[key: string]: any
} }
const props = defineProps({ const props = defineProps({
item: Object item: Object
}) })
const visible = ref<boolean>(false) const visible = ref<boolean>(false)
const popup = ref<any>(null) const popup = ref(null)
function open(): void { function open(): void {
visible.value = true visible.value = true
......
...@@ -3,275 +3,305 @@ ...@@ -3,275 +3,305 @@
<view class="views-title-box flex"> <view class="views-title-box flex">
<template v-for="(i,index) in viewsTitle" :key="index"> <template v-for="(i,index) in viewsTitle" :key="index">
<view <view
v-if="showRow(index)" v-if="showRow(index)"
:class="['title-item flex',`row-${index + 1}`]" :class="['title-item flex',`row-${index + 1}`]"
>{{i}}</view> >{{i}}</view>
</template> </template>
</view> </view>
<view class="views-content"> <view class="views-content">
<view <view
class="main" class="main"
v-if="flag && check" v-if="flag && check"
>商业险</view> >商业险</view>
<scroll-view <scroll-view
class="table" class="table"
scroll-y scroll-y
:scroll-top="scrollTop" :scroll-top="scrollTop"
> >
<template v-if="flag"> <template v-if="flag">
<template v-if="check"> <template v-if="check">
<template v-for="(i,index) in insuranceList" :key="index"> <template v-for="(i,index) in insuranceList" :key="index">
<view
:class="['insurance-item flex',{'disabled':!i.show},{'disabled-input':!i.checked}]"
v-if="showInsurance(i)"
>
<view class="row-1 flex">
<view :class="['block',defaultBlock(i)]"></view>
<view <view
class="name flex" :class="['insurance-item flex',{'disabled':!i.show},{'disabled-input':!i.checked}]"
@click="choose(i,index)" v-if="showInsurance(i)"
> >
<template v-if="!isPreview"> <view class="row-1 flex">
<view :class="['check-box flex',{'checked':i.checked}]"> <view :class="['block',defaultBlock(i)]">
<uni-icons
type="checkmarkempty"
:size="14"
color="#fff"
></uni-icons>
</view> </view>
</template> <view
<view class="text-two-line">{{i.itemName}}</view> class="name flex"
</view> @click="choose(i,index)"
</view> >
<view <template v-if="!isPreview">
class="range row-2" <view :class="['check-box flex',{'checked':i.checked}]">
@click="showDetail(i)" <uni-icons
> type="checkmarkempty"
<view class="text-two-line"> :size="14"
<rich-text :nodes="i.itemDesc"></rich-text> color="#fff"
>
</uni-icons>
</view>
</template>
<view class="text-two-line">
{{i.itemName}}
</view>
</view>
</view>
<view
class="range row-2"
@click="showDetail(i)"
>
<view class="text-two-line">
<rich-text :nodes="i.itemDesc">
</rich-text>
</view>
</view>
<view class="cost row-3">
<view class="cost-input">
<input
type="digit"
maxlength="9"
v-model="i.cost"
class="input"
placeholder="输入金额"
:disabled="!i.show || !i.checked"
:placeholder-style="`color:${i.show && i.checked?'#999':'#ccc'}`"
@blur="handleInput"
:data-index="index"
/>
<view class="unit">
元
</view>
</view>
</view>
<view
class="show row-4"
@click="setItemDisabled(i,index)"
>
<view :class="['sprite-icon',`${i.show ? 'icon-visible' : 'icon-invisible'}`]">
</view>
</view>
</view> </view>
</view> </template>
<view class="cost row-3"> </template>
<view class="cost-input"> <template v-else>
<input <view class="nothing flex">
type="digit" <view class="sprite-icon icon-no-insurance-data">
maxlength="9"
v-model="i.cost"
class="input"
placeholder="输入金额"
:disabled="!i.show || !i.checked"
:placeholder-style="`color:${i.show && i.checked?'#999':'#ccc'}`"
@blur="handleInput"
:data-index="index"
/>
<view class="unit">元</view>
</view> </view>
暂无数据{{!isPreview?',请进入预览模式,开启相关车险及权益内容':''}}
</view> </view>
<view </template>
class="show row-4"
@click="setItemDisabled(i,index)"
>
<view :class="['sprite-icon',`${i.show ? 'icon-visible' : 'icon-invisible'}`]"></view>
</view>
</view>
</template> </template>
</template> </scroll-view>
<template v-else> </view>
<view class="nothing flex">
<view class="sprite-icon icon-no-insurance-data"></view>
暂无数据{{!isPreview?',请进入预览模式,开启相关车险及权益内容':''}}
</view>
</template>
</template>
</scroll-view>
</view>
<view class="views-footer flex"> <view class="views-footer flex">
<view class="sprite-icon icon-total"></view> <view class="sprite-icon icon-total">
合计 </view>
<view class="total">{{total}}</view> 合计
<view class="util">元</view> <view class="total">
</view> {{total}}
<insurance-popup </view>
ref="popupRef" <view class="util">
:item="currentItem" 元
></insurance-popup> </view>
</view> </view>
<insurance-popup
ref="popupRef"
:item="currentItem"
>
</insurance-popup>
</view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import NP from 'number-precision' import NP from 'number-precision'
import InsurancePopup from './InsurancePopup.uvue' import InsurancePopup from './InsurancePopup.uvue'
import { store } from '@/store/index.uts' import { store } from '@/store/index.uts'
import {getMerchantInsuranceListApi} from '@/api/user-api.uts' import {getMerchantInsuranceListApi} from '@/api/user-api.uts'
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
interface InsuranceItem { interface InsuranceItem {
id: string | number id: string | number
itemName: string itemName: string
itemDesc: string itemDesc: string
cost: string cost: string
checked: boolean checked: boolean
show: boolean show: boolean
main: string main: string
[key: string]: any }
}
const props = defineProps({ const props = defineProps({
isPreview: Boolean, isPreview: Boolean,
show: Boolean show: Boolean
}) })
const viewsTitle = ref<Array<string>>(['险种及权益', '主要保障范围', '费用', '是否显示']) const viewsTitle = ref<Array<string>>(['险种及权益',
const currentItem = ref<any>({}) '主要保障范围',
const insuranceList = ref<Array<InsuranceItem>>([]) '费用',
const scrollTop = ref<number>(0) '是否显示'])
const storageKey = ref<string>('') const currentItem = ref<any>({} as any)
const flag = ref<boolean>(false) const insuranceList = ref<Array<InsuranceItem>>([] as Array<InsuranceItem>)
const popupRef = ref<any>(null) const scrollTop = ref<number>(0)
const storageKey = ref<string>('')
const flag = ref<boolean>(false)
const popupRef = ref(null)
const watchStatus = computed(() => { const watchStatus = computed(() => {
return store.state.user.historyStatus const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
}) })
const total = computed(() => { const total = computed(() => {
return insuranceList.value.reduce((pre, cur) => { return insuranceList.value.reduce((pre, cur) => {
return NP.plus(pre, NP.times(cur.cost, (props.isPreview ? cur.show : cur.checked) ? 1 : 0)) const shouldCount: boolean = props.isPreview ? (cur.show === true) : (cur.checked === true)
return NP.plus(pre, NP.times(cur.cost, shouldCount ? 1 : 0))
}, 0) }, 0)
}) })
const check = computed(() => { const check = computed(() => {
return props.isPreview ? insuranceList.value.length : insuranceList.value.filter(item => item.show).length return props.isPreview === true ? insuranceList.value.length : insuranceList.value.filter(item => item.show === true).length
}) })
watch(() => watchStatus.value, (newval) => { watch(watchStatus.value, (newval) => {
;(popupRef.value as any)?.close() ;(popupRef.value as any)?.close()
flag.value = false flag.value = false
scrollTop.value = -1 scrollTop.value = -1
setTimeout(() => { setTimeout(() => {
scrollTop.value = 0 scrollTop.value = 0
}, 10) }, 10)
const key = getStorageKey() const key = getStorageKey()
const insuranceListData = uni.getStorageSync(key) const insuranceListData = uni.getStorageSync(key)
if (insuranceListData) { if (insuranceListData != null) {
insuranceListData.map((e: any) => e.cost = '') insuranceListData.map((e: any) => e.cost = '')
insuranceList.value = JSON.parse(JSON.stringify(insuranceListData)) insuranceList.value = JSON.parse(JSON.stringify(insuranceListData)) as Array<InsuranceItem>
flag.value = true flag.value = true
} }
}, { immediate: true }) }, { immediate: true })
watch(() => props.show, (n) => { watch(() => props.show, (n) => {
if (n) { if (n === true) {
getMerchantInsuranceList() getMerchantInsuranceList()
} }
}) })
function getStorageKey(): string { function getStorageKey(): string {
const { uuid, shopMerchantId } = storage.get("userInfo") const { uuid, shopMerchantId } = storage.get("userInfo")
const key = `${shopMerchantId}_${uuid}_insurance_list` const key = `${shopMerchantId}_${uuid}_insurance_list`
storageKey.value = key storageKey.value = key
return key return key
} }
function showRow(index: number): boolean { function showRow(index: number): boolean {
let flg = true let flg = true
if (index == viewsTitle.value.length - 1 && !props.isPreview) flg = false if (index == viewsTitle.value.length - 1 && props.isPreview === false) flg = false
return flg return flg
} }
function showDetail(e: any): void { function showDetail(e: any): void {
currentItem.value = e currentItem.value = e
;(popupRef.value as any).open() ;(popupRef.value as any).open()
} }
function handleInput(event: any): void { function handleInput(event: any): void {
let value = event.target.value let value = event.target.value
const { index } = event.currentTarget.dataset const { index } = event.currentTarget.dataset
if (value.length == 0) return if (value.length == 0) return
value = Number(value) > 999999 ? 999999 : value value = Number(value) > 999999 ? 999999 : value
if (!Number.isInteger(value)) value = String(value).replace(/(\d*\.?\d{0,2})\d*/, '$1') if (!Number.isInteger(value)) value = String(value).replace(/(\d*\.?\d{0,2})\d*/, '$1')
value = Number(String(value).replace(/^0+/, '')) value = Number(String(value).replace(/^0+/, ''))
insuranceList.value[index].cost = Number(value).toFixed(2) ? Number(value).toFixed(2) >= 0 ? value : '' : '' insuranceList.value[index].cost = Number(value).toFixed(2) != null && Number(value).toFixed(2) >= 0 ? value : ''
} }
function defaultBlock(item: InsuranceItem): string { function defaultBlock(item: InsuranceItem): string {
return item.main == '交强险' ? (props.isPreview ? 'has-default' : item.show ? 'has-default' : '') : '' const isJq: boolean = item.main == '交强险'
if (props.isPreview === true) {
return isJq === true ? 'has-default' : ''
} else {
return item.show === true ? 'has-default' : ''
} }
}
function showInsurance(item: InsuranceItem): boolean { function showInsurance(item: InsuranceItem): boolean {
return props.isPreview ? true : item.show ? true : false return props.isPreview === true ? true : (item.show === true ? true : false)
} }
function setItemDisabled(item: InsuranceItem, index: number): void { function setItemDisabled(item: InsuranceItem, index: number): void {
insuranceList.value[index].show = !item.show insuranceList.value[index].show = item.show === true ? false : true
uni.setStorageSync(storageKey.value, insuranceList.value) uni.setStorageSync(storageKey.value, insuranceList.value)
} }
async function getMerchantInsuranceList(): Promise<void> {
try {
const { shopMerchantId } = storage.get("userInfo")
const storageInsuranceList = storage.get(storageKey.value)
const list = await getMerchantInsuranceListApi({
merchantId: shopMerchantId
})
list?.map((e: any) => {
e.cost = ''
e.checked = true
e.main = e.itemName == '交强险' ? '交强险' : '商业险'
e.show = false
e.itemDesc = e.itemDesc != null ? processHtmlString(e.itemDesc) : ''
})
async function getMerchantInsuranceList(): Promise<void> { if (storageInsuranceList == null) {
try { uni.showLoading({ mask: true })
const { shopMerchantId } = storage.get("userInfo") setInsuranceList(storageKey.value, list || [])
const storageInsuranceList = storage.get(storageKey.value) } else {
const list = await getMerchantInsuranceListApi({ const combinedList = [...insuranceList.value, ...list]
merchantId: shopMerchantId const deduplicatedList = combinedList.reduce((acc: Array<any>, item: any) => {
}) const existingItem = acc.find(existing => String(existing.id) === String(item.id))
if (existingItem != null) {
list?.map((e: any) => { existingItem.itemName = existingItem.itemName != null ? existingItem.itemName : ''
e.cost = '' existingItem.itemDesc = existingItem.itemDesc != null ? existingItem.itemDesc : ''
e.checked = true if (currentItem.value.id == existingItem.id) currentItem.value = existingItem
e.main = e.itemName == '交强险' ? '交强险' : '商业险'
e.show = false
e.itemDesc = e.itemDesc ? processHtmlString(e.itemDesc) : ''
})
if (!storageInsuranceList) {
uni.showLoading({ mask: true })
setInsuranceList(storageKey.value, list || [])
} else { } else {
const combinedList = [...insuranceList.value, ...list] acc.push(item)
const deduplicatedList = combinedList.reduce((acc: any[], item: any) => {
const existingItem = acc.find(existing => String(existing.id) === String(item.id))
if (existingItem) {
existingItem.itemName = item.itemName || ''
existingItem.itemDesc = item.itemDesc || ''
if (currentItem.value.id == existingItem.id) currentItem.value = existingItem
} else {
acc.push(item)
}
return acc
}, [])
const arr: any[] = []
deduplicatedList.map((e: any) => {
const index = list.findIndex((item: any) => String(item.id) === String(e.id))
if (index != -1) arr.push(e)
})
setInsuranceList(storageKey.value, arr)
} }
} catch (error) { return acc
flag.value = true }, [])
}
}
function setInsuranceList(key: string, value: any[]): void { const arr: Array<any> = []
uni.hideLoading() deduplicatedList.map((e: any) => {
insuranceList.value = JSON.parse(JSON.stringify(value)) const index = list.findIndex((item: any) => String(item.id) === String(e.id))
value.map((e: any) => e.checked = true) if (index != -1) arr.push(e)
uni.setStorageSync(key, value) })
flag.value = true setInsuranceList(storageKey.value, arr)
}
} catch (error) {
flag.value = true
} }
}
function processHtmlString(htmlString: string): string { function setInsuranceList(key: string, value: Array<any>): void {
let processedString = htmlString.replace(/<\/?br\s*\/??>|\n/g, '<div></div>') uni.hideLoading()
processedString = processedString.replace(/style="[^"]*"/g, '') insuranceList.value = JSON.parse(JSON.stringify(value)) as Array<InsuranceItem>
processedString = processedString.replace(/<strong>|<\/strong>|<em>|<\/em>|<>/g, '') value.map((e: any) => e.checked = true)
processedString = processedString.replace(/<(?!div|span|p)[^>]*>/g, '</div>') uni.setStorageSync(key, value)
return processedString flag.value = true
} }
function choose(item: InsuranceItem, index: number): void { function processHtmlString(htmlString: string): string {
if (props.isPreview) return let processedString = htmlString.replace(/<\/?br\s*\/??>|\n/g, 'div></div>')
insuranceList.value[index].checked = !item.checked processedString = processedString.replace(/style="[^"]*"/g, '')
} processedString = processedString.replace(/<strong>|<\/strong>|<em>|<\/em>|<>/g, '')
processedString = processedString.replace(/<(?!div|span|p)[^>]*>/g, '</div>')
return processedString
}
function choose(item: InsuranceItem, index: number): void {
if (props.isPreview === true) return
insuranceList.value[index].checked = item.checked === true ? false : true
}
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
...@@ -280,317 +310,317 @@ import { storage } from '@/utils/storage.uts' ...@@ -280,317 +310,317 @@ import { storage } from '@/utils/storage.uts'
align-items: center; align-items: center;
flex-direction: row; flex-direction: row;
} }
.views-box { .views-box {
width: 2090rpx; width: 2090rpx;
height: 1080rpx; height: 1080rpx;
box-sizing: border-box;
border: 4rpx solid #ffffff;
border-radius: 40rpx;
margin: 56rpx auto 0;
.views-title-box {
height: 96rpx;
background-image: linear-gradient(92deg, #d0e6fecc 0%, #c2dbffcc 33%, #d1e4ffcc 77%, #bdd6ffcc 100%);
backdrop-filter: blur(6rpx);
border-radius: 40rpx 40rpx 0 0;
color: #292d33;
line-height: 40rpx;
.title-item {
height: 96rpx;
justify-content: center;
box-sizing: border-box;
flex-shrink: 0;
align-items: center;
font-weight: 500;
font-size: 26rpx;
}
}
.row-1 {
width: 470rpx;
height: 100%;
overflow: visible;
}
.row-2 {
width: 1092rpx;
border-right: 4rpx solid #fff;
border-left: 4rpx solid #fff;
}
.row-3 {
width: 528rpx;
}
.views-content {
height: calc(100% - 192rpx);
display: flex;
box-sizing: border-box; box-sizing: border-box;
border-top: 4rpx solid #ffffff; border: 4rpx solid #ffffff;
border-bottom: 4rpx solid #ffffff; border-radius: 40rpx;
position: relative; margin: 56rpx auto 0;
.main { .views-title-box {
position: absolute; height: 96rpx;
top: 120rpx; background-image: linear-gradient(92deg, #d0e6fecc 0%, #c2dbffcc 33%, #d1e4ffcc 77%, #bdd6ffcc 100%);
left: 0; backdrop-filter: blur(6rpx);
width: 108rpx; border-radius: 40rpx 40rpx 0 0;
height: 748rpx;
font-weight: 500;
font-size: 26rpx;
color: #292d33; color: #292d33;
display: flex; line-height: 40rpx;
align-items: center; .title-item {
justify-content: center; height: 96rpx;
writing-mode: vertical-lr; justify-content: center;
text-orientation: upright; box-sizing: border-box;
letter-spacing: 32rpx; flex-shrink: 0;
z-index: 2; align-items: center;
font-weight: 500;
font-size: 26rpx;
}
} }
.table { .row-1 {
width: 470rpx;
height: 100%; height: 100%;
.insurance-item { overflow: visible;
background-color: #f7f9ff; }
border-bottom: 4rpx solid #ffffff; .row-2 {
position: relative; width: 1092rpx;
flex-direction: row; border-right: 4rpx solid #fff;
overflow: visible; border-left: 4rpx solid #fff;
.name, }
.range, .row-3 {
.cost, width: 528rpx;
.show { }
min-height: 120rpx; .views-content {
display: flex; height: calc(100% - 192rpx);
align-items: center; display: flex;
justify-content: center; box-sizing: border-box;
flex-shrink: 0; border-top: 4rpx solid #ffffff;
transition: all 0.25s; border-bottom: 4rpx solid #ffffff;
.text-two-line{ position: relative;
flex:1; .main {
font-size: 26rpx; position: absolute;
} top: 120rpx;
} left: 0;
.name, width: 108rpx;
.range { height: 748rpx;
font-size: 26rpx; font-weight: 500;
color: #292d33; font-size: 26rpx;
padding: 40rpx 0; color: #292d33;
} display: flex;
.block { align-items: center;
position: absolute; justify-content: center;
width: 104rpx; writing-mode: vertical-lr;
height: calc(100% + 4rpx); text-orientation: upright;
background: #cfe3fe; letter-spacing: 32rpx;
top: 0; z-index: 2;
left: 0; }
} .table {
.name { height: 100%;
width: 366rpx; .insurance-item {
margin-left: 108rpx; background-color: #f7f9ff;
justify-content: flex-start; border-bottom: 4rpx solid #ffffff;
padding: 0 40rpx; position: relative;
.check-box { flex-direction: row;
width: 32rpx; overflow: visible;
height: 32rpx; .name,
background: #ffffff; .range,
border: 3rpx solid #a8c1ff; .cost,
border-radius: 4rpx; .show {
box-sizing: border-box; min-height: 120rpx;
margin-right: 32rpx; display: flex;
align-items: center;
justify-content: center; justify-content: center;
overflow: hidden;
font-weight: 700;
transition: all 0.25s;
flex-shrink: 0; flex-shrink: 0;
transition: all 0.25s;
.text-two-line{
flex:1;
font-size: 26rpx;
}
} }
.checked { .name,
background: #2c66f7; .range {
border-color: #2c66f7; font-size: 26rpx;
color: #292d33;
padding: 40rpx 0;
} }
} .block {
.range { position: absolute;
padding: 40rpx 64rpx; width: 104rpx;
box-sizing: border-box; height: calc(100% + 4rpx);
text-align: center; background: #cfe3fe;
.text-two-line{ top: 0;
text-align: center; left: 0;
} }
} .name {
.cost { width: 366rpx;
&-input { margin-left: 108rpx;
position: relative; justify-content: flex-start;
width: 368rpx; padding: 0 40rpx;
height: 72rpx; .check-box {
background: #ffffff; width: 32rpx;
border: 3rpx solid #a8c1ff; height: 32rpx;
border-radius: 12rpx; background: #ffffff;
border: 3rpx solid #a8c1ff;
border-radius: 4rpx;
box-sizing: border-box;
margin-right: 32rpx;
justify-content: center;
overflow: hidden;
font-weight: 700;
transition: all 0.25s;
flex-shrink: 0;
}
.checked {
background: #2c66f7;
border-color: #2c66f7;
}
}
.range {
padding: 40rpx 64rpx;
box-sizing: border-box; box-sizing: border-box;
padding: 0 24rpx; text-align: center;
.input { .text-two-line{
width: 100%; text-align: center;
height: 100%; }
font-size: 28rpx; }
border: none !important; .cost {
outline: none; &-input {
color: #292d33; position: relative;
line-height: 72rpx; width: 368rpx;
&::placeholder { height: 72rpx;
padding: 0 !important; background: #ffffff;
border: 3rpx solid #a8c1ff;
border-radius: 12rpx;
box-sizing: border-box;
padding: 0 24rpx;
.input {
width: 100%;
height: 100%;
font-size: 28rpx;
border: none !important;
outline: none;
color: #292d33;
line-height: 72rpx;
&::placeholder {
padding: 0 !important;
}
}
.unit {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 24rpx;
font-weight: 300;
font-size: 28rpx;
color: #292d33;
line-height: 36rpx;
} }
} }
.unit { }
position: absolute; &:nth-child(even) {
top: 50%; background: #ebf1ff;
transform: translateY(-50%); }
right: 24rpx; &:last-child {
font-weight: 300; border: none;
font-size: 28rpx; .block {
color: #292d33; height: 100%;
line-height: 36rpx;
} }
} }
} .has-default {
&:nth-child(even) { box-sizing: border-box;
background: #ebf1ff; border-bottom: 4rpx solid #ffffff;
}
&:last-child {
border: none;
.block {
height: 100%;
} }
} }
.has-default { .disabled {
box-sizing: border-box; .name,
border-bottom: 4rpx solid #ffffff; .range {
} color: #999999;
} }
.disabled { .cost {
.name, &-input {
.range { border-color: #d8dce6;
color: #999999; .input,
} .unit {
.cost { color: #cccccc;
&-input { }
border-color: #d8dce6;
.input,
.unit {
color: #cccccc;
} }
} }
} }
} .disabled-input {
.disabled-input { .cost {
.cost { &-input {
&-input { border-color: #d8dce6;
border-color: #d8dce6; .input,
.input, .unit {
.unit { color: #cccccc;
color: #cccccc; }
} }
} }
} }
} }
} &::before {
&::before { position: absolute;
position: absolute; left: 100rpx;
left: 100rpx; top: 0;
top: 0; width: 4rpx;
width: 4rpx; height: 100%;
height: 100%; background: #fff;
background: #fff; content: '';
content: ''; z-index: 2;
z-index: 2; }
} &::after {
&::after { position: absolute;
position: absolute; top: 0;
top: 0; left: 0;
left: 0; height: 100%;
height: 100%; width: 104rpx;
width: 104rpx; background: #cfe3fe;
background: #cfe3fe; content: '';
content: ''; z-index: -1;
z-index: -1; }
}
.nothing { .nothing {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
justify-content: center; justify-content: center;
flex-direction: column; flex-direction: column;
font-size: 26rpx; font-size: 26rpx;
color: #808291; color: #808291;
align-items: center;
.sprite-icon {
margin-bottom: 24rpx;
}
}
}
.views-footer {
height: 96rpx;
background-image: linear-gradient(92deg, #d1e7ffcc 0%, #c2dbffcc 33%, #d1e4ffcc 77%, #bdd6ffcc 100%);
backdrop-filter: blur(6rpx);
border-radius: 0 0 40rpx 40rpx;
justify-content: flex-end;
box-sizing: border-box;
padding-right: 104rpx;
font-weight: 500;
font-size: 28rpx;
color: #292d33;
line-height: 40rpx;
flex-direction: row;
align-items: center; align-items: center;
.sprite-icon { .sprite-icon {
margin-bottom: 24rpx; margin-right: 14rpx;
}
.total {
color: #2c66f7;
font-size: 48rpx;
margin: 0 16rpx 0 32rpx;
line-height: 64rpx;
}
.util {
color: #2c66f7;
} }
} }
} }
.views-footer { //预览模式样式
height: 96rpx; .preview {
background-image: linear-gradient(92deg, #d1e7ffcc 0%, #c2dbffcc 33%, #d1e4ffcc 77%, #bdd6ffcc 100%); .row-1,
backdrop-filter: blur(6rpx); .row-2,
border-radius: 0 0 40rpx 40rpx; .row-3,
justify-content: flex-end; .row-4 {
box-sizing: border-box; flex-shrink: 0;
padding-right: 104rpx;
font-weight: 500;
font-size: 28rpx;
color: #292d33;
line-height: 40rpx;
flex-direction: row;
align-items: center;
.sprite-icon {
margin-right: 14rpx;
} }
.total { .row-1 {
color: #2c66f7; width: 404rpx;
font-size: 48rpx;
margin: 0 16rpx 0 32rpx;
line-height: 64rpx;
} }
.util { .row-2 {
color: #2c66f7; width: 1052rpx;
} }
} .row-3 {
} width: 465rpx;
//预览模式样式
.preview {
.row-1,
.row-2,
.row-3,
.row-4 {
flex-shrink: 0;
}
.row-1 {
width: 404rpx;
}
.row-2 {
width: 1052rpx;
}
.row-3 {
width: 465rpx;
}
.row-4 {
border-left: 4rpx solid #fff;
width: 158rpx;
}
.insurance-item {
position: relative;
.name {
width: 296rpx !important;
padding: 0 24rpx !important;
} }
.show { .row-4 {
border-left: none; border-left: 4rpx solid #fff;
width: 158rpx;
} }
&::after { .insurance-item {
position: absolute; position: relative;
top: 0; .name {
right: 158rpx; width: 296rpx !important;
width: 4rpx; padding: 0 24rpx !important;
height: 100%; }
background: #fff; .show {
content: ''; border-left: none;
}
&::after {
position: absolute;
top: 0;
right: 158rpx;
width: 4rpx;
height: 100%;
background: #fff;
content: '';
}
} }
} }
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -22,65 +22,74 @@ ...@@ -22,65 +22,74 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import MessageBox from '@/components/MessageBox.uvue' import MessageBox from '@/components/MessageBox.uvue'
import { state } from '@/store/index.uts' import { state } from '@/store/index.uts'
const props = defineProps({ type CarBuyersItem = {
title: { name: string
type: String, id: number
default: '购车方式' }
},
salesPropsUuid: {
type: String,
default: ''
}
})
const emit = defineEmits(['close', 'select']) const props = defineProps({
title: {
type: String,
default: '购车方式'
},
salesPropsUuid: {
type: String,
default: ''
}
})
const carBuyersVisible = ref<any>(null) const emit = defineEmits(['close', 'select'])
const carBuyersList = ref<Array<{name: string, id: number}>>([ const carBuyersVisible = ref(null)
{
name: '全款',
id: 1
},
{
name: '按揭',
id: 2
}
])
const watchStatus = computed(() => { const carBuyersList = ref<Array<CarBuyersItem>>([{
return state.user.historyStatus name: '全款',
}) id: 1
}, {
name: '按揭',
id: 2
}] as Array<CarBuyersItem>)
const carBuyers = computed(() => { const watchStatus = computed(() => {
return state.user.customerInfo.carBuyers const status = state.user?.historyStatus
}) if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
watch(() => watchStatus.value, (newval) => { const carBuyers = computed(() => {
close() return state.user.customerInfo.carBuyers
}, { immediate: true }) })
function open(): void { watch(watchStatus.value, (newval) => {
;(carBuyersVisible.value as any).open() close()
} }, { immediate: true })
function handleSelect(item: {name: string, id: number}): void { function open(): void {
close() ;(carBuyersVisible.value as any).open()
emit('select', item) }
}
function close(): void { function handleSelect(item: CarBuyersItem): void {
;(carBuyersVisible.value as any)?.close() close()
} emit('select', item)
}
function onClose(): void { function close(): void {
emit('close') ;(carBuyersVisible.value as any)?.close()
} }
function onClose(): void {
emit('close')
}
defineExpose({ open, close }) defineExpose({ open, close })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
<template> <template>
<view class="layout"> <view class="layout">
<wnCanvas <wnCanvas
:canvasId="`c-${madiaId}`" :canvasId="`c-${madiaId}`"
:drawStatus="penSwitch" :drawStatus="penSwitch"
custom custom
@scale="onScale" @scale="onScale"
:scaleSwitch="false" :scaleSwitch="false"
> >
<template #customContent> <template #customContent>
<view class="layout-content"> <view class="layout-content">
<view class="title"> <view class="title">
<view class="text">{{title}}</view> <view class="text">
{{title}}
</view>
</view> </view>
<view class="content"> <view class="content">
<view <view
class="form-box" class="form-box"
:key="watchStatus" :key="watchStatus"
> >
<view class="form"> <view class="form">
<template v-for="(i, index) in formObject" :key="index"> <template v-for="(i, index) in formObject" :key="index">
<view <view
:class="['form-item' ,{active:focusIndex == index}]" :class="['form-item' ,{active:focusIndex == index}]"
> >
<view class="form-item-box"> <view class="form-item-box">
<template v-if="i.type == 'input'"> <template v-if="i.type == 'input'">
<input <input
:type="i.inputType" :type="i.inputType"
:maxlength="i.maxlength" :maxlength="i.maxlength"
v-model="customerInfo[i.key]" v-model="customerInfo[i.key]"
class="input" class="input"
@input="inputCustomer" @input="inputCustomer"
:placeholder="i.placeholder" :placeholder="i.placeholder"
@focus="focusIndex = index" @focus="focusIndex = index"
@blur="resetFocusIndex" @blur="resetFocusIndex"
:data-key="i.key" :data-key="i.key"
/> />
<customer-autocomplete <customer-autocomplete
:showType="i.inputType" :showType="i.inputType"
:searchValue="customerInfo[i.key]" :searchValue="customerInfo[i.key]"
:show="focusIndex == index" :show="focusIndex == index"
@choose="chooseCustomer" @choose="chooseCustomer"
v-if="i.hasCustomerAutocomplete" v-if="i.hasCustomerAutocomplete"
/> />
<template v-if="i.unit"> <template v-if="i.unit">
<view class="unit">{{i.unit}}</view> <view class="unit">
{{i.unit}}
</view>
</template> </template>
</template> </template>
<template v-else> <template v-else>
<view <view
:class="['select flex',{placeholderStyle:!customerInfo[i.key]}]" :class="['select flex',{placeholderStyle:!customerInfo[i.key]}]"
@click="showPopup(i.popKey,index)" @click="showPopup(i.popKey,index)"
> >
<view class="value text-hide">{{customerInfo[i.key] ||i.placeholder}}</view> <view class="value text-hide">
{{customerInfo[i.key] ?customerInfo[i.key] :i.placeholder}}
</view>
<uni-icons <uni-icons
class="arrow" class="arrow"
type="right" type="right"
:size="16" :size="16"
></uni-icons> >
</uni-icons>
</view> </view>
</template> </template>
</view> </view>
...@@ -67,300 +74,295 @@ ...@@ -67,300 +74,295 @@
</view> </view>
</view> </view>
<insurance-table <insurance-table
:isPreview="isPreview" :isPreview="isPreview"
:show="show" :show="show"
/> />
</view> </view>
</template> </template>
</wnCanvas> </wnCanvas>
<car-brands <car-brands
ref="carBrandListVisible" ref="carBrandListVisible"
@select="handleSelect($event,'carBrandListVisible')" @select="handleSelect($event,'carBrandListVisible')"
@close="resetFocusIndex" @close="resetFocusIndex"
/> />
<carBuyers <carBuyers
ref="carBuyersVisible" ref="carBuyersVisible"
@select="handleSelect($event,'carBuyersVisible')" @select="handleSelect($event,'carBuyersVisible')"
@close="resetFocusIndex" @close="resetFocusIndex"
/> />
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import CarBrands from '@/components/CarBrands.uvue' import CarBrands from '@/components/CarBrands.uvue'
import InsuranceTable from './components/InsuranceTable.uvue' import InsuranceTable from './components/InsuranceTable.uvue'
import carBuyers from './components/carBuyers.uvue' import carBuyers from './components/carBuyers.uvue'
import CustomerAutocomplete from '@/components/CustomerAutocomplete.uvue' import CustomerAutocomplete from '@/components/CustomerAutocomplete.uvue'
import wnCanvas from '@/components/PanCanvas/index.uvue' import wnCanvas from '@/components/PanCanvas/index.uvue'
import { store } from '@/store/index.uts' import { store } from '@/store/index.uts'
interface FormItem { interface FormItem {
placeholder: string placeholder: string
key: string key: string
type: string type: string
inputType?: string inputType?: string
maxlength?: number maxlength?: number
hasCustomerAutocomplete?: boolean hasCustomerAutocomplete?: boolean
unit?: string unit?: string
popKey?: string popKey?: string
} }
interface CustomerInfo { interface CustomerInfo {
customerName?: string customerName?: string
phoneNumber?: string phoneNumber?: string
carModel?: string carModel?: string
carModelId?: string | number carModelId?: string | number
salesUuid?: string salesUuid?: string
staffName?: string staffName?: string
newCarFare?: string newCarFare?: string
carBuyers?: string carBuyers?: string
carPurchaseMethod?: string | number carPurchaseMethod?: string | number
[key: string]: any }
}
const props = defineProps({ const props = defineProps({
penSwitch: Boolean, penSwitch: Boolean,
show: Boolean, show: Boolean,
title: String, title: String,
isPreview: Boolean, isPreview: Boolean,
madiaId: Number madiaId: Number
}) })
const emit = defineEmits(['scale']) const emit = defineEmits(['scale'])
const formObject = ref<Array<FormItem>>([ const formObject = ref<Array<FormItem>>([
{ {
placeholder: '车主姓名', placeholder: '车主姓名',
key: 'customerName', key: 'customerName',
type: 'input', type: 'input',
inputType: 'text', inputType: 'text',
maxlength: 50, maxlength: 50,
hasCustomerAutocomplete: true hasCustomerAutocomplete: true
}, },
{ {
placeholder: '车主电话', placeholder: '车主电话',
key: 'phoneNumber', key: 'phoneNumber',
type: 'input', type: 'input',
inputType: 'tel', inputType: 'tel',
maxlength: 11, maxlength: 11,
hasCustomerAutocomplete: true hasCustomerAutocomplete: true
}, },
{ {
placeholder: '品牌车型', placeholder: '品牌车型',
key: 'carModel', key: 'carModel',
type: 'select', type: 'select',
popKey: 'carBrandListVisible' popKey: 'carBrandListVisible'
}, },
{ {
placeholder: '新车开票价', placeholder: '新车开票价',
key: 'newCarFare', key: 'newCarFare',
type: 'input', type: 'input',
inputType: 'digit', inputType: 'digit',
maxlength: 10, maxlength: 10,
unit: '元' unit: '元'
}, },
{ {
placeholder: '购车方式', placeholder: '购车方式',
key: 'carBuyers', key: 'carBuyers',
type: 'select', type: 'select',
popKey: 'carBuyersVisible' popKey: 'carBuyersVisible'
} }
]) ])
const customerInfo = ref<CustomerInfo>({}) const customerInfo = ref<CustomerInfo>({})
const focusIndex = ref<number>(-1) const focusIndex = ref<number>(-1)
const watchCustomerInfo = computed(() => { const watchCustomerInfo = computed(() => {
return store.state.user.customerInfo return store.state?.user.customerInfo
}) })
const watchStatus = computed(() => { const watchStatus = computed(() => {
return store.state.user.historyStatus return store.state?.user.historyStatus
}) })
watch(() => watchCustomerInfo.value, (newval) => { watch(() => watchCustomerInfo.value, (newval) => {
if (newval) { if (newval) {
customerInfo.value = newval as CustomerInfo customerInfo.value = newval as CustomerInfo
} }
}, { immediate: true }) }, { immediate: true })
const carBrandListVisible = ref<any>(null) const carBrandListVisible = ref(null)
const carBuyersVisible = ref<any>(null) const carBuyersVisible = ref(null)
function inputCustomer(): void { function inputCustomer(): void {
store.dispatch('setCustomerInfo', customerInfo.value) store.dispatch?.('setCustomerInfo', customerInfo.value)
} }
function handleSelect(item: any, popkey: string): void {
;(carBuyersVisible.value as any).close()
if (popkey == 'employeeBoxVisible') {
customerInfo.value.salesUuid = item.uuid
customerInfo.value.staffName = item.staffName
} else if (popkey == 'carBuyersVisible') {
customerInfo.value.carBuyers = item.name
customerInfo.value.carPurchaseMethod = item.id
} else {
;(carBrandListVisible.value as any).close()
customerInfo.value.carModel = item.name
customerInfo.value.carModelId = item.id
}
resetFocusIndex()
store.dispatch('setCustomerInfo', customerInfo.value)
}
function showPopup(e: string, index: number): void { function handleSelect(item: any, popkey: string): void {
focusIndex.value = index if (popkey == 'carBuyersVisible') {
if (e == 'carBrandListVisible') { customerInfo.value.carBuyers = item.name
;(carBrandListVisible.value as any).open() customerInfo.value.carPurchaseMethod = item.id
} else if (e == 'carBuyersVisible') { store.dispatch?.('setCustomerInfo', customerInfo.value)
;(carBuyersVisible.value as any).open() } else {
} (carBrandListVisible.value as any).close()
customerInfo.value.carModel = item.name
customerInfo.value.carModelId = item.id
} }
resetFocusIndex()
}
function closeAllPopup(): void { function showPopup(e: string, index: number): void {
;(carBrandListVisible.value as any).close() focusIndex.value = index
resetFocusIndex() if (e == 'carBrandListVisible') {
;(carBrandListVisible.value as any).open()
} else if (e == 'carBuyersVisible') {
;(carBuyersVisible.value as any).open()
} }
}
function resetFocusIndex(e?: any): void { function closeAllPopup(): void {
focusIndex.value = -1 ;(carBrandListVisible.value as any).close()
if (e?.currentTarget && e?.target) { resetFocusIndex()
const { key } = e.currentTarget.dataset }
if (e.target.value.length == 0) return
if (key == 'newCarFare') {
let value = Number(e.target.value) >= 9999999 ? 9999999 : e.target.value
if (!Number.isInteger(value)) value = String(value).replace(/(\d*\.?\d{0,2})\d*/, '$1')
value = Number(String(value).replace(/^0+/, ''))
customerInfo.value[key] = Number(value).toFixed(2) ? Number(value).toFixed(2) >= 0 ? value : '' : ''
inputCustomer()
}
}
}
function chooseCustomer(e: any): void { function resetFocusIndex(e?: any): void {
customerInfo.value = { focusIndex.value = -1
...customerInfo.value, if (e?.currentTarget && e?.target) {
phoneNumber: e.ownerPhone, const { key } = e.currentTarget.dataset
customerName: e.ownerName, if (e.target.value.length == 0) return
carModel: e.brandModel if (key == 'newCarFare') {
} let value = Number(e.target.value) >= 9999999 ? 9999999 : e.target.value
if (!Number.isInteger(value)) value = String(value).replace(/(\d*\.?\d{0,2})\d*/, '$1')
value = Number(String(value).replace(/^0+/, ''))
const numValue = Number(value)
customerInfo.value[key] = numValue >= 0 ? value : ''
inputCustomer() inputCustomer()
}
} }
}
function onScale(e: any): void { function chooseCustomer(e: any): void {
emit('scale', e) customerInfo.value = {
...customerInfo.value,
phoneNumber: e.ownerPhone,
customerName: e.ownerName,
carModel: e.brandModel
} }
inputCustomer()
}
function onScale(e: any): void {
emit('scale', e)
}
defineExpose({ closeAllPopup }) defineExpose({ closeAllPopup })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.layout { .layout {
position: relative;
width: 100%;
height: 100%;
background-image: url('@/assets/images/media/insurance-bg.webp');
background-size: 100%;
&-content {
height: 100%;
position: relative; position: relative;
} width: 100%;
.title { height: 100%;
padding: 120rpx 0 48rpx 128rpx; background-image: url('@/assets/images/media/insurance-bg.webp');
.text { background-size: 100%;
line-height: 80rpx; &-content {
font-weight: 500; height: 100%;
font-size: 56rpx; position: relative;
color: #333333;
} }
} .title {
.content { padding: 120rpx 0 48rpx 128rpx;
.form-box { .text {
height: 80rpx; line-height: 80rpx;
padding: 0 128rpx; font-weight: 500;
.form { font-size: 56rpx;
display: flex; color: #333333;
gap: 0 28rpx; }
height: 100%; }
flex-direction: row; .content {
&-item { .form-box {
width: 368rpx; height: 80rpx;
padding: 0 128rpx;
.form {
display: flex;
gap: 0 28rpx;
height: 100%; height: 100%;
position: relative; flex-direction: row;
&-item {
&-box { width: 368rpx;
position: relative;
width: 100%;
height: 100%; height: 100%;
background: #ffffff; position: relative;
border: 3rpx solid #a8c1ff;
border-radius: 16rpx; &-box {
box-sizing: border-box; position: relative;
padding: 0 24rpx; width: 100%;
z-index: 2; height: 100%;
display: flex; background: #ffffff;
align-items: center; border: 3rpx solid #a8c1ff;
flex-direction: row; border-radius: 16rpx;
.unit { box-sizing: border-box;
position: absolute; padding: 0 24rpx;
top: 50%; z-index: 2;
transform: translateY(-50%); display: flex;
right: 24rpx; align-items: center;
font-weight: 300; flex-direction: row;
.unit {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 24rpx;
font-weight: 300;
font-size: 28rpx;
color: #292d33;
line-height: 36rpx;
}
}
.input,
.select {
width: 100%;
height: 60rpx;
border: none !important;
outline: none;
font-size: 28rpx; font-size: 28rpx;
color: #292d33; color: #333333;
line-height: 36rpx; border-radius: 16rpx;
box-sizing: border-box;
padding: 0 !important;
display: flex;
align-items: center;
flex-direction: row;
font-size:28rpx;
.value{
font-size:28rpx;
}
&::placeholder {
color: #999999;
}
} }
} .placeholderStyle {
.input,
.select {
width: 100%;
height: 60rpx;
border: none !important;
outline: none;
font-size: 28rpx;
color: #333333;
border-radius: 16rpx;
box-sizing: border-box;
padding: 0 !important;
display: flex;
align-items: center;
flex-direction: row;
font-size:28rpx;
.value{
font-size:28rpx;
}
&::placeholder {
color: #999999; color: #999999;
line-height: 80rpx;
}
.arrow {
color: #999 !important;
margin-left: auto;
flex-shrink: 0;
} }
} }
.placeholderStyle { .active {
color: #999999; &::after {
line-height: 80rpx; position: absolute;
} left: -2rpx;
.arrow { top: -2rpx;
color: #999 !important; width: calc(100% + 4rpx);
margin-left: auto; height: calc(100% + 4rpx);
flex-shrink: 0; content: '';
} background-image: linear-gradient(#2f6af7, #75bcff);
} box-shadow: 0 0 0 8rpx #2c66f71a;
.active { border-radius: 16rpx;
&::after { }
position: absolute;
left: -2rpx;
top: -2rpx;
width: calc(100% + 4rpx);
height: calc(100% + 4rpx);
content: '';
background-image: linear-gradient(#2f6af7, #75bcff);
box-shadow: 0 0 0 8rpx #2c66f71a;
border-radius: 16rpx;
} }
} }
} }
} }
} }
} </style>
</style>
\ No newline at end of file \ No newline at end of file
...@@ -42,21 +42,19 @@ import wnCanvas from '@/components/PanCanvas/index.uvue' ...@@ -42,21 +42,19 @@ import wnCanvas from '@/components/PanCanvas/index.uvue'
import { state } from "@/store/index.uts" import { state } from "@/store/index.uts"
import nothingImage from '@/assets/images/media/nothing.webp' import nothingImage from '@/assets/images/media/nothing.webp'
interface Views { type Views = {
detailUrl?: string detailUrl?: string
bgUrl?: string bgUrl?: string
[key: string]: any
} }
interface CustomerInfo { type CustomerInfo = {
carModelId?: string carModelId?: string
[key: string]: any
} }
const props = defineProps({ const props = defineProps({
views: { views: {
type: Object as () => Views | Array<any>, type: Object as () => UTSJSONObject,
default: () => ({}) default: () => ({})
}, },
penSwitch: Boolean, penSwitch: Boolean,
...@@ -68,14 +66,15 @@ const props = defineProps({ ...@@ -68,14 +66,15 @@ const props = defineProps({
const emit = defineEmits(['scale']) const emit = defineEmits(['scale'])
const canvasRef = ref<any>(null) const canvasRef = ref(null)
const customerInfo = computed<CustomerInfo>(() => { const customerInfo = computed<CustomerInfo>(() => {
return state.user.customerInfo || {} const info = state.user.customerInfo
return info != null ? info.as(CustomerInfo) : {} as CustomerInfo
}) })
const viewKey = computed<string>(() => { const viewKey = computed<string>(() => {
return state.user?.viewKey || '' return state.user?.viewKey != null ? state.user.viewKey : ''
}) })
function onScale(e: number): void { function onScale(e: number): void {
......
...@@ -2,114 +2,117 @@ ...@@ -2,114 +2,117 @@
<view class="page-title-box flex"> <view class="page-title-box flex">
{{title}} {{title}}
<view <view
class="car-options flex" class="car-options flex"
v-if="hasCarBrand" v-if="hasCarBrand"
@click="openCarBrand" @click="openCarBrand"
> >
{{customerInfo.carModel||'请选择'}} {{customerInfo.carModel||'请选择'}}
<view class="sprite-icon icon-arrow-bottom"></view> <view class="sprite-icon icon-arrow-bottom">
</view>
</view> </view>
<CarBrands <CarBrands
ref="carBrandListVisible" ref="carBrandListVisible"
@select="handleSelect" @select="handleSelect"
/> />
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import CarBrands from '@/components/CarBrands.uvue' import CarBrands from '@/components/CarBrands.uvue'
import { state , store } from "@/store/index.uts" import { state , store } from "@/store/index.uts"
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
interface CustomerInfo { type CustomerInfo = UTSJSONObject
carModel?: string
carModelId?: string type UserInfo = UTSJSONObject
[key: string]: any
}
const props = defineProps({
interface UserInfo { title: String,
channelType: number hasCarBrand: Boolean,
[key: string]: any show: Boolean
} })
const carBrandListVisible = ref(null)
const props = defineProps({ const customerInfo = ref<CustomerInfo>({} as CustomerInfo)
title: String,
hasCarBrand: Boolean, const watchCustomerInfo = computed<CustomerInfo>(() => {
show: Boolean return state.user?.customerInfo != null ? state.user.customerInfo : {} as CustomerInfo
}) })
const carBrandListVisible = ref<any>(null) const watchStatus = computed(() => {
const customerInfo = ref<CustomerInfo>({}) const status = state.user?.historyStatus
if (status == null) {
const watchCustomerInfo = computed<CustomerInfo>(() => { return false
return state.user?.customerInfo || {} } else if (status == 1) {
}) return true
} else {
const watchStatus = computed<boolean>(() => { return false
return state.user?.historyStatus || false }
}) })
const isAito = computed<boolean>(() => { const isAito = computed<boolean>(() => {
const userInfo: UserInfo = storage.get('userInfo') || { channelType: 0 } const userInfo: UserInfo = storage.get('userInfo') != null ? storage.get('userInfo') : { channelType: 0 } as UserInfo
return userInfo.channelType == 1 return userInfo.channelType == 1
}) })
watch(() => props.show, (newval) => { watch(() => props.show, (newval) => {
if (newval && props.hasCarBrand && !customerInfo.value.carModel && isAito.value) { if (newval === true && props.hasCarBrand === true && (customerInfo.value.carModel == null || customerInfo.value.carModel === '') && isAito.value === true) {
setTimeout(() => { setTimeout(() => {
carBrandListVisible.value?.autoSelect() carBrandListVisible.value?.autoSelect()
}, 1000) }, 1000)
}
}, { immediate: true })
watch(() => watchCustomerInfo.value, (newval) => {
if (newval != null) {
customerInfo.value = { ...newval }
}
}, { immediate: true })
function handleSelect(item: any): void {
carBrandListVisible.value?.close()
onSelect(item)
} }
}, { immediate: true })
watch(() => watchCustomerInfo.value, (newval) => { function onSelect(item: any): void {
if (newval) { customerInfo.value.carModel = item.name
customerInfo.value = { ...newval } customerInfo.value.carModelId = item.id
store.dispatch?.('setCustomerInfo', customerInfo.value)
} }
}, { immediate: true })
function openCarBrand(): void {
function handleSelect(item: any): void { carBrandListVisible.value?.open()
carBrandListVisible.value?.close() }
customerInfo.value.carModel = item.name
customerInfo.value.carModelId = item.id defineExpose({ carBrandListVisible })
store.dispatch('setCustomerInfo', customerInfo.value)
}
function openCarBrand(): void {
carBrandListVisible.value?.open()
}
defineExpose({
carBrandListVisible
})
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.page-title-box { .page-title-box {
justify-content: center; justify-content: center;
position: absolute; position: absolute;
height: 96rpx; height: 96rpx;
left: 0; left: 0;
top: 48rpx; top: 48rpx;
font-weight: 500; font-weight: 500;
font-size: 36rpx; font-size: 36rpx;
color: #333; color: #333;
width: 100%; width: 100%;
z-index: 2; z-index: 2;
flex-direction: row; flex-direction: row;
align-items: center;
.car-options {
align-items: center; align-items: center;
flex-direction: row;; .car-options {
&::before { align-items: center;
content: ''; flex-direction: row;
width: 2rpx; &::before {
height: 36rpx; content: '';
opacity: 1; width: 2rpx;
background: #333333; height: 36rpx;
margin: 0 24rpx; opacity: 1;
} background: #333333;
margin: 0 24rpx;
}
}
} }
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
@click="showPopup(i.popKey, index)" @click="showPopup(i.popKey, index)"
> >
<view class="value text-hide"> <view class="value text-hide">
{{ customerInfo[i.key] || i.placeholder }} {{ customerInfo[i.key] ? customerInfo[i.key] : i.placeholder }}
</view> </view>
<uni-icons <uni-icons
class="arrow" class="arrow"
...@@ -95,19 +95,7 @@ ...@@ -95,19 +95,7 @@
popKey?: string popKey?: string
} }
interface CustomerInfo { type CustomerInfo = UTSJSONObject
customerName?: string
phoneNumber?: string
carModel?: string
carModelId?: string | number
salesUuid?: string
staffName?: string
carBrand?: string
carBrandId?: string | number
oneCarBrand?: string
oneCarBrandId?: string | number
[key: string]: any
}
const props = defineProps({ const props = defineProps({
penSwitch: Boolean, penSwitch: Boolean,
...@@ -146,22 +134,21 @@ ...@@ -146,22 +134,21 @@
const focusIndex = ref<number>(-1) const focusIndex = ref<number>(-1)
const watchCustomerInfo = computed(() => { const watchCustomerInfo = computed(() => {
return store.state.user.customerInfo return store.state?.user.customerInfo
}) })
const watchStatus = computed(() => { const watchStatus = computed(() => {
return store.state.user.historyStatus return store.state?.user.historyStatus
}) })
const isAito = computed(() => { const isAito = computed(() => {
const userInfo = storage.get('userInfo') const userInfo = storage.get('userInfo')
return userInfo.channelType == 1 return userInfo?.channelType == 1
}) })
watch(() => watchCustomerInfo.value, (newval) => { watch(() => watchCustomerInfo.value, (newval) => {
if (newval) { if (newval) {
customerInfo.value = newval as CustomerInfo customerInfo.value = newval as CustomerInfo
console.log( customerInfo.value,'==========')
} }
}, { immediate: true }) }, { immediate: true })
...@@ -169,42 +156,33 @@ ...@@ -169,42 +156,33 @@
if (n && !customerInfo.value.carModel && isAito.value) { if (n && !customerInfo.value.carModel && isAito.value) {
setTimeout(() => { setTimeout(() => {
carBrandListVisibleRef.value.$callMethod('autoSelect') carBrandListVisibleRef.value?.$callMethod('autoSelect')
}, 1000) }, 1000)
} }
}, { immediate: true }) }, { immediate: true })
const carBrandListVisibleRef = ref<any>(null) const carBrandListVisibleRef = ref(null)
function onInputCustomer(): void { function onInputCustomer(): void {
store.dispatch('setCustomerInfo', customerInfo.value) store.dispatch?.('setCustomerInfo', customerInfo.value)
} }
function onSelect(item: any, popkey: string): void { function onSelect(item: any, popkey: string): void {
carBrandListVisibleRef.value.$callMethod('close') customerInfo.value.carModel = item.name
// const customerInfo = dispatch('getCustomerInfo') customerInfo.value.carModelId = item.id
// if (popkey == 'employeeBoxVisible') { carBrandListVisibleRef.value?.$callMethod('close')
// customerInfo.value.salesUuid = item.uuid
// customerInfo.value.staffName = item.staffName
// } else {
// customerInfo.value.carModel = item.name
// customerInfo.value.carModelId = item.id
// }
resetFocusIndex() resetFocusIndex()
// store.dispatch('setCustomerInfo', customerInfo.value)
} }
function showPopup(e: string, index: number): void { function showPopup(e: string, index: number): void {
focusIndex.value = index focusIndex.value = index
if (e == 'carBrandListVisible') { if (e == 'carBrandListVisible') {
carBrandListVisibleRef.value.$callMethod('open') carBrandListVisibleRef.value?.$callMethod('open')
} }
} }
function closeAllPopup(): void { function closeAllPopup(): void {
carBrandListVisibleRef.value.$callMethod('close') carBrandListVisibleRef.value?.$callMethod('close')
resetFocusIndex() resetFocusIndex()
} }
...@@ -219,7 +197,7 @@ ...@@ -219,7 +197,7 @@
customerName: e.ownerName customerName: e.ownerName
} }
uni.$logger.local.info(`从客户档案选择:${JSON.stringify(e)}`) // uni.$logger.local.info(`从客户档案选择:${JSON.stringify(e)}`)
if (e.carModelId) { if (e.carModelId) {
customerInfo.value.carModelId = e.carModelId customerInfo.value.carModelId = e.carModelId
...@@ -236,9 +214,8 @@ ...@@ -236,9 +214,8 @@
function contentUrl(): string { function contentUrl(): string {
const views = props.views as any const views = props.views as any
const carModelId = customerInfo.value.carModelId const carModelId = customerInfo.value.carModelId
if (Array.isArray(views)) { if (Array.isArray(views)) {
return (views as any)[carModelId] || '/static/images/media/nothing.webp' return (views as any)[carModelId ?? ''] || '/static/images/media/nothing.webp'
} else if ((views as UTSJSONObject).detailUrl) { } else if ((views as UTSJSONObject).detailUrl) {
return (views as UTSJSONObject).detailUrl as string return (views as UTSJSONObject).detailUrl as string
} else { } else {
......
...@@ -87,7 +87,6 @@ ...@@ -87,7 +87,6 @@
defultTabId?: number defultTabId?: number
pageStyle?: string pageStyle?: string
carIcon?: string carIcon?: string
[key: string]: any
} }
const props = defineProps({ const props = defineProps({
...@@ -104,7 +103,7 @@ ...@@ -104,7 +103,7 @@
const direction = ref<string>('bottom') const direction = ref<string>('bottom')
const imgKey = ref<number>(Date.now()) const imgKey = ref<number>(Date.now())
const tabIndex = ref<number>(2) const tabIndex = ref<number>(2)
const threeGuarantees = ref<any>(null) const threeGuarantees = ref(null)
const watchStatus = computed(() => { const watchStatus = computed(() => {
return store.state.user.historyStatus return store.state.user.historyStatus
...@@ -114,7 +113,7 @@ ...@@ -114,7 +113,7 @@
return (props.detail as Detail).tabList.find(item => item.id == activeIndex.value).imgIdList return (props.detail as Detail).tabList.find(item => item.id == activeIndex.value).imgIdList
}) })
watch(() => watchStatus.value, () => { watch(watchStatus.value, () => {
activeIndex.value = (props.detail as Detail).defultActiveId || 0 activeIndex.value = (props.detail as Detail).defultActiveId || 0
tabIndex.value = (props.detail as Detail).defultTabId tabIndex.value = (props.detail as Detail).defultTabId
}) })
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
imgUrl?: string imgUrl?: string
} }
const INFO_LIST: InfoListItem[] = [ const INFO_LIST: Array<InfoListItem> = [
{ {
id: 1, id: 1,
title: "客户付款凭证", title: "客户付款凭证",
...@@ -92,19 +92,19 @@ ...@@ -92,19 +92,19 @@
}) })
const emit = defineEmits(['update:showPayPage', 'finish']) const emit = defineEmits(['update:showPayPage', 'finish'])
const infoList = ref<InfoListItem[]>(JSON.parse(JSON.stringify(INFO_LIST))) const infoList = ref<Array<InfoListItem>>(JSON.parse(JSON.stringify(INFO_LIST)) as Array<InfoListItem>)
const previewImg = ref<string>('') const previewImg = ref<string>('')
const isPreview = ref<boolean>(false) const isPreview = ref<boolean>(false)
const watchBooksList = computed(() => { const watchBooksList = computed<Array<InfoListItem>>(() => {
return state.audio.booksList return state.audio.booksList
}) })
watch(() => watchBooksList.value, (newValue: InfoListItem[]) => { watch(() => watchBooksList.value, (newValue: Array<InfoListItem>) => {
if (newValue && newValue.length) { if (newValue != null && newValue.length > 0) {
infoList.value = newValue infoList.value = newValue
} else { } else {
infoList.value = JSON.parse(JSON.stringify(INFO_LIST)) infoList.value = JSON.parse(JSON.stringify(INFO_LIST)) as Array<InfoListItem>
} }
}, { immediate: true }) }, { immediate: true })
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
// "imgUrl", // "imgUrl",
// url // url
// ); // );
infoList.value[index].imgUrl = url // infoList.value[index].imgUrl = url
// setBooks(utils.deepClone(infoList.value)) // setBooks(utils.deepClone(infoList.value))
} catch (error) { } catch (error) {
console.error(`上传付款凭证失败:${error}`) console.error(`上传付款凭证失败:${error}`)
...@@ -160,16 +160,17 @@ ...@@ -160,16 +160,17 @@
// 删除图片 // 删除图片
function close(index: number): void { function close(index: number): void {
infoList.value[index].imgUrl = '' infoList.value[index].imgUrl = ''
dispatch('setBooks', JSON.parse(JSON.stringify(infoList.value))) dispatch('setBooks', JSON.parse(JSON.stringify(infoList.value)) as Array<InfoListItem>)
} }
// 预览图片 // 预览图片
function preview(index: number): void { function preview(index: number): void {
isPreview.value = true isPreview.value = true
previewImg.value = infoList.value[index].imgUrl || '' previewImg.value = infoList.value[index].imgUrl != null ? infoList.value[index].imgUrl : ''
const imageUrl: string = infoList.value[index].imgUrl != null ? infoList.value[index].imgUrl : ''
uni.previewImage({ uni.previewImage({
urls: [infoList.value[index].imgUrl || ''], urls: [imageUrl],
longPressActions: { longPressActions: {
success: function (data) { success: function (data) {
console.log( console.log(
...@@ -314,4 +315,4 @@ ...@@ -314,4 +315,4 @@
.preview-img { .preview-img {
height: 1300rpx; height: 1300rpx;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
const title = ref<string>('') const title = ref<string>('')
const accountInfo = ref<Record<string, any>>({}) const accountInfo = ref<Record<string, any>>({})
const payInfo = ref<Record<string, any>>({}) const payInfo = ref<Record<string, any>>({})
const popup = ref<any>(null) const popup = ref(null)
const visible = ref<boolean>(false) const visible = ref<boolean>(false)
// 使用传入的 paymentType 或从 store 获取 // 使用传入的 paymentType 或从 store 获取
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
:penSwitch="penSwitch" :penSwitch="penSwitch"
:show="id == item.id" :show="id == item.id"
:ref="'media' + item.id" :ref="'media' + item.id"
:title="item.detailTitle || ''" :title="title"
:madiaId="item.id" :madiaId="item.id"
@scale="scale" @scale="scale"
:ulList="item.ulList" :ulList="item.ulList"
...@@ -43,51 +43,51 @@ ...@@ -43,51 +43,51 @@
:isPreview="isPreview" :isPreview="isPreview"
:hasCarBrand="item.hasCarBrand" :hasCarBrand="item.hasCarBrand"
/> --> /> -->
<template v-if="item.componentName == 'reception'"> <template v-if="item.componentName == 'reception'">
<reception <reception
:views="item.receptionSourceDetailList || []" :views="item.receptionSourceDetailList || []"
:penSwitch="penSwitch" :penSwitch="penSwitch"
:show="id == item.id" :show="id == item.id"
:ref="(el) => setMediaRef(item.id, el)" :ref="(el) => setMediaRef(item.id, el)"
:title="item.detailTitle || ''" :title="title"
/> />
</template> </template>
<template v-else-if="item.componentName == 'history'"> <template v-else-if="item.componentName == 'history'">
<history <history
:show="id == item.id" :show="id == item.id"
:ref="(el) => setMediaRef(item.id, el)" :ref="(el) => setMediaRef(item.id, el)"
:title="item.detailTitle || ''" :title="title"
:madiaId="item.id" :madiaId="item.id"
/> />
</template> </template>
<template v-else-if="item.componentName == 'three-guarantees'"> <template v-else-if="item.componentName == 'three-guarantees'">
<three-guarantees <three-guarantees
:views="item.receptionSourceDetailList || []" :views="item.receptionSourceDetailList || []"
:penSwitch="penSwitch" :penSwitch="penSwitch"
:show="id == item.id" :show="id == item.id"
:ref="(el) => setMediaRef(item.id, el)" :ref="(el) => setMediaRef(item.id, el)"
:title="item.detailTitle || ''" :title="title"
:madiaId="item.id" :madiaId="item.id"
:detail="item" :detail="item"
/> />
</template> </template>
<template v-else-if="item.componentName == 'insurance'"> <template v-else-if="item.componentName == 'insurance'">
<insurance <insurance
:show="id == item.id" :show="id == item.id"
:ref="(el) => setMediaRef(item.id, el)" :ref="(el) => setMediaRef(item.id, el)"
:title="item.detailTitle || ''" :title="title"
:madiaId="item.id" :madiaId="item.id"
:penSwitch="penSwitch" :penSwitch="penSwitch"
:isPreview="isPreview" :isPreview="isPreview"
/> />
</template> </template>
<template v-else-if="item.componentName == 'CaseCenter'"> <template v-else-if="item.componentName == 'CaseCenter'">
<case-center <case-center
:detail="item" :detail="item"
:ref="(el) => setMediaRef(item.id, el)" :ref="(el) => setMediaRef(item.id, el)"
:title="item.detailTitle || ''" :title="title"
:show="id == item.id" :show="id == item.id"
/> />
</template> </template>
<template v-else> <template v-else>
...@@ -97,50 +97,50 @@ ...@@ -97,50 +97,50 @@
:penSwitch="penSwitch" :penSwitch="penSwitch"
:show="id == item.id" :show="id == item.id"
:ref="(el) => setMediaRef(item.id, el)" :ref="(el) => setMediaRef(item.id, el)"
:title="item.detailTitle || ''" :title="title"
:madiaId="item.id" :madiaId="item.id"
:hasCarBrand="item.hasCarBrand" :hasCarBrand="item.hasCarBrand"
/> />
</template> </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"
/>
<view
class="pen-box"
@click="drawStatus = !drawStatus"
>
<!-- <view :class="['sprite-icon', `${!drawStatus ? 'icon-pen' : 'icon-pen-active'}`]">
</view> -->
</view> </view>
</template> </template>
</template> <template v-if="type != 'preview'">
<pay-pop <template v-if="backZindex">
<tool-box
ref="toolRef"
:data="pageToolList"
:type="type"
@choose="choose"
@finish="open"
:id="id"
@toPay="toPay"
:showPayBtn="paymentTypeList.length"
/>
<view
class="pen-box"
@click="drawStatus = !drawStatus"
>
<!-- <view :class="['sprite-icon', `${!drawStatus ? 'icon-pen' : 'icon-pen-active'}`]">
</view> -->
</view>
</template>
</template>
<pay-pop
ref="payRef" ref="payRef"
:paymentType="paymentTypeList" :paymentType="paymentTypeList"
@jumpPay="showPayPage = true" @jumpPay="showPayPage = true"
> >
</pay-pop> </pay-pop>
<informationEntry <informationEntry
v-model:showPayPage="showPayPage" v-model:showPayPage="showPayPage"
@finish="open" @finish="open"
/>
<finish-step
ref="stepRef"
@submit="done"
:titleTips="finishTips"
/> />
<finish-step
ref="stepRef"
@submit="done"
:titleTips="finishTips"
/>
</view> </view>
<BackPress ref="backpressRef" @openStep="openStep" @backHome="backHome" /> <BackPress ref="backpressRef" @openStep="openStep" @backHome="backHome" />
</template> </template>
...@@ -165,67 +165,72 @@ ...@@ -165,67 +165,72 @@
import { getSoureData } from '@/api/system-api.uts' import { getSoureData } from '@/api/system-api.uts'
import { findPayInfo as findPayInfoApi } from '@/api/common-api.uts' import { findPayInfo as findPayInfoApi } from '@/api/common-api.uts'
type BackPressEvent = {
from: string
}
const backZindex = ref<number>(9) const backZindex = ref<number>(9)
const drawStatus = ref<boolean>(false) const drawStatus = ref<boolean>(false)
const startX = ref<any>(null) const startX = ref(null)
const startY = ref<any>(null) const startY = ref(null)
const screenWidth = ref<any>(null) const screenWidth = ref(null)
const scaleValueObject = ref<UJSObject>({}) const scaleValueObject = ref<Record<string, number>>({})
const showPayPage = ref<boolean>(false) const showPayPage = ref<boolean>(false)
const productModelStatus = ref<boolean>(false) const productModelStatus = ref<boolean>(false)
const modeName = ref<string>('') const modeName = ref<string>('')
const pageToolList = ref<Array>([]) const pageToolList = ref<Array<any>>([])
const moduleList = ref<Array>([]) const moduleList = ref<Array<any>>([])
const useCarConfig = ref<boolean>(false) const useCarConfig = ref<boolean>(false)
const dateilKey = ref<number>(Date.now()) const dateilKey = ref<number>(Date.now())
const currentMediaId = ref<string>('') const currentMediaId = ref<string>('')
const id = ref<string>('') const id = ref<string>('')
const type = ref<string>('') const type = ref<string>('')
const media = ref<Array>([]) const media = ref<Array<any>>([])
const toolList = ref<Array>([]) const toolList = ref<Array<any>>([])
const paymentTypeList = ref<Array<any>>([]) const paymentTypeList = ref<Array<any>>([])
// 用于存储动态 ref 的对象 // 用于存储动态ref 的对象
const mediaRefs = ref<Record<string, any>>({}) const mediaRefs = ref<Record<string, any>>({})
// 设置动态 ref 的函数 // 设置动态 ref 的函数
const setMediaRef = (id: string | number, component: any): void => { const setMediaRef = (id: string | number, component: any): void => {
if (component) { if (component) {
mediaRefs.value[`media${id}`] = component mediaRefs.value[`media${id}`] = component
} }
} }
onBackPress((event: {from: string}) => {
console.log('返回键触发', event.from) onBackPress((event: BackPressEvent) => {
console.log('返回键触发', event.from)
if (event.from === 'backbutton') {
// 如果是预览模式,直接返回 if (event.from === 'backbutton') {
if (type.value === 'preview') { // 如果是预览模式,直接返回
uni.navigateBack() if (type.value === 'preview') {
} else { uni.navigateBack()
// 非预览模式,执行自定义返回逻辑 } else {
back() // 非预览模式,执行自定义返回逻辑
back()
}
// 返回 true 阻止默认的返回行为
return true
} }
// 返回 true 阻止默认的返回行为
return true // 其他情况允许正常返回
} return false
})
// 其他情况允许正常返回
return false
})
const channelType = computed(() => { const channelType = computed(() => {
const { channelType } = storage.get('userInfo') const userInfo = storage.get('userInfo')
return channelType return userInfo?.channelType
}) })
const shopMerchantId = computed(() => { const shopMerchantId = computed(() => {
const { shopMerchantId } = storage.get('userInfo') const userInfo = storage.get('userInfo')
return shopMerchantId return userInfo?.shopMerchantId
}) })
const sceneType = computed(() => { const sceneType = computed(() => {
const { sceneType } = storage.get('userInfo') const userInfo = storage.get('userInfo')
return sceneType return userInfo?.sceneType
}) })
const currentCarInfo = computed(() => { const currentCarInfo = computed(() => {
...@@ -233,16 +238,23 @@ ...@@ -233,16 +238,23 @@
}) })
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
}) })
const penSwitch = computed(() => { const penSwitch = computed(() => {
return !isPreview.value && drawStatus.value return isPreview.value === false && drawStatus.value === true
}) })
const title = computed(() => { const title = computed(() => {
let name = media.value.find(e => e.id == id.value)?.detailTitle || '' let name = media.value.find(e => e.id == id.value)?.detailTitle != null ? media.value.find(e => e.id == id.value)?.detailTitle : ''
return name return name
}) })
...@@ -256,42 +268,42 @@ ...@@ -256,42 +268,42 @@
return type.value == 'preview' return type.value == 'preview'
}) })
const viewKey = computed(() => { const viewKey = computed(() => {
return state.user.viewKey return state.user.viewKey
}) })
watch(() => viewKey.value, (newval) => { watch(() => viewKey.value, (newval) => {
if(id.value) setPageData() if(id.value != null && id.value !== '') setPageData()
}, { immediate: true }) }, { immediate: true })
watch(() => watchStatus.value, (newval) => { watch(watchStatus.value, (newval) => {
useCarConfig.value = false useCarConfig.value = false
dateilKey.value = Date.now() dateilKey.value = Date.now()
pageToolList.value = toolList.value pageToolList.value = toolList.value
currentMediaId.value = id.value currentMediaId.value = id.value
if (newval) drawStatus.value = false if (newval === true) drawStatus.value = false
}, { immediate: true }) }, { immediate: true })
watch(() => id.value, (newval) => { watch(() => id.value, (newval) => {
if (!pageToolList.value.length) pageToolList.value = toolList.value if (pageToolList.value.length == 0) pageToolList.value = toolList.value
}, { immediate: true }) }, { immediate: true })
onMounted(() => { onMounted(() => {
const systemInfo = uni.getSystemInfoSync() const systemInfo = uni.getSystemInfoSync()
screenWidth.value = systemInfo.screenWidth screenWidth.value = systemInfo.screenWidth
}) })
onLoad((options: OnLoadOptions) => { onLoad((options) => {
dispatch('setCustomerInfo', {}) dispatch('setCustomerInfo', {})
const storageKey = `source_${sceneType.value}_${shopMerchantId.value}` const storageKey = `source_${sceneType.value}_${shopMerchantId.value}`
const data = uni.getStorageSync(storageKey) const data = uni.getStorageSync(storageKey)
id.value = options.id id.value = options.id ?? ''
type.value = options.type type.value = options.type ?? ''
toolList.value = data.toolList if (data != null) {
media.value = data.moduleList toolList.value = data.toolList
media.value = data.moduleList
}
setPageData() setPageData()
findPayInfo() findPayInfo()
}) })
...@@ -305,7 +317,7 @@ ...@@ -305,7 +317,7 @@
} }
function handleFull(val: boolean) { function handleFull(val: boolean) {
backZindex.value = val ? 0 : 9 backZindex.value = val === true ? 0 : 9
} }
function choose(e: any): void { function choose(e: any): void {
...@@ -322,15 +334,15 @@ ...@@ -322,15 +334,15 @@
const refsToClose: Array<any> = [] const refsToClose: Array<any> = []
// 收集所有 media 开头的 ref // 收集所有 media 开头的 ref
const currentList = useCarConfig.value ? moduleList.value : media.value const currentList = useCarConfig.value === true ? moduleList.value : media.value
currentList.forEach(item => { currentList.forEach(item => {
const refName = `media${item.id}` const refName = `media${item.id}`
const refValue = mediaRefs.value[refName] const refValue = mediaRefs.value[refName]
if (refValue) { if (refValue != null) {
// 处理可能是数组的情况(v-for 生成的 ref 通常是数组) // 处理可能是数组的情况(v-for 生成的 ref 通常是数组)
const componentInstance = Array.isArray(refValue) ? refValue[0] : refValue const componentInstance = Array.isArray(refValue) ? refValue[0] : refValue
if (componentInstance && componentInstance.closeAllPopup) { if (componentInstance != null && componentInstance.closeAllPopup != null) {
componentInstance.closeAllPopup() componentInstance.closeAllPopup()
} }
} }
...@@ -341,9 +353,9 @@ ...@@ -341,9 +353,9 @@
payRef, payRef,
stepRef] stepRef]
fixedRefs.forEach(ref => { fixedRefs.forEach(ref => {
if (ref && ref.value) { if (ref != null && ref.value != null) {
const componentInstance = ref.value const componentInstance = ref.value
if (componentInstance.closeAllPopup) { if (componentInstance.closeAllPopup != null) {
componentInstance.closeAllPopup() componentInstance.closeAllPopup()
} }
} }
...@@ -354,9 +366,15 @@ ...@@ -354,9 +366,15 @@
dispatch('clearHistory') dispatch('clearHistory')
dispatch('clearReceptionTrack') dispatch('clearReceptionTrack')
} }
function back (): void{ function back(): void {
if(showPayPage.value) return showPayPage.value = false if(showPayPage.value === true) {
if(!isPreview.value) return backpressRef.value.open() showPayPage.value = false
return
}
if(isPreview.value === false) {
backpressRef.value?.open()
return
}
backHome() backHome()
} }
...@@ -366,34 +384,34 @@ ...@@ -366,34 +384,34 @@
stepRef.value.close() stepRef.value.close()
// receptionTrackLeave() // receptionTrackLeave()
} }
function backHome():void{ function backHome():void{
clearHistory() clearHistory()
uni.navigateBack() uni.navigateBack()
} }
function toPay(): void { function toPay(): void {
payRef.value?.show() payRef.value?.show()
} }
function touchStart(e: any) { function touchStart(e: any) {
if (!drawStatus.value && e.changedTouches?.length) { if (drawStatus.value === false && e.changedTouches != null && e.changedTouches.length > 0) {
startX.value = e.changedTouches[0].pageX startX.value = e.changedTouches[0].pageX
startY.value = e.changedTouches[0].pageY startY.value = e.changedTouches[0].pageY
} }
} }
function touchEnd(e: any) { function touchEnd(e: any) {
if (modeName.value) return if (modeName.value != null && modeName.value !== '') return
try { try {
if (!e || !e.changedTouches || drawStatus.value || pageToolList.value.length == 0 || e.changedTouches.length === 0) return if (e == null || e.changedTouches == null || drawStatus.value === true || pageToolList.value.length == 0 || (e.changedTouches.length == 0)) return
let halfScreenWidth = screenWidth.value / 2, let halfScreenWidth = screenWidth.value / 2,
touch = e.changedTouches[0], touch = e.changedTouches[0],
isDistanceSignificant = Math.abs(touch.pageX - startX.value) > screenWidth.value / 6, isDistanceSignificant = Math.abs(touch.pageX - startX.value) > screenWidth.value / 6,
index = pageToolList.value.findIndex((item: any) => item.id == id.value) index = pageToolList.value.findIndex((item: any) => item.id == id.value)
if (Math.abs(startY.value - touch.pageY) > 150) return if (Math.abs(startY.value - touch.pageY) > 150) return
if (!scaleValueObject.value[id.value]) scaleValueObject.value[id.value] = 1 if (scaleValueObject.value[id.value] == null) scaleValueObject.value[id.value] = 1
if (isDistanceSignificant && index != -1 && scaleValueObject.value[id.value] == 1 && !productModelStatus.value) { if (isDistanceSignificant === true && index != -1 && scaleValueObject.value[id.value] == 1 && productModelStatus.value === false) {
const { nextId, modeName: modeNameVal, title: titleVal } = getNextId(index, pageToolList.value, startX.value, halfScreenWidth) const { nextId, modeName: modeNameVal, title: titleVal } = getNextId(index, pageToolList.value, startX.value, halfScreenWidth)
modeName.value = modeNameVal modeName.value = modeNameVal
// receptionTrackLeave() // receptionTrackLeave()
...@@ -408,8 +426,8 @@ ...@@ -408,8 +426,8 @@
} }
} }
function getNextId(index: number, pageToolList: Array, startX: number, halfScreenWidth: number) { function getNextId(index: number, pageToolList: Array<any>, startX: number, halfScreenWidth: number) {
let nextItem = {}, let nextItem: any = {},
modeName = '' modeName = ''
if (startX > halfScreenWidth) { if (startX > halfScreenWidth) {
nextItem = index === pageToolList.length - 1 ? pageToolList[0] : pageToolList[index + 1] nextItem = index === pageToolList.length - 1 ? pageToolList[0] : pageToolList[index + 1]
...@@ -426,8 +444,7 @@ ...@@ -426,8 +444,7 @@
} }
function scale(e: number) { function scale(e: number) {
let { id } = props scaleValueObject.value[id.value] = e
scaleValueObject.value[id] = e
} }
async function setPageData() { async function setPageData() {
...@@ -441,31 +458,32 @@ ...@@ -441,31 +458,32 @@
try { try {
console.log('try',currentCarInfo.value) console.log('try',currentCarInfo.value)
let requestData = await getSoureData(shopMerchantId.value, sceneType.value, params) let requestData = await getSoureData(shopMerchantId.value, sceneType.value, params)
if (requestData) setViewInfo(requestData) if (requestData != null) setViewInfo(requestData)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
if (data) setViewInfo(data) if (data != null) setViewInfo(data)
} }
} }
function setViewInfo(data: any): void { function setViewInfo(data: any): void {
const currentMediaIdVal = currentMediaId.value if (data == null) return
const pageId = id.vlaue
const pageId = id.value
const useCarConfigVal = useCarConfig.value const useCarConfigVal = useCarConfig.value
const pageModuleListVal = moduleList.value const pageModuleListVal = moduleList.value
const pageMediaVal = media.value const pageMediaVal = media.value
const array = useCarConfigVal ? pageModuleListVal : pageMediaVal const array = useCarConfigVal === true ? pageModuleListVal : pageMediaVal
const findItem = array.find(item => item.id == pageId) const findItem = array.find(item => item.id == pageId)
const detailTitle = findItem?.detailTitle || '' const detailTitle = findItem != null ? (findItem.detailTitle != null ? findItem.detailTitle : '') : ''
// receptionTrackLeave() // receptionTrackLeave()
moduleList.value = data.moduleList moduleList.value = data.moduleList
pageToolList.value = data.toolList pageToolList.value = data.toolList
useCarConfig.value = true useCarConfig.value = true
if (id != currentMediaIdVal) { if (id.value != currentMediaId.value) {
const jumpItem = data.moduleList.find(e => e.detailTitle == detailTitle) const jumpItem = data.moduleList.find(e => e.detailTitle == detailTitle)
id.value = jumpItem ? jumpItem.id : data.moduleList[0].id id.value = jumpItem != null ? jumpItem.id : data.moduleList[0].id
} }
currentMediaId.value = data.id currentMediaId.value = data.id
} }
...@@ -474,31 +492,31 @@ ...@@ -474,31 +492,31 @@
const userInfo = storage.get('userInfo') const userInfo = storage.get('userInfo')
const userInfoObj = userInfo as UTSJSONObject const userInfoObj = userInfo as UTSJSONObject
const shopMerchantId = userInfoObj['shopMerchantId'] as string | number const shopMerchantId = userInfoObj['shopMerchantId'] as string | number
const data = await findPayInfoApi({ const data = await findPayInfoApi({
merchantId: shopMerchantId merchantId: shopMerchantId
}) })
let paymentType: Array<any> = [] let paymentType: Array<any> = []
data.find((item: any) => { data.find((item: any) => {
if (item.paymentType == 1) { if (item.paymentType == 1) {
paymentType.push({ paymentType.push({
name: '扫码支付', name: '扫码支付',
type: 1, type: 1,
title: '付款二维码', title: '付款二维码',
...item ...item
}) })
} }
if (item.paymentType == 2) { if (item.paymentType == 2) {
paymentType.push({ paymentType.push({
name: '对公账户', name: '对公账户',
type: 2, type: 2,
title: '付款方式', title: '付款方式',
...item ...item
}) })
} }
}) })
paymentTypeList.value = paymentType paymentTypeList.value = paymentType
} }
...@@ -507,10 +525,10 @@ ...@@ -507,10 +525,10 @@
'back', 'back',
'done']) 'done'])
const toolRef = ref<any>(null) const toolRef = ref(null)
const payRef = ref<any>(null) const payRef = ref(null)
const stepRef = ref<any>(null) const stepRef = ref(null)
const backpressRef = ref<any>(null) const backpressRef = ref(null)
</script> </script>
<style lang="scss"> <style lang="scss">
...@@ -519,17 +537,17 @@ ...@@ -519,17 +537,17 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
margin: 0 auto; margin: 0 auto;
&::after { &::after {
content: ''; content: '';
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-image: url('@/assets/images/common/home-bg-1.webp'); background-image: url('@/assets/images/common/home-bg-1.webp');
background-size: 100% 100%; background-size: 100% 100%;
z-index: -1; z-index: -1;
} }
} }
.nav-bar { .nav-bar {
position: fixed; position: fixed;
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { state , dispatch } from "@/store/index.uts"; import { state , dispatch } from "@/store/index.uts";
import HomeFrame from '@/components/HomeFrame/index.uvue' import HomeFrame from '@/components/HomeFrame/index.uvue'
import { getMerchantCarBrandList, getEmployeeList , getCarBrandsListApi } from '@/api/common-api.uts' import { getMerchantCarBrandList, getEmployeeListApi , getCarBrandsListApi } from '@/api/common-api.uts'
import { getMockData, getSoureData } from '@/api/system-api.uts' import { getMockData, getSoureData } from '@/api/system-api.uts'
const homeRef = ref(null) const homeRef = ref(null)
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
function handleStart(): void { function handleStart(): void {
const currentModuleList = moduleList.value const currentModuleList = moduleList.value
if (!currentModuleList.length) { if (currentModuleList.length == 0) {
return uni.showToast({ return uni.showToast({
title: '该场景尚未配置素材,请联系总部人员', title: '该场景尚未配置素材,请联系总部人员',
icon: 'none' icon: 'none'
...@@ -99,17 +99,17 @@ ...@@ -99,17 +99,17 @@
getSoure(brandIdList, subBrandIdList) getSoure(brandIdList, subBrandIdList)
dispatch('setCarBrandsList', carBrandList) dispatch('setCarBrandsList', carBrandList)
storage.set('carBrandList', carBrandList) storage.set('carBrandList', carBrandList)
if (carBrandList.length) { if (carBrandList.length > 0) {
let index = 0 let index = 0
getCarBrandsList(carBrandList, index) getCarBrandsList(carBrandList, index)
} }
}) })
/**获取销售人员 */ /**获取销售人员 */
getEmployeeList({ getEmployeeListApi({
merchantId: shopMerchantId merchantId: shopMerchantId
}).then(res => { }).then(res => {
dispatch('setEmployeeList', res || []) dispatch('setEmployeeList', res != null ? res : [])
storage.set('employeeList', res || []) storage.set('employeeList', res != null ? res : [])
}) })
} }
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
const storageKey = `source_${sceneType}_${shopMerchantId}` const storageKey = `source_${sceneType}_${shopMerchantId}`
const data = uni.getStorageSync(storageKey) const data = uni.getStorageSync(storageKey)
if (data) { if (data != null) {
setViewInfo(data) setViewInfo(data)
} }
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
brandIdList: brandIdList, brandIdList: brandIdList,
subBrandIdList: subBrandIdList subBrandIdList: subBrandIdList
}) })
if (requestData) { if (requestData != null) {
setViewInfo(requestData) setViewInfo(requestData)
} else { } else {
loadComplete.value = true loadComplete.value = true
...@@ -140,15 +140,15 @@ ...@@ -140,15 +140,15 @@
} }
} }
onLoad((options: OnLoadOptions) => { onLoad((options) => {
getMockData(true).then(mockdata =>{ getMockData(true).then(mockdata =>{
console.log(mockdata,'===') console.log(mockdata,'===')
const userInfo = storage.get('userInfo') const userInfo = storage.get('userInfo')
const mockDataObj = mockdata as UTSJSONObject const mockDataObj = mockdata as UTSJSONObject
const {channelType} = userInfo as UTSJSONObject const {channelType} = userInfo as UTSJSONObject
if (channelType == 1 && mockDataObj.boutiqueDefaultCarBrandId) { if (channelType == 1 && mockDataObj.boutiqueDefaultCarBrandId != null) {
state.user.boutiqueDefaultCarBrandId = mockDataObj.boutiqueDefaultCarBrandId //默认车辆品牌 state.user.boutiqueDefaultCarBrandId = mockDataObj.boutiqueDefaultCarBrandId //默认车辆品牌
if (mockDataObj.defaultCarId) { if (mockDataObj.defaultCarId != null) {
state.user.defaultCarId = mockDataObj.defaultCarId //默认车系 state.user.defaultCarId = mockDataObj.defaultCarId //默认车系
} }
} }
...@@ -185,19 +185,19 @@ ...@@ -185,19 +185,19 @@
/**按序加载车型 */ /**按序加载车型 */
async function getCarBrandsList(carBrandList: Array<any>, index: number) { async function getCarBrandsList(carBrandList: Array<any>, index: number) {
const item = carBrandList[index] const item = carBrandList[index]
if (!item) return if (item == null) return
const storageKey = `${item.id}_${item.brandId}_carlist` const storageKey = `${item.id}_${item.brandId}_carlist`
const carList = uni.getStorageSync(storageKey) const carList = uni.getStorageSync(storageKey)
if (index < carBrandList.length - 1) { if (index < carBrandList.length - 1) {
const nextIndex = index + 1 const nextIndex = index + 1
if (!carList) { if (carList == null) {
const list = await getCarBrandsListApi({ const list = await getCarBrandsListApi({
brandId: item.brandId, brandId: item.brandId,
childBrandId: item.id childBrandId: item.id
}) })
if (list) { if (list != null) {
uni.setStorageSync(storageKey, list) uni.setStorageSync(storageKey, list)
} }
getCarBrandsList(carBrandList, nextIndex) getCarBrandsList(carBrandList, nextIndex)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!