2.14.0 • Published 2 years ago

@wii/user v2.14.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Wii User SDK

wii user javascript sdk

使用

NPM

npm i @wii/user
import wii from '@wii/user';

// 配置
wii.setConfig({
  apiBase: 'http://custom_api_base.com/usrv',
});

// 调用方法
wii.user.login();

Browser

<script>
  // 初始化全局配置
  var wiiUserConfig = {
    // api base url
    apiBase: '',
    // 登录页地址
    loginUrl: '',
  };
</script>
<!-- 使用方式 -->
<!-- 本地使用 -->
<script type="text/javascript" src="./dist/user.min.js"></script>
<!-- unpkg: todo -->
<!-- jsdelivr: todo -->

API

API 支持 Promise 方式调用。

设置 SDK

wii.setConfig({
  apiBase: 'http://custom_api_base.com/usrv',
});

支持配置项

名称类型说明是否必填默认值
apiBasestring网关地址-
skeystring用户授权后得到的凭据-
appIdstring应用的 appId-

用户模块

跳转登录

// 跳转登录
wii.user.login({
  // login options
  app_id: 'your_app_id', // 默认使用全局配置 appId
  redirect_uri: 'http://your.domain.com',
  scope: 'user_base',
  type: 'app_admin',
  state: 'MY_STATE',
  tenantAppId: 'tenantAppId',
  namespace: '9',
});

退出登录

// 退出登录
wii.user
  .logout()
  .then((res) => {
    // handle it
  })
  .catch((err) => {
    // handle it
  });

获取用户信息

// 获取用户信息
// promise
wii.user
  .getUserInfo()
  .then((res) => {
    // handle it
  })
  .catch((err) => {
    // handle it
  });

密码登录(单点方式)

// 密码登录(单点方式)
// promise
wii.user
  .loginByPassword(params)
  .then((res) => {
    // handle it
  })
  .catch((err) => {
    // handle it
  });

验证码登录

// 验证码登录
// promise
wii.user
  .loginByCaptcha(params)
  .then((res) => {
    // handle it
  })
  .catch((err) => {
    // handle it
  });

发送验证码

// 发送验证码
// promise

wii.user
  .sendCaptcha(params)
  .then((res) => {
    // handle it
  })
  .catch((err) => {
    // handle it
  });

获取用户在指定应用的权限 key

wii.user.getPermissionKeys({
  uid: 'xx',
  appId: 'xxx',
});

获取用户在指定应用的权限列表

wii.user.getPermissionList({
  uid: 'xx',
  appId: 'xxx',
});

系统模块

根据 appId 获取页面配置

wii.system.getPageConfigByAppId(app?: string)

注:appId 非必传,默认为 wii.setConfig 中所设置的 appId

2.13.2

2 years ago

2.13.0

2 years ago

2.12.1

2 years ago

2.14.0

2 years ago

2.13.1

2 years ago

2.12.2

2 years ago

2.1.0

2 years ago