getWeappLoginCode = function getWeappLoginCode() {
  if (typeof wx === 'undefined' || typeof wx.login !== 'function') {
    throw new Error('Weapp Login is only available in Weapp');
  }
  return new Promise(function (resolve, reject) {
    wx.login({
      success: function success(_ref) {
        var code = _ref.code,
            errMsg = _ref.errMsg;

        if (code) {
          resolve(code);
        } else {
          reject(new Error(errMsg));
        }
      }
    });
  });
}
Internal method to handle special fields in a _User response.
@private