Commit e1904c38 by liimin

feat(HomeSlot/BusinessTypeSelector): 优化产品切换和类型选择器样式

- 在HomeSlot中改进产品类型显示样式,添加高亮效果和更美观的切换按钮
- 重构BusinessTypeSelector为网格布局,添加主题色、选中状态和悬停效果
- 使用uni-icons替换原有图标,增强视觉一致性
1 parent 3b42bf33
<template> <template>
<MessageBox :popupW="704" ref="bizTypeBox" :isFooter="false" title="请选择类型"> <MessageBox ref="bizTypeBox" position="bottom" :isFooter="false" title="请选择接待类型" :maxHeight="900">
<view class="footer"> <view class="selector-container">
<template v-for="(i, index) in businessTypeList"> <view class="options-grid">
<view class="footer-btn confirm flex" :key="index" @click="chooseBusinessType(i)"> <template v-for="(i, index) in businessTypeList">
{{ i.typeName }} <view class="option-item flex" :class="{ 'active-item': currentId == i.typeCode }" :key="index" @click="chooseBusinessType(i)" :style="getThemeStyle(index)" hover-class="option-hover">
</view> <view class="item-content">
</template> <view class="icon-badge">
{{ i.typeName ? i.typeName[0] : '类' }}
<view class="check-mark" v-if="currentId == i.typeCode">
<uni-icons type="checkmarkempty" size="14" color="#fff"></uni-icons>
</view>
</view>
<view class="text-info">
<view class="name">{{ i.typeName }}</view>
<view class="sub-text">Business</view>
</view>
</view>
<!-- 装饰性背景字 -->
<view class="bg-decoration">{{ i.typeName ? i.typeName[0] : 'B' }}</view>
<!-- 装饰性光晕 -->
<view class="shine-effect"></view>
</view>
</template>
</view>
</view> </view>
</MessageBox> </MessageBox>
</template> </template>
...@@ -14,42 +31,187 @@ ...@@ -14,42 +31,187 @@
export default { export default {
data() { data() {
return { return {
businessTypeList: [] businessTypeList: [],
currentId: '', // 当前选中的ID
// 预设6种高级配色方案 (背景渐变, 主色调)
themes: [
{ bg: 'linear-gradient(135deg, #EFF4FF 0%, #DEE9FD 100%)', color: '#3B73FF', shadow: 'rgba(59, 115, 255, 0.15)' }, // 蓝
{ bg: 'linear-gradient(135deg, #F0FDF4 0%, #DCFCE7 100%)', color: '#16A34A', shadow: 'rgba(22, 163, 74, 0.15)' }, // 绿
{ bg: 'linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%)', color: '#EA580C', shadow: 'rgba(234, 88, 12, 0.15)' }, // 橙
{ bg: 'linear-gradient(135deg, #FAF5FF 0%, #F3E8FF 100%)', color: '#9333EA', shadow: 'rgba(147, 51, 234, 0.15)' }, // 紫
{ bg: 'linear-gradient(135deg, #ECFEFF 0%, #CFFAFE 100%)', color: '#0891B2', shadow: 'rgba(8, 145, 178, 0.15)' }, // 青
{ bg: 'linear-gradient(135deg, #FFF1F2 0%, #FFE4E6 100%)', color: '#E11D48', shadow: 'rgba(225, 29, 72, 0.15)' } // 红
]
} }
}, },
methods: { methods: {
async open() { async open() {
const typeItem = uni.$storage.get('typeItem')
this.currentId = typeItem.typeCode
const res = await uni.$api.commonApi.getPadBusinessTypeList() const res = await uni.$api.commonApi.getPadBusinessTypeList()
const list = Array.isArray(res?.data) ? res.data : (Array.isArray(res) ? res : []) const list = Array.isArray(res?.data) ? res.data : Array.isArray(res) ? res : []
this.businessTypeList = list this.businessTypeList = list
this.$refs.bizTypeBox.open() this.$refs.bizTypeBox.open()
}, },
chooseBusinessType(item) { chooseBusinessType(item) {
this.currentId = item.typeCode
this.$refs.bizTypeBox.close() this.$refs.bizTypeBox.close()
this.$emit('choose', item) this.$emit('choose', item)
},
getThemeStyle(index) {
const theme = this.themes[index % this.themes.length]
return {
background: theme.bg,
'--theme-color': theme.color,
'--theme-shadow': theme.shadow
}
} }
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.footer { .selector-container {
border-top: toRpx(2) solid #eff0f2; padding: 0 toRpx(40) toRpx(80);
font-weight: 600; width: 100%;
font-size: toRpx(32); box-sizing: border-box;
margin-top: toRpx(48);
.options-grid {
.footer-btn { display: grid;
justify-content: center; grid-template-columns: repeat(3, 1fr);
margin: toRpx(16) auto 0; gap: toRpx(32);
} }
.confirm { .option-item {
width: toRpx(608); position: relative;
height: toRpx(80); height: toRpx(200);
background: #2c66f7; border-radius: toRpx(32);
border-radius: toRpx(40); overflow: hidden;
color: #fff; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
box-sizing: border-box;
padding: toRpx(24);
/* 玻璃拟态边框 */
border: 1px solid rgba(255, 255, 255, 0.6);
box-shadow: 0 toRpx(8) toRpx(24) rgba(0, 0, 0, 0.03);
.item-content {
position: relative;
z-index: 2;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
.icon-badge {
width: toRpx(72);
height: toRpx(72);
background: #ffffff;
border-radius: toRpx(24);
display: flex;
align-items: center;
justify-content: center;
font-size: toRpx(36);
font-weight: 600;
color: var(--theme-color);
box-shadow: 0 toRpx(8) toRpx(16) var(--theme-shadow);
position: relative;
.check-mark {
position: absolute;
right: toRpx(-6);
bottom: toRpx(-6);
width: toRpx(28);
height: toRpx(28);
background: var(--theme-color);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid #fff;
}
}
.text-info {
.name {
font-size: toRpx(30);
font-weight: 600;
color: #1a1a1a;
line-height: 1.2;
margin-bottom: toRpx(4);
/* 单行溢出 */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sub-text {
font-size: toRpx(20);
color: rgba(0, 0, 0, 0.4);
font-weight: 500;
text-transform: uppercase;
letter-spacing: 1px;
}
}
}
.bg-decoration {
position: absolute;
right: toRpx(-10);
bottom: toRpx(-20);
font-size: toRpx(140);
font-weight: 800;
color: var(--theme-color);
opacity: 0.08;
z-index: 1;
pointer-events: none;
font-family: Arial, sans-serif;
}
.shine-effect {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 100%);
z-index: 1;
opacity: 0.5;
}
&.active-item {
transform: translateY(toRpx(-8)) scale(1.02);
box-shadow: 0 toRpx(20) toRpx(40) var(--theme-shadow);
/* 增加明显的选中边框 */
border: 2px solid var(--theme-color) !important;
background: #fff !important;
.bg-decoration {
opacity: 0.15;
transform: scale(1.1) rotate(-10deg);
transition: all 0.4s;
}
.shine-effect {
opacity: 0.8;
}
}
&.option-hover {
transform: translateY(toRpx(-8)) scale(1.02);
box-shadow: 0 toRpx(20) toRpx(40) var(--theme-shadow);
.bg-decoration {
opacity: 0.15;
transform: scale(1.1) rotate(-10deg);
transition: all 0.4s;
}
.shine-effect {
opacity: 0.8;
}
}
} }
} }
</style> </style>
...@@ -7,10 +7,15 @@ ...@@ -7,10 +7,15 @@
<view class="content-left"> <view class="content-left">
<view class="module-box box-class"> <view class="module-box box-class">
<view class="common-title"> <view class="common-title">
<text class="title-text">{{ currentType.typeName }}产品介绍</text> <text class="title-text">
<view class="switch-btn" @click="changeType"> <text class="highlight-type">{{ currentType.typeName }}</text>
<view class="sprite-icon icon-scene-change icon-exchange"></view> 产品介绍
<text>切换</text> </text>
<view class="switch-btn flex" @click="changeType">
<view class="icon-box flex">
<uni-icons type="loop" size="14" color="#2c66f7"></uni-icons>
</view>
<text>切换产品</text>
</view> </view>
</view> </view>
<view class="content-box"> <view class="content-box">
...@@ -145,43 +150,45 @@ export default { ...@@ -145,43 +150,45 @@ export default {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
.highlight-type {
color: #2c66f7;
font-weight: bold;
margin-right: toRpx(8);
font-size: 1.1em;
text-shadow: 0 toRpx(4) toRpx(8) rgba(44, 102, 247, 0.15);
}
} }
.switch-btn { .switch-btn {
display: flex; padding: toRpx(8) toRpx(20) toRpx(8) toRpx(12);
align-items: center; background: rgba(44, 102, 247, 0.08);
background: rgba(255, 255, 255, 0.4); /* 半透明白底,融入蓝底 */ border-radius: toRpx(32);
border: 1px solid rgba(255, 255, 255, 0.6); border: 1px solid rgba(44, 102, 247, 0.15);
border-radius: toRpx(26); transition: all 0.3s ease;
padding: 0 toRpx(20);
height: toRpx(52);
box-sizing: border-box;
margin-left: toRpx(24); margin-left: toRpx(24);
transition: all 0.2s ease;
cursor: pointer; .icon-box {
width: toRpx(36);
height: toRpx(36);
background: #FFFFFF;
border-radius: 50%;
justify-content: center;
align-items: center;
margin-right: toRpx(12);
box-shadow: 0 toRpx(4) toRpx(8) rgba(44, 102, 247, 0.15);
}
text { text {
font-size: toRpx(24); font-size: toRpx(24);
color: #5b6b8c; /* 蓝灰色,低调且协调 */ color: #2c66f7;
font-weight: 400; font-weight: 500;
margin-left: toRpx(8); line-height: 1;
}
.icon-exchange {
/* 复用 sprite 图标 */
zoom: 0.7;
opacity: 0.7;
/* 移除去色滤镜,让图标自然的色调显露,或者保持微调 */
} }
/* 移除之前的 SVG 图标样式 */
&::before {
display: none;
}
&:active { &:active {
background: rgba(255, 255, 255, 0.7); transform: scale(0.96);
transform: scale(0.98); background: rgba(44, 102, 247, 0.15);
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!