// patient/pages/videoList/videoList.js
const app = getApp()
import {doctorList} from "../../../api/consultExpert"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    pageNumber:10,
    lock:false,
    doctorList:[],
    img_host:'https://oss.prod.applets.igandanyiyuan.com/applet/patient/static',
  },
  goExpertDetail(event){
    app.method.navigateTo({
      url: '/patient/pages/expertDetail/expertDetail?doctor_id='+event.currentTarget.dataset.doctorid
    })
  },
  onfresh(){
    this.setData({
      page:1,
      doctorList:[],
      lock:false
    })
    this.getDoctorList();
  },
  lower(e) {
    let {lock}=this.data;
    let addPage=this.data.page+1;
    if(!lock){
      this.setData({
        page:addPage
      });
      this.getDoctorList();
    }  
  },
  getDoctorList(){
    let {page,pageNumber}=this.data;
    doctorList({
      page:page,
      inquiry_type:1,
      inquiry_mode:2,
      per_page:pageNumber
    }).then((res)=>{
      let {doctorList}=this.data;
       if(res.data.length==0){
        this.setData({
          lock:true
        });
        return false;
       }else{
          this.setData({
            doctorList:doctorList.concat(res.data)
          })
       }
    })
   },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getDoctorList();
  },

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

  },

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

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

  },

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

  },

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

  },

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

  },

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

  }
})