Commit 8fe8604c by 李伟康

feat(OrderPopup): 新增车型选择功能

- 添加 CarModelList 组件用于选择车型
- 在 config.js 中配置车型选择选项
- 修改 index.vue 以支持新的车型选择功能
- 优化 DiversionMerchant 和 EmployeeList 组件的代码结构
1 parent 9abe7974
...@@ -20,5 +20,16 @@ module.exports = { ...@@ -20,5 +20,16 @@ module.exports = {
...data ...data
}) })
}, },
/**
* 获取门店品牌车型
*/
getMerchantCarBrandList (data) {
return http.post({
method: 'dj.api.get.car.brandList',
projectName: 'boutique',
needCarSeries: true,
...data
})
},
} }
\ No newline at end of file \ No newline at end of file
<template>
<view class="car-model-box">
<scroll-view
class="scroll-view"
scroll-y
:scroll-into-view="letter"
>
<template v-for="(i, index) in list">
<view
class="item-box"
:key="index"
:id="i.letter"
>
<view class="letter-title flex">{{i.letter}}</view>
<template v-for="(c,cindex) in i.list">
<view
class="car-model"
:key="cindex"
>
<view class="brand-name">{{c.name}}</view>
<template v-for="(j, jindex) in c.childs">
<view
class="brand-list"
:key="jindex"
>
<view class="sub-brand-name">{{j.name}}</view>
<view class="car-model-list">
<template v-for="(k, kindex) in j.childs">
<view
:class="['item flex',{
active: currentId ? k.id == currentId : k.id == data.customer[params.idKey]
}]"
:key="`${k.id}_${kindex}`"
@click="choose(k , c)"
>{{k.name}}</view>
</template>
</view>
</view>
</template>
</view>
</template>
</view>
</template>
</scroll-view>
<view class="letter-list">
<template v-for="(i, index) in list">
<view
class="letter-item"
:key="index"
@click="letter = i.letter"
>
{{i.letter}}
</view>
</template>
</view>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'CarModelList',
inject: ['userInfo'],
data () {
return {
list: [],
currentId: '',
searchList: [],
letter: 'A'
}
},
props: {
params: Object,
data: Object,
apiData: Array
},
mounted () {
},
methods: {
async getList () {
const { userInfo, apiData } = this
this.currentId = ''
if (apiData && apiData.length) {
this.list = apiData
return
}
const { shopMerchantId } = userInfo,
data = await uni.$api.popupApi.getMerchantCarBrandList({
merchantId: shopMerchantId
})
if (data && data.length) this.initCarList(data)
},
initCarList (carData) {
let { params: { idKey }, data: { customer } } = this,
letterList = Array.from(new Set([...carData.map((e) => e.letter)])),
carModelList = letterList.map(e => {
let list = []
carData.map(i => {
if (e === i.letter) {
let c_list = []
i.childs.map(c => {
if (c.childs) {
c.childs.map((s) => {
s.carChildsBrandId = c.id;
s.carChildsBrandName = c.name;
if (customer[idKey]) {
if (s.id == customer[idKey]) {
s.active = true;
this.letter = i.letter;
}
}
});
let carSecondInfo = {
carChildsBrandId: c.id,
carChildsBrandName: c.name,
name: c.name,
isTitle: true,
};
c_list = [...c_list, carSecondInfo, ...c.childs];
}
})
i.childs_list = c_list;
list.push(i)
}
})
return {
letter: e,
list,
}
})
console.log(carModelList)
this.list = carModelList
this.$emit('update:apiData', carModelList)
},
handleSearch (searchValue) {
console.log(searchValue)
},
choose (that, item) {
let chooseItem = {
carBrandId: item.id,
carBrand: item.name,
carChildsBrandId: that.carChildsBrandId,
carChildsBrandName: that.carChildsBrandName,
carSeriesId: that.id,
carSeriesName: that.name,
}
this.currentId = that.id
this.$emit('choose', chooseItem)
}
}
}
</script>
<style scoped lang='scss'>
.car-model-box {
position: relative;
height: 100%;
width: 100%;
.scroll-view {
height: 100%;
}
.letter-list {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 0;
color: #888888;
font-size: 28rpx;
line-height: 40rpx;
padding: 0 18rpx;
text-align: center;
}
.item-box {
margin-bottom: 32rpx;
.letter-title {
color: #888888;
font-size: 28rpx;
height: 40rpx;
background: #f5f7fa;
padding-left: 48rpx;
}
.car-model {
margin: 0 48rpx;
.brand-name {
color: #333333;
font-size: 32rpx;
line-height: 44rpx;
margin-top: 16rpx;
}
.sub-brand-name {
margin: 16rpx 0;
color: #888888;
font-size: 28rpx;
line-height: 40rpx;
}
}
}
.car-model-list {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 32rpx;
.item {
justify-content: center;
height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
props: { props: {
params: Object, params: Object,
data: Object, data: Object,
apiData: Object apiData: Array
}, },
mounted () { mounted () {
}, },
...@@ -35,7 +35,7 @@ export default { ...@@ -35,7 +35,7 @@ export default {
const { userInfo, apiData } = this, const { userInfo, apiData } = this,
{ shopMerchantId } = userInfo { shopMerchantId } = userInfo
this.currentId = '' this.currentId = ''
if (apiData.length) { if (apiData && apiData.length) {
this.list = apiData this.list = apiData
return return
} }
...@@ -60,6 +60,7 @@ export default { ...@@ -60,6 +60,7 @@ export default {
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);
gap: 32rpx; gap: 32rpx;
margin: 0 48rpx;
.item { .item {
justify-content: center; justify-content: center;
height: 72rpx; height: 72rpx;
......
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
props: { props: {
params: Object, params: Object,
data: Object, data: Object,
apiData: Object apiData: Array
}, },
mounted () { mounted () {
}, },
...@@ -34,7 +34,7 @@ export default { ...@@ -34,7 +34,7 @@ export default {
async getList (searchValue) { async getList (searchValue) {
const { userInfo, params, apiData } = this const { userInfo, params, apiData } = this
this.currentId = '' this.currentId = ''
if (apiData.length) { if (apiData && apiData.length) {
this.list = apiData this.list = apiData
return return
} }
...@@ -66,6 +66,7 @@ export default { ...@@ -66,6 +66,7 @@ export default {
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
gap: 32rpx; gap: 32rpx;
margin: 0 48rpx;
.item { .item {
justify-content: center; justify-content: center;
height: 72rpx; height: 72rpx;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* 1:交付专员 * 1:交付专员
* 2:二级流量方 * 2:二级流量方
* 3:转化人员 * 3:转化人员
* 4:车品牌
*/ */
const componentConfig = { const componentConfig = {
...@@ -30,10 +31,17 @@ const componentConfig = { ...@@ -30,10 +31,17 @@ const componentConfig = {
placeholder: '请输入姓名', placeholder: '请输入姓名',
idKey: 'sellerUserId', idKey: 'sellerUserId',
}, },
4: {
name: 'CarModelList',
title: '选择车型',
placeholder: '查找',
idKey: 'carSeriesId'
},
} }
import EmployeeList from './components/EmployeeList.vue' import EmployeeList from './components/EmployeeList.vue'
import DiversionMerchant from './components/DiversionMerchant.vue' import DiversionMerchant from './components/DiversionMerchant.vue'
import CarModelList from './components/CarModelList.vue'
export default { export default {
data(){ data(){
return { return {
...@@ -43,5 +51,6 @@ export default { ...@@ -43,5 +51,6 @@ export default {
components: { components: {
EmployeeList, EmployeeList,
DiversionMerchant, DiversionMerchant,
CarModelList
}, },
} }
\ No newline at end of file \ No newline at end of file
...@@ -88,10 +88,6 @@ export default { ...@@ -88,10 +88,6 @@ export default {
type: [Number, String], type: [Number, String],
default: 0 default: 0
}, },
apiData: {
type: Object,
default: () => ({})
},
data: { data: {
type: Object, type: Object,
default: () => ({}) default: () => ({})
...@@ -106,7 +102,8 @@ export default { ...@@ -106,7 +102,8 @@ export default {
return { return {
position: 'bottom', position: 'bottom',
searchValue: '', searchValue: '',
chooseContent: null chooseContent: null,
apiData: null
} }
}, },
watch: { watch: {
...@@ -129,7 +126,6 @@ export default { ...@@ -129,7 +126,6 @@ export default {
}, },
}, },
mounted () { mounted () {
console.log(this.componentConfig)
}, },
methods: { methods: {
componentRef () { componentRef () {
...@@ -228,7 +224,7 @@ export default { ...@@ -228,7 +224,7 @@ export default {
height: calc(100% - 392rpx); height: calc(100% - 392rpx);
.popup-scroll-view { .popup-scroll-view {
height: 100%; height: 100%;
padding: 32rpx 48rpx 0; padding-top: 32rpx;
} }
} }
.hide-search { .hide-search {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!