// pages/sickDetail/sickDetail.js
const app = getApp()
import {pathographyDetail} from "../../../api/sickRecord"
import {throttle} from "../../../utils/util"
import {pathographyDelete} from "../../../api/sickRecord"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sickInfo:{},
    index:0,
    pathography_id:'',
    show:false,
    message:'',
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onDel() {
   this.setData({
     show:true,
     message:"确定删除该病情记录？"
   })
 },
 confirm:throttle(function(event){
  if(event.detail){
    this.handlePathographyListDelte();
  }
}),
  previewImage(event) {
    let id = event.currentTarget.dataset.id;
    let urls = this.data.sickInfo.diagnose_images;
    wx.previewImage({
      current: urls[id], // 当前显示图片的http链接
      urls: urls // 需要预览的图片http链接列表
    })
  },
  handlePathographyListDelte(){
    let id=this.data.pathography_id
    pathographyDelete(id).then(data=>{
     wx.showToast({
       title: '删除成功',
       icon:'none'
     })
    });
    wx.navigateBack();
  },
  handlepathographyDetail(id){
    pathographyDetail(id).then(data=>{
     this.setData({
      sickInfo:data
     })
    })
  },
  onLoad(options) {
    if(options.pathography_id){
      this.setData({
        pathography_id:options.pathography_id
      })
       this.handlepathographyDetail(options.pathography_id);
    };
  if(options.index){
    this.setData({
      index:options.index
     })
   };
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})