univerify.js 768 字节
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
async function getPhoneNumber ({
  // eslint-disable-next-line camelcase
  access_token,
  openid
} = {}) {
  const requiredParams = ['apiKey', 'apiSecret']
  const univerifyConfig = (this.config.service && this.config.service.univerify) || {}
  for (let i = 0; i < requiredParams.length; i++) {
    const key = requiredParams[i]
    if (!univerifyConfig[key]) {
      throw new Error(`Missing config param: service.univerify.${key}`)
    }
  }
  return uniCloud.getPhoneNumber({
    provider: 'univerify',
    appid: this.getClientInfo().appId,
    apiKey: univerifyConfig.apiKey,
    apiSecret: univerifyConfig.apiSecret,
    // eslint-disable-next-line camelcase
    access_token,
    openid
  })
}

module.exports = {
  getPhoneNumber
}