// pages/commonSick/commonSick.js
import {sickList,hotSickList} from "../../../api/common"
const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
   list:[],
   showKeyboard:false,
   isSearch:false,
   commonList:[],
   img_host:'https://oss.prod.applets.igandanyiyuan.com/applet/patient/static',
   keyWord:''
  },
  getSick() {
    let { keyWord }=this.data;
    sickList({
      disease_class_name:keyWord
    }).then((data) => {
      this.setData({
        list: data
      })
    })
  },
  gethotSickList(){
    hotSickList().then(data=>{
      this.setData({
        commonList:data
      })
    })
   },
   onfoucs(){
    this.setData({
      showKeyboard:true,
    })
   },
  goSearch(event){
   this.setData({
     keyWord:event.detail.value,
     isSearch:true,
   })
   this.getSick()
  },
  changeIpt(event){
    this.setData({
      keyWord:event.detail.value,
    })
  },
  handleSearch(){
    console.log(111);
    this.setData({
      isSearch:true,
    })
    this.getSick()
  },
  confirmBack(event){
    let {id,name}=event.currentTarget.dataset;
    let pages = getCurrentPages();
    let prevPage = pages[pages.length - 2]; //上一页
    prevPage.setData({
      prevData:{
        disease_class_name:name,
        disease_class_id:id      
      }
    });
   wx.navigateBack({
     delta: 1,
   })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.gethotSickList();
    //this.getSick()
  },

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

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
   this.setData({
    img_host:app.hostConfig().imghost
   })
  },

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

  },

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

  },

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

  },

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

  },

  /**
   * 用户点击右上角分享
   */
  
})