search.js 3.68 KB
// pages/reserve/home.js
import App from '../../utils/api';
import util from  '../../utils/util'
import PubSub from '../../utils/PubSub'
const {regeneratorRuntime} = global
Page({

  /**
   * 页面的初始数据
   */
  data: {
    location:'获取中...',
	navborder:false,
    hasFilter:false,//
	taocanpos:{
		top:193,
		left:30,
		right:30
	}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    PubSub.emit('custom-tab-bar')
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return{
      title:'请客订包间,就上周到安排'
    }
  },
  dispalySearchHow(){
    this.selectComponent('#search-how').show();
  },
  howEvent(e){
    console.log('howEvent555555',e.detail)
    //this.eventChannel.emit('findSellerData',e.detail)
    this.findSellerData=e.detail
    this.setData({
      findSellerData:e.detail
    })
    //setTimeout(()=>{this.getList();},0)
    this.selectComponent('#search-how').hide();
  },
  dispalyLocation(){
    this.selectComponent('#location').show();
  },
  meLocation(){
    this.selectComponent('#location').rePos({currentTarget:{dataset:{isAddr:true}}});
  },
  GetRecomList(){
    App.Customer.GetRecomList({
      pid:this.city.pid,
      code:this.city.code,
      lat:this.position.latitude,
      lng:this.position.longitude,
      offset:1,
      size:100
    }).then(res=>{
      this.setData({
        sellers:res.data,
      })
    })
  },
  locationEvent(e){
    console.log('locationEvent',e.detail)
    this.city=e.detail.city
    this.position=e.detail.position
    this.setData({
      location:e.detail.isAddr?e.detail.address:e.detail.city.name,
      IsSetActivityByFoods:true,
      sellers:[],
    })
    // App.Customer.IsSetActivityByFoods({
    //   pid:this.city.pid,
    //   code:this.city.code,
    // }).then(res=>{
    //   this.setData({
    //     IsSetActivityByFoods:res.data,
    //   })
    // })
    this.GetRecomList()
  },
  filterParams:null,
  displayFilter(){
    this.selectComponent('#filter').show(this.filterParams);
    this.setData({
      hasFilter:true,
    })
  },
  filterEvent(e){
    console.log('filterEvent',e.detail)
    if(e.detail.type=='set'){
      this.filterParams=e.detail.data
      this.setData({
        hasFilter:false,
        consumeStr:e.detail.data.consumeStr,
      })
    }else{
      this.filterParams=null;
      this.setData({
        hasFilter:false,
        consumeStr:'',
      })
    }
  },
  goPath(e){
    let path=util.attr(e,'path'),tabidx=util.attr(e,'tabidx');
    wx.navigateTo({
      url:util.http_build_query({
        filter:this.filterParams?JSON.stringify(this.filterParams):null,
        city:JSON.stringify(this.city),
        hows:JSON.stringify(this.findSellerData),
		tabidx:tabidx,
      },path)
    })
  },
  sellerCardEvent(e){
    if(e.detail.type=='phone'){
      this.selectComponent('#as').show(e.detail.seller);
    }
  },
  onPageScroll(e){
	console.log('scroll',e)  
	if(e.scrollTop>=88){
		if(!this.data.navborder){
			this.setData({
				navborder:true
			})
		}
		
	}else{
		if(this.data.navborder){
			this.setData({
				navborder:false
			})
		}
	}
  }
})