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> <template>
<view class="button-group"> <view class="button-group">
<template v-for="(item, index) in selectList">
<view <view
v-for="(item, index) in selectList"
:key="index" :key="index"
class="button-item" class="button-item"
:class="{ active: index === selectIndex }" :class="{ active: index === selectIndex }"
@click="chooseType(index, item)" @click="chooseType(index, item)"
:style="{ width: itemWidth + 'rpx', marginRight: index === selectList.length - 1 ? 0 : gap + 'rpx' }" :style="{ width: itemWidth + 'rpx' }"
> >
<text class="label">{{ item[labelKey] }}</text> <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 class="active-bg" v-if="index === selectIndex"></view>
</view> </view>
<view class="divider" v-if="index < selectList.length - 1" :key="'divider-' + index"></view>
</template>
</view> </view>
</template> </template>
...@@ -30,8 +35,7 @@ export default { ...@@ -30,8 +35,7 @@ export default {
data() { data() {
return { return {
selectIndex: 0, selectIndex: 0,
itemWidth: 104, // 按钮固定宽度 itemWidth: 140, // 按钮固定宽度
gap: 16 // 按钮间距
} }
}, },
methods: { methods: {
...@@ -76,6 +80,17 @@ export default { ...@@ -76,6 +80,17 @@ export default {
z-index: 2; /* 文字在最上层 */ 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 { .active-bg {
position: absolute; position: absolute;
...@@ -95,6 +110,13 @@ export default { ...@@ -95,6 +110,13 @@ export default {
box-shadow: 0 toRpx(2) toRpx(8) rgba(55, 115, 248, 0.15); 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 { @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 @@ ...@@ -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;" /> <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>
<template v-else-if="i.type == 'radio'"> <template v-else-if="i.type == 'radio'">
<radio-group @change="radioChange"> <CustomerTypeRadio :value="formData[i.key]" @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>
</template> </template>
<!-- <template v-else> <!-- <template v-else>
<view <view
...@@ -46,14 +39,7 @@ ...@@ -46,14 +39,7 @@
</template> </template>
<template v-else> <template v-else>
<view class="pop-tips">请完善本次接待结果</view> <view class="pop-tips">请完善本次接待结果</view>
<view class="choose-box"> <ResultList :list="resultList" :value="receptionStatus" @change="chooseResult" />
<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>
</template> </template>
</view> </view>
</MessageBox> </MessageBox>
...@@ -65,9 +51,15 @@ ...@@ -65,9 +51,15 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
import { mapMutations } from "vuex"; import { mapMutations } from "vuex";
import ResultList from '@/components/ResultList.vue'
import CustomerTypeRadio from '@/components/CustomerTypeRadio.vue'
const phoneRex = /^[1]([2-9])[0-9]{9}$/; const phoneRex = /^[1]([2-9])[0-9]{9}$/;
export default { export default {
name: 'FinishStep', name: 'FinishStep',
components: {
ResultList,
CustomerTypeRadio
},
props: { props: {
sceneType: { sceneType: {
type: Number, type: Number,
...@@ -105,20 +97,6 @@ export default { ...@@ -105,20 +97,6 @@ export default {
label: "客户类型", label: "客户类型",
key: "customerType", key: "customerType",
type: "radio", type: "radio",
items: [
{
label: "VIP",
value: 'VIP'
},
{
label: "潜客",
value: '潜客'
},
{
label: "普通",
value: '普通'
}
],
placeholder: '请输入客户类型', placeholder: '请输入客户类型',
required: true required: true
}, },
...@@ -407,30 +385,4 @@ export default { ...@@ -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> </style>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<view class="module-box box-class"> <view class="module-box box-class">
<view class="common-title"> <view class="common-title">
<text class="title-text"> <text class="title-text">
<text class="highlight-type">{{ currentType.typeName }}</text> <text class="highlight-type" @click="changeType">{{ currentType.typeName }}</text>
产品介绍 产品介绍
</text> </text>
<view class="switch-btn flex" @click="changeType"> <view class="switch-btn flex" @click="changeType">
......
...@@ -122,7 +122,7 @@ export default { ...@@ -122,7 +122,7 @@ export default {
]), ]),
uploadTypeList: Object.freeze([ uploadTypeList: Object.freeze([
{ label: '待上传' }, { label: '待上传' },
{ label: '待提交' }, { label: '待提交', dot: () => this.preRecordFailList.length },
]), ]),
itemObject: Object.freeze([ itemObject: Object.freeze([
// { label: '接待结果', key: 'result' }, // { label: '接待结果', key: 'result' },
...@@ -194,6 +194,7 @@ export default { ...@@ -194,6 +194,7 @@ export default {
item = { item = {
"id": null, "id": null,
"merchantId": "44210895", "merchantId": "44210895",
customerType: 'VIP',
"customerName": "1211第五", "customerName": "1211第五",
"phoneNumber": "13512110555", "phoneNumber": "13512110555",
"salesUuid": "77936e318e9844e4af0b099c7ccc98e4", "salesUuid": "77936e318e9844e4af0b099c7ccc98e4",
...@@ -287,11 +288,18 @@ export default { ...@@ -287,11 +288,18 @@ export default {
}, },
async getPreRecordNum () { async getPreRecordNum () {
const preRecordList = await this.recorder.getRecords() const preRecordList = await this.recorder.getRecords()
this.preRecordFailList = preRecordList this.preRecordFailList =this.formatRecordList(preRecordList)
//[{
// result: '',
// customerPhone: '',
// customerType: 'VIP',
// customerName: '',
// carType: '',
// startTime: '',
// endTime: '' }]
}, },
getRecordFail () { formatRecordList(list) {
this.getRecordNum() return list.map(record => {
this.list[0] = this.recordFailList.map(record => {
return { return {
result: record.result, result: record.result,
customerPhone: record.customerPhone, customerPhone: record.customerPhone,
...@@ -303,6 +311,10 @@ export default { ...@@ -303,6 +311,10 @@ export default {
endTime: record.endTime endTime: record.endTime
} }
}) })
},
getRecordFail () {
this.getRecordNum()
this.list[0] = this.formatRecordList(this.recordFailList)
this.flag = true this.flag = true
this.isPrePage = false this.isPrePage = false
this.nothing = !!this.recordFailList.length this.nothing = !!this.recordFailList.length
...@@ -396,24 +408,7 @@ export default { ...@@ -396,24 +408,7 @@ export default {
async submitRecord (val) { async submitRecord (val) {
this.flag = false this.flag = false
delete val.duration delete val.duration
delete val.startTime // 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)
await this.recorder.save(val) await this.recorder.save(val)
this.getRecordNum() this.getRecordNum()
await this.getPreRecordFail() await this.getPreRecordFail()
......
<template> <template>
<view class="container" @click="handleTouchStart"> <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" /> <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="tips-box" :style="tipsObject.style" @click.stop="closeTips">{{ tipsObject.text }}</view>
<view class="right-side"> <view class="right-side">
...@@ -11,9 +11,12 @@ ...@@ -11,9 +11,12 @@
</view> </view>
<store-address v-if="footerBox" /> <store-address v-if="footerBox" />
</view> </view>
<view :class="['detail', { show: id }]"> <view :class="['detail', { show: activeDetailId }]">
<slot name="detail" /> <slot name="detail" />
</view> </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> <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')" /> <finish-reception-dialog ref="finish" @confirm="$emit('openStep')" @cancel="$emit('backHome')" />
...@@ -37,14 +40,19 @@ import recorder from '@/mixin/record/recorder' ...@@ -37,14 +40,19 @@ import recorder from '@/mixin/record/recorder'
import uploader from '@/mixin/record/uploader.js' import uploader from '@/mixin/record/uploader.js'
import versionCheck from '@/mixin/versionCheck.js' import versionCheck from '@/mixin/versionCheck.js'
import LeftSide from './components/LeftSide.vue' import LeftSide from './components/LeftSide.vue'
import Material from '@/components/MaterialIndex.vue'
import HomeSlot from './components/HomeSlot.vue' import HomeSlot from './components/HomeSlot.vue'
import Order from './components/Order/index.vue' import Order from './components/Order/index.vue'
const TAB_COMPONENTS = {
1: 'ReceptionCenter',
2: 'Order'
}
export default { export default {
mixins: [recorder, uploader, timeout, versionCheck], mixins: [recorder, uploader, timeout, versionCheck],
components: { LeftSide, Material, ReceptionCenter, FinishReceptionDialog, StoreAddress, HomeSlot, Order }, components: { LeftSide, ReceptionCenter, FinishReceptionDialog, StoreAddress, HomeSlot, Order },
props: { props: {
id: [String, Number], activeDetailId: [String, Number],
finishDoneText: String, finishDoneText: String,
finishContene: { finishContene: {
type: String, type: String,
...@@ -97,8 +105,7 @@ export default { ...@@ -97,8 +105,7 @@ export default {
return this.$refs.finish return this.$refs.finish
}, },
componentName() { componentName() {
let tabs = this.$refs.leftBox?.tabs return TAB_COMPONENTS[this.tabIndex] || ''
return tabs ? tabs[this.tabIndex].name : ''
} }
}, },
methods: { methods: {
...@@ -161,6 +168,7 @@ export default { ...@@ -161,6 +168,7 @@ export default {
text-align: left; text-align: left;
display: none; display: none;
opacity: 0; opacity: 0;
will-change: opacity, display; // 优化动画性能
} }
&::after { &::after {
...@@ -173,10 +181,10 @@ export default { ...@@ -173,10 +181,10 @@ export default {
background-image: url('@/assets/images/common/home-bg-1.webp'); background-image: url('@/assets/images/common/home-bg-1.webp');
background-size: 100% 100%; background-size: 100% 100%;
z-index: 1; z-index: 1;
pointer-events: none; // 避免背景图阻挡交互
} }
.home, .home {
.detail {
position: fixed; position: fixed;
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -185,6 +193,29 @@ export default { ...@@ -185,6 +193,29 @@ export default {
left: 0; left: 0;
visibility: hidden; visibility: hidden;
opacity: 0; 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 { .point-page {
...@@ -250,16 +281,17 @@ export default { ...@@ -250,16 +281,17 @@ export default {
z-index: 2; z-index: 2;
visibility: visible; visibility: visible;
animation: show-content-left 0.15s forwards; animation: show-content-left 0.15s forwards;
will-change: transform;
} }
} }
@keyframes show-content-left { @keyframes show-content-left {
0% { 0% {
left: 100%; transform: translateX(100%);
} }
100% { 100% {
left: 0; transform: translateX(0);
} }
} }
...@@ -267,6 +299,7 @@ export default { ...@@ -267,6 +299,7 @@ export default {
flex: 1; flex: 1;
position: relative; position: relative;
width: calc(100vw - #{toRpx(240)}); width: calc(100vw - #{toRpx(240)});
contain: layout style; // 限制样式和布局计算范围
.right-content { .right-content {
height: 100vh; height: 100vh;
...@@ -274,15 +307,16 @@ export default { ...@@ -274,15 +307,16 @@ export default {
position: relative; position: relative;
animation: show-box 0.15s forwards; animation: show-box 0.15s forwards;
overflow: hidden; overflow: hidden;
will-change: transform; // 优化动画
} }
@keyframes show-box { @keyframes show-box {
0% { 0% {
left: 100%; transform: translateX(100%);
} }
100% { 100% {
left: 0; transform: translateX(0);
} }
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
:type="position" :type="position"
:is-mask-click="false" :is-mask-click="false"
:animation="animation" :animation="animation"
:mask-background-color="maskBackgroundColor"
> >
<view <view
class="tips-wrapper" class="tips-wrapper"
...@@ -111,6 +112,10 @@ export default { ...@@ -111,6 +112,10 @@ export default {
showCancelBtn: { showCancelBtn: {
type: Boolean, type: Boolean,
default: true, default: true,
},
maskBackgroundColor: {
type: String,
default: 'rgba(0, 0, 0, 0.4)'
} }
}, },
methods: { methods: {
...@@ -135,8 +140,10 @@ export default { ...@@ -135,8 +140,10 @@ export default {
<style scoped lang="scss"> <style scoped lang="scss">
.tips-wrapper { .tips-wrapper {
background: #ffffff; background: #ffffff;
border-radius: toRpx(20); border-radius: toRpx(24);
height: 100%; 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 { .tips-content {
padding: toRpx(48); padding: toRpx(48);
box-sizing: border-box; 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 { ...@@ -377,7 +377,12 @@ export default {
try { try {
if (str && (str.includes('=') || str.length > 50)) { if (str && (str.includes('=') || str.length > 50)) {
const decrypted = decryptAES(str) const decrypted = decryptAES(str)
if (decrypted) return decrypted if (decrypted) {
if (label == 'Region' && decrypted.includes('.')) {
decrypted = decrypted.split('.')[0]
}
}
return decrypted
} }
} catch (e) { } catch (e) {
console.error(`${label} decryption error`, e) console.error(`${label} decryption error`, e)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: huyue * @Author: huyue
* @Date: 2024-04-08 11:30:30 * @Date: 2024-04-08 11:30:30
* @LastEditors: limin * @LastEditors: limin
* @LastEditTime: 2025-12-29 08:46:10 * @LastEditTime: 2025-12-29 11:40:42
--> -->
<template> <template>
<view class="detail-box" :key="dateilKey"> <view class="detail-box" :key="dateilKey">
...@@ -13,9 +13,12 @@ ...@@ -13,9 +13,12 @@
</view> </view>
</view> </view>
<template v-for="(item, index) in moduleList"> <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"> @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" :views="item.receptionSourceDetailList || []" :penSwitch="penSwitch" :show="id == item.id"
:ref="'media' + item.id" :title="item.materialName || ''" :madiaId="item.id" @scale="scale" :ref="'media' + item.id" :title="item.materialName || ''" :madiaId="item.id" @scale="scale"
:ulList="item.ulList" :screenList="item.screenList" @onProductModel="productModelStatus = $event" :ulList="item.ulList" :screenList="item.screenList" @onProductModel="productModelStatus = $event"
...@@ -412,22 +415,27 @@ export default { ...@@ -412,22 +415,27 @@ export default {
}, },
touchEnd(e) { touchEnd(e) {
if (this.modeName || this.isAnimating) return 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] const { pageToolList, drawStatus, startX, screenWidth, id, scaleValueObject, productModelStatus } = this
let diffX = touch.pageX - startX // 快速前置检查
if (!e?.changedTouches?.length || drawStatus || !pageToolList.length) return
let isDistanceSignificant = Math.abs(diffX) > screenWidth / this.swipeConfig.sensitivity const touch = e.changedTouches[0]
let index = pageToolList.findIndex(item => item.id == id) const diffX = touch.pageX - startX
// 垂直滑动过大则忽略水平滑动,避免误触
if (Math.abs(this.startY - touch.pageY) > this.swipeConfig.verticalLimit) return 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 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 let nextIndex
if (isNext) { if (isNext) {
nextIndex = index === pageToolList.length - 1 ? 0 : index + 1 nextIndex = index === pageToolList.length - 1 ? 0 : index + 1
...@@ -438,12 +446,11 @@ export default { ...@@ -438,12 +446,11 @@ export default {
} }
const nextItem = pageToolList[nextIndex] const nextItem = pageToolList[nextIndex]
// 使用 nextTick 确保状态更新
this.$nextTick(() => {
this.$emit('update:id', nextItem.id) this.$emit('update:id', nextItem.id)
})
uni.$logger.local.info(`预览${nextItem.title}`) uni.$logger.local.info(`预览${nextItem.title}`)
}
} catch (error) {
console.log(error)
}
}, },
getViewClass(item) { getViewClass(item) {
const isCurrent = item.id == this.id const isCurrent = item.id == this.id
...@@ -502,6 +509,29 @@ export default { ...@@ -502,6 +509,29 @@ export default {
this.$emit('update:id', jumpItem ? jumpItem.id : moduleList[0].id) this.$emit('update:id', jumpItem ? jumpItem.id : moduleList[0].id)
} }
this.currentMediaId = 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
} }
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
@start="start" @start="start"
@changeType="changeType" @changeType="changeType"
ref="home" ref="home"
:id="id" :activeDetailId="id"
@openStep="openStep" @openStep="openStep"
@backHome="backHome" @backHome="backHome"
@changeTab="changeTab" @changeTab="changeTab"
...@@ -34,8 +34,9 @@ ...@@ -34,8 +34,9 @@
</template> </template>
<script> <script>
import detail from './detail/detail' import detail from './detail/detail'
import { mapMutations } from 'vuex' import { mapMutations, mapActions } from 'vuex'
import HomeFrame from '@/components/HomeFrame/index.vue' import HomeFrame from '@/components/HomeFrame/index.vue'
export default { export default {
components: { HomeFrame, detail }, components: { HomeFrame, detail },
data () { data () {
...@@ -59,41 +60,33 @@ export default { ...@@ -59,41 +60,33 @@ export default {
return this.$refs.home return this.$refs.home
}, },
previewRef() { previewRef() {
return this.homeRef.previewRef return this.homeRef?.previewRef
}, },
finishRef() { finishRef() {
return this.homeRef.finishRef return this.homeRef?.finishRef
} }
}, },
onBackPress (options) { onBackPress (options) {
if (options.from === 'backbutton') { if (options.from === 'backbutton') {
// 物理返回按钮触发
// 阻止默认行为,即不执行页面返回
this.back() this.back()
return true return true
} }
// 其他情况允许正常返回
return false return false
}, },
async onLoad () { async onLoad () {
// uni.hideLoading() const mockdata = await uni.$api.systemApi.getMockData(true)
const mockdata = await uni.$api.systemApi.getMockData(true) //获取APP配置信息
uni.$storage.set('typeItem', { uni.$storage.set('typeItem', {
typeCode: mockdata?.typeCode || '', typeCode: mockdata?.typeCode || '',
typeName: mockdata?.typeName || '' typeName: mockdata?.typeName || ''
}) })
// if (this.channelType == 1 && mockdata.boutiqueDefaultCarBrandId) {
// this.$store.state.user.boutiqueDefaultCarBrandId = mockdata.boutiqueDefaultCarBrandId //默认车辆品牌 await Promise.all([
// if (mockdata.defaultCarId) this.$store.state.user.defaultCarId = mockdata.defaultCarId //默认车系 this.getHomeSource(mockdata?.typeCode),
// }
// this.get_Vehicle_Sales_Data()
// this.requested = true
// this.$refs.home.updateApp(true)
this.getHomeSource(mockdata?.typeCode)
this.getSource(mockdata?.typeCode) this.getSource(mockdata?.typeCode)
// setTimeout(() => { ])
// this.start()
// }, 1e3) // 确保初始化时清空id,保证显示首页
this.id = ''
}, },
async onShow () { async onShow () {
this.init() this.init()
...@@ -101,43 +94,45 @@ export default { ...@@ -101,43 +94,45 @@ export default {
methods: { methods: {
...mapMutations('audio', ['setReceptionStatus']), ...mapMutations('audio', ['setReceptionStatus']),
...mapMutations('material', ['setMaterial']), ...mapMutations('material', ['setMaterial']),
...mapActions(['clearCustomerInfo', 'clearHistory', 'clearReceptionTrack']),
init () { init () {
// this.findPayInfo() if (this.requested && !this.id) this.homeRef?.updateApp()
if (this.requested && !this.id) this.homeRef.updateApp()
}, },
// 查询素材
// 查询素材(优化版:减少循环中的await)
async getSource (typeCode) { async getSource (typeCode) {
const first_res = await uni.$api.commonApi.getPadFolderList({ const first_res = await uni.$api.commonApi.getPadFolderList({
typeCode, typeCode,
status: 0 status: 0
}) })
this.folderList = Array.isArray(first_res?.data) ? first_res.data : [] this.folderList = Array.isArray(first_res?.data) ? first_res.data : []
if (!this.folderList.length) { if (!this.folderList.length) return this.resetLists()
this.moduleList = []
this.toolList = [] // 并行请求所有文件夹内容
return const folderPromises = this.folderList.map(folder =>
} uni.$api.commonApi.getPadMaterialList({
let materials = []
for (let i = 0; i < this.folderList.length; i++) {
const folder = this.folderList[i]
const res = await uni.$api.commonApi.getPadMaterialList({
folderCode: folder.folderCode, folderCode: folder.folderCode,
typeCode: folder.typeCode, typeCode: folder.typeCode,
status: 0 status: 0
}) })
const list = Array.isArray(res?.data) ? res.data : [] )
if (list.length) {
materials = list const results = await Promise.all(folderPromises)
break // 找到第一个有数据的文件夹
} const validResult = results.find(res => Array.isArray(res?.data) && res.data.length > 0)
}
if (!validResult) return this.resetLists()
this.processMaterials(validResult.data)
},
if (!materials.length) { resetLists() {
this.moduleList = [] this.moduleList = []
this.toolList = [] this.toolList = []
return },
}
processMaterials(materials) {
this.moduleList = materials.map(item => ({ this.moduleList = materials.map(item => ({
...item, ...item,
thumbnail: item.materialUrl, thumbnail: item.materialUrl,
...@@ -159,6 +154,7 @@ export default { ...@@ -159,6 +154,7 @@ export default {
shortTitleUrl: item.materialUrl shortTitleUrl: item.materialUrl
})) }))
}, },
// 获取首页素材 // 获取首页素材
async getHomeSource(typeCode) { async getHomeSource(typeCode) {
const res = await uni.$api.commonApi.getPadMaterialList({ const res = await uni.$api.commonApi.getPadMaterialList({
...@@ -168,42 +164,43 @@ export default { ...@@ -168,42 +164,43 @@ export default {
}) })
this.homeList = Array.isArray(res?.data) ? res.data : [] this.homeList = Array.isArray(res?.data) ? res.data : []
}, },
changeType () { changeType () {
const typeItem = uni.$storage.get('typeItem') const typeItem = uni.$storage.get('typeItem')
const typeCode = typeItem?.typeCode || '' const typeCode = typeItem?.typeCode || ''
this.getHomeSource(typeCode) this.getHomeSource(typeCode)
this.getSource(typeCode) this.getSource(typeCode)
}, },
async start (item) { async start (item) {
if (!this.moduleList.length) return uni.showToast({ if (!this.moduleList.length) return uni.showToast({
title: '该场景尚未配置素材,请联系总部人员', title: '该场景尚未配置素材,请联系总部人员',
icon: 'none' icon: 'none'
}) })
const isPermision = await this.homeRef.isPermission() const isPermision = await this.homeRef.isPermission()
if (this.recording || !isPermision) return if (this.recording || !isPermision) return
const material = this.moduleList[0] const material = this.moduleList[0]
this.setMaterial(material) this.setMaterial(material)
// uni.showLoading({
// mask: true
// })
await this.homeRef.startAudio() await this.homeRef.startAudio()
this.clearHistory() this.clearAllHistory()
this.id = +material.id this.id = +material.id
// this.id = 6
this.type = 'edit' this.type = 'edit'
this.recording = true this.recording = true
// setTimeout(() => {
// uni.hideLoading()
// }, 1e3)
}, },
toDetail (index) { toDetail (index) {
let item = this.moduleList[index] this.chooseItem = this.moduleList[index]
this.chooseItem = item this.previewRef?.open()
this.previewRef.open()
}, },
cancel () { cancel () {
this.previewRef.close() this.previewRef?.close()
}, },
preview () { preview () {
let { id, title } = this.chooseItem let { id, title } = this.chooseItem
this.type = 'preview' this.type = 'preview'
...@@ -211,109 +208,60 @@ export default { ...@@ -211,109 +208,60 @@ export default {
uni.$logger.local.info(`预览${title}`) uni.$logger.local.info(`预览${title}`)
this.cancel() this.cancel()
}, },
// 完成接待 // 完成接待
done (e) { done (e) {
this.finishRef.close() this.finishRef?.close()
if (this.recording) this.homeRef.stopAudio() if (this.recording) this.homeRef?.stopAudio()
this.recording = false this.recording = false
setTimeout(() => { setTimeout(() => {
this.id = '' this.id = ''
this.type = '' this.type = ''
this.setReceptionStatus(e) this.setReceptionStatus(e)
this.$store.dispatch('clearHistory') this.clearAllHistory()
this.$store.dispatch('clearReceptionTrack')
}, 1500) }, 1500)
}, },
back () { back () {
const detailRef = this.$refs.detail const detailRef = this.$refs.detail
if (detailRef.showPayPage) return (detailRef.showPayPage = false) if (detailRef?.showPayPage) return (detailRef.showPayPage = false)
if (!this.id) return uni.navigateBack() if (!this.id) return uni.navigateBack()
if (this.type != 'preview') return this.finishRef.open() if (this.type != 'preview') return this.finishRef?.open()
this.backHome() this.backHome()
}, },
backHome () { backHome () {
if (this.recording) this.homeRef.stopAudio(true) if (this.recording) this.homeRef?.stopAudio(true)
this.finishRef.close() this.finishRef?.close()
this.id = '' this.id = ''
this.type = '' this.type = ''
this.clearHistory() this.clearAllHistory()
// this.init()
this.recording = false this.recording = false
// this.$refs.home.$refs.leftBox.getMessageInfo()
}, },
nextStep () { nextStep () {
let { id } = this.moduleList[0] let { id } = this.moduleList[0]
this.type = 'preview' this.type = 'preview'
this.id = id this.id = id
}, },
clearHistory () {
this.$store.dispatch('clearCustomerInfo') clearAllHistory () {
this.$store.dispatch('clearHistory') this.clearCustomerInfo()
// this.$refs.home.setBooks([]) this.clearHistory()
this.$store.dispatch('clearReceptionTrack') this.clearReceptionTrack()
}, },
openStep () { openStep () {
this.finishRef.close() this.finishRef?.close()
this.$refs.detail.open() this.$refs.detail?.open()
}, },
// 查询门店支付配置
// async findPayInfo () {
// const { shopMerchantId } = uni.$storage.get('userInfo')
// const data = await uni.$api.commonApi.findPayInfo({
// merchantId: shopMerchantId
// })
// let paymentType = []
// data.find(item => {
// if (item.paymentType == 1)
// paymentType.push({
// name: '扫码支付',
// type: 1,
// title: '付款二维码',
// ...item
// })
// if (item.paymentType == 2)
// paymentType.push({
// name: '对公账户',
// type: 2,
// title: '付款方式',
// ...item
// })
// })
// this.$store.dispatch('setPaymentType', paymentType)
// },
changeTab (index) { changeTab (index) {
// if (index == 0) this.init() // if (index == 0) this.init()
}
}, },
beforeDestroy () {
/**按序加载车型 */ this.backHome()
// async getCarBrandsList (carBrandList, index) {
// const item = carBrandList[index]
// if (!item) return
// const carList = uni.getStorageSync(`${item.id}_${item.brandId}_carlist`)
// if (index < carBrandList.length - 1) {
// index += 1
// if (!carList) {
// const list = await uni.$api.commonApi.getCarBrandsList({
// brandId: item.brandId,
// childBrandId: item.id
// })
// if (list) uni.setStorageSync(`${item.id}_${item.brandId}_carlist`, list)
// this.getCarBrandsList(carBrandList, ++index)
// } else this.getCarBrandsList(carBrandList, ++index)
// }
// },
/**素材内容 */
// setViewInfo (data) {
// let { moduleList, toolList, id } = data
// this.moduleList = moduleList
// this.toolList = toolList
// this.mediaId = id
// this.loadComplete = true
// this.$store.state.user = {
// ...this.$store.state.user,
// ...data
// }
// }
} }
} }
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!