const app = getApp()
Page({
  data: {

  },
  onUnload(){
    if(this.innerAudioContext)this.innerAudioContext.stop()
  },
  onLoad: function (options) {
    const {imei,devicetype} = options;
    var that = this
    app.requestP({
      url: "/query/scanChip2",
      method:"post",
      needToken:false,
      contentType:' application/json',
      data:{
        payload:imei,
        deviceType:devicetype,
      }
    }).then(function(res){
      // var data = res.data
      var temp = res.data.data.warning
      if(temp == 1){
        const innerAudioContext = wx.createInnerAudioContext()
        innerAudioContext.autoplay = true
        innerAudioContext.src = 'http://oss.zhongyihz.cn/group156/default/20210618/15/56/6/niyouyigexyfyhe.mp3'
        that.innerAudioContext = innerAudioContext
      }
      that.setData({
        info:res.data.data
      })
    }).catch(function(err){
      app.showToptip(that,'error',err.data.msg);
      setTimeout(() => {
        wx.navigateBack()
      }, 2000);
    })
  },
  copyTxt(){
    var txt = "IMEI:"+this.data.info.imei+" ICCID:"+this.data.info.iccid
    wx.setClipboardData({
      data:txt
    })
  }
})