Commit f1259e46 by 李伟康

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

- 将getEmployeeList函数重命名为getEmployeeListApi
- 更新BackPress组件中的组件实例调用方式为$callMethod
- 重构CarBrands组件的数据类型定义和状态管理逻辑
- 优化CustomPopup组件中的位置映射计算方法
- 调整CustomerAutocomplete组件的模板结构和样式
- 修复组件中多处类型安全问题并改进响应式数据处理
1 parent d901015c
Showing 25 changed files with 495 additions and 422 deletions
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import http from "@/api/request/http.uts"; import http from "@/api/request/http.uts";
/** 获取交付人员列表 */ /** 获取交付人员列表 */
export function getEmployeeList(data: UTSJSONObject): Promise<any> { export function getEmployeeListApi(data: UTSJSONObject): Promise<any> {
return http.post({ return http.post({
'method': 'dj.api.smartcarlife.employee.getByMerchantId.new', 'method': 'dj.api.smartcarlife.employee.getByMerchantId.new',
'projectName': 'boutique', 'projectName': 'boutique',
......
...@@ -8,12 +8,16 @@ ...@@ -8,12 +8,16 @@
</template> </template>
<template v-else> <template v-else>
完成接待 完成接待
<text>(推荐)</text> <text>
(推荐)
</text>
</template> </template>
</view> </view>
<view class="footer-btn cancel flex" @click="$emit('backHome')"> <view class="footer-btn cancel flex" @click="$emit('backHome')">
仍要退出 仍要退出
<text>(不推荐)</text> <text>
(不推荐)
</text>
</view> </view>
</view> </view>
</MessageBox> </MessageBox>
...@@ -21,6 +25,7 @@ ...@@ -21,6 +25,7 @@
<script setup lang="uts"> <script setup lang="uts">
import MessageBox from './MessageBox.uvue' import MessageBox from './MessageBox.uvue'
import { ComponentPublicInstance } from 'vue'
const props = defineProps({ const props = defineProps({
finishDoneText: String, finishDoneText: String,
...@@ -29,22 +34,19 @@ ...@@ -29,22 +34,19 @@
default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」' default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」'
} }
}) })
const finishRef = ref(null)
function open(): void { function open(): void {
finishRef.value.open() (finishRef.value as ComponentPublicInstance).$callMethod('open')
} }
function hide(): void { function hide(): void {
finishRef.value.close() (finishRef.value as ComponentPublicInstance).$callMethod('close')
} }
const finishRef = ref<any>(null)
const emit = defineEmits(['openStep', 'backHome']) const emit = defineEmits(['openStep', 'backHome'])
defineExpose({ defineExpose({ open, hide })
open,
hide
})
</script> </script>
<style lang="scss"> <style lang="scss">
.footer { .footer {
border-top: 2rpx solid #eff0f2; border-top: 2rpx solid #eff0f2;
font-weight: 600; font-weight: 600;
font-size: 32rpx; font-size: 32rpx;
...@@ -76,5 +78,5 @@ ...@@ -76,5 +78,5 @@
text { text {
font-size: 24rpx; font-size: 24rpx;
} }
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -10,13 +10,14 @@ ...@@ -10,13 +10,14 @@
:class="[`popup-${positionClass}`, { 'content-visible': isAnimated }]" :class="[`popup-${positionClass}`, { 'content-visible': isAnimated }]"
@click.stop @click.stop
> >
<slot></slot> <slot>
</slot>
</view> </view>
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
const props = defineProps({ const props = defineProps({
visible: { visible: {
type: Boolean, type: Boolean,
default: false default: false
...@@ -33,35 +34,56 @@ const props = defineProps({ ...@@ -33,35 +34,56 @@ const props = defineProps({
type: Number, type: Number,
default: 300 default: 300
} }
}) })
const emit = defineEmits(['update:visible', 'close', 'mask-click', 'opened', 'closed']) 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(() => { function close(): void {
const positionMap: Record<string, string> = { emit('update:visible', false)
emit('close')
}
function open(): void {
emit('update:visible', true)
}
function handleMaskClick(): void {
emit('mask-click')
if (props.maskClosable) {
close()
}
}
const showMask = ref<boolean>(props.visible)
const isAnimated = ref<boolean>(false)
let closeTimer: any | null = null
let openTimer: any | null = null
const positionClass = computed<string>(() => {
const positionMap: UTSJSONObject = {
'top': 'top', 'top': 'top',
'center': 'center', 'center': 'center',
'bottom': 'bottom', 'bottom': 'bottom',
'left': 'left', 'left': 'left',
'right': 'right' 'right': 'right'
} as UTSJSONObject
const mappedValue = positionMap[props.position] as string | null
if (mappedValue == null) {
return 'center'
} }
return positionMap[props.position] || 'center' return mappedValue
}) })
watch(() => props.visible, (newVal) => { watch(props.visible, (newVal: boolean) => {
if (newVal) { if (newVal == true) {
// 打开流程 // 打开流程
if (closeTimer) { if (closeTimer != null) {
clearTimeout(closeTimer) clearTimeout(closeTimer as number)
closeTimer = null closeTimer = null
} }
if (openTimer) { if (openTimer != null) {
clearTimeout(openTimer) clearTimeout(openTimer as number)
openTimer= null openTimer= null
} }
...@@ -80,8 +102,8 @@ watch(() => props.visible, (newVal) => { ...@@ -80,8 +102,8 @@ watch(() => props.visible, (newVal) => {
} else { } else {
// 关闭流程 // 关闭流程
if (openTimer) { if (openTimer != null) {
clearTimeout(openTimer) clearTimeout(openTimer as number)
openTimer = null openTimer = null
} }
...@@ -92,32 +114,15 @@ watch(() => props.visible, (newVal) => { ...@@ -92,32 +114,15 @@ watch(() => props.visible, (newVal) => {
emit('closed') emit('closed')
}, props.duration) }, props.duration)
} }
}, { immediate: true }) }, { immediate: true })
function handleMaskClick(): void {
emit('mask-click')
if (props.maskClosable) {
close()
}
}
function close(): void {
emit('update:visible', false)
emit('close')
}
function open(): void {
emit('update:visible', true)
}
defineExpose({ defineExpose({ open, close })
open,
close
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.custom-popup-mask { .custom-popup-mask {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
...@@ -134,9 +139,9 @@ defineExpose({ ...@@ -134,9 +139,9 @@ defineExpose({
&.mask-visible { &.mask-visible {
opacity: 1; opacity: 1;
} }
} }
.custom-popup-content { .custom-popup-content {
position: absolute; position: absolute;
max-height: 90%; max-height: 90%;
opacity: 0; opacity: 0;
...@@ -213,5 +218,5 @@ defineExpose({ ...@@ -213,5 +218,5 @@ defineExpose({
transform: translateX(0) translateY(-50%); transform: translateX(0) translateY(-50%);
} }
} }
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<view :class="['customer-box',{'is-show':showCustomerBox}]"> <view :class="['customer-box',{'is-show':showCustomerBox}]">
<view class="customer-title">客户档案的记录</view> <view class="customer-title">
客户档案的记录
</view>
<scroll-view <scroll-view
scroll-y scroll-y
class="scroll-box" class="scroll-box"
...@@ -12,7 +14,8 @@ ...@@ -12,7 +14,8 @@
:size="46" :size="46"
color="#3773F8" color="#3773F8"
class="icon" class="icon"
></uni-icons> >
</uni-icons>
</view> </view>
</template> </template>
<template v-else> <template v-else>
...@@ -30,7 +33,8 @@ ...@@ -30,7 +33,8 @@
</template> </template>
<template v-else> <template v-else>
<view class="nothing flex"> <view class="nothing flex">
<view class="icon"></view> <view class="icon">
</view>
未匹配到客户信息 未匹配到客户信息
</view> </view>
</template> </template>
...@@ -43,53 +47,41 @@ ...@@ -43,53 +47,41 @@
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { state } from '@/store/index.uts' import { state } from '@/store/index.uts'
import { getCustomerInfoListApi } from '@/api/customer-api.uts' import { getCustomerInfoListApi } from '@/api/customer-api.uts'
interface CustomerInfo { type CustomerInfo = UTSJSONObject
ownerPhone?: string
ownerName?: string
[key: string]: any
}
interface UserInfo { type UserInfo = UTSJSONObject
shopMerchantId: string
sceneType: number
[key: string]: any
}
interface SearchParams { type SearchParams = {
merchantId: string merchantId: string
bussinessScene: number bussinessScene: number
ownerPhone?: string ownerPhone?: string
ownerName?: string ownerName?: string
} }
const props = defineProps({ const props = defineProps({
searchValue: String, searchValue: String,
showType: String, showType: String,
show: Boolean show: Boolean
}) })
const emit = defineEmits(['choose'])
const loading = ref<boolean>(true) const emit = defineEmits(['choose'])
const searchList = ref<Array<CustomerInfo>>([])
const showCustomerBox = computed<boolean>(() => { const loading = ref<boolean>(true)
return props.show && state.user?.haveCustomerAccess && props.searchValue const searchList = ref<Array<CustomerInfo>>([])
})
watch(() => showCustomerBox.value, (newval) => { const showCustomerBox = computed<boolean>(() => {
if (newval) { const searchValue = props.searchValue ?? ''
getCustomerInfoList(props.searchValue || '', props.showType || '') return props.show == true && (state.user?.haveCustomerAccess ?? false) && (searchValue !== '' && searchValue !== null)
} })
}, { immediate: true }) async function getCustomerInfoList(val: string, type: string): Promise<void> {
async function getCustomerInfoList(val: string, type: string): Promise<void> {
try { try {
loading.value = true loading.value = true
const userInfo: UserInfo = storage.get("userInfo") || { shopMerchantId: '', sceneType: 0 } const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null
const userInfoObj = userInfo ?? { shopMerchantId: '', sceneType: 0 }
const shopMerchantId = userInfoObj.shopMerchantId
const params: SearchParams = { const params: SearchParams = {
merchantId: userInfo.shopMerchantId, merchantId: shopMerchantId as String,
bussinessScene: userInfo.sceneType == 0 ? 1 : 2 bussinessScene: userInfoObj.sceneType == 0 ? 1 : 2
} }
if (type == 'tel') { if (type == 'tel') {
...@@ -98,22 +90,28 @@ async function getCustomerInfoList(val: string, type: string): Promise<void> { ...@@ -98,22 +90,28 @@ async function getCustomerInfoList(val: string, type: string): Promise<void> {
params.ownerName = val params.ownerName = val
} }
const result = await getCustomerInfoListApi(params) const result = await getCustomerInfoListApi(params as UTSJSONObject)
searchList.value = result || [] searchList.value = result as UTSArray<UTSJSONObject>
loading.value = false loading.value = false
} catch (error) { } catch (error) {
loading.value = false loading.value = false
console.error('获取客户信息失败:', error)
} }
} }
watch(showCustomerBox.value , (newVal: boolean) => {
if (newVal == true) {
getCustomerInfoList(props.searchValue ?? '', props.showType ?? '')
}
}, { immediate: true })
function chooseItem(item: CustomerInfo): void {
function chooseItem(item: CustomerInfo): void {
emit('choose', item) emit('choose', item)
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.customer-box { .customer-box {
position: absolute; position: absolute;
left: 0; left: 0;
top: 88rpx; top: 88rpx;
...@@ -183,10 +181,10 @@ function chooseItem(item: CustomerInfo): void { ...@@ -183,10 +181,10 @@ function chooseItem(item: CustomerInfo): void {
} }
} }
} }
} }
.is-show { .is-show {
z-index: 1; z-index: 1;
opacity: 1; opacity: 1;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -26,18 +26,20 @@ ...@@ -26,18 +26,20 @@
import MessageBox from './MessageBox.uvue' import MessageBox from './MessageBox.uvue'
import { state, dispatch } from '@/store/index.uts' import { state, dispatch } from '@/store/index.uts'
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { getEmployeeList as getEmployeeListApi } from '@/api/common-api.uts' import { getEmployeeListApi } from '@/api/common-api.uts'
import { ComponentPublicInstance } from 'vue'
interface EmployeeItem { interface EmployeeItem {
staffName: string staffName: string
uuid: string uuid: string
[key: string]: any
} }
interface Props { interface Props {
title?: string title?: string
salesPropsUuid?: string salesPropsUuid?: string
} }
type UserInfo = UTSJSONObject
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
title: '销售', title: '销售',
...@@ -46,21 +48,42 @@ ...@@ -46,21 +48,42 @@
const emit = defineEmits(['close', 'select']) const emit = defineEmits(['close', 'select'])
const employeeBoxVisible = ref<any>(null) const employeeBoxVisible = ref(null)
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
}) })
const updateView = ref<number>(Date.now())
const salesUuid = computed(() => { const salesUuid = computed(() => {
return state.user.customerInfo.salesUuid || props.salesPropsUuid const val1 = state.user.customerInfo.salesUuid
const val2 = props.salesPropsUuid
return val1 !== null && val1 !== '' ? val1 : val2
}) })
const employeeList = computed(() => { // const employeeList = computed(() => {
return state.user.employeeList // return state.user.employeeList
}) // })
const employeeList = ref<Array<EmployeeItem>>([])
watch(updateView.value,()=>{
const list = storage.get("employeeList") as UTSArray<EmployeeItem>
employeeList.value = list !== null ? list : []
}, { immediate: true, deep: true })
function close(): void {
if (employeeBoxVisible.value != null) {
(employeeBoxVisible.value as ComponentPublicInstance).$callMethod('close')
}
}
watch(() => watchStatus.value, (newval: number) => { watch(watchStatus.value, (newval: number) => {
close() close()
}, { immediate: true }) }, { immediate: true })
...@@ -69,19 +92,21 @@ ...@@ -69,19 +92,21 @@
} }
function open(): void { function open(): void {
employeeBoxVisible.value?.open() if (employeeBoxVisible.value != null) {
const userInfo = storage.get('userInfo') (employeeBoxVisible.value as ComponentPublicInstance).$callMethod('open')
const userInfoObj = userInfo as any }
const shopMerchantId = userInfoObj?.shopMerchantId const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null
if (userInfo == null) return
const shopMerchantId = userInfo.shopMerchantId
// 获取销售人员列表 // 获取销售人员列表
getEmployeeListApi({ getEmployeeListApi({ merchantId: shopMerchantId }).then((res: any) => {
merchantId: shopMerchantId const employeeList = res as Array<EmployeeItem>
}).then((res: EmployeeItem[]) => { dispatch('setEmployeeList', employeeList)
dispatch('setEmployeeList', res) const listToStore = employeeList != null ? employeeList : []
storage.set('employeeList', res || []) storage.set('employeeList', listToStore, 0)
}).catch((error: any) => { updateView.value = Date.now()
console.error('获取员工列表失败:', error)
}) })
} }
...@@ -90,18 +115,12 @@ ...@@ -90,18 +115,12 @@
emit('select', item) emit('select', item)
} }
function close(): void {
employeeBoxVisible.value?.close()
}
defineExpose({ defineExpose({ open, close })
open,
close
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.select-box { .select-box {
margin: 40rpx 0; margin: 40rpx 0;
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
...@@ -124,5 +143,5 @@ ...@@ -124,5 +143,5 @@
border: 2rpx solid #292d33; border: 2rpx solid #292d33;
} }
} }
} }
</style> </style>
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
:position="position" :position="position"
:mask-closable="false" :mask-closable="false"
:duration="300" :duration="300"
@update:visible="visible = $event" @update:visible="visible = $event as Boolean"
@close="onClose" @close="onClose"
> >
<view <view
:class="['tips-wrapper',{'radius': position === 'center'}]" :class="['tips-wrapper',{'radius': position === 'center'}]"
:style="{ width: popupW + 'rpx', minHeight: popupH + 'rpx', maxHeight: maxHeight + 'rpx' }" :style="{ width: (popupW ?? 0) + 'rpx', minHeight: (popupH ?? 0) + 'rpx', maxHeight: (maxHeight ?? 0) + 'rpx' }"
> >
<view class="tips-content"> <view class="tips-content">
<view <view
...@@ -22,14 +22,16 @@ ...@@ -22,14 +22,16 @@
type="closeempty" type="closeempty"
:size="18" :size="18"
color="#1A1A1A" color="#1A1A1A"
></uni-icons> >
</uni-icons>
</view> </view>
<view class="tips-title"> <view class="tips-title">
<template v-if="back"> <template v-if="back">
<view <view
class="sprite-icon icon-back" class="sprite-icon icon-back"
@click="close" @click="close"
></view> >
</view>
</template> </template>
{{ title }} {{ title }}
</view> </view>
...@@ -37,7 +39,8 @@ ...@@ -37,7 +39,8 @@
class="tips-text" class="tips-text"
v-if="content" v-if="content"
>{{ content }}</text> >{{ content }}</text>
<slot></slot> <slot>
</slot>
</view> </view>
<view <view
class="tips-footer" class="tips-footer"
...@@ -58,16 +61,18 @@ ...@@ -58,16 +61,18 @@
}}</view> }}</view>
</view> </view>
<template v-else> <template v-else>
<slot name="footer"></slot> <slot name="footer">
</slot>
</template> </template>
</view> </view>
</CustomPopup> </CustomPopup>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import CustomPopup from './CustomPopup.uvue' import CustomPopup from './CustomPopup.uvue'
import { ComponentPublicInstance } from 'vue'
const props = defineProps({ const props = defineProps({
isAutoClose: { isAutoClose: {
type: Boolean, type: Boolean,
default: true default: true
...@@ -107,52 +112,53 @@ const props = defineProps({ ...@@ -107,52 +112,53 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: true default: true
} }
}) })
const emit = defineEmits(['close', 'cancel', 'confirm']) const emit = defineEmits(['close',
'cancel',
'confirm'])
const visible = ref<boolean>(false) const visible = ref<boolean>(false)
const popupRef= ref<any>(null) const popupRef= ref(null)
function onClose(): void { function onClose(): void {
emit('close') emit('close')
} }
function close(): void { function close(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false
} else { } else {
popupRef.value?.close() if (popupRef.value != null) {
(popupRef.value as ComponentPublicInstance).$callMethod('close')
}
} }
emit('close') emit('close')
} }
function open(): void { function open(): void {
visible.value = true visible.value = true
} }
function cancel(): void { function cancel(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false
} }
emit('cancel') emit('cancel')
} }
function confirm(): void { function confirm(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false
} }
emit('confirm') emit('confirm')
} }
defineExpose({ defineExpose({ open, close })
open,
close
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.tips-wrapper { .tips-wrapper {
background: #ffffff; background: #ffffff;
border-radius: 20rpx 20rpx 0 0; border-radius: 20rpx 20rpx 0 0;
height: 100%; height: 100%;
...@@ -207,7 +213,7 @@ defineExpose({ ...@@ -207,7 +213,7 @@ defineExpose({
justify-content: center; justify-content: center;
height: 100rpx; height: 100rpx;
border-top: 1px solid #e8e8e8; border-top: 1px solid #e8e8e8;
flex-direction: row; flex-direction: row;
.close { .close {
color: #6c6c70; color: #6c6c70;
} }
...@@ -225,9 +231,9 @@ flex-direction: row; ...@@ -225,9 +231,9 @@ flex-direction: row;
line-height: 44rpx; line-height: 44rpx;
font-weight: 500; font-weight: 500;
} }
} }
.radius{ .radius{
border-radius: 20rpx; border-radius: 20rpx;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
<view <view
class="zoom-pan-container" class="zoom-pan-container"
:style="{ 'overflow': 'hidden', 'position': 'relative', 'touch-action': 'none' }" :style="{ 'overflow': 'hidden', 'position': 'relative', 'touch-action': 'none' }"
@touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd"
> >
<!-- @touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd" -->
<view <view
class="content" class="content"
:style="contentStyle" :style="contentStyle"
...@@ -17,10 +18,29 @@ ...@@ -17,10 +18,29 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { throttle } from '@/utils/common.uts' import { throttle } from '@/utils/common.uts'
import { state } from "@/store/index.uts" import { state } from "@/store/index.uts"
type Point = {
x: number
y: number
}
type TouchPoint = {
pageX: number
pageY: number
clientX: number
clientY: number
x: number
y: number
}
type TouchEvent = {
touches: Array<TouchPoint>
changedTouches: Array<TouchPoint>
}
const props = defineProps({ const props = defineProps({
disabled: Boolean, disabled: Boolean,
scaleMax: { scaleMax: {
type: Number, type: Number,
...@@ -30,18 +50,18 @@ const props = defineProps({ ...@@ -30,18 +50,18 @@ const props = defineProps({
type: Number, type: Number,
default: 1 default: 1
} }
}) })
const scale = ref<number>(1) const scale = ref<number>(1)
const isScaling = ref<boolean>(false) const isScaling = ref<boolean>(false)
const initialDistance = ref<number>(0) const initialDistance = ref<number>(0)
const initialScale = ref<number>(1) const initialScale = ref<number>(1)
const translateX = ref<number>(0) const translateX = ref<number>(0)
const translateY = ref<number>(0) const translateY = ref<number>(0)
const lastTouchCenter = ref<{ x: number; y: number }>({ x: 0, y: 0 }) const lastTouchCenter = ref<Point>({ x: 0, y: 0 })
const currentTouchCenter = ref<{ x: number; y: number }>({ x: 0, y: 0 }) const currentTouchCenter = ref<Point>({ x: 0, y: 0 })
const contentStyle = computed(() => { const contentStyle = computed(() => {
return { return {
'transform': `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`, 'transform': `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`,
'transform-origin': 'center center', 'transform-origin': 'center center',
...@@ -53,103 +73,110 @@ const contentStyle = computed(() => { ...@@ -53,103 +73,110 @@ const contentStyle = computed(() => {
'width': '100%', 'width': '100%',
'height': '100%' 'height': '100%'
} }
}) })
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
}) if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
watch(() => watchStatus.value, (newval) => { watch(watchStatus.value , () => {
if (scale.value != 1) { if (scale.value != 1) {
scale.value = 1 scale.value = 1
translateX.value = 0 translateX.value = 0
translateY.value = 0 translateY.value = 0
} }
}, { immediate: true }) }, { immediate: true })
function handleTouchStart(e: any): void { // function handleTouchStart(e: TouchEvent): void {
if (props.disabled) return // if (props.disabled == true) return
if (e.touches.length === 2) { // if (e.touches.length === 2) {
isScaling.value = true // isScaling.value = true
initialDistance.value = getTouchDistance(e.touches) // initialDistance.value = getTouchDistance(e.touches)
initialScale.value = scale.value // initialScale.value = scale.value
const center = getTouchCenter(e.touches) // const center = getTouchCenter(e.touches)
lastTouchCenter.value = center // lastTouchCenter.value = center
currentTouchCenter.value = center // currentTouchCenter.value = center
} // }
} // }
const handleTouchMove = throttle(function(e: any): void { // const handleTouchMove = throttle(function(e: TouchEvent): void {
if (props.disabled) return // if (props.disabled == true) return
if (isScaling.value && e.touches.length === 2) { // if (isScaling.value && e.touches.length === 2) {
const currentDistance = getTouchDistance(e.touches) // const currentDistance = getTouchDistance(e.touches)
const newScale = Math.max( // const newScale = Math.max(
props.scaleMin, // props.scaleMin,
Math.min( // Math.min(
props.scaleMax, // props.scaleMax,
initialScale.value * (currentDistance / initialDistance.value) // initialScale.value * (currentDistance / initialDistance.value)
) // )
) // )
scale.value = newScale // scale.value = newScale
const center = getTouchCenter(e.touches) // const center = getTouchCenter(e.touches)
currentTouchCenter.value = center // currentTouchCenter.value = center
if (scale.value > 1) { // if (scale.value > 1) {
const deltaX = center.x - lastTouchCenter.value.x // const deltaX = center.x - lastTouchCenter.value.x
const deltaY = center.y - lastTouchCenter.value.y // const deltaY = center.y - lastTouchCenter.value.y
translateX.value += deltaX // translateX.value += deltaX
translateY.value += deltaY // translateY.value += deltaY
} // }
lastTouchCenter.value = center // lastTouchCenter.value = center
emit('scale', scale.value) // emit('scale', scale.value)
} // }
}, 16) // }, 16)
function handleTouchEnd(): void { // function handleTouchEnd(): void {
if (isScaling.value) { // if (isScaling.value) {
isScaling.value = false // isScaling.value = false
adjustPosition() // adjustPosition()
} // }
} // }
function adjustPosition(): void { function adjustPosition(): void {
if (scale.value <= 1) { if (scale.value <= 1) {
translateX.value = 0 translateX.value = 0
translateY.value = 0 translateY.value = 0
scale.value = 1 scale.value = 1
} }
} }
function getTouchDistance(touches: Array<any>): number { function getTouchDistance(touches: Array<TouchPoint>): number {
const dx = touches[0].pageX - touches[1].pageX const dx = touches[0].pageX - touches[1].pageX
const dy = touches[0].pageY - touches[1].pageY const dy = touches[0].pageY - touches[1].pageY
return Math.sqrt(dx * dx + dy * dy) return Math.sqrt(dx * dx + dy * dy)
} }
function getTouchCenter(touches: Array<any>): { x: number; y: number } { function getTouchCenter(touches: Array<TouchPoint>): Point {
const centerX = (touches[0].pageX + touches[1].pageX) / 2 const centerX = (touches[0].pageX + touches[1].pageX) / 2
const centerY = (touches[0].pageY + touches[1].pageY) / 2 const centerY = (touches[0].pageY + touches[1].pageY) / 2
return { x: centerX, y: centerY } return { x: centerX, y: centerY }
} }
const emit = defineEmits(['scale']) const emit = defineEmits(['scale'])
</script> </script>
<style lang="scss"> <style lang="scss">
.zoom-pan-container { .zoom-pan-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
touch-action: none; touch-action: none;
} }
.content { .content {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: absolute; position: absolute;
...@@ -157,5 +184,5 @@ const emit = defineEmits(['scale']) ...@@ -157,5 +184,5 @@ const emit = defineEmits(['scale'])
top: 0; top: 0;
transform-origin: center center; transform-origin: center center;
will-change: transform; will-change: transform;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<view class="tool-box" :style="toolStyle"> <view class="tool-box" :style="toolStyle as string">
<view :class="['btn', { hideIcon: !show }]" @click="show = false"> <view :class="['btn', { hideIcon: !show }]" @click="show = false">
<view class="icon sprite-icon icon-tool-file"> <view class="icon sprite-icon icon-tool-file">
</view> </view>
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
文件夹 文件夹
</view> </view>
<view class="list-body"> <view class="list-body">
<template v-for="(i, index) in data" :key="index"> <template v-for="(item, index) in displayData" :key="index">
<view :class="['item', { active: i[idKey] == id }]" @click="jump(i)"> <view :class="['item', { active: item.id == props.id }]" @click="jump(item)">
<image class="icon" :src="i.shortTitleUrl" mode="scaleToFill" /> <image class="icon" :src="item.shortTitleUrl" mode="scaleToFill" />
{{ i.shortTitle }} {{ item.shortTitle }}
</view> </view>
</template> </template>
</view> </view>
<template v-if="showPayBtn"> <template v-if="props.showPayBtn">
<view class="item" @click="toPay"> <view class="item" @click="toPay">
<view class="icon"> <view class="icon">
<view class="sprite-icon icon-tool-pay"> <view class="sprite-icon icon-tool-pay">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
付款方式 付款方式
</view> </view>
</template> </template>
<template v-if="type != 'preview'"> <template v-if="props.type != 'preview'">
<view class="item" @click="finish"> <view class="item" @click="finish">
<view class="icon"> <view class="icon">
<view class="sprite-icon icon-tool-finish"> <view class="sprite-icon icon-tool-finish">
...@@ -42,11 +42,18 @@ ...@@ -42,11 +42,18 @@
<script setup lang="uts"> <script setup lang="uts">
import { state } from "@/store/index.uts"; import { state } from "@/store/index.uts";
const emit = defineEmits(['choose', 'finish', 'toPay'])
type ToolItem = {
id?: string | number
shortTitleUrl?: string
shortTitle?: string
}
const props = defineProps({ const props = defineProps({
type: String, type: String,
data: Array, data: Array as () => Array<ToolItem>,
id: [String, id: [String, Number],
Number],
showPayBtn: Boolean, showPayBtn: Boolean,
idKey: { idKey: {
type: String, type: String,
...@@ -57,11 +64,25 @@ ...@@ -57,11 +64,25 @@
const show = ref<boolean>(true) const show = ref<boolean>(true)
const displayData = computed<Array<ToolItem>>(() => {
if (props.data == null) {
return []
}
return props.data as Array<ToolItem>
})
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
}) })
watch(() => watchStatus.value, (newval) => { watch(watchStatus.value, () => {
show.value = true show.value = true
}, { immediate: true }) }, { immediate: true })
...@@ -69,7 +90,21 @@ ...@@ -69,7 +90,21 @@
show.value = true show.value = true
} }
function jump(item: any): void { function getItemTitle(item: ToolItem): string {
if (item.shortTitle == null) {
return ''
}
return item.shortTitle
}
function getItemImageUrl(item: ToolItem): string {
if (item.shortTitleUrl == null) {
return ''
}
return item.shortTitleUrl
}
function jump(item: ToolItem): void {
show.value = true show.value = true
emit('choose', item) emit('choose', item)
} }
...@@ -82,12 +117,8 @@ ...@@ -82,12 +117,8 @@
emit('toPay') emit('toPay')
} }
const emit = defineEmits(['choose',
'finish', defineExpose({ hide })
'toPay'])
defineExpose({
hide
})
</script> </script>
......
...@@ -227,31 +227,27 @@ ...@@ -227,31 +227,27 @@
<script setup lang="uts"> <script setup lang="uts">
import { ref, computed, watch } from 'vue' import { ref, computed, watch } from 'vue'
interface ReceptionpriproCusCaseStageDetail { type ReceptionpriproCusCaseStageDetail = {
stageName: string stageName: string
imageUrl: string imageUrl: string
imageTag: string imageTag: string
[key: string]: any
} }
interface ReceptionpriproCusCaseStage { type ReceptionpriproCusCaseStage = {
receptionpriproCusCaseStageDetailList: Array<ReceptionpriproCusCaseStageDetail> receptionpriproCusCaseStageDetailList: Array<ReceptionpriproCusCaseStageDetail>
[key: string]: any
} }
interface ReceptionpriproCusCase { type ReceptionpriproCusCase = {
customerName: string customerName: string
licPlateNumber: string licPlateNumber: string
comAmount: string | number comAmount: string | number
receptionpriproCusCaseStageList: Array<ReceptionpriproCusCaseStage> receptionpriproCusCaseStageList: Array<ReceptionpriproCusCaseStage>
[key: string]: any
} }
interface DetailData { type DetailData = {
title: string title: string
productPoster: string productPoster: string
receptionpriproCusCaseList: Array<ReceptionpriproCusCase> receptionpriproCusCaseList: Array<ReceptionpriproCusCase>
[key: string]: any
} }
interface Thumbnail { interface Thumbnail {
......
...@@ -35,14 +35,13 @@ import CustomPopup from '@/components/CustomPopup.uvue' ...@@ -35,14 +35,13 @@ import CustomPopup from '@/components/CustomPopup.uvue'
itemName: string itemName: string
main: string main: string
itemDesc: string itemDesc: string
[key: string]: any
} }
const props = defineProps({ const props = defineProps({
item: Object item: Object
}) })
const visible = ref<boolean>(false) const visible = ref<boolean>(false)
const popup = ref<any>(null) const popup = ref(null)
function open(): void { function open(): void {
visible.value = true visible.value = true
......
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
import MessageBox from '@/components/MessageBox.uvue' import MessageBox from '@/components/MessageBox.uvue'
import { state } from '@/store/index.uts' import { state } from '@/store/index.uts'
type CarBuyersItem = {
name: string
id: number
}
const props = defineProps({ const props = defineProps({
title: { title: {
type: String, type: String,
...@@ -38,28 +43,32 @@ ...@@ -38,28 +43,32 @@
const emit = defineEmits(['close', 'select']) const emit = defineEmits(['close', 'select'])
const carBuyersVisible = ref<any>(null) const carBuyersVisible = ref(null)
const carBuyersList = ref<Array<{name: string, id: number}>>([ const carBuyersList = ref<Array<CarBuyersItem>>([{
{
name: '全款', name: '全款',
id: 1 id: 1
}, }, {
{
name: '按揭', name: '按揭',
id: 2 id: 2
} }] as Array<CarBuyersItem>)
])
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
}) })
const carBuyers = computed(() => { const carBuyers = computed(() => {
return state.user.customerInfo.carBuyers return state.user.customerInfo.carBuyers
}) })
watch(() => watchStatus.value, (newval) => { watch(watchStatus.value, (newval) => {
close() close()
}, { immediate: true }) }, { immediate: true })
...@@ -67,7 +76,7 @@ ...@@ -67,7 +76,7 @@
;(carBuyersVisible.value as any).open() ;(carBuyersVisible.value as any).open()
} }
function handleSelect(item: {name: string, id: number}): void { function handleSelect(item: CarBuyersItem): void {
close() close()
emit('select', item) emit('select', item)
} }
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
<template #customContent> <template #customContent>
<view class="layout-content"> <view class="layout-content">
<view class="title"> <view class="title">
<view class="text">{{title}}</view> <view class="text">
{{title}}
</view>
</view> </view>
<view class="content"> <view class="content">
<view <view
...@@ -44,7 +46,9 @@ ...@@ -44,7 +46,9 @@
v-if="i.hasCustomerAutocomplete" v-if="i.hasCustomerAutocomplete"
/> />
<template v-if="i.unit"> <template v-if="i.unit">
<view class="unit">{{i.unit}}</view> <view class="unit">
{{i.unit}}
</view>
</template> </template>
</template> </template>
<template v-else> <template v-else>
...@@ -52,12 +56,15 @@ ...@@ -52,12 +56,15 @@
:class="['select flex',{placeholderStyle:!customerInfo[i.key]}]" :class="['select flex',{placeholderStyle:!customerInfo[i.key]}]"
@click="showPopup(i.popKey,index)" @click="showPopup(i.popKey,index)"
> >
<view class="value text-hide">{{customerInfo[i.key] ||i.placeholder}}</view> <view class="value text-hide">
{{customerInfo[i.key] ?customerInfo[i.key] :i.placeholder}}
</view>
<uni-icons <uni-icons
class="arrow" class="arrow"
type="right" type="right"
:size="16" :size="16"
></uni-icons> >
</uni-icons>
</view> </view>
</template> </template>
</view> </view>
...@@ -115,7 +122,6 @@ ...@@ -115,7 +122,6 @@
newCarFare?: string newCarFare?: string
carBuyers?: string carBuyers?: string
carPurchaseMethod?: string | number carPurchaseMethod?: string | number
[key: string]: any
} }
const props = defineProps({ const props = defineProps({
...@@ -171,11 +177,11 @@ ...@@ -171,11 +177,11 @@
const focusIndex = ref<number>(-1) const focusIndex = ref<number>(-1)
const watchCustomerInfo = computed(() => { const watchCustomerInfo = computed(() => {
return store.state.user.customerInfo return store.state?.user.customerInfo
}) })
const watchStatus = computed(() => { const watchStatus = computed(() => {
return store.state.user.historyStatus return store.state?.user.historyStatus
}) })
watch(() => watchCustomerInfo.value, (newval) => { watch(() => watchCustomerInfo.value, (newval) => {
...@@ -184,29 +190,24 @@ ...@@ -184,29 +190,24 @@
} }
}, { immediate: true }) }, { immediate: true })
const carBrandListVisible = ref<any>(null) const carBrandListVisible = ref(null)
const carBuyersVisible = ref<any>(null) const carBuyersVisible = ref(null)
function inputCustomer(): void { function inputCustomer(): void {
store.dispatch('setCustomerInfo', customerInfo.value) store.dispatch?.('setCustomerInfo', customerInfo.value)
} }
function handleSelect(item: any, popkey: string): void { function handleSelect(item: any, popkey: string): void {
;(carBuyersVisible.value as any).close() if (popkey == 'carBuyersVisible') {
if (popkey == 'employeeBoxVisible') {
customerInfo.value.salesUuid = item.uuid
customerInfo.value.staffName = item.staffName
} else if (popkey == 'carBuyersVisible') {
customerInfo.value.carBuyers = item.name customerInfo.value.carBuyers = item.name
customerInfo.value.carPurchaseMethod = item.id customerInfo.value.carPurchaseMethod = item.id
store.dispatch?.('setCustomerInfo', customerInfo.value)
} else { } else {
;(carBrandListVisible.value as any).close() (carBrandListVisible.value as any).close()
customerInfo.value.carModel = item.name customerInfo.value.carModel = item.name
customerInfo.value.carModelId = item.id customerInfo.value.carModelId = item.id
} }
resetFocusIndex() resetFocusIndex()
store.dispatch('setCustomerInfo', customerInfo.value)
} }
function showPopup(e: string, index: number): void { function showPopup(e: string, index: number): void {
...@@ -232,8 +233,10 @@ ...@@ -232,8 +233,10 @@
let value = Number(e.target.value) >= 9999999 ? 9999999 : e.target.value 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') if (!Number.isInteger(value)) value = String(value).replace(/(\d*\.?\d{0,2})\d*/, '$1')
value = Number(String(value).replace(/^0+/, '')) value = Number(String(value).replace(/^0+/, ''))
customerInfo.value[key] = Number(value).toFixed(2) ? Number(value).toFixed(2) >= 0 ? value : '' : '' const numValue = Number(value)
customerInfo.value[key] = numValue >= 0 ? value : ''
inputCustomer() inputCustomer()
} }
} }
} }
...@@ -256,7 +259,7 @@ ...@@ -256,7 +259,7 @@
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.layout { .layout {
position: relative; position: relative;
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -361,6 +364,5 @@ ...@@ -361,6 +364,5 @@
} }
} }
} }
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -42,21 +42,19 @@ import wnCanvas from '@/components/PanCanvas/index.uvue' ...@@ -42,21 +42,19 @@ import wnCanvas from '@/components/PanCanvas/index.uvue'
import { state } from "@/store/index.uts" import { state } from "@/store/index.uts"
import nothingImage from '@/assets/images/media/nothing.webp' import nothingImage from '@/assets/images/media/nothing.webp'
interface Views { type Views = {
detailUrl?: string detailUrl?: string
bgUrl?: string bgUrl?: string
[key: string]: any
} }
interface CustomerInfo { type CustomerInfo = {
carModelId?: string carModelId?: string
[key: string]: any
} }
const props = defineProps({ const props = defineProps({
views: { views: {
type: Object as () => Views | Array<any>, type: Object as () => UTSJSONObject,
default: () => ({}) default: () => ({})
}, },
penSwitch: Boolean, penSwitch: Boolean,
...@@ -68,14 +66,15 @@ const props = defineProps({ ...@@ -68,14 +66,15 @@ const props = defineProps({
const emit = defineEmits(['scale']) const emit = defineEmits(['scale'])
const canvasRef = ref<any>(null) const canvasRef = ref(null)
const customerInfo = computed<CustomerInfo>(() => { const customerInfo = computed<CustomerInfo>(() => {
return state.user.customerInfo || {} const info = state.user.customerInfo
return info != null ? info.as(CustomerInfo) : {} as CustomerInfo
}) })
const viewKey = computed<string>(() => { const viewKey = computed<string>(() => {
return state.user?.viewKey || '' return state.user?.viewKey != null ? state.user.viewKey : ''
}) })
function onScale(e: number): void { function onScale(e: number): void {
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
@click="openCarBrand" @click="openCarBrand"
> >
{{customerInfo.carModel||'请选择'}} {{customerInfo.carModel||'请选择'}}
<view class="sprite-icon icon-arrow-bottom"></view> <view class="sprite-icon icon-arrow-bottom">
</view>
</view> </view>
<CarBrands <CarBrands
ref="carBrandListVisible" ref="carBrandListVisible"
...@@ -17,76 +18,78 @@ ...@@ -17,76 +18,78 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import CarBrands from '@/components/CarBrands.uvue' import CarBrands from '@/components/CarBrands.uvue'
import { state , store } from "@/store/index.uts" import { state , store } from "@/store/index.uts"
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
interface CustomerInfo { type CustomerInfo = UTSJSONObject
carModel?: string
carModelId?: string
[key: string]: any
}
interface UserInfo { type UserInfo = UTSJSONObject
channelType: number
[key: string]: any
}
const props = defineProps({ const props = defineProps({
title: String, title: String,
hasCarBrand: Boolean, hasCarBrand: Boolean,
show: Boolean show: Boolean
}) })
const carBrandListVisible = ref<any>(null) const carBrandListVisible = ref(null)
const customerInfo = ref<CustomerInfo>({}) const customerInfo = ref<CustomerInfo>({} as CustomerInfo)
const watchCustomerInfo = computed<CustomerInfo>(() => { const watchCustomerInfo = computed<CustomerInfo>(() => {
return state.user?.customerInfo || {} return state.user?.customerInfo != null ? state.user.customerInfo : {} as CustomerInfo
}) })
const watchStatus = computed<boolean>(() => { const watchStatus = computed(() => {
return state.user?.historyStatus || false const status = state.user?.historyStatus
}) if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
const isAito = computed<boolean>(() => { const isAito = computed<boolean>(() => {
const userInfo: UserInfo = storage.get('userInfo') || { channelType: 0 } const userInfo: UserInfo = storage.get('userInfo') != null ? storage.get('userInfo') : { channelType: 0 } as UserInfo
return userInfo.channelType == 1 return userInfo.channelType == 1
}) })
watch(() => props.show, (newval) => { watch(() => props.show, (newval) => {
if (newval && props.hasCarBrand && !customerInfo.value.carModel && isAito.value) { if (newval === true && props.hasCarBrand === true && (customerInfo.value.carModel == null || customerInfo.value.carModel === '') && isAito.value === true) {
setTimeout(() => { setTimeout(() => {
carBrandListVisible.value?.autoSelect() carBrandListVisible.value?.autoSelect()
}, 1000) }, 1000)
} }
}, { immediate: true }) }, { immediate: true })
watch(() => watchCustomerInfo.value, (newval) => { watch(() => watchCustomerInfo.value, (newval) => {
if (newval) { if (newval != null) {
customerInfo.value = { ...newval } customerInfo.value = { ...newval }
} }
}, { immediate: true }) }, { immediate: true })
function handleSelect(item: any): void { function handleSelect(item: any): void {
carBrandListVisible.value?.close() carBrandListVisible.value?.close()
onSelect(item)
}
function onSelect(item: any): void {
customerInfo.value.carModel = item.name customerInfo.value.carModel = item.name
customerInfo.value.carModelId = item.id customerInfo.value.carModelId = item.id
store.dispatch('setCustomerInfo', customerInfo.value) store.dispatch?.('setCustomerInfo', customerInfo.value)
} }
function openCarBrand(): void { function openCarBrand(): void {
carBrandListVisible.value?.open() carBrandListVisible.value?.open()
} }
defineExpose({ defineExpose({ carBrandListVisible })
carBrandListVisible
})
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.page-title-box { .page-title-box {
justify-content: center; justify-content: center;
position: absolute; position: absolute;
height: 96rpx; height: 96rpx;
...@@ -101,7 +104,7 @@ defineExpose({ ...@@ -101,7 +104,7 @@ defineExpose({
align-items: center; align-items: center;
.car-options { .car-options {
align-items: center; align-items: center;
flex-direction: row;; flex-direction: row;
&::before { &::before {
content: ''; content: '';
width: 2rpx; width: 2rpx;
...@@ -111,5 +114,5 @@ defineExpose({ ...@@ -111,5 +114,5 @@ defineExpose({
margin: 0 24rpx; margin: 0 24rpx;
} }
} }
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
@click="showPopup(i.popKey, index)" @click="showPopup(i.popKey, index)"
> >
<view class="value text-hide"> <view class="value text-hide">
{{ customerInfo[i.key] || i.placeholder }} {{ customerInfo[i.key] ? customerInfo[i.key] : i.placeholder }}
</view> </view>
<uni-icons <uni-icons
class="arrow" class="arrow"
...@@ -95,19 +95,7 @@ ...@@ -95,19 +95,7 @@
popKey?: string popKey?: string
} }
interface CustomerInfo { type CustomerInfo = UTSJSONObject
customerName?: string
phoneNumber?: string
carModel?: string
carModelId?: string | number
salesUuid?: string
staffName?: string
carBrand?: string
carBrandId?: string | number
oneCarBrand?: string
oneCarBrandId?: string | number
[key: string]: any
}
const props = defineProps({ const props = defineProps({
penSwitch: Boolean, penSwitch: Boolean,
...@@ -146,22 +134,21 @@ ...@@ -146,22 +134,21 @@
const focusIndex = ref<number>(-1) const focusIndex = ref<number>(-1)
const watchCustomerInfo = computed(() => { const watchCustomerInfo = computed(() => {
return store.state.user.customerInfo return store.state?.user.customerInfo
}) })
const watchStatus = computed(() => { const watchStatus = computed(() => {
return store.state.user.historyStatus return store.state?.user.historyStatus
}) })
const isAito = computed(() => { const isAito = computed(() => {
const userInfo = storage.get('userInfo') const userInfo = storage.get('userInfo')
return userInfo.channelType == 1 return userInfo?.channelType == 1
}) })
watch(() => watchCustomerInfo.value, (newval) => { watch(() => watchCustomerInfo.value, (newval) => {
if (newval) { if (newval) {
customerInfo.value = newval as CustomerInfo customerInfo.value = newval as CustomerInfo
console.log( customerInfo.value,'==========')
} }
}, { immediate: true }) }, { immediate: true })
...@@ -169,42 +156,33 @@ ...@@ -169,42 +156,33 @@
if (n && !customerInfo.value.carModel && isAito.value) { if (n && !customerInfo.value.carModel && isAito.value) {
setTimeout(() => { setTimeout(() => {
carBrandListVisibleRef.value.$callMethod('autoSelect') carBrandListVisibleRef.value?.$callMethod('autoSelect')
}, 1000) }, 1000)
} }
}, { immediate: true }) }, { immediate: true })
const carBrandListVisibleRef = ref<any>(null) const carBrandListVisibleRef = ref(null)
function onInputCustomer(): void { function onInputCustomer(): void {
store.dispatch('setCustomerInfo', customerInfo.value) store.dispatch?.('setCustomerInfo', customerInfo.value)
} }
function onSelect(item: any, popkey: string): void { function onSelect(item: any, popkey: string): void {
carBrandListVisibleRef.value.$callMethod('close') customerInfo.value.carModel = item.name
// const customerInfo = dispatch('getCustomerInfo') customerInfo.value.carModelId = item.id
// if (popkey == 'employeeBoxVisible') { carBrandListVisibleRef.value?.$callMethod('close')
// customerInfo.value.salesUuid = item.uuid
// customerInfo.value.staffName = item.staffName
// } else {
// customerInfo.value.carModel = item.name
// customerInfo.value.carModelId = item.id
// }
resetFocusIndex() resetFocusIndex()
// store.dispatch('setCustomerInfo', customerInfo.value)
} }
function showPopup(e: string, index: number): void { function showPopup(e: string, index: number): void {
focusIndex.value = index focusIndex.value = index
if (e == 'carBrandListVisible') { if (e == 'carBrandListVisible') {
carBrandListVisibleRef.value.$callMethod('open') carBrandListVisibleRef.value?.$callMethod('open')
} }
} }
function closeAllPopup(): void { function closeAllPopup(): void {
carBrandListVisibleRef.value.$callMethod('close') carBrandListVisibleRef.value?.$callMethod('close')
resetFocusIndex() resetFocusIndex()
} }
...@@ -219,7 +197,7 @@ ...@@ -219,7 +197,7 @@
customerName: e.ownerName customerName: e.ownerName
} }
uni.$logger.local.info(`从客户档案选择:${JSON.stringify(e)}`) // uni.$logger.local.info(`从客户档案选择:${JSON.stringify(e)}`)
if (e.carModelId) { if (e.carModelId) {
customerInfo.value.carModelId = e.carModelId customerInfo.value.carModelId = e.carModelId
...@@ -236,9 +214,8 @@ ...@@ -236,9 +214,8 @@
function contentUrl(): string { function contentUrl(): string {
const views = props.views as any const views = props.views as any
const carModelId = customerInfo.value.carModelId const carModelId = customerInfo.value.carModelId
if (Array.isArray(views)) { if (Array.isArray(views)) {
return (views as any)[carModelId] || '/static/images/media/nothing.webp' return (views as any)[carModelId ?? ''] || '/static/images/media/nothing.webp'
} else if ((views as UTSJSONObject).detailUrl) { } else if ((views as UTSJSONObject).detailUrl) {
return (views as UTSJSONObject).detailUrl as string return (views as UTSJSONObject).detailUrl as string
} else { } else {
......
...@@ -87,7 +87,6 @@ ...@@ -87,7 +87,6 @@
defultTabId?: number defultTabId?: number
pageStyle?: string pageStyle?: string
carIcon?: string carIcon?: string
[key: string]: any
} }
const props = defineProps({ const props = defineProps({
...@@ -104,7 +103,7 @@ ...@@ -104,7 +103,7 @@
const direction = ref<string>('bottom') const direction = ref<string>('bottom')
const imgKey = ref<number>(Date.now()) const imgKey = ref<number>(Date.now())
const tabIndex = ref<number>(2) const tabIndex = ref<number>(2)
const threeGuarantees = ref<any>(null) const threeGuarantees = ref(null)
const watchStatus = computed(() => { const watchStatus = computed(() => {
return store.state.user.historyStatus return store.state.user.historyStatus
...@@ -114,7 +113,7 @@ ...@@ -114,7 +113,7 @@
return (props.detail as Detail).tabList.find(item => item.id == activeIndex.value).imgIdList return (props.detail as Detail).tabList.find(item => item.id == activeIndex.value).imgIdList
}) })
watch(() => watchStatus.value, () => { watch(watchStatus.value, () => {
activeIndex.value = (props.detail as Detail).defultActiveId || 0 activeIndex.value = (props.detail as Detail).defultActiveId || 0
tabIndex.value = (props.detail as Detail).defultTabId tabIndex.value = (props.detail as Detail).defultTabId
}) })
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
imgUrl?: string imgUrl?: string
} }
const INFO_LIST: InfoListItem[] = [ const INFO_LIST: Array<InfoListItem> = [
{ {
id: 1, id: 1,
title: "客户付款凭证", title: "客户付款凭证",
...@@ -92,19 +92,19 @@ ...@@ -92,19 +92,19 @@
}) })
const emit = defineEmits(['update:showPayPage', 'finish']) const emit = defineEmits(['update:showPayPage', 'finish'])
const infoList = ref<InfoListItem[]>(JSON.parse(JSON.stringify(INFO_LIST))) const infoList = ref<Array<InfoListItem>>(JSON.parse(JSON.stringify(INFO_LIST)) as Array<InfoListItem>)
const previewImg = ref<string>('') const previewImg = ref<string>('')
const isPreview = ref<boolean>(false) const isPreview = ref<boolean>(false)
const watchBooksList = computed(() => { const watchBooksList = computed<Array<InfoListItem>>(() => {
return state.audio.booksList return state.audio.booksList
}) })
watch(() => watchBooksList.value, (newValue: InfoListItem[]) => { watch(() => watchBooksList.value, (newValue: Array<InfoListItem>) => {
if (newValue && newValue.length) { if (newValue != null && newValue.length > 0) {
infoList.value = newValue infoList.value = newValue
} else { } else {
infoList.value = JSON.parse(JSON.stringify(INFO_LIST)) infoList.value = JSON.parse(JSON.stringify(INFO_LIST)) as Array<InfoListItem>
} }
}, { immediate: true }) }, { immediate: true })
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
// "imgUrl", // "imgUrl",
// url // url
// ); // );
infoList.value[index].imgUrl = url // infoList.value[index].imgUrl = url
// setBooks(utils.deepClone(infoList.value)) // setBooks(utils.deepClone(infoList.value))
} catch (error) { } catch (error) {
console.error(`上传付款凭证失败:${error}`) console.error(`上传付款凭证失败:${error}`)
...@@ -160,16 +160,17 @@ ...@@ -160,16 +160,17 @@
// 删除图片 // 删除图片
function close(index: number): void { function close(index: number): void {
infoList.value[index].imgUrl = '' infoList.value[index].imgUrl = ''
dispatch('setBooks', JSON.parse(JSON.stringify(infoList.value))) dispatch('setBooks', JSON.parse(JSON.stringify(infoList.value)) as Array<InfoListItem>)
} }
// 预览图片 // 预览图片
function preview(index: number): void { function preview(index: number): void {
isPreview.value = true isPreview.value = true
previewImg.value = infoList.value[index].imgUrl || '' previewImg.value = infoList.value[index].imgUrl != null ? infoList.value[index].imgUrl : ''
const imageUrl: string = infoList.value[index].imgUrl != null ? infoList.value[index].imgUrl : ''
uni.previewImage({ uni.previewImage({
urls: [infoList.value[index].imgUrl || ''], urls: [imageUrl],
longPressActions: { longPressActions: {
success: function (data) { success: function (data) {
console.log( console.log(
......
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
const title = ref<string>('') const title = ref<string>('')
const accountInfo = ref<Record<string, any>>({}) const accountInfo = ref<Record<string, any>>({})
const payInfo = ref<Record<string, any>>({}) const payInfo = ref<Record<string, any>>({})
const popup = ref<any>(null) const popup = ref(null)
const visible = ref<boolean>(false) const visible = ref<boolean>(false)
// 使用传入的 paymentType 或从 store 获取 // 使用传入的 paymentType 或从 store 获取
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { state , dispatch } from "@/store/index.uts"; import { state , dispatch } from "@/store/index.uts";
import HomeFrame from '@/components/HomeFrame/index.uvue' import HomeFrame from '@/components/HomeFrame/index.uvue'
import { getMerchantCarBrandList, getEmployeeList , getCarBrandsListApi } from '@/api/common-api.uts' import { getMerchantCarBrandList, getEmployeeListApi , getCarBrandsListApi } from '@/api/common-api.uts'
import { getMockData, getSoureData } from '@/api/system-api.uts' import { getMockData, getSoureData } from '@/api/system-api.uts'
const homeRef = ref(null) const homeRef = ref(null)
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
function handleStart(): void { function handleStart(): void {
const currentModuleList = moduleList.value const currentModuleList = moduleList.value
if (!currentModuleList.length) { if (currentModuleList.length == 0) {
return uni.showToast({ return uni.showToast({
title: '该场景尚未配置素材,请联系总部人员', title: '该场景尚未配置素材,请联系总部人员',
icon: 'none' icon: 'none'
...@@ -99,17 +99,17 @@ ...@@ -99,17 +99,17 @@
getSoure(brandIdList, subBrandIdList) getSoure(brandIdList, subBrandIdList)
dispatch('setCarBrandsList', carBrandList) dispatch('setCarBrandsList', carBrandList)
storage.set('carBrandList', carBrandList) storage.set('carBrandList', carBrandList)
if (carBrandList.length) { if (carBrandList.length > 0) {
let index = 0 let index = 0
getCarBrandsList(carBrandList, index) getCarBrandsList(carBrandList, index)
} }
}) })
/**获取销售人员 */ /**获取销售人员 */
getEmployeeList({ getEmployeeListApi({
merchantId: shopMerchantId merchantId: shopMerchantId
}).then(res => { }).then(res => {
dispatch('setEmployeeList', res || []) dispatch('setEmployeeList', res != null ? res : [])
storage.set('employeeList', res || []) storage.set('employeeList', res != null ? res : [])
}) })
} }
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
const storageKey = `source_${sceneType}_${shopMerchantId}` const storageKey = `source_${sceneType}_${shopMerchantId}`
const data = uni.getStorageSync(storageKey) const data = uni.getStorageSync(storageKey)
if (data) { if (data != null) {
setViewInfo(data) setViewInfo(data)
} }
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
brandIdList: brandIdList, brandIdList: brandIdList,
subBrandIdList: subBrandIdList subBrandIdList: subBrandIdList
}) })
if (requestData) { if (requestData != null) {
setViewInfo(requestData) setViewInfo(requestData)
} else { } else {
loadComplete.value = true loadComplete.value = true
...@@ -140,15 +140,15 @@ ...@@ -140,15 +140,15 @@
} }
} }
onLoad((options: OnLoadOptions) => { onLoad((options) => {
getMockData(true).then(mockdata =>{ getMockData(true).then(mockdata =>{
console.log(mockdata,'===') console.log(mockdata,'===')
const userInfo = storage.get('userInfo') const userInfo = storage.get('userInfo')
const mockDataObj = mockdata as UTSJSONObject const mockDataObj = mockdata as UTSJSONObject
const {channelType} = userInfo as UTSJSONObject const {channelType} = userInfo as UTSJSONObject
if (channelType == 1 && mockDataObj.boutiqueDefaultCarBrandId) { if (channelType == 1 && mockDataObj.boutiqueDefaultCarBrandId != null) {
state.user.boutiqueDefaultCarBrandId = mockDataObj.boutiqueDefaultCarBrandId //默认车辆品牌 state.user.boutiqueDefaultCarBrandId = mockDataObj.boutiqueDefaultCarBrandId //默认车辆品牌
if (mockDataObj.defaultCarId) { if (mockDataObj.defaultCarId != null) {
state.user.defaultCarId = mockDataObj.defaultCarId //默认车系 state.user.defaultCarId = mockDataObj.defaultCarId //默认车系
} }
} }
...@@ -185,19 +185,19 @@ ...@@ -185,19 +185,19 @@
/**按序加载车型 */ /**按序加载车型 */
async function getCarBrandsList(carBrandList: Array<any>, index: number) { async function getCarBrandsList(carBrandList: Array<any>, index: number) {
const item = carBrandList[index] const item = carBrandList[index]
if (!item) return if (item == null) return
const storageKey = `${item.id}_${item.brandId}_carlist` const storageKey = `${item.id}_${item.brandId}_carlist`
const carList = uni.getStorageSync(storageKey) const carList = uni.getStorageSync(storageKey)
if (index < carBrandList.length - 1) { if (index < carBrandList.length - 1) {
const nextIndex = index + 1 const nextIndex = index + 1
if (!carList) { if (carList == null) {
const list = await getCarBrandsListApi({ const list = await getCarBrandsListApi({
brandId: item.brandId, brandId: item.brandId,
childBrandId: item.id childBrandId: item.id
}) })
if (list) { if (list != null) {
uni.setStorageSync(storageKey, list) uni.setStorageSync(storageKey, list)
} }
getCarBrandsList(carBrandList, nextIndex) getCarBrandsList(carBrandList, nextIndex)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!