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.
 

124 lines
2.4 KiB

// pages/pbService/bus/search/index.js
import commonApi from "../../../../utils/https/common"
Page({
/**
* 页面的初始数据
*/
data: {
keywords:"",
realKeywords:"",
type:null,
info:[],
carIndex:0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
searchInput:function(e){
this.setData({
keywords:e.detail.value
})
},
search:function(){
if(!this.data.keywords){
wx.showToast({
title: '请输入搜索关键字',
icon:'none'
})
return;
}
this.setData({
realKeywords:this.data.keywords,
list:[],
page_no:1,
total:1
})
this.getList();
},
getList:function(){
if(!this.data.realKeywords) return
commonApi._post("pbservice/Publicbus/search",{
keywords:this.data.realKeywords
}).then(res=>{
this.setData({
type:res.data.lines && res.data.lines.response.DataType=='QueryLineInfo'?'QueryLineInfo':'QueryStandNoteGUID',
list:res.data.lines && res.data.lines.response.DataType=='QueryLineInfo'?res.data.lines.response.LineInfo:res.data.stations.response.StandInfo
})
if(this.data.type=='QueryStandNoteGUID'){
this.getInfo()
}
})
},
selectIndex:function(e){
let list = this.data.list,index = e.currentTarget.dataset.index;
if(index==this.data.carIndex) return;
this.setData({
carIndex:index
})
this.getInfo()
},
getInfo:function(){
let list = this.data.list,index = this.data.carIndex
commonApi._post("pbservice/Publicbus/stationRealtimeInfo",{
sguid:list[index].SGuid,
noteguid:list[index].NoteGuid
}).then(res=>{
this.setData({
info:res.data.Status
})
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
// this.getList()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})