Commit f1259e46 by 李伟康

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

- 将getEmployeeList函数重命名为getEmployeeListApi
- 更新BackPress组件中的组件实例调用方式为$callMethod
- 重构CarBrands组件的数据类型定义和状态管理逻辑
- 优化CustomPopup组件中的位置映射计算方法
- 调整CustomerAutocomplete组件的模板结构和样式
- 修复组件中多处类型安全问题并改进响应式数据处理
1 parent d901015c
Showing 25 changed files with 1098 additions and 1027 deletions
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import http from "@/api/request/http.uts"; import http from "@/api/request/http.uts";
/** 获取交付人员列表 */ /** 获取交付人员列表 */
export function getEmployeeList(data: UTSJSONObject): Promise<any> { export function getEmployeeListApi(data: UTSJSONObject): Promise<any> {
return http.post({ return http.post({
'method': 'dj.api.smartcarlife.employee.getByMerchantId.new', 'method': 'dj.api.smartcarlife.employee.getByMerchantId.new',
'projectName': 'boutique', 'projectName': 'boutique',
......
<!-- 退出弹框 --> <!-- 退出弹框 -->
<template> <template>
<MessageBox :popupW="704" ref="finishRef" :content="finishContene" :isFooter="false"> <MessageBox :popupW="704" ref="finishRef" :content="finishContene" :isFooter="false">
<view class="footer"> <view class="footer">
<view class="footer-btn confirm flex" @click="$emit('openStep')"> <view class="footer-btn confirm flex" @click="$emit('openStep')">
<template v-if="finishDoneText"> <template v-if="finishDoneText">
{{ finishDoneText }} {{ finishDoneText }}
</template> </template>
<template v-else> <template v-else>
完成接待 完成接待
<text>(推荐)</text> <text>
</template> (推荐)
</view> </text>
<view class="footer-btn cancel flex" @click="$emit('backHome')"> </template>
仍要退出
<text>(不推荐)</text>
</view>
</view> </view>
</MessageBox> <view class="footer-btn cancel flex" @click="$emit('backHome')">
仍要退出
<text>
(不推荐)
</text>
</view>
</view>
</MessageBox>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import MessageBox from './MessageBox.uvue' import MessageBox from './MessageBox.uvue'
import { ComponentPublicInstance } from 'vue'
const props = defineProps({
finishDoneText: String, const props = defineProps({
finishContene: { finishDoneText: String,
type: String, finishContene: {
default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」' type: String,
} default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」'
}) }
function open(): void {
finishRef.value.open()
}
function hide(): void {
finishRef.value.close()
}
const finishRef = ref<any>(null)
const emit = defineEmits(['openStep', 'backHome'])
defineExpose({
open,
hide
}) })
const finishRef = ref(null)
function open(): void {
(finishRef.value as ComponentPublicInstance).$callMethod('open')
}
function hide(): void {
(finishRef.value as ComponentPublicInstance).$callMethod('close')
}
const emit = defineEmits(['openStep', 'backHome'])
defineExpose({ open, hide })
</script> </script>
<style lang="scss"> <style lang="scss">
.footer { .footer {
border-top: 2rpx solid #eff0f2; border-top: 2rpx solid #eff0f2;
font-weight: 600; font-weight: 600;
font-size: 32rpx; font-size: 32rpx;
margin-top: 48rpx; margin-top: 48rpx;
.footer-btn { .footer-btn {
justify-content: center; justify-content: center;
margin: 16rpx auto 0; margin: 16rpx auto 0;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
} }
.confirm { .confirm {
width: 608rpx; width: 608rpx;
height: 80rpx; height: 80rpx;
background: #2c66f7; background: #2c66f7;
border-radius: 40rpx; border-radius: 40rpx;
color: #fff; color: #fff;
} }
.cancel { .cancel {
width: 608rpx; width: 608rpx;
height: 80rpx; height: 80rpx;
background: #ffffff00; background: #ffffff00;
border-radius: 40rpx; border-radius: 40rpx;
color: #2c66f7; color: #2c66f7;
} }
text { text {
font-size: 24rpx; font-size: 24rpx;
}
} }
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -2,216 +2,221 @@ ...@@ -2,216 +2,221 @@
<view <view
v-if="showMask" v-if="showMask"
class="custom-popup-mask" class="custom-popup-mask"
:class="{ 'mask-visible': isAnimated }" :class="{ 'mask-visible': isAnimated }"
@click="handleMaskClick" @click="handleMaskClick"
> >
<view <view
class="custom-popup-content" class="custom-popup-content"
:class="[`popup-${positionClass}`, { 'content-visible': isAnimated }]" :class="[`popup-${positionClass}`, { 'content-visible': isAnimated }]"
@click.stop @click.stop
> >
<slot></slot> <slot>
</slot>
</view> </view>
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
const props = defineProps({ const props = defineProps({
visible: { visible: {
type: Boolean, type: Boolean,
default: false default: false
}, },
position: { position: {
type: String, type: String,
default: "center" default: "center"
}, },
maskClosable: { maskClosable: {
type: Boolean, type: Boolean,
default: true default: true
}, },
duration: { duration: {
type: Number, type: Number,
default: 300 default: 300
}
})
const emit = defineEmits(['update:visible', 'close', 'mask-click', 'opened', 'closed'])
function close(): void {
emit('update:visible', false)
emit('close')
} }
})
function open(): void {
const emit = defineEmits(['update:visible', 'close', 'mask-click', 'opened', 'closed']) emit('update:visible', true)
const showMask = ref<boolean>(props.visible)
const isAnimated = ref<boolean>(false)
let closeTimer: any = null
let openTimer: any = null
const positionClass = computed(() => {
const positionMap: Record<string, string> = {
'top': 'top',
'center': 'center',
'bottom': 'bottom',
'left': 'left',
'right': 'right'
} }
return positionMap[props.position] || 'center' function handleMaskClick(): void {
}) emit('mask-click')
if (props.maskClosable) {
watch(() => props.visible, (newVal) => { close()
if (newVal) {
// 打开流程
if (closeTimer) {
clearTimeout(closeTimer)
closeTimer = null
} }
if (openTimer) {
clearTimeout(openTimer)
openTimer= null
}
showMask.value = true
isAnimated.value = false
// 等待 DOM 渲染后添加动画类
openTimer = setTimeout(() => {
isAnimated.value = true
}, 50)
// 动画完成后触发事件
setTimeout(() => {
emit('opened')
}, props.duration + 50)
} else {
// 关闭流程
if (openTimer) {
clearTimeout(openTimer)
openTimer = null
}
isAnimated.value = false
closeTimer= setTimeout(() => {
showMask.value = false
emit('closed')
}, props.duration)
} }
}, { immediate: true }) const showMask = ref<boolean>(props.visible)
const isAnimated = ref<boolean>(false)
let closeTimer: any | null = null
let openTimer: any | null = null
function handleMaskClick(): void { const positionClass = computed<string>(() => {
emit('mask-click') const positionMap: UTSJSONObject = {
if (props.maskClosable) { 'top': 'top',
close() 'center': 'center',
} 'bottom': 'bottom',
} 'left': 'left',
'right': 'right'
} as UTSJSONObject
const mappedValue = positionMap[props.position] as string | null
if (mappedValue == null) {
return 'center'
}
return mappedValue
})
watch(props.visible, (newVal: boolean) => {
if (newVal == true) {
// 打开流程
if (closeTimer != null) {
clearTimeout(closeTimer as number)
closeTimer = null
}
if (openTimer != null) {
clearTimeout(openTimer as number)
openTimer= null
}
showMask.value = true
isAnimated.value = false
// 等待 DOM 渲染后添加动画类
openTimer = setTimeout(() => {
isAnimated.value = true
}, 50)
// 动画完成后触发事件
setTimeout(() => {
emit('opened')
}, props.duration + 50)
} else {
// 关闭流程
if (openTimer != null) {
clearTimeout(openTimer as number)
openTimer = null
}
function close(): void { isAnimated.value = false
emit('update:visible', false)
emit('close')
}
function open(): void { closeTimer= setTimeout(() => {
emit('update:visible', true) showMask.value = false
} emit('closed')
}, props.duration)
}
}, { immediate: true })
defineExpose({
open,
close defineExpose({ open, close })
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.custom-popup-mask { .custom-popup-mask {
position: fixed; position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.3);
z-index: 1000;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s ease;
&.mask-visible {
opacity: 1;
}
}
.custom-popup-content {
position: absolute;
max-height: 90%;
opacity: 0;
transform: scale(0.95);
transition: opacity 0.3s ease, transform 0.3s ease;
&.content-visible {
opacity: 1;
transform: scale(1);
}
&.popup-top {
top: 0; top: 0;
left: 50%; left: 0;
transform: translateY(-100%) translateX(-50%); right: 0;
width: 100%; bottom: 0;
border-bottom-left-radius: 20rpx; background-color: rgba(0, 0, 0, 0.3);
border-bottom-right-radius: 20rpx; z-index: 1000;
display: flex;
&.content-visible { justify-content: center;
transform: translateY(0) translateX(-50%); align-items: center;
opacity: 0;
transition: opacity 0.3s ease;
&.mask-visible {
opacity: 1;
} }
} }
&.popup-center { .custom-popup-content {
top: 50%; position: absolute;
left: 50%; max-height: 90%;
transform: translate(-50%, -50%) scale(0.95); opacity: 0;
min-width: 600rpx; transform: scale(0.95);
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.15); transition: opacity 0.3s ease, transform 0.3s ease;
&.content-visible { &.content-visible {
transform: translate(-50%, -50%) scale(1); opacity: 1;
transform: scale(1);
} }
}
&.popup-top {
&.popup-bottom { top: 0;
bottom: 0; left: 50%;
left: 50%; transform: translateY(-100%) translateX(-50%);
transform: translateY(100%) translateX(-50%); width: 100%;
width: 100%; border-bottom-left-radius: 20rpx;
border-top-left-radius: 20rpx; border-bottom-right-radius: 20rpx;
border-top-right-radius: 20rpx;
&.content-visible {
&.content-visible { transform: translateY(0) translateX(-50%);
transform: translateY(0) translateX(-50%); }
} }
}
&.popup-center {
&.popup-left { top: 50%;
top: 50%; left: 50%;
left: 0; transform: translate(-50%, -50%) scale(0.95);
transform: translateX(-100%) translateY(-50%); min-width: 600rpx;
height: 100%; box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.15);
max-width: 80%;
border-top-right-radius: 20rpx; &.content-visible {
border-bottom-right-radius: 20rpx; transform: translate(-50%, -50%) scale(1);
}
&.content-visible {
transform: translateX(0) translateY(-50%);
} }
}
&.popup-bottom {
&.popup-right { bottom: 0;
top: 50%; left: 50%;
right: 0; transform: translateY(100%) translateX(-50%);
transform: translateX(100%) translateY(-50%); width: 100%;
height: 100%; border-top-left-radius: 20rpx;
max-width: 80%; border-top-right-radius: 20rpx;
border-top-left-radius: 20rpx;
border-bottom-left-radius: 20rpx; &.content-visible {
transform: translateY(0) translateX(-50%);
&.content-visible { }
transform: translateX(0) translateY(-50%); }
&.popup-left {
top: 50%;
left: 0;
transform: translateX(-100%) translateY(-50%);
height: 100%;
max-width: 80%;
border-top-right-radius: 20rpx;
border-bottom-right-radius: 20rpx;
&.content-visible {
transform: translateX(0) translateY(-50%);
}
}
&.popup-right {
top: 50%;
right: 0;
transform: translateX(100%) translateY(-50%);
height: 100%;
max-width: 80%;
border-top-left-radius: 20rpx;
border-bottom-left-radius: 20rpx;
&.content-visible {
transform: translateX(0) translateY(-50%);
}
} }
} }
}
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<view :class="['customer-box',{'is-show':showCustomerBox}]"> <view :class="['customer-box',{'is-show':showCustomerBox}]">
<view class="customer-title">客户档案的记录</view> <view class="customer-title">
客户档案的记录
</view>
<scroll-view <scroll-view
scroll-y scroll-y
class="scroll-box" class="scroll-box"
> >
<template v-if="loading"> <template v-if="loading">
<view class="loading flex"> <view class="loading flex">
<uni-icons <uni-icons
type="refreshempty" type="refreshempty"
:size="46" :size="46"
color="#3773F8" color="#3773F8"
class="icon" class="icon"
></uni-icons> >
</uni-icons>
</view> </view>
</template> </template>
<template v-else> <template v-else>
...@@ -20,18 +23,19 @@ ...@@ -20,18 +23,19 @@
<template v-for="(i,index) in searchList" :key="index"> <template v-for="(i,index) in searchList" :key="index">
<view <view
class="item flex" class="item flex"
hover-class="active" hover-class="active"
@click="chooseItem(i)" @click="chooseItem(i)"
> >
{{ `${showType == 'tel'?i.ownerPhone:i.ownerName}`}} {{ `${showType == 'tel'?i.ownerPhone:i.ownerName}`}}
</view> </view>
</template> </template>
</template> </template>
<template v-else> <template v-else>
<view class="nothing flex"> <view class="nothing flex">
<view class="icon"></view> <view class="icon">
未匹配到客户信息 </view>
未匹配到客户信息
</view> </view>
</template> </template>
</template> </template>
...@@ -40,153 +44,147 @@ ...@@ -40,153 +44,147 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { state } from '@/store/index.uts' import { state } from '@/store/index.uts'
import { getCustomerInfoListApi } from '@/api/customer-api.uts' import { getCustomerInfoListApi } from '@/api/customer-api.uts'
interface CustomerInfo { type CustomerInfo = UTSJSONObject
ownerPhone?: string
ownerName?: string
[key: string]: any
}
interface UserInfo { type UserInfo = UTSJSONObject
shopMerchantId: string
sceneType: number
[key: string]: any
}
interface SearchParams { type SearchParams = {
merchantId: string merchantId: string
bussinessScene: number bussinessScene: number
ownerPhone?: string ownerPhone?: string
ownerName?: string ownerName?: string
} }
const props = defineProps({ const props = defineProps({
searchValue: String, searchValue: String,
showType: String, showType: String,
show: Boolean show: Boolean
}) })
const emit = defineEmits(['choose']) const emit = defineEmits(['choose'])
const loading = ref<boolean>(true) const loading = ref<boolean>(true)
const searchList = ref<Array<CustomerInfo>>([]) const searchList = ref<Array<CustomerInfo>>([])
const showCustomerBox = computed<boolean>(() => { const showCustomerBox = computed<boolean>(() => {
return props.show && state.user?.haveCustomerAccess && props.searchValue const searchValue = props.searchValue ?? ''
}) return props.show == true && (state.user?.haveCustomerAccess ?? false) && (searchValue !== '' && searchValue !== null)
})
async function getCustomerInfoList(val: string, type: string): Promise<void> {
try {
loading.value = true
const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null
const userInfoObj = userInfo ?? { shopMerchantId: '', sceneType: 0 }
const shopMerchantId = userInfoObj.shopMerchantId
const params: SearchParams = {
merchantId: shopMerchantId as String,
bussinessScene: userInfoObj.sceneType == 0 ? 1 : 2
}
watch(() => showCustomerBox.value, (newval) => { if (type == 'tel') {
if (newval) { params.ownerPhone= val
getCustomerInfoList(props.searchValue || '', props.showType || '') } else {
} params.ownerName = val
}, { immediate: true }) }
async function getCustomerInfoList(val: string, type: string): Promise<void> { const result = await getCustomerInfoListApi(params as UTSJSONObject)
try { searchList.value = result as UTSArray<UTSJSONObject>
loading.value = true loading.value = false
const userInfo: UserInfo = storage.get("userInfo") || { shopMerchantId: '', sceneType: 0 } } catch (error) {
const params: SearchParams = { loading.value = false
merchantId: userInfo.shopMerchantId, }
bussinessScene: userInfo.sceneType == 0 ? 1 : 2
}
if (type == 'tel') {
params.ownerPhone= val
} else {
params.ownerName = val
}
const result = await getCustomerInfoListApi(params)
searchList.value = result || []
loading.value = false
} catch (error) {
loading.value = false
console.error('获取客户信息失败:', error)
} }
} watch(showCustomerBox.value , (newVal: boolean) => {
if (newVal == true) {
getCustomerInfoList(props.searchValue ?? '', props.showType ?? '')
}
}, { immediate: true })
function chooseItem(item: CustomerInfo): void {
emit('choose', item)
} function chooseItem(item: CustomerInfo): void {
emit('choose', item)
}
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.customer-box { .customer-box {
position: absolute; position: absolute;
left: 0; left: 0;
top: 88rpx; top: 88rpx;
width: 100%; width: 100%;
height: 352rpx; height: 352rpx;
background: #ffffff; background: #ffffff;
border-radius: 16rpx; border-radius: 16rpx;
z-index: -1; z-index: -1;
opacity: 0; opacity: 0;
.customer-title { .customer-title {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
line-height: 40rpx; line-height: 40rpx;
padding: 16rpx 24rpx 8rpx; padding: 16rpx 24rpx 8rpx;
} }
.scroll-box { .scroll-box {
height: calc(100% - 64rpx); height: calc(100% - 64rpx);
.loading { .loading {
width: 100%; width: 100%;
height: 100%; height: 100%;
justify-content: center; justify-content: center;
.icon { .icon {
animation: rotate-loading 1s linear infinite; animation: rotate-loading 1s linear infinite;
} }
} }
.nothing { .nothing {
width: 100%; width: 100%;
height: 100%; height: 100%;
font-size: 24rpx; font-size: 24rpx;
color: #c7ccd7; color: #c7ccd7;
flex-direction: column; flex-direction: column;
.icon { .icon {
margin-top: 52rpx; margin-top: 52rpx;
width: 96rpx; width: 96rpx;
height: 96rpx; height: 96rpx;
/* background-image: url('@/assets/images/common/nothing.webp'); */ /* background-image: url('@/assets/images/common/nothing.webp'); */
background-size: 100%; background-size: 100%;
} }
} }
.item { .item {
width: 100%; width: 100%;
height: 48rpx; height: 48rpx;
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
line-height: 40rpx; line-height: 40rpx;
padding-left: 24rpx; padding-left: 24rpx;
margin-bottom: 8rpx; margin-bottom: 8rpx;
} }
.active { .active {
background: #ecf1ff; background: #ecf1ff;
} }
@keyframes rotate-loading { @keyframes rotate-loading {
0% { 0% {
transform: rotate(0); transform: rotate(0);
} }
100% { 100% {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
}
} }
}
.is-show { .is-show {
z-index: 1; z-index: 1;
opacity: 1; opacity: 1;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<MessageBox <MessageBox
ref="employeeBoxVisible" ref="employeeBoxVisible"
position="bottom" position="bottom"
:isFooter="false" :isFooter="false"
:title="`请选择${title}`" :title="`请选择${title}`"
:maxHeight="1000" :maxHeight="1000"
@close="handleClose" @close="handleClose"
> >
<view class="select-box"> <view class="select-box">
<view <view
class="select-item" class="select-item"
:class="{ checked: salesUuid == item.uuid }" :class="{ checked: salesUuid == item.uuid }"
@click="handleSelect(item)" @click="handleSelect(item)"
v-for="(item, index) in employeeList" v-for="(item, index) in employeeList"
:key="index" :key="index"
> >
{{ item.staffName }} {{ item.staffName }}
</view> </view>
...@@ -26,63 +26,88 @@ ...@@ -26,63 +26,88 @@
import MessageBox from './MessageBox.uvue' import MessageBox from './MessageBox.uvue'
import { state, dispatch } from '@/store/index.uts' import { state, dispatch } from '@/store/index.uts'
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { getEmployeeList as getEmployeeListApi } from '@/api/common-api.uts' import { getEmployeeListApi } from '@/api/common-api.uts'
import { ComponentPublicInstance } from 'vue'
interface EmployeeItem { interface EmployeeItem {
staffName: string staffName: string
uuid: string uuid: string
[key: string]: any
} }
interface Props { interface Props {
title?: string title?: string
salesPropsUuid?: string salesPropsUuid?: string
} }
type UserInfo = UTSJSONObject
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
title: '销售', title: '销售',
salesPropsUuid: '' salesPropsUuid: ''
}) })
const emit = defineEmits(['close', 'select']) const emit = defineEmits(['close', 'select'])
const employeeBoxVisible = ref<any>(null) const employeeBoxVisible = ref(null)
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
}) if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
const updateView = ref<number>(Date.now())
const salesUuid = computed(() => { const salesUuid = computed(() => {
return state.user.customerInfo.salesUuid || props.salesPropsUuid const val1 = state.user.customerInfo.salesUuid
}) const val2 = props.salesPropsUuid
return val1 !== null && val1 !== '' ? val1 : val2
})
const employeeList = computed(() => { // const employeeList = computed(() => {
return state.user.employeeList // return state.user.employeeList
}) // })
const employeeList = ref<Array<EmployeeItem>>([])
watch(updateView.value,()=>{
const list = storage.get("employeeList") as UTSArray<EmployeeItem>
employeeList.value = list !== null ? list : []
watch(() => watchStatus.value, (newval: number) => { }, { immediate: true, deep: true })
close() function close(): void {
}, { immediate: true }) if (employeeBoxVisible.value != null) {
(employeeBoxVisible.value as ComponentPublicInstance).$callMethod('close')
}
}
watch(watchStatus.value, (newval: number) => {
close()
}, { immediate: true })
function handleClose(): void { function handleClose(): void {
emit('close') emit('close')
} }
function open(): void { function open(): void {
employeeBoxVisible.value?.open() if (employeeBoxVisible.value != null) {
const userInfo = storage.get('userInfo') (employeeBoxVisible.value as ComponentPublicInstance).$callMethod('open')
const userInfoObj = userInfo as any }
const shopMerchantId = userInfoObj?.shopMerchantId const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null
if (userInfo == null) return
const shopMerchantId = userInfo.shopMerchantId
// 获取销售人员列表 // 获取销售人员列表
getEmployeeListApi({ getEmployeeListApi({ merchantId: shopMerchantId }).then((res: any) => {
merchantId: shopMerchantId const employeeList = res as Array<EmployeeItem>
}).then((res: EmployeeItem[]) => { dispatch('setEmployeeList', employeeList)
dispatch('setEmployeeList', res) const listToStore = employeeList != null ? employeeList : []
storage.set('employeeList', res || []) storage.set('employeeList', listToStore, 0)
}).catch((error: any) => { updateView.value = Date.now()
console.error('获取员工列表失败:', error)
}) })
} }
function handleSelect(item: EmployeeItem): void { function handleSelect(item: EmployeeItem): void {
...@@ -90,39 +115,33 @@ ...@@ -90,39 +115,33 @@
emit('select', item) emit('select', item)
} }
function close(): void {
employeeBoxVisible.value?.close()
}
defineExpose({ defineExpose({ open, close })
open,
close
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.select-box { .select-box {
margin: 40rpx 0; margin: 40rpx 0;
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
gap: 32rpx; gap: 32rpx;
overflow-y: scroll; overflow-y: scroll;
max-height: 50vh; max-height: 50vh;
padding-bottom: 60rpx; padding-bottom: 60rpx;
.select-item { .select-item {
text-align: center; text-align: center;
height: 68rpx; height: 68rpx;
line-height: 44rpx; line-height: 44rpx;
opacity: 1; opacity: 1;
border: 2rpx solid #dce0e6; border: 2rpx solid #dce0e6;
color: #333; color: #333;
font-size: 32rpx; font-size: 32rpx;
border-radius: 8rpx; border-radius: 8rpx;
&.checked { &.checked {
border: 2rpx solid #292d33; border: 2rpx solid #292d33;
}
} }
} }
}
</style> </style>
<template> <template>
<CustomPopup <CustomPopup
ref="popupRef" ref="popupRef"
:visible="visible" :visible="visible"
:position="position" :position="position"
:mask-closable="false" :mask-closable="false"
:duration="300" :duration="300"
@update:visible="visible = $event" @update:visible="visible = $event as Boolean"
@close="onClose" @close="onClose"
> >
<view <view
:class="['tips-wrapper',{'radius': position === 'center'}]" :class="['tips-wrapper',{'radius': position === 'center'}]"
:style="{ width: popupW + 'rpx', minHeight: popupH + 'rpx', maxHeight: maxHeight + 'rpx' }" :style="{ width: (popupW ?? 0) + 'rpx', minHeight: (popupH ?? 0) + 'rpx', maxHeight: (maxHeight ?? 0) + 'rpx' }"
> >
<view class="tips-content"> <view class="tips-content">
<view <view
class="icon-close-box flex" class="icon-close-box flex"
@click="close" @click="close"
> >
<uni-icons <uni-icons
class="icon-close" class="icon-close"
type="closeempty" type="closeempty"
:size="18" :size="18"
color="#1A1A1A" color="#1A1A1A"
></uni-icons> >
</uni-icons>
</view> </view>
<view class="tips-title"> <view class="tips-title">
<template v-if="back"> <template v-if="back">
<view <view
class="sprite-icon icon-back" class="sprite-icon icon-back"
@click="close" @click="close"
></view> >
</view>
</template> </template>
{{ title }} {{ title }}
</view> </view>
<text <text
class="tips-text" class="tips-text"
v-if="content" v-if="content"
>{{ content }}</text> >{{ content }}</text>
<slot></slot> <slot>
</view> </slot>
<view </view>
class="tips-footer"
v-if="isFooter"
>
<view <view
v-if="showCancelBtn" class="tips-footer"
class="tips-btn close" v-if="isFooter"
>
<view
v-if="showCancelBtn"
class="tips-btn close"
@click="cancel" @click="cancel"
>{{ >{{
cancelBtnText cancelBtnText
}}</view> }}</view>
<view <view
class="tips-btn preview" class="tips-btn preview"
@click="confirm" @click="confirm"
>{{ >{{
confirmBtnText confirmBtnText
}}</view> }}</view>
</view> </view>
<template v-else> <template v-else>
<slot name="footer"></slot> <slot name="footer">
</template> </slot>
</view> </template>
</CustomPopup> </view>
</CustomPopup>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import CustomPopup from './CustomPopup.uvue' import CustomPopup from './CustomPopup.uvue'
import { ComponentPublicInstance } from 'vue'
const props = defineProps({
isAutoClose: { const props = defineProps({
type: Boolean, isAutoClose: {
default: true type: Boolean,
}, default: true
position: { },
type: String, position: {
default: "center" type: String,
}, default: "center"
popupW: Number, },
popupH: { popupW: Number,
type: Number, popupH: {
default: 372 type: Number,
}, default: 372
isFooter: { },
type: Boolean, isFooter: {
default: true type: Boolean,
}, default: true
title: { },
type: String, title: {
default: "提示" type: String,
}, default: "提示"
content: { },
type: String, content: {
default: "" type: String,
}, default: ""
confirmBtnText: { },
type: String, confirmBtnText: {
default: "确定" type: String,
}, default: "确定"
cancelBtnText: { },
type: String, cancelBtnText: {
default: "取消" type: String,
}, default: "取消"
maxHeight: Number, },
back: Boolean, maxHeight: Number,
showCancelBtn: { back: Boolean,
type: Boolean, showCancelBtn: {
default: true type: Boolean,
} default: true
}) }
})
const emit = defineEmits(['close', 'cancel', 'confirm']) const emit = defineEmits(['close',
'cancel',
'confirm'])
const visible = ref<boolean>(false) const visible = ref<boolean>(false)
const popupRef= ref<any>(null) const popupRef= ref(null)
function onClose(): void { function onClose(): void {
emit('close') emit('close')
} }
function close(): void { function close(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false
} else { } else {
popupRef.value?.close() if (popupRef.value != null) {
(popupRef.value as ComponentPublicInstance).$callMethod('close')
}
}
emit('close')
} }
emit('close')
}
function open(): void { function open(): void {
visible.value = true visible.value = true
} }
function cancel(): void { function cancel(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false
}
emit('cancel')
} }
emit('cancel')
}
function confirm(): void { function confirm(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false
}
emit('confirm')
} }
emit('confirm')
}
defineExpose({ defineExpose({ open, close })
open,
close
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.tips-wrapper { .tips-wrapper {
background: #ffffff; background: #ffffff;
border-radius: 20rpx 20rpx 0 0; border-radius: 20rpx 20rpx 0 0;
height: 100%; height: 100%;
.tips-content { .tips-content {
padding: 48rpx; padding: 48rpx;
box-sizing: border-box; box-sizing: border-box;
height: calc(100% - 100rpx); height: calc(100% - 100rpx);
position: relative;
.icon-close-box {
position: absolute;
right: 0;
top: 0;
width: 120rpx;
height: 120rpx;
justify-content: center;
z-index: 2;
align-items: center;
}
.tips-title {
position: relative; position: relative;
width: 100%;
font-weight: 500; .icon-close-box {
font-size: 36rpx;
color: #292d33;
text-align: center;
.icon-back {
position: absolute; position: absolute;
left: 0; right: 0;
top: 50%; top: 0;
transform: translateY(-50%); width: 120rpx;
height: 120rpx;
justify-content: center;
z-index: 2;
align-items: center;
}
.tips-title {
position: relative;
width: 100%;
font-weight: 500;
font-size: 36rpx;
color: #292d33;
text-align: center;
.icon-back {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
}
} }
} }
}
.tips-text {
.tips-text { display: block;
display: block; font-size: 30rpx;
font-size: 30rpx; color: #5a5e66;
color: #5a5e66; letter-spacing: 1rpx;
letter-spacing: 1rpx; text-align: center;
text-align: center; line-height: 40rpx;
line-height: 40rpx; margin-top: 48rpx;
margin-top: 48rpx;
}
.tips-footer {
display: flex;
align-items: center;
justify-content: center;
height: 100rpx;
border-top: 1px solid #e8e8e8;
flex-direction: row;
.close {
color: #6c6c70;
} }
.preview { .tips-footer {
color: #2c66f7; display: flex;
align-items: center;
justify-content: center;
height: 100rpx;
border-top: 1px solid #e8e8e8;
flex-direction: row;
.close {
color: #6c6c70;
}
.preview {
color: #2c66f7;
}
}
.tips-btn {
width: 50%;
text-align: center;
font-size: 32rpx;
text-align: center;
line-height: 44rpx;
font-weight: 500;
} }
} }
.radius{
.tips-btn { border-radius: 20rpx;
width: 50%;
text-align: center;
font-size: 32rpx;
text-align: center;
line-height: 44rpx;
font-weight: 500;
}
}
.radius{
border-radius: 20rpx;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<view <view
class="zoom-pan-container" class="zoom-pan-container"
:style="{ 'overflow': 'hidden', 'position': 'relative', 'touch-action': 'none' }" :style="{ 'overflow': 'hidden', 'position': 'relative', 'touch-action': 'none' }"
@touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd"
> >
<!-- @touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd" -->
<view <view
class="content" class="content"
:style="contentStyle" :style="contentStyle"
> >
<slot name="content"> <slot name="content">
</slot> </slot>
...@@ -17,145 +18,171 @@ ...@@ -17,145 +18,171 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { throttle } from '@/utils/common.uts' import { throttle } from '@/utils/common.uts'
import { state } from "@/store/index.uts" import { state } from "@/store/index.uts"
const props = defineProps({
disabled: Boolean,
scaleMax: {
type: Number,
default: 10
},
scaleMin: {
type: Number,
default: 1
}
})
const scale = ref<number>(1)
const isScaling = ref<boolean>(false)
const initialDistance = ref<number>(0)
const initialScale = ref<number>(1)
const translateX = ref<number>(0)
const translateY = ref<number>(0)
const lastTouchCenter = ref<{ x: number; y: number }>({ x: 0, y: 0 })
const currentTouchCenter = ref<{ x: number; y: number }>({ x: 0, y: 0 })
const contentStyle = computed(() => {
return {
'transform': `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`,
'transform-origin': 'center center',
'transition': isScaling.value ? 'none' : 'transform 0.3s ease-out',
'will-change': 'transform',
'position': 'absolute',
'left': '0',
'top': '0',
'width': '100%',
'height': '100%'
}
})
const watchStatus = computed(() => { type Point = {
return state.user.historyStatus x: number
}) y: number
}
watch(() => watchStatus.value, (newval) => { type TouchPoint = {
if (scale.value != 1) { pageX: number
scale.value = 1 pageY: number
translateX.value = 0 clientX: number
translateY.value = 0 clientY: number
} x: number
}, { immediate: true }) y: number
}
function handleTouchStart(e: any): void { type TouchEvent = {
if (props.disabled) return touches: Array<TouchPoint>
changedTouches: Array<TouchPoint>
if (e.touches.length === 2) {
isScaling.value = true
initialDistance.value = getTouchDistance(e.touches)
initialScale.value = scale.value
const center = getTouchCenter(e.touches)
lastTouchCenter.value = center
currentTouchCenter.value = center
}
} }
const handleTouchMove = throttle(function(e: any): void { const props = defineProps({
if (props.disabled) return disabled: Boolean,
scaleMax: {
if (isScaling.value && e.touches.length === 2) { type: Number,
const currentDistance = getTouchDistance(e.touches) default: 10
const newScale = Math.max( },
props.scaleMin, scaleMin: {
Math.min( type: Number,
props.scaleMax, default: 1
initialScale.value * (currentDistance / initialDistance.value) }
) })
)
const scale = ref<number>(1)
scale.value = newScale const isScaling = ref<boolean>(false)
const initialDistance = ref<number>(0)
const center = getTouchCenter(e.touches) const initialScale = ref<number>(1)
currentTouchCenter.value = center const translateX = ref<number>(0)
const translateY = ref<number>(0)
if (scale.value > 1) { const lastTouchCenter = ref<Point>({ x: 0, y: 0 })
const deltaX = center.x - lastTouchCenter.value.x const currentTouchCenter = ref<Point>({ x: 0, y: 0 })
const deltaY = center.y - lastTouchCenter.value.y
translateX.value += deltaX const contentStyle = computed(() => {
translateY.value += deltaY return {
'transform': `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`,
'transform-origin': 'center center',
'transition': isScaling.value ? 'none' : 'transform 0.3s ease-out',
'will-change': 'transform',
'position': 'absolute',
'left': '0',
'top': '0',
'width': '100%',
'height': '100%'
}
})
const watchStatus = computed(() => {
const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
watch(watchStatus.value , () => {
if (scale.value != 1) {
scale.value = 1
translateX.value = 0
translateY.value = 0
}
}, { immediate: true })
// function handleTouchStart(e: TouchEvent): void {
// if (props.disabled == true) return
// if (e.touches.length === 2) {
// isScaling.value = true
// initialDistance.value = getTouchDistance(e.touches)
// initialScale.value = scale.value
// const center = getTouchCenter(e.touches)
// lastTouchCenter.value = center
// currentTouchCenter.value = center
// }
// }
// const handleTouchMove = throttle(function(e: TouchEvent): void {
// if (props.disabled == true) return
// if (isScaling.value && e.touches.length === 2) {
// const currentDistance = getTouchDistance(e.touches)
// const newScale = Math.max(
// props.scaleMin,
// Math.min(
// props.scaleMax,
// initialScale.value * (currentDistance / initialDistance.value)
// )
// )
// scale.value = newScale
// const center = getTouchCenter(e.touches)
// currentTouchCenter.value = center
// if (scale.value > 1) {
// const deltaX = center.x - lastTouchCenter.value.x
// const deltaY = center.y - lastTouchCenter.value.y
// translateX.value += deltaX
// translateY.value += deltaY
// }
// lastTouchCenter.value = center
// emit('scale', scale.value)
// }
// }, 16)
// function handleTouchEnd(): void {
// if (isScaling.value) {
// isScaling.value = false
// adjustPosition()
// }
// }
function adjustPosition(): void {
if (scale.value <= 1) {
translateX.value = 0
translateY.value = 0
scale.value = 1
} }
lastTouchCenter.value = center
emit('scale', scale.value)
} }
}, 16)
function handleTouchEnd(): void { function getTouchDistance(touches: Array<TouchPoint>): number {
if (isScaling.value) { const dx = touches[0].pageX - touches[1].pageX
isScaling.value = false const dy = touches[0].pageY - touches[1].pageY
adjustPosition() return Math.sqrt(dx * dx + dy * dy)
} }
}
function adjustPosition(): void { function getTouchCenter(touches: Array<TouchPoint>): Point {
if (scale.value <= 1) { const centerX = (touches[0].pageX + touches[1].pageX) / 2
translateX.value = 0 const centerY = (touches[0].pageY + touches[1].pageY) / 2
translateY.value = 0 return { x: centerX, y: centerY }
scale.value = 1
} }
}
function getTouchDistance(touches: Array<any>): number { const emit = defineEmits(['scale'])
const dx = touches[0].pageX - touches[1].pageX
const dy = touches[0].pageY - touches[1].pageY
return Math.sqrt(dx * dx + dy * dy)
}
function getTouchCenter(touches: Array<any>): { x: number; y: number } {
const centerX = (touches[0].pageX + touches[1].pageX) / 2
const centerY = (touches[0].pageY + touches[1].pageY) / 2
return { x: centerX, y: centerY }
}
const emit = defineEmits(['scale'])
</script> </script>
<style lang="scss"> <style lang="scss">
.zoom-pan-container { .zoom-pan-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
touch-action: none; touch-action: none;
} }
.content { .content {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
transform-origin: center center; transform-origin: center center;
will-change: transform; will-change: transform;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<view class="tool-box" :style="toolStyle"> <view class="tool-box" :style="toolStyle as string">
<view :class="['btn', { hideIcon: !show }]" @click="show = false"> <view :class="['btn', { hideIcon: !show }]" @click="show = false">
<view class="icon sprite-icon icon-tool-file"> <view class="icon sprite-icon icon-tool-file">
</view> </view>
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
文件夹 文件夹
</view> </view>
<view class="list-body"> <view class="list-body">
<template v-for="(i, index) in data" :key="index"> <template v-for="(item, index) in displayData" :key="index">
<view :class="['item', { active: i[idKey] == id }]" @click="jump(i)"> <view :class="['item', { active: item.id == props.id }]" @click="jump(item)">
<image class="icon" :src="i.shortTitleUrl" mode="scaleToFill" /> <image class="icon" :src="item.shortTitleUrl" mode="scaleToFill" />
{{ i.shortTitle }} {{ item.shortTitle }}
</view> </view>
</template> </template>
</view> </view>
<template v-if="showPayBtn"> <template v-if="props.showPayBtn">
<view class="item" @click="toPay"> <view class="item" @click="toPay">
<view class="icon"> <view class="icon">
<view class="sprite-icon icon-tool-pay"> <view class="sprite-icon icon-tool-pay">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
付款方式 付款方式
</view> </view>
</template> </template>
<template v-if="type != 'preview'"> <template v-if="props.type != 'preview'">
<view class="item" @click="finish"> <view class="item" @click="finish">
<view class="icon"> <view class="icon">
<view class="sprite-icon icon-tool-finish"> <view class="sprite-icon icon-tool-finish">
...@@ -42,11 +42,18 @@ ...@@ -42,11 +42,18 @@
<script setup lang="uts"> <script setup lang="uts">
import { state } from "@/store/index.uts"; import { state } from "@/store/index.uts";
const emit = defineEmits(['choose', 'finish', 'toPay'])
type ToolItem = {
id?: string | number
shortTitleUrl?: string
shortTitle?: string
}
const props = defineProps({ const props = defineProps({
type: String, type: String,
data: Array, data: Array as () => Array<ToolItem>,
id: [String, id: [String, Number],
Number],
showPayBtn: Boolean, showPayBtn: Boolean,
idKey: { idKey: {
type: String, type: String,
...@@ -57,11 +64,25 @@ ...@@ -57,11 +64,25 @@
const show = ref<boolean>(true) const show = ref<boolean>(true)
const displayData = computed<Array<ToolItem>>(() => {
if (props.data == null) {
return []
}
return props.data as Array<ToolItem>
})
const watchStatus = computed(() => { const watchStatus = computed(() => {
return state.user.historyStatus const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
}) })
watch(() => watchStatus.value, (newval) => { watch(watchStatus.value, () => {
show.value = true show.value = true
}, { immediate: true }) }, { immediate: true })
...@@ -69,7 +90,21 @@ ...@@ -69,7 +90,21 @@
show.value = true show.value = true
} }
function jump(item: any): void { function getItemTitle(item: ToolItem): string {
if (item.shortTitle == null) {
return ''
}
return item.shortTitle
}
function getItemImageUrl(item: ToolItem): string {
if (item.shortTitleUrl == null) {
return ''
}
return item.shortTitleUrl
}
function jump(item: ToolItem): void {
show.value = true show.value = true
emit('choose', item) emit('choose', item)
} }
...@@ -82,13 +117,9 @@ ...@@ -82,13 +117,9 @@
emit('toPay') emit('toPay')
} }
const emit = defineEmits(['choose',
'finish', defineExpose({ hide })
'toPay'])
defineExpose({
hide
})
</script> </script>
<style lang="scss"> <style lang="scss">
......
...@@ -227,31 +227,27 @@ ...@@ -227,31 +227,27 @@
<script setup lang="uts"> <script setup lang="uts">
import { ref, computed, watch } from 'vue' import { ref, computed, watch } from 'vue'
interface ReceptionpriproCusCaseStageDetail { type ReceptionpriproCusCaseStageDetail = {
stageName: string stageName: string
imageUrl: string imageUrl: string
imageTag: string imageTag: string
[key: string]: any
} }
interface ReceptionpriproCusCaseStage { type ReceptionpriproCusCaseStage = {
receptionpriproCusCaseStageDetailList: Array<ReceptionpriproCusCaseStageDetail> receptionpriproCusCaseStageDetailList: Array<ReceptionpriproCusCaseStageDetail>
[key: string]: any
} }
interface ReceptionpriproCusCase { type ReceptionpriproCusCase = {
customerName: string customerName: string
licPlateNumber: string licPlateNumber: string
comAmount: string | number comAmount: string | number
receptionpriproCusCaseStageList: Array<ReceptionpriproCusCaseStage> receptionpriproCusCaseStageList: Array<ReceptionpriproCusCaseStage>
[key: string]: any
} }
interface DetailData { type DetailData = {
title: string title: string
productPoster: string productPoster: string
receptionpriproCusCaseList: Array<ReceptionpriproCusCase> receptionpriproCusCaseList: Array<ReceptionpriproCusCase>
[key: string]: any
} }
interface Thumbnail { interface Thumbnail {
......
...@@ -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
......
...@@ -22,65 +22,74 @@ ...@@ -22,65 +22,74 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import MessageBox from '@/components/MessageBox.uvue' import MessageBox from '@/components/MessageBox.uvue'
import { state } from '@/store/index.uts' import { state } from '@/store/index.uts'
const props = defineProps({ type CarBuyersItem = {
title: { name: string
type: String, id: number
default: '购车方式' }
},
salesPropsUuid: {
type: String,
default: ''
}
})
const emit = defineEmits(['close', 'select']) const props = defineProps({
title: {
type: String,
default: '购车方式'
},
salesPropsUuid: {
type: String,
default: ''
}
})
const carBuyersVisible = ref<any>(null) const emit = defineEmits(['close', 'select'])
const carBuyersList = ref<Array<{name: string, id: number}>>([ const carBuyersVisible = ref(null)
{
name: '全款',
id: 1
},
{
name: '按揭',
id: 2
}
])
const watchStatus = computed(() => { const carBuyersList = ref<Array<CarBuyersItem>>([{
return state.user.historyStatus name: '全款',
}) id: 1
}, {
name: '按揭',
id: 2
}] as Array<CarBuyersItem>)
const carBuyers = computed(() => { const watchStatus = computed(() => {
return state.user.customerInfo.carBuyers const status = state.user?.historyStatus
}) if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
watch(() => watchStatus.value, (newval) => { const carBuyers = computed(() => {
close() return state.user.customerInfo.carBuyers
}, { immediate: true }) })
function open(): void { watch(watchStatus.value, (newval) => {
;(carBuyersVisible.value as any).open() close()
} }, { immediate: true })
function handleSelect(item: {name: string, id: number}): void { function open(): void {
close() ;(carBuyersVisible.value as any).open()
emit('select', item) }
}
function close(): void { function handleSelect(item: CarBuyersItem): void {
;(carBuyersVisible.value as any)?.close() close()
} emit('select', item)
}
function onClose(): void { function close(): void {
emit('close') ;(carBuyersVisible.value as any)?.close()
} }
function onClose(): void {
emit('close')
}
defineExpose({ open, close }) defineExpose({ open, close })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -42,21 +42,19 @@ import wnCanvas from '@/components/PanCanvas/index.uvue' ...@@ -42,21 +42,19 @@ import wnCanvas from '@/components/PanCanvas/index.uvue'
import { state } from "@/store/index.uts" import { state } from "@/store/index.uts"
import nothingImage from '@/assets/images/media/nothing.webp' import nothingImage from '@/assets/images/media/nothing.webp'
interface Views { type Views = {
detailUrl?: string detailUrl?: string
bgUrl?: string bgUrl?: string
[key: string]: any
} }
interface CustomerInfo { type CustomerInfo = {
carModelId?: string carModelId?: string
[key: string]: any
} }
const props = defineProps({ const props = defineProps({
views: { views: {
type: Object as () => Views | Array<any>, type: Object as () => UTSJSONObject,
default: () => ({}) default: () => ({})
}, },
penSwitch: Boolean, penSwitch: Boolean,
...@@ -68,14 +66,15 @@ const props = defineProps({ ...@@ -68,14 +66,15 @@ const props = defineProps({
const emit = defineEmits(['scale']) const emit = defineEmits(['scale'])
const canvasRef = ref<any>(null) const canvasRef = ref(null)
const customerInfo = computed<CustomerInfo>(() => { const customerInfo = computed<CustomerInfo>(() => {
return state.user.customerInfo || {} const info = state.user.customerInfo
return info != null ? info.as(CustomerInfo) : {} as CustomerInfo
}) })
const viewKey = computed<string>(() => { const viewKey = computed<string>(() => {
return state.user?.viewKey || '' return state.user?.viewKey != null ? state.user.viewKey : ''
}) })
function onScale(e: number): void { function onScale(e: number): void {
......
...@@ -2,114 +2,117 @@ ...@@ -2,114 +2,117 @@
<view class="page-title-box flex"> <view class="page-title-box flex">
{{title}} {{title}}
<view <view
class="car-options flex" class="car-options flex"
v-if="hasCarBrand" v-if="hasCarBrand"
@click="openCarBrand" @click="openCarBrand"
> >
{{customerInfo.carModel||'请选择'}} {{customerInfo.carModel||'请选择'}}
<view class="sprite-icon icon-arrow-bottom"></view> <view class="sprite-icon icon-arrow-bottom">
</view>
</view> </view>
<CarBrands <CarBrands
ref="carBrandListVisible" ref="carBrandListVisible"
@select="handleSelect" @select="handleSelect"
/> />
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import CarBrands from '@/components/CarBrands.uvue' import CarBrands from '@/components/CarBrands.uvue'
import { state , store } from "@/store/index.uts" import { state , store } from "@/store/index.uts"
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
interface CustomerInfo { type CustomerInfo = UTSJSONObject
carModel?: string
carModelId?: string type UserInfo = UTSJSONObject
[key: string]: any
}
const props = defineProps({
interface UserInfo { title: String,
channelType: number hasCarBrand: Boolean,
[key: string]: any show: Boolean
} })
const carBrandListVisible = ref(null)
const props = defineProps({ const customerInfo = ref<CustomerInfo>({} as CustomerInfo)
title: String,
hasCarBrand: Boolean, const watchCustomerInfo = computed<CustomerInfo>(() => {
show: Boolean return state.user?.customerInfo != null ? state.user.customerInfo : {} as CustomerInfo
}) })
const carBrandListVisible = ref<any>(null) const watchStatus = computed(() => {
const customerInfo = ref<CustomerInfo>({}) const status = state.user?.historyStatus
if (status == null) {
const watchCustomerInfo = computed<CustomerInfo>(() => { return false
return state.user?.customerInfo || {} } else if (status == 1) {
}) return true
} else {
const watchStatus = computed<boolean>(() => { return false
return state.user?.historyStatus || false }
}) })
const isAito = computed<boolean>(() => { const isAito = computed<boolean>(() => {
const userInfo: UserInfo = storage.get('userInfo') || { channelType: 0 } const userInfo: UserInfo = storage.get('userInfo') != null ? storage.get('userInfo') : { channelType: 0 } as UserInfo
return userInfo.channelType == 1 return userInfo.channelType == 1
}) })
watch(() => props.show, (newval) => { watch(() => props.show, (newval) => {
if (newval && props.hasCarBrand && !customerInfo.value.carModel && isAito.value) { if (newval === true && props.hasCarBrand === true && (customerInfo.value.carModel == null || customerInfo.value.carModel === '') && isAito.value === true) {
setTimeout(() => { setTimeout(() => {
carBrandListVisible.value?.autoSelect() carBrandListVisible.value?.autoSelect()
}, 1000) }, 1000)
}
}, { immediate: true })
watch(() => watchCustomerInfo.value, (newval) => {
if (newval != null) {
customerInfo.value = { ...newval }
}
}, { immediate: true })
function handleSelect(item: any): void {
carBrandListVisible.value?.close()
onSelect(item)
} }
}, { immediate: true })
watch(() => watchCustomerInfo.value, (newval) => { function onSelect(item: any): void {
if (newval) { customerInfo.value.carModel = item.name
customerInfo.value = { ...newval } customerInfo.value.carModelId = item.id
store.dispatch?.('setCustomerInfo', customerInfo.value)
} }
}, { immediate: true })
function openCarBrand(): void {
function handleSelect(item: any): void { carBrandListVisible.value?.open()
carBrandListVisible.value?.close() }
customerInfo.value.carModel = item.name
customerInfo.value.carModelId = item.id defineExpose({ carBrandListVisible })
store.dispatch('setCustomerInfo', customerInfo.value)
}
function openCarBrand(): void {
carBrandListVisible.value?.open()
}
defineExpose({
carBrandListVisible
})
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.page-title-box { .page-title-box {
justify-content: center; justify-content: center;
position: absolute; position: absolute;
height: 96rpx; height: 96rpx;
left: 0; left: 0;
top: 48rpx; top: 48rpx;
font-weight: 500; font-weight: 500;
font-size: 36rpx; font-size: 36rpx;
color: #333; color: #333;
width: 100%; width: 100%;
z-index: 2; z-index: 2;
flex-direction: row; flex-direction: row;
align-items: center;
.car-options {
align-items: center; align-items: center;
flex-direction: row;; .car-options {
&::before { align-items: center;
content: ''; flex-direction: row;
width: 2rpx; &::before {
height: 36rpx; content: '';
opacity: 1; width: 2rpx;
background: #333333; height: 36rpx;
margin: 0 24rpx; opacity: 1;
} background: #333333;
margin: 0 24rpx;
}
}
} }
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
@click="showPopup(i.popKey, index)" @click="showPopup(i.popKey, index)"
> >
<view class="value text-hide"> <view class="value text-hide">
{{ customerInfo[i.key] || i.placeholder }} {{ customerInfo[i.key] ? customerInfo[i.key] : i.placeholder }}
</view> </view>
<uni-icons <uni-icons
class="arrow" class="arrow"
...@@ -95,19 +95,7 @@ ...@@ -95,19 +95,7 @@
popKey?: string popKey?: string
} }
interface CustomerInfo { type CustomerInfo = UTSJSONObject
customerName?: string
phoneNumber?: string
carModel?: string
carModelId?: string | number
salesUuid?: string
staffName?: string
carBrand?: string
carBrandId?: string | number
oneCarBrand?: string
oneCarBrandId?: string | number
[key: string]: any
}
const props = defineProps({ const props = defineProps({
penSwitch: Boolean, penSwitch: Boolean,
...@@ -146,22 +134,21 @@ ...@@ -146,22 +134,21 @@
const focusIndex = ref<number>(-1) const focusIndex = ref<number>(-1)
const watchCustomerInfo = computed(() => { const watchCustomerInfo = computed(() => {
return store.state.user.customerInfo return store.state?.user.customerInfo
}) })
const watchStatus = computed(() => { const watchStatus = computed(() => {
return store.state.user.historyStatus return store.state?.user.historyStatus
}) })
const isAito = computed(() => { const isAito = computed(() => {
const userInfo = storage.get('userInfo') const userInfo = storage.get('userInfo')
return userInfo.channelType == 1 return userInfo?.channelType == 1
}) })
watch(() => watchCustomerInfo.value, (newval) => { watch(() => watchCustomerInfo.value, (newval) => {
if (newval) { if (newval) {
customerInfo.value = newval as CustomerInfo customerInfo.value = newval as CustomerInfo
console.log( customerInfo.value,'==========')
} }
}, { immediate: true }) }, { immediate: true })
...@@ -169,42 +156,33 @@ ...@@ -169,42 +156,33 @@
if (n && !customerInfo.value.carModel && isAito.value) { if (n && !customerInfo.value.carModel && isAito.value) {
setTimeout(() => { setTimeout(() => {
carBrandListVisibleRef.value.$callMethod('autoSelect') carBrandListVisibleRef.value?.$callMethod('autoSelect')
}, 1000) }, 1000)
} }
}, { immediate: true }) }, { immediate: true })
const carBrandListVisibleRef = ref<any>(null) const carBrandListVisibleRef = ref(null)
function onInputCustomer(): void { function onInputCustomer(): void {
store.dispatch('setCustomerInfo', customerInfo.value) store.dispatch?.('setCustomerInfo', customerInfo.value)
} }
function onSelect(item: any, popkey: string): void { function onSelect(item: any, popkey: string): void {
carBrandListVisibleRef.value.$callMethod('close') customerInfo.value.carModel = item.name
// const customerInfo = dispatch('getCustomerInfo') customerInfo.value.carModelId = item.id
// if (popkey == 'employeeBoxVisible') { carBrandListVisibleRef.value?.$callMethod('close')
// customerInfo.value.salesUuid = item.uuid
// customerInfo.value.staffName = item.staffName
// } else {
// customerInfo.value.carModel = item.name
// customerInfo.value.carModelId = item.id
// }
resetFocusIndex() resetFocusIndex()
// store.dispatch('setCustomerInfo', customerInfo.value)
} }
function showPopup(e: string, index: number): void { function showPopup(e: string, index: number): void {
focusIndex.value = index focusIndex.value = index
if (e == 'carBrandListVisible') { if (e == 'carBrandListVisible') {
carBrandListVisibleRef.value.$callMethod('open') carBrandListVisibleRef.value?.$callMethod('open')
} }
} }
function closeAllPopup(): void { function closeAllPopup(): void {
carBrandListVisibleRef.value.$callMethod('close') carBrandListVisibleRef.value?.$callMethod('close')
resetFocusIndex() resetFocusIndex()
} }
...@@ -219,7 +197,7 @@ ...@@ -219,7 +197,7 @@
customerName: e.ownerName customerName: e.ownerName
} }
uni.$logger.local.info(`从客户档案选择:${JSON.stringify(e)}`) // uni.$logger.local.info(`从客户档案选择:${JSON.stringify(e)}`)
if (e.carModelId) { if (e.carModelId) {
customerInfo.value.carModelId = e.carModelId customerInfo.value.carModelId = e.carModelId
...@@ -236,9 +214,8 @@ ...@@ -236,9 +214,8 @@
function contentUrl(): string { function contentUrl(): string {
const views = props.views as any const views = props.views as any
const carModelId = customerInfo.value.carModelId const carModelId = customerInfo.value.carModelId
if (Array.isArray(views)) { if (Array.isArray(views)) {
return (views as any)[carModelId] || '/static/images/media/nothing.webp' return (views as any)[carModelId ?? ''] || '/static/images/media/nothing.webp'
} else if ((views as UTSJSONObject).detailUrl) { } else if ((views as UTSJSONObject).detailUrl) {
return (views as UTSJSONObject).detailUrl as string return (views as UTSJSONObject).detailUrl as string
} else { } else {
......
...@@ -87,7 +87,6 @@ ...@@ -87,7 +87,6 @@
defultTabId?: number defultTabId?: number
pageStyle?: string pageStyle?: string
carIcon?: string carIcon?: string
[key: string]: any
} }
const props = defineProps({ const props = defineProps({
...@@ -104,7 +103,7 @@ ...@@ -104,7 +103,7 @@
const direction = ref<string>('bottom') const direction = ref<string>('bottom')
const imgKey = ref<number>(Date.now()) const imgKey = ref<number>(Date.now())
const tabIndex = ref<number>(2) const tabIndex = ref<number>(2)
const threeGuarantees = ref<any>(null) const threeGuarantees = ref(null)
const watchStatus = computed(() => { const watchStatus = computed(() => {
return store.state.user.historyStatus return store.state.user.historyStatus
...@@ -114,7 +113,7 @@ ...@@ -114,7 +113,7 @@
return (props.detail as Detail).tabList.find(item => item.id == activeIndex.value).imgIdList return (props.detail as Detail).tabList.find(item => item.id == activeIndex.value).imgIdList
}) })
watch(() => watchStatus.value, () => { watch(watchStatus.value, () => {
activeIndex.value = (props.detail as Detail).defultActiveId || 0 activeIndex.value = (props.detail as Detail).defultActiveId || 0
tabIndex.value = (props.detail as Detail).defultTabId tabIndex.value = (props.detail as Detail).defultTabId
}) })
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
imgUrl?: string imgUrl?: string
} }
const INFO_LIST: InfoListItem[] = [ const INFO_LIST: Array<InfoListItem> = [
{ {
id: 1, id: 1,
title: "客户付款凭证", title: "客户付款凭证",
...@@ -92,19 +92,19 @@ ...@@ -92,19 +92,19 @@
}) })
const emit = defineEmits(['update:showPayPage', 'finish']) const emit = defineEmits(['update:showPayPage', 'finish'])
const infoList = ref<InfoListItem[]>(JSON.parse(JSON.stringify(INFO_LIST))) const infoList = ref<Array<InfoListItem>>(JSON.parse(JSON.stringify(INFO_LIST)) as Array<InfoListItem>)
const previewImg = ref<string>('') const previewImg = ref<string>('')
const isPreview = ref<boolean>(false) const isPreview = ref<boolean>(false)
const watchBooksList = computed(() => { const watchBooksList = computed<Array<InfoListItem>>(() => {
return state.audio.booksList return state.audio.booksList
}) })
watch(() => watchBooksList.value, (newValue: InfoListItem[]) => { watch(() => watchBooksList.value, (newValue: Array<InfoListItem>) => {
if (newValue && newValue.length) { if (newValue != null && newValue.length > 0) {
infoList.value = newValue infoList.value = newValue
} else { } else {
infoList.value = JSON.parse(JSON.stringify(INFO_LIST)) infoList.value = JSON.parse(JSON.stringify(INFO_LIST)) as Array<InfoListItem>
} }
}, { immediate: true }) }, { immediate: true })
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
// "imgUrl", // "imgUrl",
// url // url
// ); // );
infoList.value[index].imgUrl = url // infoList.value[index].imgUrl = url
// setBooks(utils.deepClone(infoList.value)) // setBooks(utils.deepClone(infoList.value))
} catch (error) { } catch (error) {
console.error(`上传付款凭证失败:${error}`) console.error(`上传付款凭证失败:${error}`)
...@@ -160,16 +160,17 @@ ...@@ -160,16 +160,17 @@
// 删除图片 // 删除图片
function close(index: number): void { function close(index: number): void {
infoList.value[index].imgUrl = '' infoList.value[index].imgUrl = ''
dispatch('setBooks', JSON.parse(JSON.stringify(infoList.value))) dispatch('setBooks', JSON.parse(JSON.stringify(infoList.value)) as Array<InfoListItem>)
} }
// 预览图片 // 预览图片
function preview(index: number): void { function preview(index: number): void {
isPreview.value = true isPreview.value = true
previewImg.value = infoList.value[index].imgUrl || '' previewImg.value = infoList.value[index].imgUrl != null ? infoList.value[index].imgUrl : ''
const imageUrl: string = infoList.value[index].imgUrl != null ? infoList.value[index].imgUrl : ''
uni.previewImage({ uni.previewImage({
urls: [infoList.value[index].imgUrl || ''], urls: [imageUrl],
longPressActions: { longPressActions: {
success: function (data) { success: function (data) {
console.log( console.log(
...@@ -314,4 +315,4 @@ ...@@ -314,4 +315,4 @@
.preview-img { .preview-img {
height: 1300rpx; height: 1300rpx;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
const title = ref<string>('') const title = ref<string>('')
const accountInfo = ref<Record<string, any>>({}) const accountInfo = ref<Record<string, any>>({})
const payInfo = ref<Record<string, any>>({}) const payInfo = ref<Record<string, any>>({})
const popup = ref<any>(null) const popup = ref(null)
const visible = ref<boolean>(false) const visible = ref<boolean>(false)
// 使用传入的 paymentType 或从 store 获取 // 使用传入的 paymentType 或从 store 获取
......
...@@ -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!