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