//index.js
//获取应用实例
const app = getApp()
Page({
data: {
nav_list: [false, false, false, false],
leftMin: 0, //左边滑块最小值
leftMax: 25, //左边滑块最大值
rightMin: 25, //右边滑块的最小值
rightMax: 50, //右边滑块最大值
leftValue: 0, //左边滑块默认值
rightValue: 25, //右边滑块默认值
leftWidth: '50', //左边滑块可滑动长度:百分比
rightWidth: '50', //右边滑块可滑动长度:百分比
nav_data: [
[{
title: "推荐排序",
selected: false
}, {
title: "价格最低",
selected: false
}, {
title: "价格最高",
selected: false
}, {
title: "时间最新",
selected: false
}, {
title: "车龄最短",
slected: false
}, {
title: "里程最少",
selected: false
}],
[{
title: "不限",
selected: false
}, {
title: "3万内",
selected: false
}, {
title: "3-5万",
selected: false
}, {
title: "5-8万",
selected: false
}, {
title: "8-10万",
selected: false
}, {
title: "10-15万",
selected: false
}],
[{name: "车龄",list:[{title: "不限",selected: false},
{title: "1年内",selected: false},
{title: "2年内",selected: false},
{title: "3年内",selected: false},
{title: "3-5年内",selected: false},
{title: "5-8年内",selected: false},
{ title: "8年以上", selected: false }]},
{
name: "里程", list: [{ title: "1万公里以内", selected: false },
{ title: "3万公里以内", selected: false },
{ title: "3-5万", selected: false },
{ title: "5-8万", selected: false },
{ title: "8-10万", selected: false },
{ title: "10-15万", selected: false }]
},
{
name: "级别", list: [{ title: "微型车", selected: false,img:"../../images/图像/首页筛选_03.jpg" },
{ title: "小型车", selected: false, img: "../../images/图像/首页筛选_07.jpg" },
{ title: "紧凑型", selected: false, img: "../../images/图像/首页筛选_09.jpg" },
{ title: "中型车", selected: false, img: "../../images/图像/首页筛选_10.jpg" },
{ title: "大中型车", selected: false, img: "../../images/图像/首页筛选_13.jpg" },
{ title: "豪华车", selected: false, img: "../../images/图像/首页筛选_14.jpg" },
{ title: "MPV", selected: false, img: "../../images/图像/首页筛选_15.jpg" },
{ title: "SUV", selected: false, img: "../../images/图像/首页筛选_16.jpg" },
{ title: "跑车", selected: false, img: "../../images/图像/首页筛选_19.jpg" },
{ title: "面包车", selected: false, img: "../../images/图像/首页筛选_22.jpg" },
{ title: "皮卡车", selected: false, img: "../../images/图像/首页筛选_27.jpg" }]
}, {
name: "颜色", list: [{ title: "黑色", selected: false, img: "../../images/首页筛选-04.png" },
{ title: "银灰色", selected: false, img: "../../images/首页筛选-05.png" },
{ title: "白色", selected: false, img: "../../images/首页筛选-06.png" },
{ title: "红色", selected: false, img: "../../images/首页筛选-07.png" },
{ title: "蓝色", selected: false, img: "../../images/首页筛选-08.png" },
{ title: "深灰色", selected: false, img: "../../images/首页筛选-09.png" },
{ title: "香槟色", selected: false, img: "../../images/首页筛选-10.png" },
{ title: "绿色", selected: false, img: "../../images/首页筛选-11.png" },
{ title: "黄色", selected: false, img: "../../images/首页筛选-12.png" },
{ title: "橙色", selected: false, img: "../../images/首页筛选-13.png" },
{ title: "咖啡色", selected: false, img: "../../images/首页筛选-14.png" },
{ title: "紫色", selected: false, img: "../../images/首页筛选-15.png" },
{ title: "多彩色", selected: false, img: "../../images/首页筛选-19.png" }]
},
]
],
select_arr:[],//排序
select_arr2: [],//车价
select_arr3: [],//筛选
product_data:[]//商品数据
},
onLoad() {
console.log(this.data.nav_data)
},
/**改变导航 */
changNav(res) {
var index = res.currentTarget.dataset.id;
var nav = this.data.nav_list;
for (var i in nav) {
nav[i] = false
}
nav[index] = true;
this.setData({
nav_list: nav
})
},
// 左边滑块滑动的值
leftChange: function(e) {
var old_data = this.data.nav_data;
for (var i in old_data.price_filter) {
old_data.price_filter[i].selected = false;
}
var that = this;
that.setData({
leftValue: e.detail.value, //设置左边当前值
nav_data: old_data
})
},
// 右边滑块滑动的值
rightChange: function(e) {
var old_data = this.data.nav_data;
for (var i in old_data.price_filter) {
old_data.price_filter[i].selected = false;
}
var that = this;
that.setData({
rightValue: e.detail.value,
nav_data: old_data
})
},
/***车价确定 */
pirceConfirm(){
var old_data = this.data.nav_data;
var is_pirce=true;
var select_item=''
for (var i in old_data.price_filter) {
if (old_data.price_filter[i].selected){
is_pirce=false;
select_item = old_data.price_filter[i];
}
}
var select_arr = [];
if (is_pirce){
// console.log("选择区间", this.data.leftValue, "到", this.data.rightValue);
var obj={};
obj.price = this.data.leftValue + "-" + this.data.rightValue
select_arr.push(obj)
}else{
select_arr.push(select_item)
}
var nav = this.data.nav_list;
for (var i in nav) {
nav[i] = false
}
this.setData({
select_arr2: select_arr,
nav_list: nav
})
this.getData(select_arr);
},
/***排序选择 */
select_sort(res) {
var index = res.currentTarget.dataset.index;
var old_data = this.data.nav_data;
for (var i in old_data.sort_filter) {
old_data.sort_filter[i].selected = false;
}
old_data.sort_filter[index].selected = true;
// console.log(old_data.sort_filter[index])
var select_arr=[];
select_arr.push(old_data.sort_filter[index])
var nav = this.data.nav_list;
for (var i in nav) {
nav[i] = false
}
this.setData({
nav_data: old_data,
select_arr: select_arr,
nav_list: nav
})
this.getData(select_arr);
},
/***车价选择 */
selectCircleTap(res) {
var index = res.currentTarget.dataset.index;
var old_data = this.data.nav_data;
for (var i in old_data.price_filter) {
old_data.price_filter[i].selected = false;
}
old_data.price_filter[index].selected = true;
this.setData({
nav_data: old_data
})
},
/**级别选择 */
ageTap(res) {
var index = res.currentTarget.dataset.index;
var old_data = this.data.nav_data;
for (var i in old_data.more.level) {
old_data.more.level[i].selected = false;
}
old_data.more.level[index].selected = true;
this.setData({
nav_data: old_data
})
},
/**月供选择 */
rangeTap(res){
var index = res.currentTarget.dataset.index;
var old_data = this.data.nav_data;
for (var i in old_data.more.money) {
old_data.more.money[i].selected = false;
}
old_data.more.money[index].selected = true;
this.setData({
nav_data: old_data
})
},
/***选择 */
classTap(res){
var index = res.currentTarget.dataset.index;
var old_data = this.data.nav_data;
for (var i in old_data[