小程序本地测试没有问题,苹果正常,安卓无法发送请求?

小程序本地测试没有问题,苹果正常,安卓无法发送请求,https ssl证书正常。

  1. Page({
  2.   data:{
  3.     height:height,
  4.     width:width,
  5.   },
  6.   onLoad:function(options){
  7.     // 页面初始化 options为页面跳转所带来的参数
  8.         wx.login({
  9.           success: function (loginres) {
  10.             code = loginres.code;
  11.             wx.getUserInfo({
  12.               withCredentials:true,
  13.               success: function (getuserinfores) {
  14.                 //小程序判断是否绑定用户账号
  15.                 var data = {
  16.                     encryptedData: getuserinfores.encryptedData,
  17.                     iv: getuserinfores.iv,
  18.                     code: code,
  19.                     agencyid: agencyid,
  20.                   }
  21.                        wx.request({
  22.                   url: apphost+'/applet/login',
  23.                   method:'POST',
  24.                   dataType:'json',
  25.                   data: data,
  26.                   header: {
  27.                     "Content-Type": "application/x-www-form-urlencoded"
  28.                   },
  29.                   success: function(res) {
  30.                     console.log(res)
  31.                     if(res.data.code == 200){
  32.                       // 登陆成功,返回用户信息和token,跳转到首页
  33.                       getApp().globalData.wxuserinfo = res.data.data;
  34.                       app.globalData.interval = 0
  35.                       getdata()
  36.                       setTimeout(function(){
  37.                         wx.switchTab({
  38.                           url: '/pages/index/index'
  39.                         })
  40.                       },1000)
  41.                     }else if(res.data.code == 202){
  42.                       // 未绑定用户账号
  43.                       getApp().globalData.wxuserinfo = res.data.data;
  44.                       console.log(getApp().globalData.wxuserinfo)
  45.                       setTimeout(function(){
  46.                         wx.redirectTo({
  47.                           url: '/pages/login/index'
  48.                         })
  49.                       },1000)
  50.                      
  51.                     }else{
  52.                       console.log(res.data.msg)
  53.                     }
  54.                   },
  55.                   fail: function(res){
  56.                     console.log(res)
  57.                   }
  58.                 })
  59.               }
  60.             })
  61.           },
  62.           // fail: function(){
  63.           //   wx.showToast({
  64.           //     title: '登陆失败',
  65.           //     icon: 'loadding',
  66.           //     duration: 2000
  67.           //   })
  68.           // }
  69.         })
  70.   },
  71.   onReady:function(){
  72.     // 页面渲染完成
  73.   },
  74.   onShow:function(){
  75.     // 页面显示
  76.   },
  77.   onHide:function(){
  78.     // 页面隐藏
  79.   },
  80.   onUnload:function(){
  81.     // 页面关闭
  82.   }
  83. })
复制代码

猜你喜欢

转载自bkjsw.iteye.com/blog/2374025