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