let mpi = {}

// 微信登陆
mpi.wxLogin = () => {
  return new Promise((resolve, reject)=>{
    uni.login({
      success: function (res) {
        resolve(res)
      },
      fail: function (err) {
        console.warn(err)
        reject(err)
      }
    })
  })
}

//判断微信用户是否授权
mpi.wxGetSetting = () => {
  return new Promise((resolve, reject) => {
    uni.getSetting({
      success: function(res) {
        let authSetting = res.authSetting
        resolve(authSetting)
      },
      fail: function(err) {
        resolve(err)
      }
    })
  })
}

// 获取用户信息
mpi.wxGetUserInfo = () => {
  return new Promise((resolve, reject) => {
    uni.getUserInfo({
      withCredentials: true,
      success: function(res) {
        resolve(res)
      },
      fail: function(err) {
        reject(err)
      },
    })
  })
}

export default mpi
