const app =getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inoculatorId:'',
    loginRole:'',
    path:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let userInfo = wx.getStorageSync('userInfo');
    console.log(options.path);
    const {loginRole,ifOverFlow,status} = userInfo;
    this.setData({
      inoculatorId:options.inoculatorId,
      loginRole,
      path:options.path
    })
  },
  goScan(){
    var that = this;
    wx.scanCode({
      success: function (res) {
        var {result} = res;
        if(result.indexOf('imei=') != -1){
          result = result.slice(result.indexOf('imei=')+5,result.length)
        }
        app.requestP({
          url:'/chainBound/checkBind',
          method:'post',
          // contentType:' application/json',
          data:{
            deviceCode:result,
          }
        }).then(res=>{
          if(res.data.data != 1){
            app.showToptip(that,'error',res.data.msg);
            return;
          }
          app.requestP({
            url:'/chain/scan',
            method:'post',
            contentType:' application/json',
            data:{
              inoculatorId:that.data.inoculatorId,
              payload:result,
              type:20
            }
          }).then(res=>{
            const {id} = res.data.chain;
            wx.navigateTo({
              url: '/pages/workbench/scanningType/reportPdf/reportPdf?id='+id,
            })
          }).catch(err=>{
            app.showToptip(that,'error',err.data.msg);
          })
        }).catch(err=>{
          app.showToptip(that,'error',err.data.msg);
        })
      },
      fail:function(err){
        app.showToptip(that, 'error', '二维码无效');
      }
    })
  },
  getDocuorPdf(){

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})