当前位置:   article > 正文

微信小程序开发常见错误和解决方法_微信开发课本点餐小程序开发购物车可能出现的问题

微信开发课本点餐小程序开发购物车可能出现的问题

目录

1. API调用问题

2. 微信开发过程中的常见问题

3. 参考文档


1. API调用问题

微信小程序外部API调用方法,遇到的一个小问题

最近对微信小程序比较感兴趣,想写一个查询车辆违章记录的小程序。在调用外部接口时需要,appcode 这种authoriztion。发现微信小程序的

ajax请求使用这种方式不起作用。改为直接在header中赋值生效了,不知道什么原因,希望遇到同样问题的伙伴可以不用弯路。

  1. beforeSend: function (xhr){
  2. console.log('授权码');
  3. xhr.setRequestHeader("Authorization", "APPCODE "+"XXXXXXXXXXXXXXXXXXX");
  4. },

解决方法

  1. header: {
  2. 'content-type': 'application/json',
  3. 'Authorization': "APPCODE " + "XXXXXXXXXXXXXXXXXXX"
  4. },
  5. XXXXXXXXXXXXXXXXXXX"
  6. },
 

详细代码如下

  1. confirm: function () {
  2. console.log("clicked confirm");
  3. this.setData({
  4. hidden: true
  5. });
  6. var timestamp = new Date().getTime();
  7. var apiUrl = "http://ddycapi.market.alicloudapi.com/violation/query";
  1. //注释掉的代码为废弃车首页和路帮网的免费接口,使用阿里云的api收费服务
  2. //var appId = "129";
  3. //var appKey = "4263c4f0-4f56-0135-3375-0242c0a80006";
  4. //var carInfo = "{plate_num=" + this.data.plateNo + "&body_num=" + this.data.frameNo + "&engine_num=" + this.data.engineNo + "&city_id=190&car_type=02}";
  5. // var signStr = appId + carInfo + timestamp + appKey;
  6. // var sign = util.md5(signStr);
  7. //console.log("carInfo:" + carInfo);
  8. //console.log("signStr:" + signStr);
  9. //console.log("sign:" + sign);
  10. //var url = apiUrl + "car_info=" + carInfo + "&api_id=" + appId + "&sign=" + sign + "×tamp=" + timestamp;
  11. // console.log("url:" + url);
  1. var that = this;
  2. wx.request({
  3. url: apiUrl,
  4. method:'post',
  5. data: { "plateNumber": "陕AD3738", "engineNo": "695176712", "vin": "662722", "carType": "02" },
  6. header: {
  7. 'content-type': 'application/json',
  8. 'Authorization': "APPCODE " + "XXXXXXXXXXXXXXXXXXX"
  9. },
  10. beforeSend: function (xhr){
  11. console.log('授权码');
  12. xhr.setRequestHeader("Authorization", "APPCODE "+"XXXXXXXXXXXXXXXXXXX");
  13. },
  14. success: function (res) {
  15. if (res.statusCode != 200) {
  16. console.log('接口调用异常');
  17. that.setData({
  18. resultModalHidden: false,
  19. resultMsg: '接口调用异常'
  20. });
  21. }
  22. var obj = res.data;
  23. var status = Number(obj.status);
  24. that.setData({
  25. resultModalHidden: false
  26. });
  27. switch (status) {
  28. case 1002:
  29. console.log('app_id有误');
  30. break;
  31. case 1003:
  32. console.log(' sign加密有误');
  33. break;
  34. case 1004:
  35. console.log('车牌号,汽车类型,违章城市 等字段不能为空');
  36. break;
  37. case 1005:
  38. that.setData({
  39. resultMsg: '输入的车辆信息有误,请查证后重新输入'
  40. });
  41. console.log('车辆信息有误');
  42. break;
  43. case 2000:
  44. that.setData({
  45. resultMsg: '恭喜,当前城市交管局暂无您的违章记录'
  46. });
  47. console.log('正常(无违章记录)');
  48. break;
  49. case 2001:
  50. console.log('正常(有违章记录)');
  51. break;
  52. case 5000:
  53. console.log('请求超时,请稍后重试');
  54. break;
  55. case 5001:
  56. console.log('交管局系统连线忙碌中,请稍后再试');
  57. break;
  58. case 5002:
  59. console.log('恭喜,当前城市交管局暂无您的违章记录');
  60. break;
  61. case 5003:
  62. console.log('数据异常,请重新查询');
  63. break;
  64. case 5004:
  65. console.log('系统错误,请稍后重试');
  66. break;
  67. case 5005:
  68. console.log(' 车辆查询数量超过限制');
  69. break;
  70. case 5006:
  71. console.log('你访问的速度过快, 请后再试');
  72. break;
  73. case 5008:
  74. that.setData({
  75. resultMsg: '输入的车辆信息有误,请查证后重新输入'
  76. });
  77. console.log('输入的车辆信息有误,请查证后重新输入');
  78. break;
  79. default:
  80. console.log('未知错误');
  81. }
  82. console.log(res)
  83. }
  84. })
  85. },

2. 微信开发过程中的常见问题

errnoerrMsg含义
0ok成功
1cancel撤销
3system permission denied系统权限未授予微信
4internal error小程序框架内部异常
5time out接口超时
100jsapi not supportedJsApi不支持
101jsapi invalid request dataJsApi请求参数非法
102jsapi has no permissionJsApi没有权限
103jsapi user authorize deniedJsApi用户拒绝授权
104jsapi user authorize canceledJsApi用户取消授权
106invalid jsapi indexJsApi权限位序号非法
108cgi failed for network issues网络错误导致CGI逻辑失败
109cgi failed for response nullCGI响应为空
110scope or scope list emptyscope或者scope列表为空
111oom occurs发生OutOfMemoryError
112api scope is not declared in the privacy agreement接口未在隐私协议中声明
1000server system error服务端系统错误
1001invalid request parameter基础库wx接口请求参数非法
1002empty request空的请求
1003meet server frequency limit命中服务端频率限制
1004invalid openid不合法的openid
1005invalid appid不合法的appid
1006insert data failed添加数据失败
1007get no data数据不存在
1008update data failed更新数据失败
1009data expired数据过期
1010data deleted数据被删除
1011invalid user id不合法的用户身份
1012api need post methodapi要求post请求
1013api need get methodapi要求get请求
1014invalid user ticket无效的凭证
1015invalid api无效的接口
1016no websocket conn info无websocket连接信息
1017mem err服务端内存相关错误
1018duplicated uuiduuid冲突
1019not friend不是好友关系
1020code already usedcode已经使用
1021code expiredcode过期
1022invalid jsonjson数据解析错误
1023invalid state无效的状态
1024invalid plugin appid不合法的插件appid
1025wxa appid privacy api banned小程序隐私接口被封禁,解决方案参考链接
1026wxgame appid privacy api banned小游戏隐私接口被封禁,解决方案参考链接
100001json parse errorjson解析错误
101100interface is not declared in the privacy agreement接口未在隐私协议中声明
101101privacy interface is banned隐私接口已封禁
101102privacy permission is not authorized用户未同意授权隐私协议
102101settings page not foundopenSystemSettings找不到对应的系统设置页
103101applyUpdate has been calledapplyUpdate已被调用
103102update is not readyupdate未准备完成
109001invalid random value length无效的随机数长度
500001invalid style无效的style
505101require absolute path需要绝对路径
510001invoke too frequently函数调用时间间隔过短
510101invalid text无效的text
600000unknown network error未知的网络错误
600001cronet component errorcronet组件错误,详细错误参考返回中的errMsg字段。参考链接
600002url not in domain listurl域名不在安全域名列表中
600003network interrupted error网络中断
600004network logic error网络类目逻辑错误
600005network argv error网络类目参数错误
600006network system error网络类目系统错误
600007network exceed max task count超过最大请求数量
600008network reach the max redirect count超过最大重定向次数
600009invalid URLURL 格式不合法
600010invalid request data请求的 data 序列化失败
600011url validate errorURL验证错误
602000unknown network request error未知的发起请求错误
602001request system errorrequest系统错误
602002request server http errorhttp请求httpdns服务商错误
602101not buy httpdns service小程序未在服务市场购买httpdns服务
602102service expired小程序在httpdns服务市场资源包过期
602103no enough httpdns quota小程序在httpdns服务市场额度不足
602104empty servicer returnhttpdns服务商返回结果为空
602105time-out when request servicer调用httpdns服务商结果超时
602106invalid servicer responsehttpdns服务商返回数据不合法
602107empty domain httpdns resulthttpdns域名解析结果为空
602108not valid service id不支持的httpdns服务商id
602300convert native buffer parameter fail. native buffer exceed size limit超出native buffer最大限制
602301bind socket dependency is unavailable申请移动网络请求失败
602302response data convert to UTF8 fail请求数据转换格式失败
603101iOS not supported不支持ios平台
603102android not supported不支持安卓平台
603103parameter error: require packageName or packageNameArray需要包名或包名数组
603104parameter error: require downloadId or downloadIdArray or appIdArray需要下载ID或者ID数组或APPID数组
603105abort download task中断下载任务
603300download save file error保存文件出错
603301exceed max file size超出文件最大大小限制
603302file data is empty文件数据为空
603303permission denied can not open file filepath指定存储路径无权限
605103WebSocket connect is failWebSocket connect失败
606101mdns resolve system error:%d解析失败,详细错误参考返回中的errMsg字段。系统错误码参考链接
700000unknown payment error
700001limited use马甲微信拦截支付接口
701000unknown payment default class error
701001ios not support
701002need realname verify before payment
701100midas buy goods failed米大师下单失败
701101midas get account balance failed米大师查询账户额度失败
701102midas currency pay failed米大师代币付款失败
701103midas currency canel pay failed米大师代币退款失败
701104midas currency present failed米大师赠送代币失败
701105midas get user water failed米大师拉取用户流水失败
701106midas currency in sufficient米大师代币余额不足
701107midas order not exists米大师订单不存在
701108midas order already refunded米大师订单已经退款
701109midas order refunded amount exceed米大师代币退款金额超过上限
701110midas order duplicated pperator付款重复操作
701111midas invalid parameter参数错误
701112midas get coupons failed米大师拉取代金劵失败
701113midas get set coupon order failed米大师下单时记录代金券信息失败
701114midas no valid coupons米大师无有效的代金券
701115midas order alreay paid米大师订单已支付
701116midas no valid rollback coupon米大师无对应回滚的代金券
1103002target file not exists目标图片不存在
1103003image decode fail图片解码失败
1103004create temp file fail临时文件创建失败
1103005error occurs during the compress process压缩图片过程发生错误
1103006param compress quality invalidquality非法(<0 or >100)
1103007src image file size zero图片长或宽为零
1107001用户当前正在观看直播/视频通话/打电话
1107002当前处于rtc模式,但用户没有授予微信录音权限
1107003illegal operation in background小程序退后台时无法操作
1107004take snapshot fail截图失败
1107005save to album after take snapshot fail截图后保存到相册失败
1107006save to temp file after take snapshot fail截图后保存到临时文件失败
1107007not in picture in picture mode nowvideo/live-player组件当前不处于小窗模式下
1107008exiting picture in picture mode nowvideo/live-player组件当前正在退出小窗模式
1107009request background playback but src empty进入后台音频播放模式时src为空
1107010request background playback but in rtc modertc模式下不允许进入后台音频播放模式
1107011request background playback but in backgroundpage已经进入后台,不允许进入后台音频播放模式
1107012load resource file fail资源文件加载失败
1107013system permission denied准备推流,但用户没有授予微信录音/摄像头权限
1300001Operation not permitted操作不被允许
1300002No such file or directory找不到文件或目录
1300005Input/output error输入输出流不可用
1300009Bad file descriptor无效的fd
1300013Permission denied权限错误,文件是只读或只写
1300014Path permission denied传入的路径没有权限
1300020Not a directory指定路径不是目录,常见于指定的写入路径的上级路径为一个文件的情况
1300021Is a directory指定路径是一个目录
1300022Invalid argument无效参数,可以检查length或offset是否越界
1300036File name too long文件名过长
1300066Directory not empty目录不为空
1300201system error系统接口调用失败
1300202the maximum size of the file storage limit is exceeded存储空间不足
1300203encode error字符编码转换失败
1300300sdcard not mountedsd card挂载失败
1300301unable to open as fileType无法以fileType打开文件
1301000permission denied, cannot access file path目标路径无访问权限(usr目录)
1301002data to write is empty写入数据为空
1301003illegal operation on a directory不可对目录进行此操作
1301004illegal operation on a package directory不可对代码包目录进行此操作
1301005file already exists已有同名文件或目录
1301006value of length is out of rangelength值越界
1301007value of offset is out of rangeoffset值越界
1301008fd argument must be of type numberfd参数的值必须为number类型
1301009value of position is out of rangeposition值越界
1301100store directory is emptystore目录为空
1301102unzip open file fail压缩文件打开失败
1301103unzip entry fail解压单个文件失败
1301104unzip fail解压失败
1301111brotli decompress failbrotli解压失败(iOS独有)
1301112tempFilePath file not exist指定的tempFilePath找不到文件
1302001permission denied, fd is writeonly or readonlyfd只读/只写
1302002excced max concurrent fd limitfd数量已达上限
1302003invalid flag无效的flag
1302004permission denied when open using flag无法使用flag标志打开文件
1302005array buffer does not exist未传入arrayBuffer
1302100array buffer is readonlyarrayBuffer只读
1400001appid no enough quota小程序quota余额不足
1402101wxa login is blocked小程序登录被封禁
1416100invalid finder username非法的视频号id
1416101get finder info failed拉取视频号信息失败
1416102invalid finder feed id非法的feed_id
1416103not same contractor小程序appid和视频号的同主体校验不通过
1416104empty finder info视频号获取到的数据为空
1416105get partially visible finder info视频号获取到的数据仅部分人可见
1416106invalid finder token非法的视频号token
1416107appid token no permission视频号账号关闭小程序token引用
1416108parse token failed解析token失败
1416109user token hit spam limit用户解析token时命中风控限制
1420103not same contractor小程序appid和企业微信的同主体校验不通过
1500101not init未初始化蓝牙适配器
1500102当前蓝牙适配器不可用
1500103当前BLE设备获取不到Service/获取不到对应UUID的Service
1500104调用系统蓝牙能力失败, 详细错误见errMsg
1500105system not support系统不支持BLE
1504001系统不支持NFC
1504002not support HCE系统不支持HCE
1504003system NFC switch not opened系统NFC开关未打开
1504100not set default NFC application未设置NFC默认应用
1504101register aids failedHCE注册aid列表失败
1504200user is not authorized用户未授权App使用NFC能力
1504201parse NdefMessage failed解析NdefMessage失败
1504202NFC discovery already started之前已经调用了startDiscovery
1504203NFC discovery has not started之前没有调用startDiscovery
1504204Tech already connected当前tech已经连接上
1504205Tech has not connected当前tech还没连接上
1504206NFC tag has not been discovered系统未发现NFC标签
1504207invalid tech无效的tech
1504208unavailable tech当前NFC标签不支持该tech
1504209function not support不支持该NFC能力
1504210system internal error调用系统NFC能力失败, 详细错误见errMsg
1505000unknown WIFI error
1505001not invoke startWifi未调用startWifi
1505002wifi is disabled系统WiFi开关未开启
1505003maybe not open GPS操作失败, 可能是因为系统GPS开关未打开
1505004maybe not obtain GPS Permission操作失败, 可能是因为用户未授予App定位权限
1505005currentWifi is null获取不到当前已连接WiFi
1505006current connected wifi is invalid获取到的当前已连接WiFi信息非法, 开发者可以考虑重试
1505020unknown error连接WiFi其他未知错误
1505021weapp in background小程序在后台, 不允许调用connectWifi
1505022open settings fail仅Android, 跳转系统设置页情况下跳转失败
1505023duplicated request重复连接WiFi
1505024password error密码错误
1505025wifi config may be expired可能是WiFi配置已过期
1505026fail to connect wifi:time out连接WiFi超时
1505027user denied用户拒绝授权连接Wi-Fi
1505028weixin cannot modify system config仅iOS,系统/运营商配置拒绝连接Wi-Fi
1505029invalid ssid仅iOS,无效的ssid
1505030duplicate request仅iOS,上个请求还未完成,重复请求
1505031invalid WEP / WPA password仅iOS,无效的WEP/WPA密码
1505032system internal error系统错误,需要在errMsg中打印更多信息
1505040获取当前已连接WiFi失败, 开发者可以考虑稍后重试
1509000unknown BLE error
1509001连接BLE设备失败
1509002当前Service获取不到Characteristic/获取不到对应UUID的Characteristic
1509003未连接上该BLE设备
1509004当前Characteristic不支持该属性,详细错误见errMsg
1509005BLE操作超时
1509006device not found未找到设备
1509007already connect当前BLE设备已经连接上
1509008location permission is deniedAndroid6.0以上, BLE扫描需授权地理位置
1509010wait for bluetooth state change timeoutiOS上调用openBluetoothAdapter后客户端等待状态更新超时
1510101need pin配对当前蓝牙设备需要pin码
1510102reach max bluetooth background count支持蓝牙后台通信的设备数目已经达到上限
1517001the content of the text message exceeds the limit短信内容超出长度限制
2000000AI system error系统错误
2000001AI invalid arguments参数错误
2000002AI client device not supported客户端设备不支持
2000003AI os not supported系统不支持
2000004AI library not supported客户端设备不支持
2002000unknown error未知错误
2002001face detection does not initialize人脸检测未初始化
2002002face detection has duplicated initialization人脸检测重复初始化
2002003face detection has failed initialization人脸检测初始化失败
2002004face not detected or detection failed检测不到人脸或检测失败
2002005stop face detection failed停止人脸检测失败
2003000session unavailable会话不可用
2003001system camera not authorized系统相机权限未打开
2003002camera not authorized小程序相机权限未授权
2004000model path invalid : %s非法的模型文件路径
2004001create session fail : %s通过sdk创建session失败
2004002sessionId is emptysession id 为空
2004003input tensors is emptyinput tensors 为空
2004004data type [%s] for input tensor [%s] is unsupported不支持当前输入数据类型
2004005invalid session id无效的sessionId
2004006data type [%s] for output tensor [%s] is unsupported不支持当前输出数据类型
2004007input tensor [%s] data is invalid : %sinput tensor数据为空
2004008input tensor has invalid shape : %s无效的shape
2004009run session fail(%s)通过sdk run session失败
2004010environment not ready环境未准备就绪(比如Android so未加载)
2004011session id not exist释放的session id不存在
2004012the input tensor [%s] MUST have %s attribution输入张量缺失属性

3. 参考文档

微信官方文档 Errno错误码 | 微信开放文档

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/324692
推荐阅读
相关标签
  

闽ICP备14008679号