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.
215 lines
4.7 KiB
215 lines
4.7 KiB
// pages/pbService/sceneComfort/index.js
|
|
const device = wx.getSystemInfoSync(),radio = device.windowWidth/750;
|
|
import commonApi from "../../../utils/https/common"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
title: 'AI避高峰',
|
|
radio:radio,
|
|
comfortLevel:[],
|
|
comfortIndex:0,
|
|
areas:[],
|
|
areaIndex:0,
|
|
list:[],
|
|
pageNo:1,
|
|
total:1,
|
|
keywords:"",
|
|
areaObj:{},
|
|
comfortObj:{},
|
|
searchText:"",
|
|
sceneLevel:[],
|
|
sceneLevelIndex:-1,
|
|
sceneLevelObj:{}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if (options.title) {
|
|
this.setData({title: options.title})
|
|
}
|
|
commonApi._post("pbservice/Comfort/getSceneLevel").then(res=>{
|
|
console.log(res)
|
|
let sceneLevelObj = {};
|
|
res.data.map(item=>{
|
|
sceneLevelObj[item.level] = item.name;
|
|
})
|
|
res.data.unshift({
|
|
name:"不选择"
|
|
})
|
|
this.setData({
|
|
sceneLevel:res.data,
|
|
sceneLevelObj:sceneLevelObj
|
|
})
|
|
})
|
|
|
|
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/Comfort/getComfortAreaList').then(res=>{
|
|
let areaObj = {}
|
|
res.data.forEach(item=>{
|
|
item.area_code = item.area_code
|
|
item.area_name = item.area
|
|
areaObj[item.area_code] = item.area;
|
|
})
|
|
res.data.unshift({
|
|
area_name:"不选择"
|
|
})
|
|
if(options.area_code){
|
|
let index = res.data.findIndex(item=>item.area_code==options.area_code);
|
|
this.setData({
|
|
areaIndex:index==-1?0:index
|
|
})
|
|
}
|
|
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()
|
|
},
|
|
changeSceneLevel:function(e){
|
|
this.setData({
|
|
sceneLevelIndex: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_name:null,
|
|
page_no:this.data.pageNo,
|
|
page_num:10,
|
|
scene_level:this.data.sceneLevelIndex>0?this.data.sceneLevel[this.data.sceneLevelIndex].level:null
|
|
}).then(res=>{
|
|
let resData = res.data.rows
|
|
// 处理舒适度
|
|
resData.forEach(v=>{
|
|
v.comforLevel = this.data.comfortLevel.find(x=>x.level == v.comfort_level)
|
|
// v.comfort_level_str = comforLevel.desc
|
|
v.hourflowLeve = this.data.comfortLevel.find(x=>x.level == v.hour_flow_level)
|
|
// v.hour_flow_level_str = hourflowLeve.desc
|
|
})
|
|
|
|
this.setData({
|
|
list:this.data.list.concat(res.data.rows),
|
|
total:res.data.total
|
|
})
|
|
console.log(this.data.list.length);
|
|
console.log(res.data.total);
|
|
|
|
if (this.data.list.length<res.data.total) {
|
|
console.log(111);
|
|
this.setData({
|
|
pageNo:this.data.pageNo+1
|
|
|
|
})
|
|
}
|
|
})
|
|
},
|
|
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 () {
|
|
|
|
}
|
|
})
|