552 lines
15 KiB
Vue
552 lines
15 KiB
Vue
<template>
|
|
<view>
|
|
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" :title="$t('navbar.carinfo')"></uni-nav-bar>
|
|
<view class="content">
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.productName')}} <text class="red">*</text></view>
|
|
<view class="right">
|
|
<input :placeholder="$t('carinfo.inputproduct')" v-model="carinfo.name" />
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.product_image')}}</view>
|
|
<view class="right">
|
|
<uni-file-picker fileMediatype="image" limit="1" @select="select" @delete="delfn" :del-icon="false" disable-preview :imageStyles="imageStyles">
|
|
<image :src="carinfo.cover_full==''?'/static/image/img.png':carinfo.cover_full" mode="" class="addimg"></image>
|
|
</uni-file-picker>
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.vin')}}</view>
|
|
<view class="right">
|
|
<input :placeholder="$t('carinfo.inputVIN')" v-model="carinfo.vin" />
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.brand')}}</view>
|
|
<view class="right select" @click="showbrand=true">
|
|
<input :placeholder="$t('carinfo.selectbrand')" disabled v-model="brandname" />
|
|
<uni-icons type="right" size="18" color="#747474"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.model')}}</view>
|
|
<view class="right select" @click="showmodel = true">
|
|
<input :placeholder="$t('carinfo.selectmodel')" disabled v-model="model" />
|
|
<u-picker :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" :show="showmodel" @cancel="cancel('showmodel')" :defaultIndex="defaultIndexm" :columns="modelList" keyName="name" @confirm="modelChange"></u-picker>
|
|
<uni-icons type="right" size="18" color="#747474"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.price')}}</view>
|
|
<view class="right">
|
|
<input :placeholder="$t('carinfo.inputprice')" type="digit" v-model="carinfo.price" />
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.type')}}</view>
|
|
<view class="right select" @click="showtype=true">
|
|
<input :placeholder="$t('carinfo.selecttype')" disabled v-model="type" />
|
|
<u-picker :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" :show="showtype" @cancel="cancel('showtype')" :defaultIndex="defaultIndex2" :columns="typesList" keyName="name" @confirm="typesChange"></u-picker>
|
|
<!-- <ld-select :list="typesList" label-key="name" value-key="id" placeholder="选择车辆类型" v-model="carinfo.type" @change="typesChange"></ld-select> -->
|
|
<uni-icons type="right" size="18" color="#747474"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.energy')}}</view>
|
|
<view class="right select" @click="showenergy=true">
|
|
<input :placeholder="$t('carinfo.selectenergy')" disabled v-model="energy" />
|
|
<u-picker :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" :show="showenergy" @cancel="cancel('showenergy')" :defaultIndex="defaultIndex3" :columns="energyList" keyName="name" @confirm="energyChange"></u-picker>
|
|
<!-- <ld-select :list="energyList" label-key="name" value-key="id" placeholder="选择能源类型" v-model="carinfo.energy" @change="energyChange"></ld-select> -->
|
|
<uni-icons type="right" size="18" color="#747474"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.store_status')}}</view>
|
|
<view class="right select" @click="showstatus = true">
|
|
<input :placeholder="$t('carinfo.select')" disabled v-model="store_status" />
|
|
<u-picker :defaultIndex="defaultIndexs" :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" :show="showstatus" @cancel="cancel('showstatus')" :columns="statusList" keyName="name" @confirm="statusChange"></u-picker>
|
|
<uni-icons type="right" size="18" color="#747474"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.location')}}</view>
|
|
<view class="right select" @click="showlocation = true">
|
|
<input :placeholder="$t('carinfo.select')" disabled v-model="location" />
|
|
<u-picker :defaultIndex="defaultIndexl" :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" :show="showlocation" @cancel="cancel('showlocation')" :columns="locationList" keyName="name" @confirm="locationChange"></u-picker>
|
|
<uni-icons type="right" size="18" color="#747474"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="cell">
|
|
<view>{{$t('carinfo.mileage')}}</view>
|
|
<view class="right">
|
|
<input :placeholder="$t('carinfo.inputmileage')" type="digit" v-model="carinfo.mileage"/>
|
|
</view>
|
|
</view>
|
|
<view class="cell1">
|
|
<view>{{$t('carinfo.age')}}</view>
|
|
<view class="right">
|
|
<input :placeholder="$t('carinfo.inputage')" type="digit" v-model="carinfo.vehicle_age" />
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="zw"></view>
|
|
<view class="foot">
|
|
<button class="btn" @click="nextFn">{{$t('button.next')}}</button>
|
|
</view>
|
|
<u-popup closeOnClickOverlay :show="showbrand" mode="bottom" :round="10" @close="cancel('showbrand')">
|
|
<view class="text">
|
|
<view class="qx" @click="cancel('showbrand') ">{{$t('cancel')}}</view>
|
|
<view class="qd" @click="brandChange">{{$t('confirm')}}</view>
|
|
</view>
|
|
<view class="popup-content">
|
|
<!-- 搜索框 -->
|
|
<u-input
|
|
v-model="searchKeyword"
|
|
:placeholder="$t('keyword')"
|
|
@input="handleSearch"
|
|
></u-input>
|
|
|
|
<!-- 选项列表 -->
|
|
<scroll-view scroll-y class="option-list">
|
|
<view
|
|
v-for="(item, index) in filteredOptions"
|
|
:key="index"
|
|
class="option-item"
|
|
@click="handleSelect(item)"
|
|
:class="actives==item.id?'actives':''"
|
|
>
|
|
{{ item.name }}
|
|
</view>
|
|
<view v-if="filteredOptions.length === 0" class="no-data">
|
|
{{$t('noresults')}}
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</u-popup>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { request,showToast } from '@/api/apiT.js'
|
|
// import ldSelect from '@/components/ld-select/ld-select.vue'
|
|
export default {
|
|
data() {
|
|
return {
|
|
id:'',
|
|
imageStyles: {
|
|
width: 50,
|
|
height: 50,
|
|
},
|
|
i18locale:uni.getStorageSync('i18locale')?uni.getStorageSync('i18locale'):'zh',
|
|
actives:'',
|
|
searchKeyword: "", // 搜索关键词
|
|
selectedLabel: "", // 选中的值(显示在输入框中)
|
|
filteredOptions: [], // 过滤后的数据
|
|
brandList:[],
|
|
energyList:[],
|
|
typesList:[],
|
|
brandList1:[],
|
|
energyList1:[],
|
|
typesList1:[],
|
|
modelList:[],
|
|
locationList:[],
|
|
modelList1:[],
|
|
locationList1:[],
|
|
showbrand: false,
|
|
showtype: false,
|
|
showenergy: false,
|
|
showmodel: false,
|
|
showlocation: false,
|
|
showstatus: false,
|
|
defaultIndex1:[0],
|
|
defaultIndex2:[0],
|
|
defaultIndex3:[0],
|
|
defaultIndexm:[0],
|
|
defaultIndexl:[0],
|
|
defaultIndexs:[0],
|
|
brandname:'',
|
|
type:'',
|
|
energy:'',
|
|
statusList:[[{
|
|
name: this.$t('carinfo.in_stock'),
|
|
id: '1'
|
|
}, {
|
|
name: this.$t('carinfo.in_transit'),
|
|
id: '2'
|
|
},{
|
|
name: this.$t('carinfo.on_order'),
|
|
id: '3'
|
|
}]],
|
|
model:'',
|
|
location:'',
|
|
store_status:'',
|
|
carinfo:{
|
|
cover:'',
|
|
model:'',
|
|
location:'',
|
|
store_status:'',
|
|
name:'',
|
|
vin:'',
|
|
brand:'',
|
|
price:'',
|
|
type:'',
|
|
energy:'',
|
|
mileage :'',
|
|
vehicle_age:'',
|
|
condition_desc:'',
|
|
front_45_degree:'',
|
|
front_left_45_degree:'',
|
|
front_left_headlight:'',
|
|
front_view:'',
|
|
lower_front:'',
|
|
wheel_hub:'',
|
|
front_right_seat:'',
|
|
right_lower_side:'',
|
|
rear_right_taillight:'',
|
|
rear_right_45_degree:'',
|
|
lower_rear:'',
|
|
trunk:'',
|
|
left_lower_side:'',
|
|
rear_seats:'',
|
|
center_console:'',
|
|
control_panel:'',
|
|
gear_shift:'',
|
|
car_key:'',
|
|
steering_wheel:'',
|
|
dashboard:'',
|
|
odometer_reading:'',
|
|
front_left_door_panel:'',
|
|
front_left_door_function_area:'',
|
|
front_left_seat:'',
|
|
interior_ceiling:'',
|
|
}
|
|
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
console.log(options);
|
|
this.getbrand()
|
|
this.getenergy()
|
|
this.gettypes()
|
|
this.getlocation()
|
|
this.id = options.id;
|
|
this.getcontList()
|
|
var that = this
|
|
|
|
},
|
|
methods: {
|
|
getbrand(){
|
|
request({
|
|
url:'brand',
|
|
method:'get',
|
|
data:{
|
|
language:this.i18locale
|
|
}
|
|
}).then(res => {
|
|
var list = res.data.data
|
|
this.brandList1= list;
|
|
this.filteredOptions = list;
|
|
this.brandList = [list]
|
|
})
|
|
},
|
|
getmodel(brand_id,items){
|
|
var that =this
|
|
that.model = ''
|
|
that.defaultIndexm=['']
|
|
request({
|
|
url:'models',
|
|
method:'get',
|
|
data:{
|
|
brand_id:brand_id
|
|
}
|
|
}).then(res => {
|
|
var list = res.data.data
|
|
this.modelList1 = list
|
|
this.modelList = [list]
|
|
if(items){
|
|
that.modelList1.forEach((item,index) => {
|
|
if(item.id == items){
|
|
that.model = item.name
|
|
that.defaultIndexm=[index]
|
|
}
|
|
})
|
|
}else{
|
|
if(list.length>0){
|
|
that.model = list[0].name
|
|
that.carinfo.model = list[0].id
|
|
}else{
|
|
that.model =''
|
|
that.carinfo.model =''
|
|
}
|
|
}
|
|
|
|
|
|
})
|
|
},
|
|
getenergy(){
|
|
request({
|
|
url:'energy',
|
|
method:'get',
|
|
data:{
|
|
language:this.i18locale
|
|
}
|
|
}).then(res => {
|
|
var list = res.data.data
|
|
this.energyList1= res.data.data
|
|
this.energyList = [list]
|
|
})
|
|
},
|
|
gettypes(){
|
|
request({
|
|
url:'types',
|
|
method:'get',
|
|
data:{
|
|
language:this.i18locale
|
|
}
|
|
}).then(res => {
|
|
var list = res.data.data
|
|
this.typesList1= res.data.data
|
|
this.typesList = [list]
|
|
})
|
|
},
|
|
getlocation(){
|
|
request({
|
|
url:'location/presets',
|
|
method:'get'
|
|
}).then(res => {
|
|
var list = res.data.data
|
|
this.locationList1 = list
|
|
this.locationList = [list]
|
|
})
|
|
},
|
|
// 搜索处理函数
|
|
handleSearch() {
|
|
if (this.searchKeyword) {
|
|
console.log(this.searchKeyword)
|
|
this.filteredOptions = this.brandList1.filter((item) =>
|
|
item.name.includes(this.searchKeyword)
|
|
);
|
|
console.log(this.filteredOptions)
|
|
} else {
|
|
// 如果搜索框为空,显示全部数据
|
|
this.filteredOptions = this.brandList1;
|
|
}
|
|
},
|
|
// 选择选项
|
|
handleSelect(item) {
|
|
this.selectedLabel = item.name; // 回显选中的值
|
|
// this.searchKeyword = item.name
|
|
this.actives = item.id
|
|
// this.showPicker = false; // 关闭弹窗
|
|
console.log("选中的值:", item.id);
|
|
console.log("选中的值:", item.name);
|
|
},
|
|
brandChange(){
|
|
this.carinfo.brand = this.actives
|
|
this.brandname = this.selectedLabel
|
|
this.showbrand = false
|
|
this.getmodel(this.actives)
|
|
},
|
|
energyChange(val){
|
|
this.carinfo.energy = val.value[0].id
|
|
this.energy = val.value[0].name
|
|
this.showenergy = false
|
|
},
|
|
typesChange(val){
|
|
this.carinfo.type = val.value[0].id
|
|
this.type = val.value[0].name
|
|
this.showtype = false
|
|
},
|
|
modelChange(val){
|
|
this.carinfo.model = val.value[0].id
|
|
this.model = val.value[0].name
|
|
this.showmodel = false
|
|
},
|
|
statusChange(val){
|
|
this.carinfo.store_status = val.value[0].id
|
|
this.store_status = val.value[0].name
|
|
this.showstatus = false
|
|
},
|
|
locationChange(val){
|
|
this.carinfo.location = val.value[0].id
|
|
this.location = val.value[0].name
|
|
this.showlocation = false
|
|
},
|
|
leftClick(){
|
|
uni.navigateBack({})
|
|
},
|
|
cancel(val){
|
|
this[val] = false
|
|
},
|
|
getcontList(){
|
|
var that = this;
|
|
request({
|
|
url:'draft/detail/'+this.id,
|
|
method:'get',
|
|
}).then(res => {
|
|
that.carinfo = res.data.data
|
|
this.actives = res.data.data.brand
|
|
this.getmodel(that.carinfo.brand,that.carinfo.model)
|
|
that.brandname = that.carinfo.brand_name
|
|
that.energy = that.carinfo.energy_name
|
|
that.type = that.carinfo.type_name
|
|
that.location = that.carinfo.location_name
|
|
var statusList = that.statusList[0]
|
|
statusList.forEach((item,index) => {
|
|
if(item.id == that.carinfo.store_status){
|
|
that.store_status = item.name
|
|
that.defaultIndexs=[index]
|
|
}
|
|
})
|
|
that.brandList1.forEach((item,index) => {
|
|
if(item.id == that.carinfo.brand){
|
|
that.defaultIndex1=[index]
|
|
}
|
|
})
|
|
that.energyList1.forEach((item,index) => {
|
|
if(item.energy_id == that.carinfo.energy){
|
|
that.defaultIndex3=[index]
|
|
}
|
|
})
|
|
that.typesList1.forEach((item,index) => {
|
|
if(item.energy_id == that.carinfo.type){
|
|
that.defaultIndex2=[index]
|
|
}
|
|
})
|
|
|
|
that.locationList1.forEach((item,index) => {
|
|
if(item.id == that.carinfo.location){
|
|
that.defaultIndexl=[index]
|
|
}
|
|
})
|
|
})
|
|
},
|
|
nextFn(){
|
|
const carinfo = JSON.stringify(this.carinfo);
|
|
uni.setStorageSync('newcarinfo', carinfo);
|
|
uni.navigateTo({
|
|
url: '/pages/mine/drafts/draftsDetil1?id='+this.id
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
|
|
.zw{
|
|
height: 120px;
|
|
}
|
|
.uniui-right{
|
|
position: absolute;
|
|
top: 2px;
|
|
}
|
|
.content{
|
|
margin: 20px 12px;
|
|
background: #FFFFFF;
|
|
border-radius: 10px;
|
|
}
|
|
.red{
|
|
color: red;
|
|
}
|
|
.cell{
|
|
position: relative;
|
|
display: flex;
|
|
justify-content:space-between;
|
|
padding: 18px 20px;
|
|
/* border-bottom: 1px solid #C3C3C3; */
|
|
align-items: center;
|
|
font-weight: 500;
|
|
}
|
|
.cell::after{
|
|
content : '';
|
|
position : absolute;
|
|
width : 200%;
|
|
height : 200%;
|
|
top : 0;
|
|
left : 0;
|
|
transform-origin: 0 0;
|
|
border-width: 0;
|
|
border-bottom-width:1px;
|
|
border-style : solid;
|
|
transform : scale(0.5, 0.5);
|
|
border-radius : 1px;
|
|
box-sizing : border-box;
|
|
pointer-events : none;
|
|
border-color:#C3C3C3;
|
|
}
|
|
.cell1{
|
|
display: flex;
|
|
justify-content:space-between;
|
|
padding: 18px 20px;
|
|
align-items: center;
|
|
font-weight: 500;
|
|
}
|
|
.right{
|
|
text-align: right;
|
|
}
|
|
.select{
|
|
display: flex;
|
|
position: relative;
|
|
margin-right: 10px;
|
|
}
|
|
.foot{
|
|
position: fixed;
|
|
bottom: 0px;
|
|
width: 100%;
|
|
height: 240rpx;
|
|
background: #FFFFFF;
|
|
z-index: 2;
|
|
}
|
|
.btn{
|
|
background-color: #3F435B;
|
|
color: white;
|
|
border-radius: 50px;
|
|
width: 92%;
|
|
margin-bottom: 40px;
|
|
margin: 15px 4%;
|
|
}
|
|
.actives{
|
|
background-color: #dfdfdf;
|
|
}
|
|
.text{
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
line-height: 30px;
|
|
padding: 10px 15px 0px;
|
|
.qd{
|
|
color: #3471FF;
|
|
}
|
|
}
|
|
.popup-content {
|
|
padding: 20px;
|
|
background-color: #fff;
|
|
}
|
|
|
|
.option-list {
|
|
max-height: 400rpx;
|
|
margin-top: 20rpx;
|
|
}
|
|
|
|
.option-item {
|
|
padding: 20rpx;
|
|
border-bottom: 1rpx solid #eee;
|
|
}
|
|
|
|
.option-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.no-data {
|
|
text-align: center;
|
|
padding: 20rpx;
|
|
color: #999;
|
|
}
|
|
.addimg{
|
|
width: 50px;
|
|
height: 50px;
|
|
}
|
|
</style>
|