182 lines
4.2 KiB
JavaScript
Executable File
182 lines
4.2 KiB
JavaScript
Executable File
$(function() {
|
|
Vue.component('v-select', VueSelect.VueSelect);
|
|
var vm = new Vue({
|
|
el: '#app',
|
|
data: {
|
|
name: '',
|
|
phone: '',
|
|
email: '',
|
|
content: '',
|
|
emailinput: '',
|
|
dataList: [],
|
|
model: [],
|
|
brandlist: [],
|
|
energy: [],
|
|
mileage: [],
|
|
pricemin: [],
|
|
pricemax: [],
|
|
mileagemin: [],
|
|
mileagemax: [],
|
|
score_status: [],
|
|
vehicletypes: [],
|
|
select: {
|
|
brand: '',
|
|
model: '',
|
|
energy: '',
|
|
store_status: '',
|
|
min_price: '',
|
|
max_price: '',
|
|
min_mileage: '',
|
|
max_mileage:'',
|
|
price:'',
|
|
mileage:'',
|
|
},
|
|
},
|
|
created: function() {
|
|
this.getbrand()
|
|
this.hotList()
|
|
this.vehicletypesfn()
|
|
},
|
|
methods: {
|
|
// 热门
|
|
hotList() {
|
|
var that = this
|
|
AjaxUtils.get('apis/vehicle/list', {
|
|
page: 1,
|
|
per_page: 4,
|
|
is_hot: 1
|
|
}).done(function(data) {
|
|
that.dataList = data.data.list
|
|
}).fail(function(error) {
|
|
// console.error(error);
|
|
});
|
|
},
|
|
//车辆类型快捷搜索
|
|
vehicletypesfn() {
|
|
var that = this
|
|
AjaxUtils.get('apis/vehicle/types', {}).done(function(data) {
|
|
that.vehicletypes = data.data
|
|
}).fail(function(error) {
|
|
// console.error(error);
|
|
});
|
|
},
|
|
vehicletypesgo(item) {
|
|
window.location.href = 'rental-sidebar.html?type=' + item.id
|
|
},
|
|
godetil(item) {
|
|
window.location.href = 'vehicle-details.html?id=' + item.id
|
|
},
|
|
getbrand(brand_id) {
|
|
var that = this
|
|
AjaxUtils.get('apis/search/options', {}).done(function(data) {
|
|
var datas = data.data
|
|
that.brandlist = datas.brand
|
|
that.energy = datas.energy
|
|
that.mileage = datas.price
|
|
that.pricemin = datas.mileage
|
|
that.mileagemin = datas.mileage
|
|
that.score_status = datas.score_status
|
|
that.type = datas.type
|
|
}).fail(function(error) {
|
|
// console.error(error);
|
|
});
|
|
},
|
|
//获取品牌类型
|
|
getmodels(brand_id) {
|
|
var that = this
|
|
AjaxUtils.get('apis/get/models', {
|
|
brand_id: brand_id
|
|
}).done(function(data) {
|
|
that.model = data.data
|
|
}).fail(function(error) {
|
|
// console.error(error);
|
|
});
|
|
// fetch(baseURL+'apis/get/models?brand_id='+brand_id,options)
|
|
// .then(response => {
|
|
// if (!response.ok) {
|
|
// throw new Error('Network response was not ok');
|
|
// }
|
|
// return response.json();
|
|
// })
|
|
// .then(data => {
|
|
// that.model = data.data
|
|
// // console.log(that.model)
|
|
// })
|
|
// .catch(error => {
|
|
// this.error = error.message;
|
|
// this.loading = false;
|
|
// });
|
|
},
|
|
//品牌选择
|
|
onSelectbrand(item) {
|
|
this.select.brand = item
|
|
this.getmodels(item)
|
|
},
|
|
//类型
|
|
onSelectmodel(item) {
|
|
this.select.model = item
|
|
},
|
|
onSelectengineType(item) {
|
|
this.select.energy = item
|
|
},
|
|
onSelectinventoryStatus(item) {
|
|
this.select.store_status = item
|
|
},
|
|
onSelectpriceFromLow(item) {
|
|
var min=''
|
|
var max=''
|
|
if (item == null) {
|
|
item = ''
|
|
}else{
|
|
min = item.split(/\s*-\s*/).map(Number)[0];
|
|
max = item.split(/\s*-\s*/).map(Number)[1];
|
|
}
|
|
this.select.min_price = min
|
|
this.select.max_price = max
|
|
this.select.price = item
|
|
},
|
|
onSelectmileageRange(item) {
|
|
var min=''
|
|
var max=''
|
|
if (item == null) {
|
|
item = ''
|
|
}else{
|
|
min = item.split(/\s*-\s*/).map(Number)[0];
|
|
max = item.split(/\s*-\s*/).map(Number)[1];
|
|
}
|
|
this.select.min_mileage = min
|
|
this.select.max_mileage = max
|
|
this.select.mileage = item
|
|
},
|
|
serchfn() {
|
|
const params = new URLSearchParams();
|
|
Object.entries(this.select).forEach(([key, value]) => {
|
|
if (value !== null && value !== undefined && value !== '') {
|
|
params.append(key, value);
|
|
}
|
|
});
|
|
// console.log(params.toString())
|
|
// 跳转到rental-sidebar页面并传递参数
|
|
window.location.href = `rental-sidebar.html?${params.toString()}`;
|
|
},
|
|
bookfn() {
|
|
if (this.name == '') {
|
|
|
|
}
|
|
AjaxUtils.post('apis/contact/add', {
|
|
name: this.name,
|
|
phone: this.phone,
|
|
email: this.email,
|
|
content: this.content,
|
|
vehicle_id: 0
|
|
}).done(function(result) {
|
|
alert(result.data.message)
|
|
// console.log(result);
|
|
}).fail(function(error) {
|
|
// console.error(error);
|
|
});
|
|
|
|
}
|
|
},
|
|
})
|
|
}); |