小程序安卓手机,无法执行wx.request
发布于 6 年前 作者 tao15 1196 次浏览 来自 官方Issues

开发者工具和IOS端表现:

安卓真机调试表现:

查看network并没有没有访问api

代码片段:

/**
   * 上传识别数据
   */
clockIn: function () {
    var that = this, data={};
    _request.postRequest(_api.clockIn.clockIn, data).then(function(res){
     //逻辑代码
    }).catch(function(res){
      console.log('catchError',res)
    });
  },
/**
   * PUT类型的网络请求
   */
  putRequest(url, data, header = this._header) {
    return this.requestAll(url, data, header, 'PUT')
  }
 
  /**
   * POST类型的网络请求
   */
  postRequest(url, data, header = this._header) {
   
    return this.requestAll(url, data, header, 'POST')
  }
 
  /**
   * 网络请求
   */
  requestAll(url, data, header, method) {
    return new Promise((resolve, reject) => {
      wx.request({
        url: url,
        data: data,
        header: header,
        method: method,
        success: (res => {
          console.log('访问接口',res);
          if (res.statusCode === 200) {
            //200: 服务端业务处理正常结束
            console.log({'数据':data,"地址":url,"结果":res.data});
 
            resolve(res)
          } else {
            //其它错误,提示用户错误信息
            if (this._errorHandler != null) {
              //如果有统一的异常处理,就先调用统一异常处理函数对异常进行处理
              this._errorHandler(res)
            }
            reject(res)
          }
        }),
        fail: (res => {
          console.log('访问api失败,失败原因:',res);
          if (this._errorHandler != null) {
            this._errorHandler(res)
          }
          reject(res)
        }),
        complete:(res=>{
          console.log('complete',res);
        })
      })
    }).catch(function (res) {
      console.log(res);
    })
  }
3 回复

代码拿出来,你这是只有某个方法在安卓机型上面不发送请求呢,还是整个项目的所有请求都不走呢?

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

wx最近老出问题

回到顶部