Commit e6dada03 by liimin

feat(组件): 重构接待中心界面及新增组件

新增StoreAddress、BusinessTypeSelector、FinishReceptionDialog等组件
重构ReceptionCenter界面样式和交互逻辑
优化MaterialIndex轮播组件动画效果
提取RightContent为独立组件
调整整体布局和样式细节
1 parent 87ac4430
<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>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
props: {
selectList: {
type: Array,
default: () => []
},
labelKey: {
type: String,
default: 'label'
}
},
data() {
return {
selectIndex: 0,
itemWidth: 104, // 按钮固定宽度
gap: 16 // 按钮间距
}
},
methods: {
chooseType(index, item) {
if (this.selectIndex === index) return
this.selectIndex = index
this.$emit('chooseType', { item, index })
}
}
}
</script>
<style scoped lang='scss'>
.button-group {
display: flex;
align-items: center;
/* 移除容器背景,因为现在由外部 filter-container 提供 */
background: transparent;
height: toRpx(64); /* 略微减小高度 */
.button-item {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
/* width由行内样式控制 */
/* margin-right由行内样式控制 */
padding: 0;
font-size: toRpx(26);
color: #555;
border-radius: toRpx(32); /* 胶囊形状 */
transition: all 0.2s ease;
cursor: pointer;
background: #ffffff; /* 默认白底 */
border: 1px solid #ebedf0; /* 默认浅色边框 */
position: relative;
box-sizing: border-box;
overflow: hidden; /* 确保动画不溢出 */
.label {
position: relative;
z-index: 2; /* 文字在最上层 */
}
/* 激活状态的背景层 */
.active-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #eef4ff;
z-index: 1;
animation: pulse-fade 0.3s cubic-bezier(0.25, 0.8, 0.5, 1) forwards;
}
&.active {
color: #3773f8;
font-weight: 500;
border-color: #3773f8;
box-shadow: 0 toRpx(2) toRpx(8) rgba(55, 115, 248, 0.15);
}
}
}
@keyframes pulse-fade {
0% {
opacity: 0;
transform: scale(0.8);
}
100% {
opacity: 1;
transform: scale(1);
}
}
</style>
<template>
<MessageBox :popupW="704" ref="bizTypeBox" :isFooter="false" title="请选择类型">
<view class="footer">
<template v-for="(i, index) in businessTypeList">
<view class="footer-btn confirm flex" :key="index" @click="chooseBusinessType(i)">
{{ i.typeName }}
</view>
</template>
</view>
</MessageBox>
</template>
<script>
export default {
data() {
return {
businessTypeList: []
}
},
methods: {
async open() {
const res = await uni.$api.commonApi.getPadBusinessTypeList()
const list = Array.isArray(res?.data) ? res.data : (Array.isArray(res) ? res : [])
this.businessTypeList = list
this.$refs.bizTypeBox.open()
},
chooseBusinessType(item) {
this.$refs.bizTypeBox.close()
this.$emit('choose', item)
}
}
}
</script>
<style scoped lang="scss">
.footer {
border-top: toRpx(2) solid #eff0f2;
font-weight: 600;
font-size: toRpx(32);
margin-top: toRpx(48);
.footer-btn {
justify-content: center;
margin: toRpx(16) auto 0;
}
.confirm {
width: toRpx(608);
height: toRpx(80);
background: #2c66f7;
border-radius: toRpx(40);
color: #fff;
}
}
</style>
<template>
<MessageBox :popupW="704" ref="finish" :content="content" :isFooter="false">
<view class="footer">
<view class="footer-btn confirm flex" @click="handleConfirm">
完成接待
<text>(推荐)</text>
</view>
<view class="footer-btn cancel flex" @click="handleCancel">
仍要退出
<text>(不推荐)</text>
</view>
</view>
</MessageBox>
</template>
<script>
export default {
data() {
return {
content: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」'
}
},
methods: {
open() {
this.$refs.finish.open()
},
close() {
this.$refs.finish.close()
},
handleConfirm() {
this.$emit('confirm')
},
handleCancel() {
this.$emit('cancel')
}
}
}
</script>
<style scoped lang="scss">
.footer {
border-top: toRpx(2) solid #eff0f2;
font-weight: 600;
font-size: toRpx(32);
margin-top: toRpx(48);
.footer-btn {
justify-content: center;
margin: toRpx(16) auto 0;
}
.confirm {
width: toRpx(608);
height: toRpx(80);
background: #2c66f7;
border-radius: toRpx(40);
color: #fff;
}
.cancel {
width: toRpx(608);
height: toRpx(80);
background: #f5f6fa;
border-radius: toRpx(40);
color: #5b6b8c;
}
}
</style>
<template>
<uni-popup
ref="popup"
type="bottom"
>
<view class="popup-box">
<view class="popup-header">
<text class="title">客户标签</text>
<view
class="close-btn"
@click="close"
>
<uni-icons
type="closeempty"
size="20"
color="#999"
></uni-icons>
</view>
</view>
<view class="content">
<view class="tags-container">
<view
v-for="(item, index) in list"
:key="index"
:class="['tag-item', { active: isSelected(item) }]"
@click="toggleTag(item)"
>
{{ item.labelName }}
</view>
</view>
</view>
<view class="footer">
<button
class="btn cancel"
@click="close"
>取消</button>
<button
class="btn confirm"
@click="confirm"
>确定</button>
</view>
</view>
</uni-popup>
</template>
<script>
export default {
name: 'CustomerTags',
props: {
chooseList: {
type: Array,
default: () => []
}
},
data() {
return {
list: [],
selectedTags: []
}
},
watch: {
chooseList: {
immediate: true,
handler(val) {
this.selectedTags = [...val]
}
}
},
methods: {
open() {
this.getList()
this.$refs.popup.open()
},
close() {
this.$refs.popup.close()
},
async getList() {
try {
const { shopMerchantId, sceneType } = uni.$storage.get("userInfo")
const params = {
merchantId: shopMerchantId,
bussinessScene: sceneType == 0 ? 1 : 2 // 1.延保 2.轻改
}
const res = await uni.$api.customerApi.findCustomerTags(params)
this.list = res || []
} catch (error) {
console.error(error)
}
},
isSelected(item) {
return this.selectedTags.some(tag => tag.labelId === item.labelId)
},
toggleTag(item) {
const index = this.selectedTags.findIndex(tag => tag.labelId === item.labelId)
if (index > -1) {
this.selectedTags.splice(index, 1)
} else {
this.selectedTags.push(item)
}
},
confirm() {
this.$emit('select', this.selectedTags)
this.close()
}
}
}
</script>
<style lang="scss" scoped>
.popup-box {
background-color: #fff;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
padding-bottom: env(safe-area-inset-bottom);
max-height: 80vh;
display: flex;
flex-direction: column;
.popup-header {
padding: 30rpx;
text-align: center;
position: relative;
border-bottom: 1rpx solid #eee;
.title {
font-size: 32rpx;
font-weight: bold;
}
.close-btn {
position: absolute;
right: 30rpx;
top: 30rpx;
}
}
.content {
flex: 1;
overflow-y: auto;
padding: 30rpx;
.tags-container {
display: flex;
flex-wrap: wrap;
gap: 20rpx;
.tag-item {
padding: 10rpx 30rpx;
background-color: #f5f5f5;
border-radius: 30rpx;
font-size: 28rpx;
color: #333;
border: 1rpx solid transparent;
&.active {
background-color: #e6f0ff;
color: #007aff;
border-color: #007aff;
}
}
}
}
.footer {
padding: 20rpx 30rpx;
display: flex;
gap: 30rpx;
border-top: 1rpx solid #eee;
.btn {
flex: 1;
font-size: 30rpx;
height: 80rpx;
line-height: 80rpx;
border-radius: 40rpx;
&.cancel {
background-color: #f5f5f5;
color: #666;
}
&.confirm {
background-color: #007aff;
color: #fff;
}
&::after {
border: none;
}
}
}
}
</style>
<template>
<uni-popup
ref="popup"
type="bottom"
>
<view class="popup-box">
<view class="popup-header">
<text class="title">接待场景</text>
<view
class="close-btn"
@click="close"
>
<uni-icons
type="closeempty"
size="20"
color="#999"
></uni-icons>
</view>
</view>
<view class="content">
<view class="scene-container">
<view
v-for="(item, index) in list"
:key="index"
:class="['scene-item', { active: isSelected(item) }]"
@click="selectScene(item)"
>
{{ item.receptionSceneName }}
</view>
</view>
</view>
</view>
</uni-popup>
</template>
<script>
export default {
name: 'ReceptionSence',
props: {
customerInfo: {
type: Object,
default: () => ({})
}
},
data() {
return {
list: []
}
},
methods: {
open() {
this.getList()
this.$refs.popup.open()
},
close() {
this.$refs.popup.close()
},
async getList() {
try {
const { shopMerchantId, sceneType } = uni.$storage.get("userInfo")
const params = {
merchantId: shopMerchantId,
bussinessScene: sceneType == 0 ? 1 : 2 // 1.延保 2.轻改
}
const res = await uni.$api.customerApi.findAllSence(params)
this.list = res || []
} catch (error) {
console.error(error)
}
},
isSelected(item) {
return this.customerInfo.receptionScene === item.id
},
selectScene(item) {
this.$emit('select', item)
this.close()
}
}
}
</script>
<style lang="scss" scoped>
.popup-box {
background-color: #fff;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
padding-bottom: env(safe-area-inset-bottom);
max-height: 80vh;
display: flex;
flex-direction: column;
.popup-header {
padding: 30rpx;
text-align: center;
position: relative;
border-bottom: 1rpx solid #eee;
.title {
font-size: 32rpx;
font-weight: bold;
}
.close-btn {
position: absolute;
right: 30rpx;
top: 30rpx;
}
}
.content {
flex: 1;
overflow-y: auto;
padding: 30rpx;
.scene-container {
display: flex;
flex-direction: column;
gap: 20rpx;
.scene-item {
padding: 30rpx;
background-color: #f9f9f9;
border-radius: 12rpx;
font-size: 30rpx;
color: #333;
text-align: center;
border: 1rpx solid transparent;
&.active {
background-color: #e6f0ff;
color: #007aff;
border-color: #007aff;
}
}
}
}
}
</style>
......@@ -5,15 +5,27 @@
<view class="tabs">
<page-tabs :list="tabList" @changeTab="changeTab" />
</view>
<view class="select-box-list select-component flex">
<template v-if="tabIndex == 0">
<select-component :selectList="orderTypeList" @chooseType="searchReceptionList($event, 'orderFinishFlag')" />
<select-component :selectList="receptionTypeList" @chooseType="searchReceptionList($event, 'reviewFlag')" />
<!-- 次级筛选区域容器 -->
<view class="filter-container">
<view class="select-box-list select-component flex">
<template v-if="tabIndex == 0">
<view class="filter-group">
<button-group :selectList="orderTypeList" @chooseType="searchReceptionList($event, 'orderFinishFlag')" />
</view>
<view class="divider"></view>
<view class="filter-group">
<button-group :selectList="receptionTypeList" @chooseType="searchReceptionList($event, 'reviewFlag')" />
</view>
</template>
</view>
<template v-if="tabIndex == 1">
<view class="filter-group">
<button-group class="select-component" :selectList="uploadTypeList" @chooseType="changeUploadType" />
</view>
</template>
</view>
<template v-if="tabIndex == 1">
<select-component class="select-component" :selectList="uploadTypeList" @chooseType="changeUploadType" />
</template>
</view>
<scroll-view class="record-list" scroll-y @scrolltolower="pageonReachBottom">
<view class="record-tips flex" v-if="tabIndex == 1 && isPrePage && list.length && list[0] && list[0].length">
......@@ -85,12 +97,12 @@
<script type="text/ecmascript-6">
import dayjs from 'dayjs'
import SelectComponent from '@/components/SelectComponent.vue'
import ButtonGroup from '@/components/ButtonGroup.vue'
import PageTabs from '@/components/PageTabs.vue'
export default {
inject: ['getRecorder'],
name: '',
components: { SelectComponent, PageTabs },
components: { ButtonGroup, PageTabs },
props: {
show: Boolean
},
......@@ -419,46 +431,86 @@ export default {
</script>
<style scoped lang="scss">
.record-box {
box-sizing: border-box;
width: 100%;
height: 100%;
overflow: hidden;
box-sizing: border-box;
.data-container {
background: #ffffff;
border-radius: toRpx(48);
width: 100%;
height: 100%;
box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
box-sizing: border-box;
position: relative;
border-radius: toRpx(24);
background: #ffffff;
/* padding: toRpx(32); 移除容器内边距,改由内部元素控制 */
box-sizing: border-box;
display: flex;
flex-direction: column;
.control-box {
height: toRpx(164);
justify-content: space-between;
align-items: center;
/* margin-bottom: toRpx(32); 移除底部间距 */
margin: toRpx(32) toRpx(32) 0; /* 仅保留上左右外边距 */
flex-shrink: 0;
z-index: 10; /* 确保投影覆盖在列表之上 */
position: relative;
/* 新增设计样式 */
background: #ffffff;
border-radius: toRpx(24);
padding: toRpx(24) toRpx(32);
box-shadow: 0 toRpx(4) toRpx(16) rgba(0, 0, 0, 0.04); /* 减轻投影 */
border: 1px solid #f5f6f8;
.tabs {
width: toRpx(336);
flex-shrink: 0;
width: toRpx(336); /* 恢复固定宽度,防止被挤压 */
height: toRpx(84);
margin-left: toRpx(44);
}
.select-box-list {
margin-left: auto;
.filter-container {
display: flex;
align-items: center;
background: transparent; /* 移除容器背景,因为现在有了外层大卡片 */
border: none; /* 移除边框 */
padding: 0;
height: toRpx(88);
box-sizing: border-box;
gap: 0 toRpx(40);
}
.select-component {
margin-right: toRpx(44);
.filter-group {
display: flex;
align-items: center;
}
.divider {
width: 1px;
height: toRpx(32);
background: #ebedf0;
margin: 0 toRpx(32);
}
.select-component {
margin-left: 0;
}
}
}
}
.record-list {
box-sizing: border-box;
height: calc(100% - #{toRpx(164)});
/* height: calc(100% - #{toRpx(164)}); 使用 flex 自适应高度 */
flex: 1;
height: 0; /* 配合 flex: 1 启用滚动 */
position: relative;
z-index: 4;
.record-tips {
height: toRpx(76);
background: #f58e341a;
border-radius: toRpx(16);
font-size: toRpx(28);
color: #f58e34;
width: calc(100% - #{toRpx(88)});
margin: 0 auto toRpx(40);
width: calc(100% - #{toRpx(64)}); /* 调整宽度匹配边距 */
margin: toRpx(32) auto toRpx(20); /* 增加顶部边距,使内容不顶着头部 */
justify-content: center;
.icon {
margin-right: toRpx(8);
......@@ -469,7 +521,7 @@ export default {
display: flex;
flex-wrap: wrap;
gap: toRpx(40) toRpx(46);
padding: toRpx(2) toRpx(44) 0;
padding: toRpx(32) toRpx(32) 0; /* 调整内边距,给顶部留出空间 */
.item {
// width: toRpx(610);
width: calc(50% - #{toRpx(23)});
......
<template>
<view class="reception-box">
<view :class="['record-box-content',`${showInfo || !showRecord?'hide-record':'show-record'}`]">
<view :class="['record-box-content',`${showInfo || !showRecord?'hide-record':''}`]">
<view class="right box-class only-right">
<type-tab-component
:typeList="typeList"
......@@ -59,7 +59,7 @@ import dayjs from 'dayjs'
import RecordList from './RecordList.vue'
import saveRecord from './saveRecord.vue'
import CustomerFile from './CustomerFile.vue'
// import CustomerInfo from './CustomerInfo.vue'
import CustomerInfo from './CustomerInfo.vue'
import TypeTabComponent from '@/components/TypeTabComponent.vue'
import SelectComponent from '@/components/SelectComponent.vue'
......@@ -70,7 +70,7 @@ export default {
RecordList,
saveRecord,
CustomerFile,
// CustomerInfo,
CustomerInfo,
TypeTabComponent,
SelectComponent
},
......
<template>
<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">
<component :is="componentName" ref="pointRef" :userInfo="userInfo" @showPage="handleShowPage"
:isPermissionFunction="isPermission" />
</template>
<!-- 业务类型选择器 -->
<business-type-selector ref="bizTypeSelector" @choose="chooseBusinessType" />
</view>
</template>
<script>
import Material from '@/components/MaterialIndex.vue'
import ReceptionCenter from '../components/ReceptionCenter/index.vue'
import BusinessTypeSelector from './BusinessTypeSelector.vue'
export default {
components: { Material, ReceptionCenter, BusinessTypeSelector },
props: {
tabIndex: {
type: Number,
default: 0
},
moduleList: {
type: Array,
default: () => []
},
componentName: {
type: String,
default: ''
},
isPermission: {
type: [Boolean, Function],
default: false
}
},
data() {
return {
currentType: {},
userInfo: {}
}
},
mounted() {
this.userInfo = uni.$storage.get('userInfo') || {}
this.currentType = uni.$storage.get('typeItem') || {}
},
methods: {
handleShowPage(name, transfer) {
this.$emit('showPage', name, transfer)
},
changeType() {
this.$refs.bizTypeSelector.open()
},
chooseBusinessType(item) {
this.currentType = item
uni.$storage.set('typeItem', item)
this.$emit('changeType')
}
}
}
</script>
<style scoped lang="scss">
.right-side {
flex: 1;
position: relative;
width: calc(100vw - #{toRpx(240)});
.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>
<view class="store-addr">
<view class="icon-addr sprite-icon icon-addr"></view>
<view class="addr-text">{{ userInfo.shopMerchantName }}</view>
</view>
</template>
<script>
export default {
data() {
return {
userInfo: {}
}
},
mounted() {
this.userInfo = uni.$storage.get('userInfo') || {}
}
}
</script>
<style scoped lang="scss">
.store-addr {
position: absolute;
left: 50%;
bottom: toRpx(24);
transform: translateX(-50%);
display: flex;
align-items: center;
.icon-addr {
width: toRpx(32);
height: toRpx(32);
flex-shrink: 0;
}
.addr-text {
font-size: toRpx(24);
color: #999999;
word-wrap: break-word;
white-space: normal;
line-height: toRpx(32);
margin-left: toRpx(4);
flex-shrink: 0;
}
&::before,
&::after {
content: '';
width: toRpx(600);
height: toRpx(2);
margin: 0 toRpx(40);
}
&::before {
background-image: linear-gradient(270deg, #eeeeee 0%, #d8d8d800 100%);
}
&::after {
background-image: linear-gradient(90deg, #eeeeee 0%, #d8d8d800 100%);
}
}
</style>
<template>
<view class="container" @click="handleTouchStart">
<view :class="['home', { show: !id && 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>
<right-content :tabIndex="tabIndex" :moduleList="moduleList" :componentName="componentName" :isPermission="isPermission" @start="start" @changeType="$emit('changeType')" @showPage="handleShowPage" />
<store-address v-if="footerBox" />
</view>
<view :class="['detail', { show: id }]">
<slot name="detail" />
</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')" />
<!-- 升级弹框 -->
<update-box />
<slot name="content" />
<web-view @message="handlerMessage" ref="webview" src="/hybrid/html/index.html"></web-view>
<!-- <web-view
ref="studyWebview"
:src="jumpUrl"
v-if="showBeisen"
></web-view> -->
</view>
</template>
<script>
import ReceptionCenter from './components/ReceptionCenter/index.vue'
import RightContent from './components/RightContent.vue'
import FinishReceptionDialog from './components/FinishReceptionDialog.vue'
import StoreAddress from './components/StoreAddress.vue'
import timeout from '@/mixin/timeout'
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'
export default {
mixins: [recorder, uploader, timeout, versionCheck],
components: { LeftSide, Material, ReceptionCenter, RightContent, FinishReceptionDialog, StoreAddress },
props: {
id: [String, Number],
moduleList: {
type: Array,
default: () => []
},
bannerKey: String,
loadComplete: Boolean,
swiperNoDataObject: Object,
checkRecordAudio: {
type: Boolean,
default: true
},
swiperCustom: Boolean
},
data() {
return {
studyUrl: '',
jumpUrl: '',
transfer: '',
footerBox: true,
showHome: true,
pointComponentName: 'Point',
userInfo: {},
tabIndex: 0,
showBeisen: false,
tipsObject: {},
autoplay: true,
previewOff: false
}
},
mounted() {
const userInfo = uni.$storage.get('userInfo') || {}
this.userInfo = userInfo
// if (this.checkRecordAudio) permision.requestAndroidPermission('android.permission.RECORD_AUDIO') // 进入界面时检查权限
},
provide() {
return {
showPage: this.handleShowPage,
hideFooter: this.handleFooter
}
},
computed: {
finishRef() {
return this.$refs.finish
},
componentName() {
let tabs = this.$refs.leftBox?.tabs
return tabs ? tabs[this.tabIndex].name : ''
}
},
methods: {
async changeTab({ item, index }) {
this.previewOff = index != 0
this.$emit('changeTab', index)
},
handleFooter(val) {
this.footerBox = val
},
handleShowPage(name, transfer) {
this.transfer = transfer
this.showHome = false
this.pointComponentName = name
},
showReadCountTips(res) {
this.tipsObject = res
},
closeTips() {
this.tipsObject = {
style: '',
text: ''
}
},
previewHandler(name, off = false) {
this.previewOff = off
this.$emit(name)
},
async start() {
this.$emit('start')
}
// async changeType() {
// this.$refs.bizTypeSelector.open()
// },
// chooseBusinessType(item) {
// this.currentType = item
// uni.$storage.set('typeItem', item)
// this.$emit('changeType')
// },
}
}
</script>
<style scoped lang="scss">
.container {
position: relative;
.tips-box {
position: absolute;
color: #ffffff;
font-size: toRpx(28);
width: toRpx(310);
height: toRpx(90);
line-height: toRpx(68);
background-image: url('@/assets/images/home/daliog.png');
background-size: 100% 100%;
z-index: 9;
padding-left: toRpx(60);
text-align: left;
display: none;
opacity: 0;
}
&::after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
background-image: url('@/assets/images/common/home-bg-1.webp');
background-size: 100% 100%;
z-index: 1;
}
.home,
.detail {
position: fixed;
width: 100%;
height: 100%;
z-index: -1;
top: 0;
left: 0;
visibility: hidden;
opacity: 0;
}
.point-page {
position: fixed;
width: 100%;
height: 100%;
z-index: 2;
top: 0;
left: 0;
}
.home {
display: flex;
height: 100vh;
position: relative;
.store-addr {
position: absolute;
left: 50%;
bottom: toRpx(24);
transform: translateX(-50%);
display: flex;
align-items: center;
.icon-addr {
width: toRpx(32);
height: toRpx(32);
flex-shrink: 0;
}
.addr-text {
font-size: toRpx(24);
color: #999999;
word-wrap: break-word;
white-space: normal;
line-height: toRpx(32);
margin-left: toRpx(4);
flex-shrink: 0;
}
&::before,
&::after {
content: '';
width: toRpx(600);
height: toRpx(2);
margin: 0 toRpx(40);
}
&::before {
background-image: linear-gradient(270deg, #eeeeee 0%, #d8d8d800 100%);
}
&::after {
background-image: linear-gradient(90deg, #eeeeee 0%, #d8d8d800 100%);
}
}
}
.show {
opacity: 1;
position: absolute;
z-index: 2;
visibility: visible;
animation: show-content-left 0.15s forwards;
}
}
@keyframes show-content-left {
0% {
left: 100%;
}
100% {
left: 0;
}
}
.right-side {
flex: 1;
position: relative;
width: calc(100vw - #{toRpx(240)});
.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);
}
.select-type {
position: absolute; /* 改为绝对定位,悬浮 */
right: toRpx(48);
top: 68%; /* 向下调整,避免顶部遮挡 */
transform: translateY(-50%);
width: toRpx(128); /* 加大尺寸 */
height: toRpx(128);
border-radius: 50%;
background: linear-gradient(135deg, #6187e7 0%, #8a6ef5 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-shadow: 0 toRpx(8) toRpx(20) rgba(97, 135, 231, 0.5);
z-index: 10;
animation: breathe 3s infinite ease-in-out; /* 呼吸效果 */
.text {
font-size: toRpx(22);
color: #fff;
font-weight: 600;
line-height: 1.2;
text-align: center;
width: toRpx(80);
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.icon-arrow {
display: none; /* 圆形按钮不需要箭头 */
}
/* 流光圆环 */
&::before {
content: '';
position: absolute;
top: toRpx(-8);
left: toRpx(-8);
right: toRpx(-8);
bottom: toRpx(-8);
border-radius: 50%;
border: toRpx(4) solid transparent;
border-top-color: #ffffff;
border-right-color: rgba(255, 255, 255, 0.6);
border-bottom-color: rgba(138, 110, 245, 0.4);
/* 光影辉光效果 */
box-shadow:
0 0 toRpx(16) rgba(97, 135, 231, 0.6),
inset 0 0 toRpx(10) rgba(255, 255, 255, 0.2);
filter: drop-shadow(0 0 toRpx(6) rgba(255, 255, 255, 0.8));
animation: rotate-ring 4s linear infinite;
}
/* 内部高光 */
&::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.5) 0%, transparent 60%);
}
&:active {
transform: translateY(-50%) scale(0.9);
box-shadow: 0 toRpx(4) toRpx(10) rgba(97, 135, 231, 0.5);
}
}
@keyframes breathe {
0%,
100% {
transform: translateY(-50%) scale(1);
box-shadow: 0 toRpx(8) toRpx(20) rgba(97, 135, 231, 0.5);
}
50% {
transform: translateY(-50%) scale(1.05);
box-shadow: 0 toRpx(12) toRpx(30) rgba(97, 135, 231, 0.7);
}
}
@keyframes rotate-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.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;
}
}
.footer {
border-top: toRpx(2) solid #eff0f2;
font-weight: 600;
font-size: toRpx(32);
margin-top: toRpx(48);
.footer-btn {
justify-content: center;
margin: toRpx(16) auto 0;
}
.confirm {
width: toRpx(608);
height: toRpx(80);
background: #2c66f7;
border-radius: toRpx(40);
color: #fff;
}
.cancel {
width: toRpx(608);
height: toRpx(80);
background: #ffffff00;
border-radius: toRpx(40);
color: #2c66f7;
}
text {
font-size: toRpx(24);
}
}
.lead-page {
height: 100vh;
width: 100vw;
z-index: 999999;
position: fixed;
}
</style>
<template>
<view class="container" @click="handleTouchStart">
<view :class="['home', { show: !id && 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="right-side">
<view :class="['app-content-box right-content', { 'show-content-box': tabIndex == 0 }]">
......@@ -12,11 +11,12 @@
<view class="right-content-box flex">
<view class="content-left">
<view class="module-box box-class">
<view class="common-title"> {{ currentType.typeName }}产品介绍
<view class="select-type" @click="changeType">
<text class="text">切换接待类型</text>
<view class="icon-arrow"></view>
</view>
<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>
......@@ -28,51 +28,18 @@
</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>
</view>
<view class="store-addr" v-if="footerBox">
<view class="icon-addr sprite-icon icon-addr"></view>
<view class="addr-text">{{ userInfo.shopMerchantName }}</view>
</view>
<store-address v-if="footerBox" />
</view>
<view :class="['detail', { show: id }]">
<slot name="detail" />
</view>
<!-- 未点击开始接待,弹窗 -->
<MessageBox ref="previewRef" @confirm="previewHandler('preview', true)" :popupW="704"
content="直接点击素材可进行预览,若面向车主展示,请点击「开始接待」" confirmBtnText="预览素材" @cancel="previewHandler('previewCancel')"
@close="previewHandler('previewClose')"></MessageBox>
<!-- 停留弹框 -->
<!-- <MessageBox ref="tipBox" @cancel="tipCancel" @confirm="tipConfirm" content="系统检测到您在当前页面停留较久,是否仍在客户接待中?" cancelBtnText="否" confirmBtnText="是"></MessageBox> -->
<!-- 退出弹框 -->
<MessageBox :popupW="704" ref="finish" :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>
</view>
</MessageBox>
<MessageBox :popupW="704" ref="bizTypeBox" :isFooter="false" title="请选择类型">
<view class="footer">
<template v-for="(i, index) in businessTypeList">
<view class="footer-btn confirm flex" :key="index" @click="chooseBusinessType(i)">
{{ i.typeName }}
</view>
</template>
</view>
</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')" />
<business-type-selector ref="bizTypeSelector" @choose="chooseBusinessType" />
<!-- 升级弹框 -->
<update-box />
<slot name="content" />
......@@ -86,17 +53,18 @@
</template>
<script>
import ReceptionCenter from './components/ReceptionCenter/index.vue'
// import myClick from '@/mixin/click'
import BusinessTypeSelector from './components/BusinessTypeSelector.vue'
import FinishReceptionDialog from './components/FinishReceptionDialog.vue'
import StoreAddress from './components/StoreAddress.vue'
import timeout from '@/mixin/timeout'
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 merge from '@/mixin/record/merge.js'
import Material from '@/components/MaterialIndex.vue'
export default {
mixins: [recorder, uploader, timeout, versionCheck],
components: { LeftSide, Material, ReceptionCenter },
components: { LeftSide, Material, ReceptionCenter, BusinessTypeSelector, FinishReceptionDialog, StoreAddress },
props: {
id: [String, Number],
finishDoneText: String,
......@@ -115,7 +83,7 @@ export default {
type: Boolean,
default: true
},
swiperCustom: Boolean,
swiperCustom: Boolean
},
data() {
return {
......@@ -130,8 +98,7 @@ export default {
showBeisen: false,
tipsObject: {},
autoplay: true,
previewOff: false,
businessTypeList: [],
previewOff: false,
currentType: {}
}
},
......@@ -151,13 +118,12 @@ export default {
finishRef() {
return this.$refs.finish
},
componentName () {
componentName() {
let tabs = this.$refs.leftBox?.tabs
return tabs ? tabs[this.tabIndex].name : ''
},
}
},
methods: {
async changeTab({ item, index }) {
this.previewOff = index != 0
this.$emit('changeTab', index)
......@@ -188,20 +154,15 @@ export default {
this.$emit('start')
},
async changeType() {
const res = await uni.$api.commonApi.getPadBusinessTypeList()
console.log(res, 'res')
const list = Array.isArray(res?.data) ? res.data : (Array.isArray(res) ? res : [])
this.businessTypeList = list
this.$refs.bizTypeBox.open()
this.$refs.bizTypeSelector.open()
},
chooseBusinessType(item) {
this.$refs.bizTypeBox.close()
this.currentType = item
uni.$storage.set('typeItem', item)
this.$emit('changeType')
},
}
}
}
</script>
<style scoped lang="scss">
.container {
......@@ -397,6 +358,58 @@ export default {
.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);
......@@ -425,13 +438,13 @@ export default {
line-height: 1.2;
text-align: center;
width: toRpx(80);
text-shadow: 0 2px 4px rgba(0,0,0,0.2);
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.icon-arrow {
display: none; /* 圆形按钮不需要箭头 */
display: none; /* 圆形按钮不需要箭头 */
}
/* 流光圆环 */
&::before {
content: '';
......@@ -446,7 +459,9 @@ export default {
border-right-color: rgba(255, 255, 255, 0.6);
border-bottom-color: rgba(138, 110, 245, 0.4);
/* 光影辉光效果 */
box-shadow: 0 0 toRpx(16) rgba(97, 135, 231, 0.6), inset 0 0 toRpx(10) rgba(255, 255, 255, 0.2);
box-shadow:
0 0 toRpx(16) rgba(97, 135, 231, 0.6),
inset 0 0 toRpx(10) rgba(255, 255, 255, 0.2);
filter: drop-shadow(0 0 toRpx(6) rgba(255, 255, 255, 0.8));
animation: rotate-ring 4s linear infinite;
}
......@@ -460,7 +475,7 @@ export default {
width: 100%;
height: 100%;
border-radius: 50%;
background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.5) 0%, transparent 60%);
background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.5) 0%, transparent 60%);
}
&:active {
......@@ -470,13 +485,24 @@ export default {
}
@keyframes breathe {
0%, 100% { transform: translateY(-50%) scale(1); box-shadow: 0 toRpx(8) toRpx(20) rgba(97, 135, 231, 0.5); }
50% { transform: translateY(-50%) scale(1.05); box-shadow: 0 toRpx(12) toRpx(30) rgba(97, 135, 231, 0.7); }
0%,
100% {
transform: translateY(-50%) scale(1);
box-shadow: 0 toRpx(8) toRpx(20) rgba(97, 135, 231, 0.5);
}
50% {
transform: translateY(-50%) scale(1.05);
box-shadow: 0 toRpx(12) toRpx(30) rgba(97, 135, 231, 0.7);
}
}
@keyframes rotate-ring {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.tool-box {
......
<template>
<view class="material-box">
<template v-if="(moduleList && moduleList.length) || (imagelist && imagelist.length)">
<!-- 轮播容器:使用 movable-area 实现自定义滑动与自动播放 -->
<movable-area class="swiper-carousel" @touchstart="starts" @touchend="ends">
<!-- 展示位:根据 item.class 切换左/中/右位置,只有中间可拖拽/点击 -->
<movable-view v-for="(item, index) in imagelist" :key="index" :class="['carousel-block', item.class]"
direction="horizontal" :disabled="item.class != 'block-center' || moduleList.length == 1"
:x="item.class != 'block-center' ? 0 : viewX" @change="change" @click.stop="handleClick(item)">
<image class="image-block" :src="item.imgUrl" />
</movable-view>
</movable-area>
<!-- 标题:与当前中心卡片 materialName 联动 -->
<!-- 轮播容器 -->
<view class="swiper-carousel" @touchstart="starts" @touchend="ends">
<view v-for="(item, index) in imagelist" :key="index" :class="['carousel-block', item.class]"
@click.stop="handleClick(item)">
<image class="image-block" :src="item.imgUrl" mode="aspectFill" />
<view class="mask"></view>
</view>
</view>
<!-- 标题 -->
<view class="module-title flex">
{{ moduleTitle}}
</view>
<!-- 指示点:与 currentIndex 同步高亮 -->
<!-- 指示点 -->
<view class="module-dots flex">
<view v-for="(i, index) in moduleList" :key="index" :class="['dot', { 'active': index == currentIndex }]">
</view>
......@@ -35,7 +34,6 @@
<script>
export default {
// 自定义三卡片轮播组件:实现自动播放与手势滑动
name: 'MaterialIndex',
props: {
moduleList: {
......@@ -45,23 +43,17 @@ export default {
},
data() {
return {
// 轮播数据快照(与 moduleList 同步)
datalist: [],
// 渲染用的三卡片列表(左/中/右)
imagelist: [],
// 三卡片位置与类名映射
// 定义位置样式:左、中、右
style_object: [
{ index: 0, class: 'block-left' },
{ index: 1, class: 'block-center' },
{ index: 2, class: 'block-right' }
],
// 拖拽与位置控制
blockX: 0,
viewX: 0,
ismove: 0,
// 自动播放控制参数与状态
autoplay: true,
interval: 3000,
interval: 4000,
autoPlayTimer: null,
endTimer: null,
playStatus: true,
......@@ -69,7 +61,6 @@ export default {
}
},
computed: {
// 当前模块标题与中心卡片联动
moduleTitle() {
return this.moduleList[this.currentIndex]?.materialName || ''
}
......@@ -83,18 +74,15 @@ export default {
}
},
mounted() {
// 初始化轮播并开启自动播放
this.getDatalist()
if (this.autoplay) this.autoPlayFunction()
},
methods: {
// 初始化 imagelist(最多三项)并更新 currentIndex
getDatalist() {
this.datalist = this.moduleList
const list = JSON.parse(JSON.stringify(this.style_object))
const len = this.datalist.length
// 自动播放控制:仅当素材数量大于1时才开启
if (len > 1 && this.autoplay) {
this.autoPlayFunction()
} else {
......@@ -115,7 +103,6 @@ export default {
return
}
if (len === 2) {
// 两张素材:居中 + 右侧
this.imagelist = [
{ isToor: 1, class: 'block-center', imgUrl: this.datalist[0].materialUrl, isIndex: 0, index: 1 },
{ isToor: 2, class: 'block-right', imgUrl: this.datalist[1].materialUrl, isIndex: 1, index: 2 }
......@@ -123,11 +110,8 @@ export default {
this.currentIndex = 0
return
}
const count = Math.min(3, len)
// 初始化:
// block-left: len-1 (Last)
// block-center: 0 (First)
// block-right: 1 (Second)
this.imagelist = Array.from({ length: count }).map((_, i) => {
let isIndex
if (i === 0) isIndex = len - 1
......@@ -146,7 +130,6 @@ export default {
const ci = this.imagelist.findIndex(item => item.index === 1)
if (ci !== -1) this.currentIndex = this.imagelist[ci].isIndex
},
// 自动播放控制:递归定时触发 updateCarouselPositions
autoPlayFunction() {
if (!this.autoplay || this.datalist.length <= 1) return
if (this.autoPlayTimer) clearTimeout(this.autoPlayTimer)
......@@ -160,32 +143,25 @@ export default {
this.autoPlayFunction()
}, this.interval)
},
// 根据滑动方向更新三卡片位置与索引
updateCarouselPositions(direction = 'left') {
const { imagelist, datalist } = this
const len = datalist.length - 1
const len = datalist.length
const list = JSON.parse(JSON.stringify(this.style_object))
if (datalist.length === 2) {
// 仅两张素材:在中心与右侧之间互换
if (len === 2) {
// 两张图特殊处理
const a = this.imagelist[0]
const b = this.imagelist[1]
const aWasCenter = a.class === 'block-center'
a.class = aWasCenter ? 'block-right' : 'block-center'
a.isToor = a.class === 'block-center' ? 1 : 2
a.index = a.isToor
a.x = 0
a.imgUrl = datalist[a.isIndex]?.materialUrl || ''
b.class = aWasCenter ? 'block-center' : 'block-right'
b.isToor = b.class === 'block-center' ? 1 : 2
b.index = b.isToor
b.x = 0
b.imgUrl = datalist[b.isIndex]?.materialUrl || ''
const ci2 = this.imagelist.findIndex(item => item.class === 'block-center')
if (ci2 !== -1) this.currentIndex = this.imagelist[ci2].isIndex
const centerItem = a.class === 'block-center' ? a : b
this.currentIndex = centerItem.isIndex
} else {
// 更新 currentIndex
if (direction === 'left') {
this.currentIndex = (this.currentIndex + 1) % len
} else {
......@@ -193,93 +169,61 @@ export default {
}
this.imagelist.forEach(item => {
// 计算新的位置索引 0(Left), 1(Center), 2(Right)
// Left: isToor --;
const toor = direction === 'left'
? (item.isToor - 1) < 0 ? imagelist.length - 1 : item.isToor - 1
: (item.isToor + 1) > imagelist.length - 1 ? 0 : item.isToor + 1
? (item.isToor - 1) < 0 ? 2 : item.isToor - 1
: (item.isToor + 1) > 2 ? 0 : item.isToor + 1
item.isToor = toor
item.class = list[toor].class
item.x = 0
// 根据新位置设置内容
// Center: currentIndex
// Left: (currentIndex - 1 + len) % len
// Right: (currentIndex + 1) % len
if (item.class === 'block-center') {
// 已经是正确的数据了,或者需要更新?
// 实际上如果是滑动过来的,它原本的数据就是我们想要的
// 比如 Left (prev) -> Center (current).
// 所以这里理论上不需要动 isIndex,除非我们需要“补”数据
// 但是为了确保数据绝对正确,我们可以强制赋值
// 注意:这样可能会导致图片闪烁,如果 DOM 复用而 src 变了。
// 只有当该卡片是从“不可见/替补”区域变过来时才需要更新 src。
// 在 3 卡片循环中,Left->Center, Center->Right, Right->Left (如果是左滑)
// Right 变成了 Left(替补位),此时它应该装载 (currentIndex - 1) 的数据吗?
// 如果是左滑(看下一张):
// Center(0) -> Left(0). Left(len-1) -> Right(1). Right(1) -> Center(1).
// 此时:
// 新 Left 是旧 Center(0)。期望是 (1-1)=0。正确。
// 新 Center 是旧 Right(1)。期望是 1。正确。
// 新 Right 是旧 Left(len-1)。期望是 2。
// 所以只有“跳跃”的那张卡需要更新。
}
let isIndex = item.isIndex
// 动态更新图片逻辑:
// 只有当卡片移动到"替补"位置时才更新内容,以保持动画连贯
// 左滑 (Next): Right(2) -> Center(1) -> Left(0) -> Right(2)...
// 原 Left(0) 变成 Right(2),它需要加载下下张图
if (direction === 'left' && item.class === 'block-right') {
// 原 Left 变成了 Right,需要装载下下张图
isIndex = (this.currentIndex + 1) % len
item.isIndex = (this.currentIndex + 1) % len
item.imgUrl = datalist[item.isIndex].materialUrl
}
// 右滑 (Prev): Left(0) -> Center(1) -> Right(2) -> Left(0)...
// 原 Right(2) 变成 Left(0),它需要加载上上张图
if (direction === 'right' && item.class === 'block-left') {
// 原 Right 变成了 Left,需要装载上上张图
isIndex = (this.currentIndex - 1 + len) % len
item.isIndex = (this.currentIndex - 1 + len) % len
item.imgUrl = datalist[item.isIndex].materialUrl
}
item.isIndex = isIndex
item.imgUrl = datalist[isIndex].materialUrl || ''
item.index = list[toor].index
})
}
// 这里的 ci 计算其实是多余的,因为我们已经手动维护了 currentIndex
// const ci = this.imagelist.findIndex(item => item.index === 1)
// if (ci !== -1) this.currentIndex = this.imagelist[ci].isIndex
},
// 触摸开始:暂停自动播放、记录起点
starts(e) {
this.ismove = e.touches[0].pageX
this.playStatus = false
if (this.endTimer) {
clearTimeout(this.endTimer)
this.endTimer = null
return
}
},
// 触摸结束:判断滑动阈值,切换或回弹,并恢复自动播放
ends(e) {
if (this.moduleList.length === 1) return
if (this.moduleList.length <= 1) return
const pageX = e.changedTouches[0].pageX
const nums = this.ismove - pageX
if (nums === 0) return
if (!(nums > 50 || this.blockX < -30) || !(nums < -50 || this.blockX > 30)) {
this.viewX = -10
setTimeout(() => { this.viewX = 0 }, 16)
}
if (nums > 50 || this.blockX < -30) this.updateCarouselPositions('left')
if (nums < -50 || this.blockX > 30) this.updateCarouselPositions('right')
if (Math.abs(nums) < 30) return // 阈值防误触
if (nums > 30) this.updateCarouselPositions('left')
if (nums < -30) this.updateCarouselPositions('right')
this.endTimer = setTimeout(() => {
if (!this.playStatus) {
this.playStatus = true
this.autoPlayFunction()
}
this.playStatus = true
this.autoPlayFunction()
}, this.interval)
},
// movable-view 位移变化回调,记录偏移值
change(e) {
const { x } = e.detail
this.blockX = x
},
// 点击中心卡片,向父组件抛出 itemClick
handleClick(item) {
console.log(item)
if (item.class !== 'block-center') return
if (item.class !== 'block-center') {
// 点击两侧卡片也可以切换
if (item.class === 'block-right') this.updateCarouselPositions('left')
if (item.class === 'block-left') this.updateCarouselPositions('right')
return
}
const data = this.moduleList[item.isIndex]
this.$emit('itemClick', data, item.isIndex)
}
......@@ -288,11 +232,12 @@ export default {
</script>
<style scoped lang="scss">
/* 布局容器 */
.material-box {
width: 100%;
height: 100%;
text-align: center;
position: relative;
overflow: hidden;
}
.empty-box {
......@@ -302,105 +247,106 @@ export default {
align-items: center;
justify-content: center;
flex-direction: column;
color: #999999;
color: #999;
font-size: toRpx(28);
.empty-img {
width: toRpx(160);
height: toRpx(160);
margin-bottom: toRpx(16);
}
}
.empty-box .empty-img {
width: toRpx(160);
height: toRpx(160);
margin-bottom: toRpx(16);
}
.empty-box .empty-text {
line-height: toRpx(40);
}
/* 轮播外层:宽度 90%,上下留边距 */
.swiper-carousel {
width: 90%;
height: calc(90% - #{toRpx(96)});
width: 100%;
height: calc(100% - #{toRpx(90)});
position: relative;
overflow: visible;
margin: toRpx(60) auto;
perspective: 1000rpx;
margin-top: toRpx(10);
perspective: 2000rpx; /* 3D透视 */
}
/* 三卡片基础样式 */
.carousel-block {
position: absolute;
top: 50%;
width: 65%;
height: 96%;
border-radius: toRpx(32);
background: #fff;
overflow: hidden;
transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
border: toRpx(2) solid #ffffffb3;
box-shadow: 0 toRpx(10) toRpx(30) 0 rgba(82, 148, 255, 0.4);
border-radius: toRpx(24);
/* 使用带回弹的贝塞尔曲线 */
transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
transform-style: preserve-3d;
background: #fff;
}
.image-block {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
object-fit: cover;
box-shadow: 0 toRpx(10) toRpx(30) rgba(0, 0, 0, 0.05);
.image-block {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: toRpx(32);
display: block;
}
.mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.3);
opacity: 0;
transition: opacity 0.6s;
pointer-events: none;
}
}
/* 三个展示位:左/中/右的定位容器 */
.block-left,
.block-right,
/* 中心卡片 */
.block-center {
position: absolute;
left: 50%;
transform: translate3d(-50%, -50%, 0) scale(1);
z-index: 20;
opacity: 1;
box-shadow: 0 toRpx(30) toRpx(60) rgba(44, 102, 247, 0.35); /* 品牌色投影 */
.mask {
opacity: 0;
}
}
/* 左侧卡片 */
.block-left {
left: 0%;
top: 50%;
width: 70%;
height: 80%;
transform: translateY(-50%) translateZ(-300rpx) rotateY(45deg) scale(0.9);
left: 30%;
transform: translate3d(-50%, -50%, -100rpx) scale(0.85) rotateY(15deg);
z-index: 10;
opacity: 0.8;
filter: blur(4px) brightness(0.8);
.mask {
opacity: 1;
}
}
/* 右侧卡片 */
.block-right {
left: 30%;
top: 50%;
width: 70%;
height: 80%;
transform: translateY(-50%) translateZ(-300rpx) rotateY(-45deg) scale(0.9);
z-index: 15;
left: 70%;
transform: translate3d(-50%, -50%, -100rpx) scale(0.85) rotateY(-15deg);
z-index: 10;
opacity: 0.8;
filter: blur(4px) brightness(0.8);
}
.block-center {
left: 15%;
top: 50%;
width: 70%;
height: 96%;
transform: translateY(-50%) translateZ(100rpx) rotateY(0deg) scale(1.1);
z-index: 20;
opacity: 1;
filter: blur(0) brightness(1);
box-shadow: 0 toRpx(20) toRpx(50) 0 rgba(82, 148, 255, 0.25);
.mask {
opacity: 1;
}
}
/* 标题与指示点区域 */
.module-title {
color: #333333;
font-size: toRpx(24);
margin-top: toRpx(24);
color: #333;
font-size: toRpx(28);
font-weight: 600;
margin-top: toRpx(10);
justify-content: center;
position: relative;
}
/* 指示点:靠右下角排列 */
.module-dots {
position: absolute;
bottom: toRpx(116);
bottom: toRpx(20);
right: toRpx(98);
gap: toRpx(12);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!