Commit d02c6104 by liimin

feat: 新增组件并优化现有功能

refactor(HomeFrame): 重构布局和动画性能
feat(ResultSelect): 新增接待结果选择组件
feat(CustomerTypeRadio): 新增客户类型单选组件
feat(ResultList): 新增结果列表组件
style(ButtonGroup): 优化按钮组样式和交互
perf(RecordList): 优化记录列表性能和数据格式化
refactor(FinishStep): 使用新组件重构完成步骤
perf(equity/detail): 优化滑动切换和渲染性能
refactor(equity/index): 优化数据获取和状态管理
refactor(saveRecord): 重构表单布局和验证逻辑
1 parent e01037b1
<template>
<view class="button-group">
<view
v-for="(item, index) in selectList"
:key="index"
class="button-item"
:class="{ active: index === selectIndex }"
@click="chooseType(index, item)"
:style="{ width: itemWidth + 'rpx', marginRight: index === selectList.length - 1 ? 0 : gap + 'rpx' }"
>
<text class="label">{{ item[labelKey] }}</text>
<!-- 选中时的背景动画元素 -->
<view class="active-bg" v-if="index === selectIndex"></view>
</view>
<template v-for="(item, index) in selectList">
<view
:key="index"
class="button-item"
:class="{ active: index === selectIndex }"
@click="chooseType(index, item)"
:style="{ width: itemWidth + 'rpx' }"
>
<text class="label">{{ item[labelKey] }}</text>
<template v-if="item.dot && item.dot()">
<view class="dot"></view>
</template>
<!-- 选中时的背景动画元素 -->
<view class="active-bg" v-if="index === selectIndex"></view>
</view>
<view class="divider" v-if="index < selectList.length - 1" :key="'divider-' + index"></view>
</template>
</view>
</template>
......@@ -30,8 +35,7 @@ export default {
data() {
return {
selectIndex: 0,
itemWidth: 104, // 按钮固定宽度
gap: 16 // 按钮间距
itemWidth: 140, // 按钮固定宽度
}
},
methods: {
......@@ -76,6 +80,17 @@ export default {
z-index: 2; /* 文字在最上层 */
}
.dot {
position: absolute;
top: toRpx(8);
right: toRpx(16);
width: toRpx(12);
height: toRpx(12);
border-radius: 100%;
background: #f24724;
z-index: 3;
}
/* 激活状态的背景层 */
.active-bg {
position: absolute;
......@@ -95,6 +110,13 @@ export default {
box-shadow: 0 toRpx(2) toRpx(8) rgba(55, 115, 248, 0.15);
}
}
.divider {
width: 1px;
height: toRpx(32);
background: #ebedf0;
margin: 0 toRpx(12);
}
}
@keyframes pulse-fade {
......
<template>
<radio-group @change="handleChange" class="radio-group">
<template v-for="(item, index) in items">
<label class="radio" :key="index">
<radio :value="item.value" :checked="value == item.value" />
{{ item.label }}
</label>
</template>
</radio-group>
</template>
<script>
export default {
name: "CustomerTypeRadio",
props: {
value: {
type: [String, Number],
default: ''
},
items: {
type: Array,
default: () => [
{
label: "VIP",
value: 'VIP'
},
{
label: "潜客",
value: '潜客'
},
{
label: "普通",
value: '普通'
}
]
}
},
methods: {
handleChange(e) {
this.$emit('input', e.detail.value);
this.$emit('change', e);
}
}
}
</script>
<style scoped lang="scss">
.radio-group {
display: flex;
align-items: center;
height: 100%;
.radio {
display: flex;
align-items: center;
margin-right: toRpx(30);
}
}
</style>
......@@ -16,14 +16,7 @@
<input :type="i.inputType" :maxlength="i.maxlength" v-model="formData[i.key]" class="input" :placeholder="i.placeholder" :disabled="customerType == 0" @input="inputCustomer" placeholder-style="color:#c9c9c9;" />
</template>
<template v-else-if="i.type == 'radio'">
<radio-group @change="radioChange">
<template v-for="(item, index) in i.items">
<label class="radio" :key="index">
<radio :value="item.value" :checked="formData[i.key] == item.value" />
{{ item.label }}
</label>
</template>
</radio-group>
<CustomerTypeRadio :value="formData[i.key]" @change="radioChange" />
</template>
<!-- <template v-else>
<view
......@@ -46,14 +39,7 @@
</template>
<template v-else>
<view class="pop-tips">请完善本次接待结果</view>
<view class="choose-box">
<template v-for="(i, index) in resultList">
<view :class="['choose-item', `${i.status == receptionStatus ? (i.status == 1 ? 'success' : 'error') : ''}`]" :key="index" @click="chooseResult(i.status)">
<view :class="['sprite-icon', `icon-face-${i.status == receptionStatus ? `${i.icon}-active` : i.icon}`]"></view>
{{ i.text }}
</view>
</template>
</view>
<ResultList :list="resultList" :value="receptionStatus" @change="chooseResult" />
</template>
</view>
</MessageBox>
......@@ -65,9 +51,15 @@
<script type="text/ecmascript-6">
import { mapMutations } from "vuex";
import ResultList from '@/components/ResultList.vue'
import CustomerTypeRadio from '@/components/CustomerTypeRadio.vue'
const phoneRex = /^[1]([2-9])[0-9]{9}$/;
export default {
name: 'FinishStep',
components: {
ResultList,
CustomerTypeRadio
},
props: {
sceneType: {
type: Number,
......@@ -105,20 +97,6 @@ export default {
label: "客户类型",
key: "customerType",
type: "radio",
items: [
{
label: "VIP",
value: 'VIP'
},
{
label: "潜客",
value: '潜客'
},
{
label: "普通",
value: '普通'
}
],
placeholder: '请输入客户类型',
required: true
},
......@@ -407,30 +385,4 @@ export default {
}
}
}
.choose-box {
display: flex;
flex-direction: column;
align-items: center;
.choose-item {
width: 100%;
height: toRpx(128);
border: toRpx(2) solid #e8e8e8;
border-radius: toRpx(16);
display: flex;
align-items: center;
justify-content: center;
margin-top: toRpx(24);
.sprite-icon {
margin-right: toRpx(16);
}
}
.success {
background: #14cc681a;
border-color: #14cc681a;
}
.error {
background: #f247241a;
border-color: #f247241a;
}
}
</style>
......@@ -8,7 +8,7 @@
<view class="module-box box-class">
<view class="common-title">
<text class="title-text">
<text class="highlight-type">{{ currentType.typeName }}</text>
<text class="highlight-type" @click="changeType">{{ currentType.typeName }}</text>
产品介绍
</text>
<view class="switch-btn flex" @click="changeType">
......
......@@ -122,7 +122,7 @@ export default {
]),
uploadTypeList: Object.freeze([
{ label: '待上传' },
{ label: '待提交' },
{ label: '待提交', dot: () => this.preRecordFailList.length },
]),
itemObject: Object.freeze([
// { label: '接待结果', key: 'result' },
......@@ -194,6 +194,7 @@ export default {
item = {
"id": null,
"merchantId": "44210895",
customerType: 'VIP',
"customerName": "1211第五",
"phoneNumber": "13512110555",
"salesUuid": "77936e318e9844e4af0b099c7ccc98e4",
......@@ -287,11 +288,18 @@ export default {
},
async getPreRecordNum () {
const preRecordList = await this.recorder.getRecords()
this.preRecordFailList = preRecordList
this.preRecordFailList =this.formatRecordList(preRecordList)
//[{
// result: '',
// customerPhone: '',
// customerType: 'VIP',
// customerName: '',
// carType: '',
// startTime: '',
// endTime: '' }]
},
getRecordFail () {
this.getRecordNum()
this.list[0] = this.recordFailList.map(record => {
formatRecordList(list) {
return list.map(record => {
return {
result: record.result,
customerPhone: record.customerPhone,
......@@ -303,6 +311,10 @@ export default {
endTime: record.endTime
}
})
},
getRecordFail () {
this.getRecordNum()
this.list[0] = this.formatRecordList(this.recordFailList)
this.flag = true
this.isPrePage = false
this.nothing = !!this.recordFailList.length
......@@ -396,24 +408,7 @@ export default {
async submitRecord (val) {
this.flag = false
delete val.duration
delete val.startTime
const { maxUploadNum = 10 } = uni.$storage.get('mock_data')
if (val.recordUrlList.length > maxUploadNum) {
const userInfo = uni.$storage.get('userInfo')
const { customerName, phoneNumber, carModel, salesName } = val || {}
const { name } = userInfo || {}
uni.$logger.error({
msg: `员工: ${name}, 客户: ${customerName}`,
extra: {
'手机号: ': phoneNumber,
'姓名: ': customerName,
'销售: ': salesName,
'车型: ': carModel,
'原因: ': '录音文件过长,数量' + val.recordUrlList.length
}
})
}
val.recordUrlList = val.recordUrlList.slice(0, maxUploadNum)
// delete val.startTime
await this.recorder.save(val)
this.getRecordNum()
await this.getPreRecordFail()
......
<template>
<view class="container" @click="handleTouchStart">
<view :class="['home', { show: !id && showHome }]">
<view :class="['home', { show: !activeDetailId && showHome }]">
<left-side :userInfo="userInfo" :tabIndex.sync="tabIndex" ref="leftBox" @changeTab="changeTab" @stopAudio="stopAudio" @showReadCountTips="showReadCountTips" @closeTips="closeTips" />
<view class="tips-box" :style="tipsObject.style" @click.stop="closeTips">{{ tipsObject.text }}</view>
<view class="right-side">
......@@ -11,9 +11,12 @@
</view>
<store-address v-if="footerBox" />
</view>
<view :class="['detail', { show: id }]">
<view :class="['detail', { show: activeDetailId }]">
<slot name="detail" />
</view>
<view class="point-page" v-if="!showHome && !activeDetailId">
<component :is="pointComponentName" :transfer="transfer" @close="showHome = true" />
</view>
<!-- 未点击开始接待,弹窗 -->
<MessageBox ref="previewRef" @confirm="previewHandler('preview', true)" :popupW="704" content="直接点击素材可进行预览,若面向车主展示,请点击「开始接待」" confirmBtnText="预览素材" @cancel="previewHandler('previewCancel')" @close="previewHandler('previewClose')"></MessageBox>
<finish-reception-dialog ref="finish" @confirm="$emit('openStep')" @cancel="$emit('backHome')" />
......@@ -37,14 +40,19 @@ import recorder from '@/mixin/record/recorder'
import uploader from '@/mixin/record/uploader.js'
import versionCheck from '@/mixin/versionCheck.js'
import LeftSide from './components/LeftSide.vue'
import Material from '@/components/MaterialIndex.vue'
import HomeSlot from './components/HomeSlot.vue'
import Order from './components/Order/index.vue'
const TAB_COMPONENTS = {
1: 'ReceptionCenter',
2: 'Order'
}
export default {
mixins: [recorder, uploader, timeout, versionCheck],
components: { LeftSide, Material, ReceptionCenter, FinishReceptionDialog, StoreAddress, HomeSlot, Order },
components: { LeftSide, ReceptionCenter, FinishReceptionDialog, StoreAddress, HomeSlot, Order },
props: {
id: [String, Number],
activeDetailId: [String, Number],
finishDoneText: String,
finishContene: {
type: String,
......@@ -97,8 +105,7 @@ export default {
return this.$refs.finish
},
componentName() {
let tabs = this.$refs.leftBox?.tabs
return tabs ? tabs[this.tabIndex].name : ''
return TAB_COMPONENTS[this.tabIndex] || ''
}
},
methods: {
......@@ -161,6 +168,7 @@ export default {
text-align: left;
display: none;
opacity: 0;
will-change: opacity, display; // 优化动画性能
}
&::after {
......@@ -173,10 +181,10 @@ export default {
background-image: url('@/assets/images/common/home-bg-1.webp');
background-size: 100% 100%;
z-index: 1;
pointer-events: none; // 避免背景图阻挡交互
}
.home,
.detail {
.home {
position: fixed;
width: 100%;
height: 100%;
......@@ -185,6 +193,29 @@ export default {
left: 0;
visibility: hidden;
opacity: 0;
will-change: opacity, visibility; // 提示浏览器提前优化
// 使用3D加速,避免重绘
transform: translateZ(0);
}
.detail {
position: fixed;
width: 100vw;
height: 100vh;
left: 0;
top: 0;
z-index: -1;
visibility: hidden;
transform: translateX(100%);
transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1), visibility 0.5s;
will-change: transform, visibility; // 提示浏览器提前优化
&.show {
z-index: 2;
visibility: visible;
transform: translateX(0);
}
}
.point-page {
......@@ -250,41 +281,44 @@ export default {
z-index: 2;
visibility: visible;
animation: show-content-left 0.15s forwards;
will-change: transform;
}
}
@keyframes show-content-left {
0% {
left: 100%;
transform: translateX(100%);
}
100% {
left: 0;
transform: translateX(0);
}
}
.right-side {
flex: 1;
position: relative;
width: calc(100vw - #{toRpx(240)});
.right-content {
height: 100vh;
box-sizing: border-box;
flex: 1;
position: relative;
animation: show-box 0.15s forwards;
overflow: hidden;
}
width: calc(100vw - #{toRpx(240)});
contain: layout style; // 限制样式和布局计算范围
@keyframes show-box {
0% {
left: 100%;
.right-content {
height: 100vh;
box-sizing: border-box;
position: relative;
animation: show-box 0.15s forwards;
overflow: hidden;
will-change: transform; // 优化动画
}
100% {
left: 0;
@keyframes show-box {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(0);
}
}
}
.start {
height: toRpx(232);
......
......@@ -4,6 +4,7 @@
:type="position"
:is-mask-click="false"
:animation="animation"
:mask-background-color="maskBackgroundColor"
>
<view
class="tips-wrapper"
......@@ -111,6 +112,10 @@ export default {
showCancelBtn: {
type: Boolean,
default: true,
},
maskBackgroundColor: {
type: String,
default: 'rgba(0, 0, 0, 0.4)'
}
},
methods: {
......@@ -135,8 +140,10 @@ export default {
<style scoped lang="scss">
.tips-wrapper {
background: #ffffff;
border-radius: toRpx(20);
border-radius: toRpx(24);
height: 100%;
box-shadow: 0 toRpx(12) toRpx(48) rgba(0, 0, 0, 0.16), 0 toRpx(4) toRpx(16) rgba(0, 0, 0, 0.08);
border: 1px solid rgba(0, 0, 0, 0.06);
.tips-content {
padding: toRpx(48);
box-sizing: border-box;
......
<template>
<view class="choose-box">
<template v-for="(i, index) in list">
<view :class="['choose-item', `${i.status == value ? (i.status == '完成' || i.status == 1 ? 'success' : 'error') : ''}`]" :key="index" @click="chooseResult(i.status)">
<view :class="['sprite-icon', `icon-face-${i.status == value ? `${i.icon}-active` : i.icon}`]"></view>
{{ i.text }}
</view>
</template>
</view>
</template>
<script>
export default {
name: "ResultList",
props: {
list: {
type: Array,
default: () => []
},
value: {
type: [String, Number],
default: -1
}
},
methods: {
chooseResult(val) {
this.$emit('input', val);
this.$emit('change', val);
}
}
}
</script>
<style scoped lang="scss">
.choose-box {
display: flex;
flex-direction: column;
align-items: center;
.choose-item {
width: 100%;
height: toRpx(128);
border: toRpx(2) solid #e8e8e8;
border-radius: toRpx(16);
display: flex;
align-items: center;
justify-content: center;
margin-top: toRpx(24);
.sprite-icon {
margin-right: toRpx(16);
}
}
.success {
background: #14cc681a;
border-color: #14cc681a;
}
.error {
background: #f247241a;
border-color: #f247241a;
}
}
</style>
<template>
<MessageBox ref="popup" title="接待结果" :popupW="704" :isFooter="false" :maskBackgroundColor="maskBackgroundColor">
<ResultList :list="list" :value="value" @change="handleChange" />
</MessageBox>
</template>
<script>
import ResultList from './ResultList.vue'
export default {
name: "ResultSelect",
components: {
ResultList
},
props: {
list: {
type: Array,
default: () => [
{
icon: 'success',
text: '结果完美,成交了',
status: "完成"
},
{
icon: 'error',
text: '仍需努力,战败了',
status: "未完成"
}
]
},
value: {
type: [String, Number],
default: -1
},
maskBackgroundColor: {
type: String,
default: 'rgba(0, 0, 0, 0.4)'
}
},
methods: {
open() {
this.$refs.popup.open()
},
close() {
this.$refs.popup.close()
},
handleChange(val) {
this.$emit('input', val);
this.$emit('change', val);
}
}
}
</script>
......@@ -377,7 +377,12 @@ export default {
try {
if (str && (str.includes('=') || str.length > 50)) {
const decrypted = decryptAES(str)
if (decrypted) return decrypted
if (decrypted) {
if (label == 'Region' && decrypted.includes('.')) {
decrypted = decrypted.split('.')[0]
}
}
return decrypted
}
} catch (e) {
console.error(`${label} decryption error`, e)
......
......@@ -3,7 +3,7 @@
* @Author: huyue
* @Date: 2024-04-08 11:30:30
* @LastEditors: limin
* @LastEditTime: 2025-12-29 08:46:10
* @LastEditTime: 2025-12-29 11:40:42
-->
<template>
<view class="detail-box" :key="dateilKey">
......@@ -13,9 +13,12 @@
</view>
</view>
<template v-for="(item, index) in moduleList">
<view :class="['view', getViewClass(item)]" :key="index" @touchstart.stop="touchStart"
<view :class="['view', getViewClass(item)]" :style="{ 'animation-duration': swipeConfig.animDuration + 'ms' }" :key="index" @touchstart.stop="touchStart"
@touchend.stop="touchEnd">
<component @full="handleFull" :detail="item" :is="item.componentName"
<!-- 优化:仅渲染当前页、上一页、下一页,减少DOM节点 -->
<component
v-if="shouldRender(item)"
@full="handleFull" :detail="item" :is="item.componentName"
:views="item.receptionSourceDetailList || []" :penSwitch="penSwitch" :show="id == item.id"
:ref="'media' + item.id" :title="item.materialName || ''" :madiaId="item.id" @scale="scale"
:ulList="item.ulList" :screenList="item.screenList" @onProductModel="productModelStatus = $event"
......@@ -412,38 +415,42 @@ export default {
},
touchEnd(e) {
if (this.modeName || this.isAnimating) return
try {
let { pageToolList, drawStatus, startX, screenWidth, id, scaleValueObject, productModelStatus } = this
if (!e || !e.changedTouches || drawStatus || pageToolList.length == 0 || e.changedTouches.length === 0) return
let touch = e.changedTouches[0]
let diffX = touch.pageX - startX
let isDistanceSignificant = Math.abs(diffX) > screenWidth / this.swipeConfig.sensitivity
let index = pageToolList.findIndex(item => item.id == id)
if (Math.abs(this.startY - touch.pageY) > this.swipeConfig.verticalLimit) return
if (!scaleValueObject[id]) scaleValueObject[id] = 1
if (isDistanceSignificant && index != -1 && scaleValueObject[id] == 1 && !productModelStatus) {
const isNext = diffX < 0
let nextIndex
if (isNext) {
nextIndex = index === pageToolList.length - 1 ? 0 : index + 1
this.pendingDirection = 'next'
} else {
nextIndex = index === 0 ? pageToolList.length - 1 : index - 1
this.pendingDirection = 'prev'
}
const nextItem = pageToolList[nextIndex]
this.$emit('update:id', nextItem.id)
uni.$logger.local.info(`预览${nextItem.title}`)
}
} catch (error) {
console.log(error)
const { pageToolList, drawStatus, startX, screenWidth, id, scaleValueObject, productModelStatus } = this
// 快速前置检查
if (!e?.changedTouches?.length || drawStatus || !pageToolList.length) return
const touch = e.changedTouches[0]
const diffX = touch.pageX - startX
// 垂直滑动过大则忽略水平滑动,避免误触
if (Math.abs(this.startY - touch.pageY) > this.swipeConfig.verticalLimit) return
// 距离检查
if (Math.abs(diffX) <= screenWidth / this.swipeConfig.sensitivity) return
const index = pageToolList.findIndex(item => item.id == id)
if (index === -1) return
// 缩放状态或打开产品弹窗时不切换
if ((scaleValueObject[id] && scaleValueObject[id] !== 1) || productModelStatus) return
const isNext = diffX < 0
let nextIndex
if (isNext) {
nextIndex = index === pageToolList.length - 1 ? 0 : index + 1
this.pendingDirection = 'next'
} else {
nextIndex = index === 0 ? pageToolList.length - 1 : index - 1
this.pendingDirection = 'prev'
}
const nextItem = pageToolList[nextIndex]
// 使用 nextTick 确保状态更新
this.$nextTick(() => {
this.$emit('update:id', nextItem.id)
})
uni.$logger.local.info(`预览${nextItem.title}`)
},
getViewClass(item) {
const isCurrent = item.id == this.id
......@@ -502,6 +509,29 @@ export default {
this.$emit('update:id', jumpItem ? jumpItem.id : moduleList[0].id)
}
this.currentMediaId = id
},
// 判断是否应该渲染该组件(性能优化)
shouldRender(item) {
// 如果列表很短,直接全部渲染
if (this.moduleList.length <= 3) return true
const currentIndex = this.moduleList.findIndex(i => i.id == this.id)
if (currentIndex === -1) return false
const targetIndex = this.moduleList.findIndex(i => i.id == item.id)
// 渲染当前页
if (currentIndex === targetIndex) return true
// 渲染上一页(考虑循环)
const prevIndex = currentIndex === 0 ? this.moduleList.length - 1 : currentIndex - 1
if (prevIndex === targetIndex) return true
// 渲染下一页(考虑循环)
const nextIndex = currentIndex === this.moduleList.length - 1 ? 0 : currentIndex + 1
if (nextIndex === targetIndex) return true
return false
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!