收藏
回答

jsapi获取用户抬头 回调函数不执行?

jsapi获取用户抬头,可以到选择抬头的页面,但是选择后不执行回调(调用jsapi失败的情况下可以执行回调),搞不懂了,求大神帮忙,是在vue2环境下,代码:

wxconfig(){
  var se=this;
  wx.config({
    debug: false,
    appId: se.wx.appId,
    timestamp: se.wx.timestamp,
    nonceStr: se.wx.nonceStr,
    signature: se.wx.signature,
    beta: true,
    jsApiList: [
      "chooseInvoiceTitle",//获取发票用户抬头
    ]
  });
  wx.ready(function () {
    wx.checkJsApi({
      jsApiList: [
        "chooseInvoiceTitle"
      ], 2,
      success: function (res) {
      }
    });
    wx.invoke('chooseInvoiceTitle',{
      "scene":"1"
    },function(res) {
      alert('11111');//这里不执行
      se.callback(res);
    });
  });

  wx.error(function (res) {
    alert(res.errMsg);
  });
},
callback(res){
  alert('2222');
  var se=this;
  alert(JSON.stringify(res));
  var re = res.choose_invoice_title_info;
  alert(JSON.stringify(re));
  se.pname=re.title;
  se.pno=re.taxNumber;
  se.paddr=re.companyAddress;
  se.pphone=re.telephone;
  se.pbank=re.bankName;
  se.paccount=re.bankAccount
},

文档地址:https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/Quick_issuing/Interface_Instructions.html

最后一次编辑于  2021-06-02
回答关注问题邀请回答
收藏

3 个回答

  • Jee 苏
    Jee 苏
    2021-06-10

    太坑了,我用的是苹果手机,alert啥都不跳出来,于是我才以为是回调函数没执行,最后拿同事安卓手机试,发现都能跳出来,是执行了的,只是res.choose_invoice_title_info是字符串,要转成对象以后使用。

    ......
    var re = JSON.parse(res.choose_invoice_title_info);
    se.pname=re.title;
    ......
    
    2021-06-10
    有用
    回复
  • Khorosho
    Khorosho
    2021-06-05

    我这边企业微信升了级后也遇到了这个问题,在发送小程序到对话框时,能正常发送小程序,但是不会进入回调函数。@企业微信运营专员-千夜

    2021-06-05
    有用
    回复
  • 加油你我
    加油你我
    发表于移动端
    2021-06-02
    小了:
    2021-06-02
    有用
    回复 1
    • Jee 苏
      Jee 苏
      2021-06-02
      啥意思 大神
      2021-06-02
      回复
登录 后发表内容