You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
3.0 KiB

5 years ago
// pages/pbService/sceneComfort/index.js
const device = wx.getSystemInfoSync(),radio = device.windowWidth/750;
import commonApi from "../../../utils/https/common"
Page({
/**
* 页面的初始数据
*/
data: {
radio:radio,
comfortLevel:[],
comfortIndex:0,
areas:[],
areaIndex:0,
list:[],
pageNo:1,
total:1,
keywords:"",
areaObj:{},
comfortObj:{},
searchText:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
commonApi._post("pbservice/Comfort/getComfortLevel").then(res=>{
let comfortObj = {}
res.data.map(item=>{
comfortObj[item.level] = {
name:item.desc,
color:item.color
};
})
res.data.unshift({
desc:"不选择"
})
this.setData({
comfortLevel:res.data,
comfortObj:comfortObj
})
})
commonApi._post('pbservice/Other/getSuzhouAreas').then(res=>{
let areaObj = {}
res.data.map(item=>{
areaObj[item.area_code] = item.area_name;
})
res.data.unshift({
area_name:"不选择"
})
this.setData({
areas:res.data,
areaObj:areaObj
})
})
this.getList();
},
changeArea:function(e){
this.setData({
areaIndex:e.detail.value,
list:[],
pageNo:1,
total:1
})
this.getList()
},
changeComfortLevel:function(e){
this.setData({
comfortIndex:e.detail.value,
list:[],
pageNo:1,
total:1
})
this.getList()
},
getList:function(){
if(this.data.total<=this.data.list.length) return;
commonApi._post("pbservice/Comfort/getComfort",{
scene_name:this.data.keywords,
comfort_level:this.data.comfortIndex>0?this.data.comfortLevel[this.data.comfortIndex].level:null,
area_key:this.data.areaIndex>0?this.data.areas[this.data.areaIndex].area_code:null,
page_no:this.data.pageNo,
page_num:10
}).then(res=>{
this.setData({
list:this.data.list.concat(res.data.rows),
total:res.data.total
})
})
},
search:function(){
this.setData({
keywords:this.data.searchText,
list:[],
pageNo:1,
total:1
})
this.getList()
},
inputKeyword:function(e){
this.setData({
searchText:e.detail.value
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.getList()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})