拉取卡卷 提示没有权限
发布于 6 年前 作者 fanghan 20161 次浏览 来自 问答

在调用拉取卡卷接口,总是控制台中输出:没有权限

前端实现的js:

//配置 wx.config
//这一步配置成功的
$.ajax({
   url: '/nm/config',
   type: 'GET',
   //必须进行 url 编码
   ////////////////////
   data: {
       url: location.href.split('#')[0]//@todo 重要:后台需要获取签名使用
   },
   dataType: 'json',
   success: function (res) {
       wx.config({
           beta: true,
           debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
           appId: config.id, // 必填,公众号的唯一标识
           timestamp: res.timestamp, // 必填,生成签名的时间戳
           nonceStr: res.nonceStr, // 必填,生成签名的随机串
           signature: res.signature,// 必填,签名,见附录1
           jsApiList: ['chooseInvoice', 'chooseCard'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
       });

       // console.log(res);
   }
})
wx.ready(function () {


   function checkAPI(apiList) {
       wx.checkJsApi({
           jsApiList: apiList,
           success: function (res) {
               //@todo 备注:checkJsApi接口是客户端6.0.2新引入的一个预留接口,第一期开放的接口均可不使用checkJsApi来检测
               // 以键值对的形式返回,可用的apitrue,不可用为false
               // 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
               console.log(res);
           }
       });
   }
   //这一步都是 true ,都有权限调用接口
   checkAPI(['chooseInvoice', 'chooseCard'])


   //拉取卡卷
   // 问题:总是提示没有权限???
   chooseCard()
   function chooseCard() {
       $.ajax({
           url: '/nm/sign',
           dataType: 'json',
           success: function (res) {
               card(res)
           },
           complete: function (res) {
               console.log(res)
           }
       })
       function card(res) {
           wx.chooseCard({
               shopId: '', // 门店Id
               cardId: '', // 卡券Id
               signType: 'SHA1', //签名方式,默认'SHA1'
               cardType: '', // 卡券类型
               nonceStr: res.nonceStr,
               cardSign: res.cardSign,
               timestamp: res.timestamp,
               complete: function (res) {
                   console.log(res)
               }
           });


       }
   }

});



报错信息如下:

请问,有那个大神在开发,卡卷时候遇到过这个的问题?

回到顶部