小程序本地測試沒有問題,蘋果正常,安卓無法發送請求?

小程序本地測試沒有問題,蘋果正常,安卓無法發送請求,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. })

複製代碼


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章