您好,登录后才能下订单哦!
小程序本地测试没有问题,苹果正常,安卓无法发送请求,https ssl证书正常。
Page({
  data:{
    height:height,
    width:width,
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
        wx.login({
          success: function (loginres) {
            code = loginres.code;
            wx.getUserInfo({
              withCredentials:true,
              success: function (getuserinfores) {
                //小程序判断是否绑定用户账号
                var data = {
                    encryptedData: getuserinfores.encryptedData,
                    iv: getuserinfores.iv,
                    code: code,
                    agencyid: agencyid,
                  }
                       wx.request({
                  url: apphost+'/applet/login',
                  method:'POST',
                  dataType:'json',
                  data: data,
                  header: {
                    "Content-Type": "application/x-www-form-urlencoded"
                  },
                  success: function(res) {
                    console.log(res)
                    if(res.data.code == 200){
                      // 登陆成功,返回用户信息和token,跳转到首页
                      getApp().globalData.wxuserinfo = res.data.data;
                      app.globalData.interval = 0
                      getdata()
                      setTimeout(function(){
                        wx.switchTab({
                          url: '/pages/index/index'
                        })
                      },1000)
                    }else if(res.data.code == 202){
                      // 未绑定用户账号
                      getApp().globalData.wxuserinfo = res.data.data;
                      console.log(getApp().globalData.wxuserinfo)
                      setTimeout(function(){
                        wx.redirectTo({
                          url: '/pages/login/index'
                        })
                      },1000)
                      
                    }else{
                      console.log(res.data.msg)
                    }
                  },
                  fail: function(res){
                    console.log(res)
                  }
                })
              }
            })
          },
          // fail: function(){
          //   wx.showToast({
          //     title: '登陆失败',
          //     icon: 'loadding',
          //     duration: 2000
          //   })
          // }
        })
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})
复制代码
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。