Commit 800d1952 by 李伟康

feat(CarBrand): 优化车型选择弹窗交互与样式

- 增加子品牌和车系展开/收起功能,提升用户体验
- 调整品牌名称和子品牌名称的字体大小及间距,增强可读性
- 优化列表项的边框显示逻辑,隐藏已展开项的底部边框
- 使用 `this.$set` 替代直接赋值以确保视图响应式更新
- 移除不必要的 `viewKey` 强制刷新机制,改用更精细的控制方式
- 增加 loading 隐藏延时,避免接口返回过快导致闪动问题
1 parent cec6377a
<template> <template>
<view <view class="car-model-box">
class="car-model-box" <!-- :key="viewKey" -->
:key="viewKey"
>
<scroll-view <scroll-view
class="scroll-view" class="scroll-view"
scroll-y scroll-y
...@@ -26,7 +24,7 @@ ...@@ -26,7 +24,7 @@
<template v-for="(j, jindex) in c.childs_list"> <template v-for="(j, jindex) in c.childs_list">
<view <view
:key="jindex" :key="jindex"
:class="['sub-brand-name']" :class="['sub-brand-name',{'hide-border':j.children && j.children.length && j.open}]"
> >
<view <view
class="subtitle subtitle-one flex" class="subtitle subtitle-one flex"
...@@ -34,24 +32,25 @@ ...@@ -34,24 +32,25 @@
> >
{{j.name}} {{j.name}}
<uni-icons <uni-icons
:type="`${j.children && j.children.length?'down':'right'}`" :type="`${j.children && j.children.length && j.open ?'down':'right'}`"
size="18" size="18"
></uni-icons> ></uni-icons>
</view> </view>
</view> </view>
<template v-for="(k,kindex) in j.children"> <template v-for="(k,kindex) in j.children">
<view <view
class="sub-item flex" :class="['sub-item flex',{'last':kindex == j.children.length-1}, {hide:!j.open}]"
:key="`${k.id}_${kindex}`" :key="`${k.id}_${kindex}`"
> >
<view <view
class="subtitle subtitle-two flex" :class="['subtitle subtitle-two flex']"
@click.stop="chooseSeries(k,jindex, cindex, index ,kindex)" @click.stop="chooseSeries(k,jindex, cindex, index ,kindex)"
> >
{{k.name}} {{k.name}}
<uni-icons <uni-icons
:type="`${k.children && k.children.length?'down':'right'}`" :type="`${k.children && k.children.length && k.open ?'down':'right'}`"
size="18" size="18"
></uni-icons> ></uni-icons>
</view> </view>
...@@ -60,6 +59,7 @@ ...@@ -60,6 +59,7 @@
:class="['item flex',{active: checkActive(s)}]" :class="['item flex',{active: checkActive(s)}]"
:key="`${s.id}_${sindex}`" :key="`${s.id}_${sindex}`"
@click.stop="chooseCarType(s,c)" @click.stop="chooseCarType(s,c)"
v-if="k.open"
> >
{{s.name}} {{s.name}}
<view class="sprite-icon icon-tag-checked"></view> <view class="sprite-icon icon-tag-checked"></view>
...@@ -102,7 +102,6 @@ export default { ...@@ -102,7 +102,6 @@ export default {
data () { data () {
return { return {
letter: 'A', letter: 'A',
viewKey: Date.now()
} }
}, },
mounted () { mounted () {
...@@ -184,7 +183,10 @@ export default { ...@@ -184,7 +183,10 @@ export default {
} }
}, },
async chooseSubBrand (that, item, jindex, cindex, index) { async chooseSubBrand (that, item, jindex, cindex, index) {
if(that.children && that.children.length) return if (that.children && that.children.length) {
this.$set(this.listData[index].list[cindex].childs_list[jindex], 'open', !that.open)
return
}
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
...@@ -192,21 +194,34 @@ export default { ...@@ -192,21 +194,34 @@ export default {
brandId: item.id, brandId: item.id,
childBrandId: that.id childBrandId: that.id
}) })
// this.listData[index].list[cindex].childs_list[jindex].children = data
this.$set(this.listData[index].list[cindex].childs_list[jindex], 'children', data)
this.$set(this.listData[index].list[cindex].childs_list[jindex], 'open', true)
setTimeout(() => {
uni.hideLoading() uni.hideLoading()
this.listData[index].list[cindex].childs_list[jindex].children = data }, 200)
this.viewKey = Date.now() // this.viewKey = Date.now()
}, },
async chooseSeries (k, jindex, cindex, index, kindex) { async chooseSeries (k, jindex, cindex, index, kindex) {
if (k.children && k.children.length) return if (k.children && k.children.length) {
this.$set(this.listData[index].list[cindex].childs_list[jindex].children[kindex], 'open', !k.open)
return
}
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
const data = await uni.$api.popupApi.getCarTypeList({ const data = await uni.$api.popupApi.getCarTypeList({
carSeriesId: k.id carSeriesId: k.id
}) })
// this.listData[index].list[cindex].childs_list[jindex].children[kindex].children = data
this.$set(this.listData[index].list[cindex].childs_list[jindex].children[kindex], 'children', data)
this.$set(this.listData[index].list[cindex].childs_list[jindex].children[kindex], 'open', true)
setTimeout(() => {
uni.hideLoading() uni.hideLoading()
this.listData[index].list[cindex].childs_list[jindex].children[kindex].children = data }, 200)
this.viewKey = Date.now() // this.viewKey = Date.now()
}, },
chooseCarType (s, c) { chooseCarType (s, c) {
...@@ -264,17 +279,20 @@ export default { ...@@ -264,17 +279,20 @@ export default {
margin: 0 toRpx(48); margin: 0 toRpx(48);
.brand-name { .brand-name {
color: #333333; color: #333333;
font-size: toRpx(32); font-size: toRpx(44);
line-height: toRpx(44); line-height: toRpx(54);
margin: toRpx(16) 0; margin: toRpx(24) 0;
} }
.sub-brand-name { .sub-brand-name {
color: #888888; color: #888888;
font-size: toRpx(28); font-size: toRpx(34);
line-height: toRpx(40); line-height: toRpx(44);
width: 100%; width: 100%;
flex-shrink: 0; flex-shrink: 0;
border-bottom: toRpx(2) solid #888; border-bottom: toRpx(2) solid #eee;
}
.hide-border {
border-bottom: none;
} }
} }
} }
...@@ -290,24 +308,34 @@ export default { ...@@ -290,24 +308,34 @@ export default {
flex-shrink: 0; flex-shrink: 0;
} }
.subtitle-one { .subtitle-one {
margin: toRpx(10) 0; margin: toRpx(30) 0;
} }
.subtitle-two { .subtitle-two {
color: #000; color: #000;
font-size: toRpx(36); font-size: toRpx(32);
font-weight: 500; font-weight: 500;
} }
.last {
border-bottom: toRpx(2) solid #dce0e6;
padding-bottom: toRpx(40);
}
.hide {
visibility: hidden;
height: 0;
padding-bottom: 0;
}
.sub-item { .sub-item {
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
color: #333333; color: #333333;
font-size: toRpx(32); font-size: toRpx(28);
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: toRpx(32); gap: toRpx(32);
margin-top: toRpx(20); line-height: toRpx(60);
align-items: stretch; align-items: stretch;
box-sizing: border-box;
} }
.item { .item {
width: calc((100% - #{toRpx(96)}) / 4); width: calc((100% - #{toRpx(96)}) / 4);
...@@ -318,8 +346,9 @@ export default { ...@@ -318,8 +346,9 @@ export default {
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
color: #333333; color: #333333;
font-size: toRpx(32); font-size: toRpx(28);
padding: toRpx(10); padding: toRpx(10);
line-height: toRpx(40);
.sprite-icon { .sprite-icon {
display: none; display: none;
position: absolute; position: absolute;
......
...@@ -518,13 +518,13 @@ export default { ...@@ -518,13 +518,13 @@ export default {
let [nullCheck, validatorCheck] = equityFormRule[key] let [nullCheck, validatorCheck] = equityFormRule[key]
if (nullCheck.required) { if (nullCheck.required) {
if (!params[key]) throw equityFormRule[key][0].message if (!params[key]) throw equityFormRule[key][0].message
} else { else {
if (validatorCheck && validatorCheck.validator) { if (validatorCheck && validatorCheck.validator) {
const res = validatorCheck.validator('', params[key]) const res = validatorCheck.validator('', params[key])
if (res && res.message) throw res.message if (res && res.message) throw res.message
} }
} }
}
}) })
params.goodInfoList?.map(item => { params.goodInfoList?.map(item => {
if (item.printType == 2) { if (item.printType == 2) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!