Commit 7c969686 by 李伟康

refactor(components): 优化汽车品牌组件代码结构

- 移除多余的换行和空格以改善代码格式
- 统一方法声明语法移除不必要的空格
- 简化条件逻辑将日志记录包裹在条件判断中
- 清理模板中的冗余换行符提升可读性
- 优化样式表增加必要的间距增强视觉效果
- 删除调试用的 console.log 语句

fix(pages): 移除页面调试日志输出

- 删除优惠券弹窗组件中的调试日志
- 清理客户信息处理流程中的临时输出
- 移除员工选择功能的调试信息
1 parent bcd29cc5
<template> <template>
<view> <view>
<MessageBox <MessageBox ref="carBrandListVisible" position="bottom" :isFooter="false" title="请选择车品牌" @close="clickClose">
ref="carBrandListVisible"
position="bottom"
:isFooter="false"
title="请选择车品牌"
@close="clickClose"
>
<view class="select-box"> <view class="select-box">
<view <view class="select-item" :class="{ checked: carBrand == item.name }" @click="selectCar(item)"
class="select-item" v-for="(item, index) in carBrandList" :key="index">
:class="{ checked: carBrand == item.name }"
@click="selectCar(item)"
v-for="(item, index) in carBrandList"
:key="index"
>
{{ item.name }} {{ item.name }}
</view> </view>
</view> </view>
</MessageBox> </MessageBox>
<MessageBox <MessageBox ref="carBoxVisible" position="bottom" :isFooter="false" title="请选择车系" :maxHeight="1000" back
ref="carBoxVisible" @close="closeCarBoxVisible">
position="bottom"
:isFooter="false"
title="请选择车系"
:maxHeight="1000"
back
@close="closeCarBoxVisible"
>
<view class="select-box"> <view class="select-box">
<view <view class="select-item" :class="{ checked: carModel == item.name }" @click="handleSelect(item)"
class="select-item" v-for="(item, index) in carlist" :key="index">
:class="{ checked: carModel == item.name }"
@click="handleSelect(item)"
v-for="(item, index) in carlist"
:key="index"
>
{{ item.name }} {{ item.name }}
</view> </view>
</view> </view>
...@@ -66,7 +43,7 @@ export default { ...@@ -66,7 +43,7 @@ export default {
default: true default: true
} }
}, },
data () { data() {
return { return {
carlist: [], carlist: [],
selectItem: {}, selectItem: {},
...@@ -77,42 +54,42 @@ export default { ...@@ -77,42 +54,42 @@ export default {
watch: { watch: {
watchStatus: { watchStatus: {
immediate: true, immediate: true,
handler (newval) { handler(newval) {
this.close() this.close()
} }
}, },
}, },
computed: { computed: {
watchStatus () { watchStatus() {
return this.$store.state.user.historyStatus return this.$store.state.user.historyStatus
}, },
carModel () { carModel() {
return this.customBoolean ? this.echoData[this.carModelKey] : this.$store.state.user.customerInfo.carModel return this.customBoolean ? this.echoData[this.carModelKey] : this.$store.state.user.customerInfo.carModel
}, },
carBrandList () { carBrandList() {
return this.$store.state.user.carBrands || [] return this.$store.state.user.carBrands || []
}, },
carBrand () { carBrand() {
return this.customBoolean ? this.echoData[this.carBrandKey] : this.$store.state.user.customerInfo.carBrand return this.customBoolean ? this.echoData[this.carBrandKey] : this.$store.state.user.customerInfo.carBrand
}, },
boutiqueDefaultCarBrandId () { boutiqueDefaultCarBrandId() {
return this.$store.state.user.boutiqueDefaultCarBrandId return this.$store.state.user.boutiqueDefaultCarBrandId
}, },
defaultCarId () { defaultCarId() {
return this.$store.state.user.defaultCarId || '' return this.$store.state.user.defaultCarId || ''
} }
}, },
mounted () { mounted() {
}, },
methods: { methods: {
autoSelect () { autoSelect() {
const { carBrandList, boutiqueDefaultCarBrandId, defaultCarId } = this const { carBrandList, boutiqueDefaultCarBrandId, defaultCarId } = this
let carIndex = 0 let carIndex = 0
if (boutiqueDefaultCarBrandId) carIndex = carBrandList.findIndex(e => e.id == boutiqueDefaultCarBrandId) if (boutiqueDefaultCarBrandId) carIndex = carBrandList.findIndex(e => e.id == boutiqueDefaultCarBrandId)
if (carIndex < 0) carIndex = 0 if (carIndex < 0) carIndex = 0
if (carBrandList.length) this.selectCar(carBrandList[carIndex], true, defaultCarId) if (carBrandList.length) this.selectCar(carBrandList[carIndex], true, defaultCarId)
}, },
open () { open() {
this.$store.dispatch('setCarBrandOpenStatus', true) this.$store.dispatch('setCarBrandOpenStatus', true)
const userInfo = uni.$storage.get("userInfo"), const userInfo = uni.$storage.get("userInfo"),
{ shopMerchantId } = userInfo; { shopMerchantId } = userInfo;
...@@ -146,7 +123,7 @@ export default { ...@@ -146,7 +123,7 @@ export default {
this.$refs.carBrandListVisible.open() this.$refs.carBrandListVisible.open()
this.carBrandListOff = true this.carBrandListOff = true
}, },
selectCar (e, auto = false, carId) { selectCar(e, auto = false, carId) {
if (!e.brandId || !e.id) return uni.showToast({ if (!e.brandId || !e.id) return uni.showToast({
title: "车型ID或品牌ID为空", title: "车型ID或品牌ID为空",
icon: "none", icon: "none",
...@@ -198,7 +175,7 @@ export default { ...@@ -198,7 +175,7 @@ export default {
}) })
}, },
handleSelect (item) { handleSelect(item) {
const customerInfo = this.$store.state.user.customerInfo, const customerInfo = this.$store.state.user.customerInfo,
{ selectItem, linkage } = this { selectItem, linkage } = this
Object.assign(customerInfo, { Object.assign(customerInfo, {
...@@ -207,14 +184,14 @@ export default { ...@@ -207,14 +184,14 @@ export default {
oneCarBrand: selectItem.carBrand, oneCarBrand: selectItem.carBrand,
oneCarBrandId: selectItem.carBrandId oneCarBrandId: selectItem.carBrandId
}) })
uni.$logger.local.info(`选择车: if (linkage) {
uni.$logger.local.info(`选择车:
carModel:${item.name}, carModel:${item.name},
carModelId: ${item.id}, carModelId: ${item.id},
carBrand:${customerInfo.carBrand}, carBrand:${customerInfo.carBrand},
carBrandId:${customerInfo.carBrandId}, carBrandId:${customerInfo.carBrandId},
oneCarBrand:${customerInfo.oneCarBrand}, oneCarBrand:${customerInfo.oneCarBrand},
oneCarBrandId:${customerInfo.oneCarBrandId}`) oneCarBrandId:${customerInfo.oneCarBrandId}`)
if (linkage) {
this.$store.dispatch('setCustomerInfo', customerInfo) this.$store.dispatch('setCustomerInfo', customerInfo)
this.$store.dispatch('updateViewKey') this.$store.dispatch('updateViewKey')
this.$store.dispatch('setCurrentCarInfo', selectItem) this.$store.dispatch('setCurrentCarInfo', selectItem)
...@@ -226,18 +203,18 @@ export default { ...@@ -226,18 +203,18 @@ export default {
...selectItem ...selectItem
}) })
}, },
close () { close() {
this.$refs?.carBoxVisible?.close(); this.$refs?.carBoxVisible?.close();
this.$refs?.carBrandListVisible?.close() this.$refs?.carBrandListVisible?.close()
this.carBrandListOff = false this.carBrandListOff = false
this.$store.dispatch('setCarBrandOpenStatus', false) this.$store.dispatch('setCarBrandOpenStatus', false)
}, },
closeCarBoxVisible () { closeCarBoxVisible() {
if (this.carBrandListOff) return if (this.carBrandListOff) return
else this.$emit('close') else this.$emit('close')
}, },
clickClose () { clickClose() {
this.$store.dispatch('setCarBrandOpenStatus', false) this.$store.dispatch('setCarBrandOpenStatus', false)
this.$emit('close') this.$emit('close')
}, },
...@@ -254,6 +231,7 @@ export default { ...@@ -254,6 +231,7 @@ export default {
overflow-y: scroll; overflow-y: scroll;
max-height: 50vh; max-height: 50vh;
padding-bottom: toRpx(60); padding-bottom: toRpx(60);
.select-item { .select-item {
text-align: center; text-align: center;
height: toRpx(68); height: toRpx(68);
...@@ -263,6 +241,7 @@ export default { ...@@ -263,6 +241,7 @@ export default {
color: #333; color: #333;
font-size: toRpx(32); font-size: toRpx(32);
border-radius: toRpx(8); border-radius: toRpx(8);
&.checked { &.checked {
border: toRpx(2) solid #292d33; border: toRpx(2) solid #292d33;
} }
......
...@@ -313,7 +313,6 @@ export default { ...@@ -313,7 +313,6 @@ export default {
}, },
carInfo: { carInfo: {
handler (newval) { handler (newval) {
console.log(newval, '===')
this.pageParams.carInfo = { this.pageParams.carInfo = {
carChildsBrandId: newval.carChildsBrandId, carChildsBrandId: newval.carChildsBrandId,
carChildsBrandName: newval.carChildsBrandName, carChildsBrandName: newval.carChildsBrandName,
...@@ -446,7 +445,6 @@ export default { ...@@ -446,7 +445,6 @@ export default {
this.pageParams.customerQr = data this.pageParams.customerQr = data
if (customerInfo.inviteRecordId) this.customerInfo = customerInfo if (customerInfo.inviteRecordId) this.customerInfo = customerInfo
console.log(customerInfo)
} else throw '生成小程序码失败,请重试!' } else throw '生成小程序码失败,请重试!'
} else throw message } else throw message
...@@ -471,7 +469,6 @@ export default { ...@@ -471,7 +469,6 @@ export default {
this.$refs.couponPopup?.close() this.$refs.couponPopup?.close()
}, },
handleSelect (item, popkey) { handleSelect (item, popkey) {
console.log(item, popkey)
this.$refs[popkey].close(); this.$refs[popkey].close();
if (popkey == "employeeBoxVisible") { if (popkey == "employeeBoxVisible") {
this.customerInfo.salesUuid = item.uuid; this.customerInfo.salesUuid = item.uuid;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!