wxml 代码:
<view class='sliderView'>
<slider class='left' block-color='orange' bindchange="leftSchange" min='{{leftMin}}' max='{{leftMax}}' value='{{leftValue}}' activeColor='rgb(243,242,247)' backgroundColor='rgb(243,242,247)' block-size='14'/>
<slider class='right' block-color='orange' bindchange="rightSchange" min='{{rightMin}}' max='{{rightMax}}' value='{{rightValue}}' activeColor='rgb(243,242,247)' backgroundColor='rgb(243,242,247)' block-size='14'/>
</view>
wxss 代码:
.sliderView{
position: relative;
width: 93%;
margin: 0 15rpx
}
.left{
position: absolute;
width: 90%
}
.right{
position: absolute;
width: 90%
}
js 代码:
data: {
leftMin: 0,
leftMax: 6,
rightMin: 0,
rightMax: 6,
leftValue: 0,
rightValue: 6
},
//价格slider滑动
leftSchange: function (e) {
var that = this
that.setData({
isQuery: false
})
var value = e.detail.value
if(value==that.data.rightValue){
if(that.data.rightValue==6) value--
else value++
}
that.setData({
leftValue: value
})
if(value<that.data.rightValue){
var bg_price = that.data.priceList[value].slice(1)
var end_price = that.data.priceList[that.data.rightValue].slice(1)
}
else{
var end_price = that.data.priceList[value].slice(1)
var bg_price = that.data.priceList[that.data.rightValue].slice(1)
}
list['bg_price'] = bg_price
list['end_price'] = end_price
wx.setStorageSync("priceList", { bg_price: value, end_price: that.data.leftValue})
setTimeout(function () {
wxb.Post('/api/minsu.index/index', list, function (data) {
console.log(list,"价格slider")
console.log(data)
that.setData({
isQuery: true
})
if (data.length != 0) {
that.setData({
result: data.num + '套',
})
}
else {
that.setData({
result: '0套',
})
}
})
}, 700)
},
//右边
rightSchange: function (e) {
var that = this
that.setData({
isQuery: false
})
var value = e.detail.value
if (value == that.data.leftValue) {
if(that.data.leftValue==6) value--
else value++
}
that.setData({
rightValue: value
})
if (value < that.data.leftValue) {
var bg_price = that.data.priceList[value].slice(1)
var end_price = that.data.priceList[that.data.leftValue].slice(1)
}
else {
var end_price = that.data.priceList[value].slice(1)
var bg_price = that.data.priceList[that.data.leftValue].slice(1)
}
list['bg_price'] = bg_price
list['end_price'] = end_price
wx.setStorageSync("priceList", { bg_price: value, end_price: that.data.leftValue })
setTimeout(function () {
wxb.Post('/api/minsu.index/index', list, function (data) {
console.log(list, "价格slider")
console.log(data)
that.setData({
isQuery: true
})
if (data.length != 0) {
that.setData({
result: data.num + '套',
})
}
else {
that.setData({
result: '0套',
})
}
})
}, 700)
},
转自https://blog.csdn.net/zhanjinfeng/article/details/82422444