如下为使用默认风格的代码示例:
a、引入样式:
<link rel="stylesheet" href="http://oidc.org.cn/app/oidc.css" />b、引入数据;
<script type="text/javascript" src="http://oidc.org.cn/oauth/osp.js?key=YOUR_APP_KEY" charset="utf-8"></script>c、引入脚本:
<script type="text/javascript" src="http://oidc.org.cn/app/oidc.js" charset="utf-8"></script>e、添加容器标签:
<div id="oidc" name="oidc"></div>d、初始化调用:
<script type="text/javascript">
// 使用默认参数
oidc.init("YOUR_APP_KEY", "oidc");
// 使用自定义参数
var option = {};
oidc.init("YOUR_APP_KEY", "oidc", option);
</script>e、option选项说明
| 属性 | 类型 | 说明 |
|---|---|---|
| log | Boolean | 是否输出Log,默认否。 |
| mode | String | 应用模式,可选有web(默认),spa(单页应用) |
| view | String | 界面展示方式,可选有list(列表展示,默认),none(不展示) |
| style | String | 显示视图,可选有list(默认),card(卡片),icon(图标),item(选项) |
| target | String | 链接打开方式,可选有none(默认),tab,window,dialog |
| https | Boolean | 是否启用Https协议,默认不启用 |
| showCard | Boolean | 是否显示卡片 |
| showHead | Boolean | 是否显示卡片头部信息 |
| headHtml | String | 卡片头部自定义内容(HTML格式) |
| showFoot | Boolean | 是否显示卡片尾部信息 |
| footHtml | String | 卡片尾部自定义内容(HTML格式) |
| align | String | 图标(icon)视图时,对齐方式,start(默认),center,end |
| columns | Number | 卡片(card)视图时,显示的列数,默认1 |
| response_type | String | 响应方式 |
| redirect_uri | String | 回调地址 |
| state | String | 回调参数 |
| scope | String | 授权范围 |