Small program Local Test no problem, Apple Normal, Android can't send request?

Source: Internet
Author: User

Small program Local Test no problem, Apple Normal, Android cannot send the request, HTTPS SSL certificate is OK.

  1. Page ({

  2. data:{

  3. Height:height,

  4. Width:width,

  5. },

  6. Onload:function (options) {

  7. Page initialization options are the parameters of the page jump

  8. Wx.login ({

  9. Success:function (loginres) {

  10. Code = Loginres.code;

  11. Wx.getuserinfo ({

  12. Withcredentials:true,

  13. Success:function (getuserinfores) {

  14. Small program to determine if user account is bound

  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. Login successful, return user information and token, jump to homepage

  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. User account not bound

  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. }else{

  51. Console.log (RES.DATA.MSG)

  52. }

  53. },

  54. Fail:function (res) {

  55. Console.log (RES)

  56. }

  57. })

  58. }

  59. })

  60. },

  61. Fail:function () {

  62. Wx.showtoast ({

  63. Title: ' Failed login ',

  64. Icon: ' Loadding ',

  65. duration:2000

  66. //   })

  67. // }

  68. })

  69. },

  70. Onready:function () {

  71. Page Rendering complete

  72. },

  73. Onshow:function () {

  74. Page display

  75. },

  76. Onhide:function () {

  77. Page Hide

  78. },

  79. Onunload:function () {

  80. Page Close

  81. }

  82. })

Copy Code


Small program Local Test no problem, Apple Normal, Android can't send request?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.