js-icp-sdk
v1.2.0
Published
iframe html interface with community frame for icity.
Downloads
9
Readme
Summary
iframe html interface with community frame for icity.
Emphasize
sdk is only valid in the icity's community platform.
Install
npm install js-icp-sdk --save
OR
yarn add js-icp-sdk
Import
import icp from 'js-icp-sdk'
Use
1、Token (非三方调用)
const token = await icp.getToken()
2、User's info (获取用户信息)
const info = await icp.getUserInfo()
> info {
type, //10:市, 0:区级, 1:街道级, 2:社区级
orgId, //组织id
id, //用户唯一标识
uid, //用户唯一标识(uuid规则)
name, //姓名
mobile, //手机号
province, //省份
provinceId, //省份id
city, //市
cityId, //市id
district, //区
districtId, //区id
street, //街道
streetId, //街道id
community //社区
}
3、Grid's info(获取网格信息)
const info = await icp.getGridInfo()
> info {
name: '网格员',
role: 1, //0非网格员,1网格员
scope: [
{
gridId: '', //网格id
gridName: '' //网格名
}
]
}
4、Community's list(获取当前街道的社区列表)
const list = await icp.getCommunityList()
> list [
{
name: '演示社区',
code: '552054350c0b40a9951b0b9b8dd9ac6d'
}
]
5、Relogin (提示重新登录)
icp.relogin()
6、Code (获取临时授权码)
const code = await icp.getCode([host])
> host: 域名, 默认为https://new3.icity24.cn, 可选
> 示例: await icp.getCode()
await icp.getCode('http://www.test.cn')
7、获取手机号后四位验证ticket
const ticket = await icp.getMobileVerifyTicket()
8、记录手机号后四位验证ticket
icp.setMobileVerifyTicket(ticket)
9、获取手机号验证码ticket
const ticket = await icp.getSmsVerifyTicket()
10、记录手机号验证码ticket
icp.setSmsVerifyTicket(ticket)
11、打开URL并携带参数
icp.openUrlWithBody(url, body)
> icp.openUrlWithBody('https://www.baidu.com', ['首页', '详情页'])
12、从打开的页面中获取携带的参数
const body = await icp.getUrlBody()
13、外部打开页面获取用户信息
npm install js-guava --save
import { browser } from 'js-guava'
browser.receive(params=>{
//业务处理,返回格式参见2
})
14、跳转其他链接后,保持上个链接页面状态的方法
icp.openUrlWithBody(params)
> icp.openUrlWithBody({
url:"https://www.baidu.com"
})