部分企业微信安卓端打开页面不断执行onshow
发布于 4 年前 作者 taoliu 3062 次浏览 来自 官方Issues

企业微信从客户聊天侧边栏进入小程序后一直重复执行onshow,代码中的 this.getCustomerId()是执行wx.qy.getCurExternalContact获取客户id。firstLoad是页面首次加载时设置成true,默认为false。此情况出现在部分安卓手机,其中一个出现这个问题的手机型号如图。

代码:

  onShow: function () {
    console.log('onshow')
    if(this.data.firstLoad){
      this.setData({
        getId:false
      })
      wx.showToast({title'企业微信id刷新中',icon:'none'})
      this.getCustomerId()
    }
  },
  getCustomerId(){
    var that = this
    if(!that.data.getId){
      wx.qy.getCurExternalContact ({
        successfunction(res{
          console.log('获取用户id:',res)
          var userId = res.userId //返回当前外部联系人userId
          that.setData({
            userId:userId,
            getId:true
          })
          that.loadList()
          app.ol('打开企业微信客户档案,userId:'+userId)
        },
        fail:function(err){
          console.log('失败:',err)
          wx.showToast({icon'none',title'加载失败,请联系网管'})
          app.ol('打开企业微信客户档案失败,err:'+err)
    
        },
        complete:function(e){
          // app.ol('打开企业微信客户档案完成,e:'+e)
          console.log('完成:',e)
        }
        })
    }
    
  },
回到顶部