getPhoneNumber点击确认授权和取消

//点击微信登录授权手机号



  getPhoneNumber(e) {

    var that = this;

    console.log("微信授权手机号", e.detail)

    wx.login({

      success: res => {

        console.log("login code", res.code);



        //是否授权,授权通过进入下单页面,授权拒绝则手机号登录

        if (e.detail.errMsg == 'getPhoneNumber:ok') {

          wx.request({

            url: app.globalData.url + 'api/Account/WxLogin/',

            data: {

              encryptedData: e.detail.encryptedData, //encodeURIComponent(e.detail.encryptedData),

              iv: e.detail.iv,

              code: res.code

            },

            method: 'GET',

            header: {

              'content-type': 'application/json'

            },

            success: function(res) {

              console.log("success", res)

              if (res.data.Code == 200) {

                wx.showToast({

                  title: '授权成功',

                })

                wx.navigateTo({

                  url: '../order_company/order_company',

                })



              } else {

                wx.showToast({

                  title: res.data.Message,

                  icon: 'none'

                })

              }

            },



            fail: function(res) {

              console.log("fail", res);

              wx.showToast({

                title: res.errMsg,

                icon: 'none'

              })

            }

          })



        } else if (e.detail.errMsg === 'getPhoneNumber:fail user deny') { //拒绝授权

          wx.showToast({

            title: '您拒绝了授权',

            icon: 'none',

            duration: 2000

          })

          wx.navigateTo({

            url: '../telLogin/telLogin',

          })

        } else if (e.detail.errMsg === 'getPhoneNumber:fail 用户未绑定手机,请先在微信客户端进行绑定后重试') {

          wx.showToast({

            title: '您的微信未绑定手机号',

            icon: 'none',

            duration: 3000

          })

          wx.navigateTo({

            url: '../telLogin/telLogin',

          })

        } else {

          wx.showToast({

            title: '网络繁忙,请稍候再试',

            icon: 'none',

          })

        }

      },



      fail: function(res) {

        wx.showToast({

          title: '获取登录态失败,请检查网络',

          icon: 'none',

          duration: 2000

        })

      }

    });



  },


  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值