Commit c94e1a73 by liimin

refactor(HomeFrame): 将右侧内容组件提取为独立组件HomeSlot

重构HomeFrame组件,将原本内联的右侧内容部分提取为独立的HomeSlot组件,包含业务类型选择器和产品介绍模块
1 parent e6dada03
<template>
<view :class="['app-content-box right-content', { 'show-content-box': tabIndex == 0 }]">
<view class="start" @click="$emit('start')">
<view class="sprite-icon icon-start-text"></view>
</view>
<view class="right-content-box flex">
<view class="content-left">
<view class="module-box box-class">
<view class="common-title">
<text class="title-text">{{ currentType.typeName }}产品介绍</text>
<view class="switch-btn" @click="changeType">
<view class="sprite-icon icon-scene-change icon-exchange"></view>
<text>切换</text>
</view>
</view>
<view class="content-box">
<template>
<Material ref="materialRef" :moduleList="moduleList"></Material>
</template>
</view>
</view>
</view>
</view>
<!-- 业务类型选择器 -->
<business-type-selector ref="bizTypeSelector" @choose="chooseBusinessType" />
</view>
</template>
<script>
import Material from '@/components/MaterialIndex.vue'
import BusinessTypeSelector from './BusinessTypeSelector.vue'
export default {
name: 'HomeSlot',
components: { Material, BusinessTypeSelector },
props: {
tabIndex: {
type: Number,
default: 0
},
moduleList: {
type: Array,
default: () => []
}
},
data() {
return {
currentType: {}
}
},
mounted() {
this.currentType = uni.$storage.get('typeItem') || {}
},
methods: {
changeType() {
this.$refs.bizTypeSelector.open()
},
chooseBusinessType(item) {
this.currentType = item
uni.$storage.set('typeItem', item)
this.$emit('changeType', item)
}
}
}
</script>
<style scoped lang="scss">
.right-content {
height: 100vh;
box-sizing: border-box;
position: relative;
animation: show-box 0.15s forwards;
overflow: hidden;
}
@keyframes show-box {
0% {
left: 100%;
}
100% {
left: 0;
}
}
.start {
height: toRpx(232);
box-sizing: border-box;
margin-right: toRpx(64);
position: relative;
background: url('@/assets/images/home/start-btn.png') no-repeat;
background-size: 100% 100%;
padding-top: toRpx(60);
display: flex;
justify-content: center;
.sprite-icon {
zoom: 2;
}
}
.right-content-box {
width: 100%;
// height: calc(100% - #{toRpx(232)});
height: 100%;
gap: toRpx(48);
box-sizing: border-box;
padding: toRpx(32) 0 toRpx(80);
.box-class {
background: #ffffff59;
backdrop-filter: blur(toRpx(16));
box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
border-radius: toRpx(48);
overflow: hidden;
}
.content-box {
position: relative;
width: 100%;
height: calc(100% - #{toRpx(160)});
.message-box {
height: 100%;
}
}
.content-left,
.content-right {
height: 100%;
flex-shrink: 0;
}
.content-left {
width: calc(100% - #{toRpx(48)});
.common-title {
display: flex;
align-items: center;
/* justify-content: space-between; 不需要space-between,左对齐自然排列 */
padding-right: toRpx(48); /* 保持右侧边距 */
.title-text {
flex: 1; /* 标题占据剩余空间 */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.switch-btn {
display: flex;
align-items: center;
background: rgba(255, 255, 255, 0.4); /* 半透明白底,融入蓝底 */
border: 1px solid rgba(255, 255, 255, 0.6);
border-radius: toRpx(26);
padding: 0 toRpx(20);
height: toRpx(52);
box-sizing: border-box;
margin-left: toRpx(24);
transition: all 0.2s ease;
cursor: pointer;
text {
font-size: toRpx(24);
color: #5b6b8c; /* 蓝灰色,低调且协调 */
font-weight: 400;
margin-left: toRpx(8);
}
.icon-exchange {
/* 复用 sprite 图标 */
zoom: 0.7;
opacity: 0.7;
/* 移除去色滤镜,让图标自然的色调显露,或者保持微调 */
}
/* 移除之前的 SVG 图标样式 */
&::before {
display: none;
}
&:active {
background: rgba(255, 255, 255, 0.7);
transform: scale(0.98);
}
}
}
.module-box {
height: calc(100% - #{toRpx(235)});
margin-bottom: toRpx(48);
}
.tool-box {
height: calc(100% - #{toRpx(712)});
.content-box {
width: calc(100% - #{toRpx(96)});
margin: 0 toRpx(48);
}
}
}
.content-right {
width: calc(100% - #{toRpx(1322)});
// width: toRpx(800);
}
}
.app-content-box {
width: 100%;
position: absolute;
left: 0;
top: 0;
opacity: 0;
z-index: -999;
}
.show-content-box {
opacity: 1;
z-index: 1;
}
</style>
<template> <template>
<view class="right-side"> <view class="right-side">
<view :class="['app-content-box right-content', { 'show-content-box': tabIndex == 0 }]">
<view class="start" @click="$emit('start')">
<view class="sprite-icon icon-start-text"></view>
</view>
<view class="right-content-box flex">
<view class="content-left">
<view class="module-box box-class">
<view class="common-title">
<text class="title-text">{{ currentType.typeName }}产品介绍</text>
<view class="switch-btn" @click="changeType">
<view class="sprite-icon icon-scene-change icon-exchange"></view>
<text>切换</text>
</view>
</view>
<view class="content-box">
<template>
<Material ref="materialRef" :moduleList="moduleList"></Material>
</template>
</view>
</view>
</view>
</view>
</view>
<template v-if="tabIndex != 0 && tabIndex != 99"> <template v-if="tabIndex != 0 && tabIndex != 99">
<component :is="componentName" ref="pointRef" :userInfo="userInfo" @showPage="handleShowPage" <component :is="componentName" ref="pointRef" :userInfo="userInfo" @showPage="handleShowPage"
:isPermissionFunction="isPermission" /> :isPermissionFunction="isPermission" />
......
...@@ -4,30 +4,8 @@ ...@@ -4,30 +4,8 @@
<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">
<view :class="['app-content-box right-content', { 'show-content-box': tabIndex == 0 }]"> <home-slot v-if="tabIndex == 0" :tabIndex="tabIndex" :moduleList="moduleList" @start="start" @changeType="changeType" />
<view class="start" @click="start"> <template v-else-if="tabIndex != 99">
<view class="sprite-icon icon-start-text"></view>
</view>
<view class="right-content-box flex">
<view class="content-left">
<view class="module-box box-class">
<view class="common-title">
<text class="title-text">{{ currentType.typeName }}产品介绍</text>
<view class="switch-btn" @click="changeType">
<view class="sprite-icon icon-scene-change icon-exchange"></view>
<text>切换</text>
</view>
</view>
<view class="content-box">
<template>
<Material ref="materialRef" :moduleList="moduleList"></Material>
</template>
</view>
</view>
</view>
</view>
</view>
<template v-if="tabIndex != 0 && tabIndex != 99">
<component :is="componentName" ref="pointRef" :userInfo="userInfo" @showPage="handleShowPage" :isPermissionFunction="isPermission" /> <component :is="componentName" ref="pointRef" :userInfo="userInfo" @showPage="handleShowPage" :isPermissionFunction="isPermission" />
</template> </template>
</view> </view>
...@@ -39,7 +17,6 @@ ...@@ -39,7 +17,6 @@
<!-- 未点击开始接待,弹窗 --> <!-- 未点击开始接待,弹窗 -->
<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')" />
<business-type-selector ref="bizTypeSelector" @choose="chooseBusinessType" />
<!-- 升级弹框 --> <!-- 升级弹框 -->
<update-box /> <update-box />
<slot name="content" /> <slot name="content" />
...@@ -53,7 +30,6 @@ ...@@ -53,7 +30,6 @@
</template> </template>
<script> <script>
import ReceptionCenter from './components/ReceptionCenter/index.vue' import ReceptionCenter from './components/ReceptionCenter/index.vue'
import BusinessTypeSelector from './components/BusinessTypeSelector.vue'
import FinishReceptionDialog from './components/FinishReceptionDialog.vue' import FinishReceptionDialog from './components/FinishReceptionDialog.vue'
import StoreAddress from './components/StoreAddress.vue' import StoreAddress from './components/StoreAddress.vue'
import timeout from '@/mixin/timeout' import timeout from '@/mixin/timeout'
...@@ -62,9 +38,10 @@ import uploader from '@/mixin/record/uploader.js' ...@@ -62,9 +38,10 @@ 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 Material from '@/components/MaterialIndex.vue'
import HomeSlot from './components/HomeSlot.vue'
export default { export default {
mixins: [recorder, uploader, timeout, versionCheck], mixins: [recorder, uploader, timeout, versionCheck],
components: { LeftSide, Material, ReceptionCenter, BusinessTypeSelector, FinishReceptionDialog, StoreAddress }, components: { LeftSide, Material, ReceptionCenter, FinishReceptionDialog, StoreAddress, HomeSlot },
props: { props: {
id: [String, Number], id: [String, Number],
finishDoneText: String, finishDoneText: String,
...@@ -154,7 +131,8 @@ export default { ...@@ -154,7 +131,8 @@ export default {
this.$emit('start') this.$emit('start')
}, },
async changeType() { async changeType() {
this.$refs.bizTypeSelector.open() // this.$refs.bizTypeSelector.open()
this.$emit('changeType')
}, },
chooseBusinessType(item) { chooseBusinessType(item) {
this.currentType = item this.currentType = item
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!