processQuery.js 5.5 KB
const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
      historysearch:[],
      keyword:'',
      process:'',
      processtrue:false,
      historylist:'',
      seatchaog:true,
      ttop:'',
      latitude:'',
      longitude :'',
      wxtary: 'ibaby288',
      urls:[]
  },

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

  },

  //预览图片
  viewImg(e) {
    // let index = e.currentTarget.dataset.index;
    wx.previewImage({
      current: this.data.urls[0],
       urls: this.data.urls,
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },

 getloaction() {
    wx.getLocation({
      type: 'gcj02',
      success: (res) => {
        console.log(res)
        var latitude = res.latitude
        var longitude = res.longitude
        this.setData({
          latitude: latitude,
          longitude: longitude
        })
        console.log(this.data.latitude)
        console.log(this.data.longitude)

      }

    })
  },
  hostipal: function () {
    //获取跳转状态
    let that = this;
    var url = '/api/portal/talk/isFirst';
    var params = {
      token: wx.getStorageSync('token'),

    }
    app.post(url, params).then((res) => {
      console.log(res);
      if (res == true) {
        wx.navigateTo({
          url: '../home/stageofpregnancy/stageofpregnancy',
        })
      } else {
        wx.navigateTo({
          url: '../home/communithostipal/communithostipal',
        })
      }
    }).catch((err) => {

    })

  },
  jump(e){
    let type=e.currentTarget.dataset.type
    
    let url=e.currentTarget.dataset.src
    if(type==6){
      this.hostipal()
      
      // wx.navigateTo({
      //   url: '/pages/home/communithostipal/communithostipal',
      // })
    }else{
      wx.navigateTo({
        url: '/pages/sharepage/sharepage?url=' + url,
      })
    }
   
  },

  getsearch(e){
    let keyword=e.detail.value;
    this.setData({
      keyword: keyword
    })

    // this.searchlist()

  },
  //获取搜索历史
  historylist(){
    let that = this;
    var url = '/api/portal/hospital/getKeywords';
    var params = {
      token: wx.getStorageSync('token'),

    }
    app.post(url, params).then((res) => {
      console.log(res);
      that.setData({
        historysearch: res.history,
        ttop: res.lc
      })



    }).catch((err) => {

    })
  },
  wrong(){
    this.setData({
      reveal:true
    })
  },
  tapHide(){
    this.setData({
      reveal: false
    })
  },

  //点击复制
  paste: function () {
    let that = this
    wx.showToast({
      title: '复制成功',
    })

    wx.setClipboardData({
      data: that.data.customer_info.wechat,
      success: function (res) {
        wx.getClipboardData({

          success: function (res) {
            console.log(res.data) // data
          }
        })
      }
    })
  },
  enterhistory(e){

    let that=this;
    that.setData({
      keyword:e.currentTarget.dataset.item
    })
    var url = '/api/portal/hospital/getLiucheng';
    var params = {
      keyword: that.data.keyword,
      token: wx.getStorageSync('token'),
      lng: that.data.longitude,
      lat: that.data.latitude

    }
    app.post(url, params).then((res) => {
      console.log(res);
      if (res != null) {
        that.setData({
          processtrue: true
        })

      } else {
        wx.showToast({
          title: '暂无数据',
          icon: 'none'
        })
      }


      console.log(res.length);
      let urls=that.data.urls;
      urls.push(res.pic2)
      that.setData({
        process: res,
        seatchaog: false,
        urls:urls
      })
console.log(that.data.urls)

    }).catch((err) => {

    })
  },
  searchlist(){

    let that = this;
    if(that.data.keyword==''){
      wx.showToast({
        title: '请输入查询关键字',
        icon:'none'
      })
     
    }else{
      var url = '/api/portal/hospital/getLiucheng';
      var params = {
        keyword: that.data.keyword,
        token: wx.getStorageSync('token'),
        lng: that.data.longitude,
        lat:that.data.latitude

      }
      app.post(url, params).then((res) => {
        console.log(res);
        if(res!=null){
          that.setData({
            processtrue: true
          })

        }else{
          wx.showToast({
            title: '暂无数据',
            icon:'none'
          })
        }
        let urls = that.data.urls;
        urls.push(res.pic2)

        console.log(res.length);
        that.setData({
          process:res,
          seatchaog:false,
          urls:urls
        })


      }).catch((err) => {

      })
    }
  },



  buildtext(){
    wx.navigateTo({
      url: '../home/buildtext/buildtext',
    })

  },

  attention: function () {
    wx.navigateTo({
      url: '../home/attentionpublic/attentionpublic',
    })
  },

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

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

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

  },

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

  },

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

  },

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

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})