kjyiyi
kjyiyi
2019-06-19 15:49
采纳率: 100%
浏览 577

微信小程序怎么调用快递鸟API的快递查询接口?

报错了!!怎么解决 thirdScriptError sdk uncaught third Error util is not defined ReferenceError: util is not defined at http://127.0.0.1:48141/appservice/pages/express/express.js:14:26 at require (http://127.0.0.1:48141/appservice/__dev__/WAService.js:1:1111566) at :26:7 at HTMLScriptElement.scriptLoaded at HTMLScriptElement.script.onload

  //查物流
    //快递公司和,快递单号
    var logistics = ["YD","1111111111"]
    //数据内容
    var RequestData = "{'OrderCode':'','ShipperCode':'" + logistics[0] + "','LogisticCode':'" + logistics[1] + "'}"
    //utf-8编码的数据内容
    console.log(RequestData)
    var RequestDatautf = encodeURI(RequestData)
    console.log("RequestDatautf:" + RequestDatautf)
    //签名
    console.log(RequestData + 'apikey')
    var DataSign = encodeURI(util.Base64((util.md5(RequestData + 'apikey'))))
    console.log("DataSign:" + DataSign)
    if (logistics != null) {
      wx.request({
        url: 'https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx',
        data: {
          //数据内容(进行过url编码)
          'RequestData': RequestDatautf,
          //电商ID
          'EBusinessID': '商户id',
          //请求指令类型:1002
          'RequestType': '1002',
          //数据内容签名把(请求内容(未编码)+ApiKey)进行MD5加密,然后Base64编码,最后进行URL(utf-8)编码
          'DataSign': DataSign,
          //请求、返回数据类型: 2-json;
          'DataType': '2',
        },
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          console.log(res)
          that.setData({ data: res.data.Traces })
        }
      })
    }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • as_csdn
    代码的灵魂是bug! 2019-06-19 16:11
    已采纳

    首先确定一点,api.kdniao.com这个域名在小程序后台添加了没,然后检查express.js:14 14行的代码

    点赞 评论

相关推荐